mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-19 10:21:14 +08:00
Improve stubs for email.policy (#6631)
* Add the ABCMeta metaclass, present at runtime. * Add missing attributes from the allowlist, which are documented. * Annotate the __init__ methods according to the documentation.
This commit is contained in:
@@ -1,17 +1,27 @@
|
||||
from abc import abstractmethod
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from email.contentmanager import ContentManager
|
||||
from email.errors import MessageDefect
|
||||
from email.header import Header
|
||||
from email.message import Message
|
||||
from typing import Any, Callable
|
||||
|
||||
class Policy:
|
||||
class Policy(metaclass=ABCMeta):
|
||||
max_line_length: int | None
|
||||
linesep: str
|
||||
cte_type: str
|
||||
raise_on_defect: bool
|
||||
mange_from: bool
|
||||
def __init__(self, **kw: Any) -> None: ...
|
||||
mangle_from_: bool
|
||||
message_factory: Callable[[Policy], Message] | None
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
max_line_length: int | None = ...,
|
||||
linesep: str = ...,
|
||||
cte_type: str = ...,
|
||||
raise_on_defect: bool = ...,
|
||||
mangle_from_: bool = ...,
|
||||
message_factory: Callable[[Policy], Message] | None = ...,
|
||||
) -> None: ...
|
||||
def clone(self, **kw: Any) -> Policy: ...
|
||||
def handle_defect(self, obj: Message, defect: MessageDefect) -> None: ...
|
||||
def register_defect(self, obj: Message, defect: MessageDefect) -> None: ...
|
||||
@@ -41,6 +51,20 @@ class EmailPolicy(Policy):
|
||||
refold_source: str
|
||||
header_factory: Callable[[str, str], str]
|
||||
content_manager: ContentManager
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
max_line_length: int | None = ...,
|
||||
linesep: str = ...,
|
||||
cte_type: str = ...,
|
||||
raise_on_defect: bool = ...,
|
||||
mangle_from_: bool = ...,
|
||||
message_factory: Callable[[Policy], Message] | None = ...,
|
||||
utf8: bool = ...,
|
||||
refold_source: str = ...,
|
||||
header_factory: Callable[[str, str], str] = ...,
|
||||
content_manager: ContentManager = ...,
|
||||
) -> None: ...
|
||||
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: ...
|
||||
|
||||
Reference in New Issue
Block a user