Skip to content

Commit

Permalink
py312: Fix stubtest nits in typing/typing_extensions (python#10659)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Sep 4, 2023
1 parent d868dad commit 433204f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 16 deletions.
9 changes: 7 additions & 2 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ if sys.version_info >= (3, 11):
"reveal_type",
]

if sys.version_info >= (3, 12):
__all__ += ["TypeAliasType", "override"]

ContextManager = AbstractContextManager
AsyncContextManager = AbstractAsyncContextManager

Expand Down Expand Up @@ -323,7 +326,9 @@ AnyStr = TypeVar("AnyStr", str, bytes) # noqa: Y001

# 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): ...
class _ProtocolMeta(ABCMeta):
if sys.version_info >= (3, 12):
def __init__(cls, *args: Any, **kwargs: Any) -> None: ...

# Abstract base classes.

Expand Down Expand Up @@ -945,7 +950,7 @@ if sys.version_info >= (3, 10):
def _type_repr(obj: object) -> str: ...

if sys.version_info >= (3, 12):
def override(__arg: _F) -> _F: ...
def override(__method: _F) -> _F: ...
@_final
class TypeAliasType:
def __init__(
Expand Down
3 changes: 3 additions & 0 deletions tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,6 @@ pkgutil.ImpImporter\..*
pkgutil.ImpLoader\..*

types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime

# https://github.com/python/mypy/issues/15302
typing_extensions\.override
3 changes: 3 additions & 0 deletions tests/stubtest_allowlists/py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,6 @@ asynchat.async_chat.use_encoding
asynchat.find_prefix_at_end
pkgutil.ImpImporter\..*
pkgutil.ImpLoader\..*

# https://github.com/python/mypy/issues/15302
typing_extensions\.override
28 changes: 15 additions & 13 deletions tests/stubtest_allowlists/py312.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@ importlib.metadata._meta.SimplePath.parent
poplib.POP3_SSL.__init__
smtplib.SMTP.starttls
smtplib.SMTP_SSL.__init__
typing.ParamSpec.__mro_entries__
typing.ParamSpecArgs.__mro_entries__
typing.ParamSpecKwargs.__mro_entries__
typing.SupportsAbs.__type_params__
typing.SupportsRound.__type_params__
typing.TypeVar.__mro_entries__
typing.TypeVarTuple.__mro_entries__
typing._ProtocolMeta.__init__
typing.__all__
typing.override
typing_extensions.Protocol
typing_extensions.SupportsAbs.__type_params__
typing_extensions.SupportsRound.__type_params__
urllib.request.AbstractHTTPHandler.__init__
urllib.request.HTTPSHandler.__init__

Expand Down Expand Up @@ -135,6 +122,21 @@ typing\._SpecialForm.*
typing\.NamedTuple
typing\.LiteralString
typing\.Annotated
typing_extensions\.Protocol

# These only exist to give a better error message if you try to subclass an instance
typing.ParamSpec.__mro_entries__
typing.ParamSpecArgs.__mro_entries__
typing.ParamSpecKwargs.__mro_entries__
typing.TypeVar.__mro_entries__
typing.TypeVarTuple.__mro_entries__

# TODO: mypy should infer that this attribute is inherited from builtins.type;
# why doesn't it infer this?
typing.SupportsAbs.__type_params__
typing.SupportsRound.__type_params__
typing_extensions.SupportsAbs.__type_params__
typing_extensions.SupportsRound.__type_params__

# These two should be removable after 3.12rc2 is released:
types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime
Expand Down
1 change: 1 addition & 0 deletions tests/stubtest_allowlists/py38.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ types.WrapperDescriptorType.__get__
typing_extensions\.assert_never
typing_extensions\.assert_type
typing_extensions\.reveal_type
typing_extensions\.override

# We lie about the existence of these methods
.*.__buffer__
Expand Down
1 change: 1 addition & 0 deletions tests/stubtest_allowlists/py39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ types.WrapperDescriptorType.__get__
typing_extensions\.assert_never
typing_extensions\.assert_type
typing_extensions\.reveal_type
typing_extensions\.override

# Super-special typing primitives
typing\.NamedTuple
Expand Down
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ typing_extensions.NewType.__mro_entries__ # just exists for an error message
# https://github.com/python/mypy/issues/15302
typing_extensions.NewType.__call__
typing_extensions\.deprecated
typing_extensions\.override
typing_extensions\.get_protocol_members
typing_extensions\.is_protocol

Expand Down

0 comments on commit 433204f

Please sign in to comment.