mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Use typing_extensions.Self in the stdlib (#9694)
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from collections.abc import Iterable, Iterator
|
||||
from email.errors import HeaderParseError, MessageDefect
|
||||
from email.policy import Policy
|
||||
from re import Pattern
|
||||
from typing import Any
|
||||
from typing_extensions import Final
|
||||
from typing_extensions import Final, Self
|
||||
|
||||
WSP: Final[set[str]]
|
||||
CFWS_LEADER: Final[set[str]]
|
||||
@@ -318,7 +317,7 @@ class Terminal(str):
|
||||
syntactic_break: bool
|
||||
token_type: str
|
||||
defects: list[MessageDefect]
|
||||
def __new__(cls: type[Self], value: str, token_type: str) -> Self: ...
|
||||
def __new__(cls, value: str, token_type: str) -> Self: ...
|
||||
def pprint(self) -> None: ...
|
||||
@property
|
||||
def all_defects(self) -> list[MessageDefect]: ...
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import sys
|
||||
import types
|
||||
from _typeshed import Self
|
||||
from collections.abc import Iterable, Mapping
|
||||
from datetime import datetime as _datetime
|
||||
from email._header_value_parser import (
|
||||
@@ -15,7 +14,7 @@ from email._header_value_parser import (
|
||||
from email.errors import MessageDefect
|
||||
from email.policy import Policy
|
||||
from typing import Any, ClassVar, Protocol
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, Self
|
||||
|
||||
class BaseHeader(str):
|
||||
# max_count is actually more of an abstract ClassVar (not defined on the base class, but expected to be defined in subclasses)
|
||||
@@ -24,7 +23,7 @@ class BaseHeader(str):
|
||||
def name(self) -> str: ...
|
||||
@property
|
||||
def defects(self) -> tuple[MessageDefect, ...]: ...
|
||||
def __new__(cls: type[Self], name: str, value: Any) -> Self: ...
|
||||
def __new__(cls, name: str, value: Any) -> Self: ...
|
||||
def init(self, name: str, *, parse_tree: TokenList, defects: Iterable[MessageDefect]) -> None: ...
|
||||
def fold(self, *, policy: Policy) -> str: ...
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from _typeshed import Self
|
||||
from collections.abc import Generator, Iterator, Sequence
|
||||
from email import _ParamsType, _ParamType
|
||||
from email.charset import Charset
|
||||
@@ -6,7 +5,7 @@ from email.contentmanager import ContentManager
|
||||
from email.errors import MessageDefect
|
||||
from email.policy import Policy
|
||||
from typing import Any, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
from typing_extensions import Self, TypeAlias
|
||||
|
||||
__all__ = ["Message", "EmailMessage"]
|
||||
|
||||
@@ -84,7 +83,7 @@ class Message:
|
||||
def get_charsets(self, failobj: None = None) -> list[str] | None: ...
|
||||
@overload
|
||||
def get_charsets(self, failobj: _T) -> list[str] | _T: ...
|
||||
def walk(self: Self) -> Generator[Self, None, None]: ...
|
||||
def walk(self) -> Generator[Self, None, None]: ...
|
||||
def get_content_disposition(self) -> str | None: ...
|
||||
def as_string(self, unixfrom: bool = False, maxheaderlen: int = 0, policy: Policy | None = None) -> str: ...
|
||||
def as_bytes(self, unixfrom: bool = False, policy: Policy | None = None) -> bytes: ...
|
||||
|
||||
Reference in New Issue
Block a user