mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Reduce duplication of code between typing and typing_extensions (#7075)
This commit is contained in:
@@ -29,6 +29,7 @@ class TypeVar:
|
||||
# Used for an undocumented mypy feature. Does not exist at runtime.
|
||||
_promote = object()
|
||||
|
||||
# N.B. Keep this definition in sync with typing_extensions._SpecialForm
|
||||
class _SpecialForm:
|
||||
def __getitem__(self, typeargs: Any) -> object: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
@@ -138,13 +139,9 @@ if sys.version_info >= (3, 9):
|
||||
# Predefined type variables.
|
||||
AnyStr = TypeVar("AnyStr", str, bytes) # noqa: Y001
|
||||
|
||||
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): ...
|
||||
# Technically in 3.7 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(ABCMeta): ...
|
||||
|
||||
# Abstract base classes.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user