mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-06 21:43:59 +08:00
Add @type_check_only to stub-only private classes in stdlib (#14512)
This commit is contained in:
@@ -13,7 +13,7 @@ from email._header_value_parser import (
|
||||
)
|
||||
from email.errors import MessageDefect
|
||||
from email.policy import Policy
|
||||
from typing import Any, ClassVar, Literal, Protocol
|
||||
from typing import Any, ClassVar, Literal, Protocol, type_check_only
|
||||
from typing_extensions import Self
|
||||
|
||||
class BaseHeader(str):
|
||||
@@ -137,6 +137,7 @@ class MessageIDHeader:
|
||||
@staticmethod
|
||||
def value_parser(value: str) -> MessageID: ...
|
||||
|
||||
@type_check_only
|
||||
class _HeaderParser(Protocol):
|
||||
max_count: ClassVar[Literal[1] | None]
|
||||
@staticmethod
|
||||
|
||||
@@ -5,7 +5,7 @@ from email.charset import Charset
|
||||
from email.contentmanager import ContentManager
|
||||
from email.errors import MessageDefect
|
||||
from email.policy import Policy
|
||||
from typing import Any, Generic, Literal, Protocol, TypeVar, overload
|
||||
from typing import Any, Generic, Literal, Protocol, TypeVar, overload, type_check_only
|
||||
from typing_extensions import Self, TypeAlias
|
||||
|
||||
__all__ = ["Message", "EmailMessage"]
|
||||
@@ -24,9 +24,11 @@ _EncodedPayloadType: TypeAlias = Message | bytes
|
||||
_MultipartPayloadType: TypeAlias = list[_PayloadType]
|
||||
_CharsetType: TypeAlias = Charset | str | None
|
||||
|
||||
@type_check_only
|
||||
class _SupportsEncodeToPayload(Protocol):
|
||||
def encode(self, encoding: str, /) -> _PayloadType | _MultipartPayloadType | _SupportsDecodeToPayload: ...
|
||||
|
||||
@type_check_only
|
||||
class _SupportsDecodeToPayload(Protocol):
|
||||
def decode(self, encoding: str, errors: str, /) -> _PayloadType | _MultipartPayloadType: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user