-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy path_policybase.pyi
More file actions
80 lines (72 loc) · 3.25 KB
/
_policybase.pyi
File metadata and controls
80 lines (72 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from abc import ABCMeta, abstractmethod
from email.errors import MessageDefect
from email.header import Header
from email.message import Message
from typing import Any, Generic, Protocol, TypeVar, type_check_only
from typing_extensions import Self
__all__ = ["Policy", "Compat32", "compat32"]
_MessageT = TypeVar("_MessageT", bound=Message[Any, Any], default=Message[str, str])
_MessageT_co = TypeVar("_MessageT_co", covariant=True, bound=Message[Any, Any], default=Message[str, str])
@type_check_only
class _MessageFactory(Protocol[_MessageT]):
def __call__(self, policy: Policy[_MessageT]) -> _MessageT: ...
# Policy below is the only known direct subclass of _PolicyBase. We therefore
# assume that the __init__ arguments and attributes of _PolicyBase are
# the same as those of Policy.
class _PolicyBase(Generic[_MessageT_co]):
max_line_length: int | None
linesep: str
cte_type: str
raise_on_defect: bool
mangle_from_: bool
message_factory: _MessageFactory[_MessageT_co] | None
# Added in Python 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool
def __init__(
self,
*,
max_line_length: int | None = 78,
linesep: str = "\n",
cte_type: str = "8bit",
raise_on_defect: bool = False,
mangle_from_: bool = ..., # default depends on sub-class
message_factory: _MessageFactory[_MessageT_co] | None = None,
# Added in Python 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool = True,
) -> None: ...
def clone(
self,
*,
max_line_length: int | None = ...,
linesep: str = ...,
cte_type: str = ...,
raise_on_defect: bool = ...,
mangle_from_: bool = ...,
message_factory: _MessageFactory[_MessageT_co] | None = ...,
# Added in Python 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool = ...,
) -> Self: ...
def __add__(self, other: Policy) -> Self: ...
class Policy(_PolicyBase[_MessageT_co], metaclass=ABCMeta):
# Every Message object has a `defects` attribute, so the following
# methods will work for any Message object.
def handle_defect(self, obj: Message[Any, Any], defect: MessageDefect) -> None: ...
def register_defect(self, obj: Message[Any, Any], defect: MessageDefect) -> None: ...
def header_max_count(self, name: str) -> int | None: ...
@abstractmethod
def header_source_parse(self, sourcelines: list[str]) -> tuple[str, str]: ...
@abstractmethod
def header_store_parse(self, name: str, value: str) -> tuple[str, str]: ...
@abstractmethod
def header_fetch_parse(self, name: str, value: str) -> str: ...
@abstractmethod
def fold(self, name: str, value: str) -> str: ...
@abstractmethod
def fold_binary(self, name: str, value: str) -> bytes: ...
class Compat32(Policy[_MessageT_co]):
def header_source_parse(self, sourcelines: list[str]) -> tuple[str, str]: ...
def header_store_parse(self, name: str, value: str) -> tuple[str, str]: ...
def header_fetch_parse(self, name: str, value: str) -> str | Header: ... # type: ignore[override]
def fold(self, name: str, value: str) -> str: ...
def fold_binary(self, name: str, value: str) -> bytes: ...
compat32: Compat32[Message[str, str]]