Skip to content

Commit 5cc966c

Browse files
authored
Improve email.headerregistry.HeaderRegistry stub (#8516)
1 parent c87ccce commit 5cc966c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

stdlib/email/headerregistry.pyi

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ from email._header_value_parser import (
1414
)
1515
from email.errors import MessageDefect
1616
from email.policy import Policy
17-
from typing import Any, ClassVar
17+
from typing import Any, ClassVar, Protocol
1818
from typing_extensions import Literal
1919

2020
class BaseHeader(str):
@@ -141,9 +141,19 @@ if sys.version_info >= (3, 8):
141141
@staticmethod
142142
def value_parser(value: str) -> MessageID: ...
143143

144+
class _HeaderParser(Protocol):
145+
max_count: ClassVar[Literal[1] | None]
146+
@staticmethod
147+
def value_parser(value: str) -> TokenList: ...
148+
@classmethod
149+
def parse(cls, value: str, kwds: dict[str, Any]) -> None: ...
150+
144151
class HeaderRegistry:
152+
registry: dict[str, type[_HeaderParser]]
153+
base_class: type[BaseHeader]
154+
default_class: type[_HeaderParser]
145155
def __init__(
146-
self, base_class: type[BaseHeader] = ..., default_class: type[BaseHeader] = ..., use_default_map: bool = ...
156+
self, base_class: type[BaseHeader] = ..., default_class: type[_HeaderParser] = ..., use_default_map: bool = ...
147157
) -> None: ...
148158
def map_to_type(self, name: str, cls: type[BaseHeader]) -> None: ...
149159
def __getitem__(self, name: str) -> type[BaseHeader]: ...

0 commit comments

Comments
 (0)