mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-26 04:46:46 +08:00
typing: add _ProtocolMeta (#6394)
Co-authored-by: hauntsaninja <> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -122,6 +122,14 @@ if sys.version_info >= (3, 9):
|
||||
# Predefined type variables.
|
||||
AnyStr = TypeVar("AnyStr", str, bytes)
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
# This class did actually exist in 3.7, but had a different base.
|
||||
# We'll just pretend it didn't exist though: the main external use case for _ProtocolMeta is
|
||||
# to inherit from for your own custom protocol metaclasses. If you're using 3.7, at runtime
|
||||
# you'd use typing_extensions.Protocol, which would be unrelated to typing._ProtocolMeta and
|
||||
# so you'd run into metaclass conflicts at runtime if you used typing._ProtocolMeta.
|
||||
class _ProtocolMeta(ABCMeta): ...
|
||||
|
||||
# Abstract base classes.
|
||||
|
||||
def runtime_checkable(cls: _TC) -> _TC: ...
|
||||
|
||||
@@ -53,6 +53,11 @@ Literal: _SpecialForm = ...
|
||||
|
||||
def IntVar(name: str) -> Any: ... # returns a new TypeVar
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
# Technically in 3.6 this inherited from GenericMeta. But let's not reflect that, since
|
||||
# type checkers tend to assume that Protocols all have the ABCMeta metaclass.
|
||||
class _ProtocolMeta(abc.ABCMeta): ...
|
||||
|
||||
# Internal mypy fallback type for all typed dicts (does not exist at runtime)
|
||||
class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
|
||||
__required_keys__: frozenset[str]
|
||||
|
||||
Reference in New Issue
Block a user