-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibPython modules in the Lib dirPython modules in the Lib dirtopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
The internal function typing._type_check()
is used extensively to check whether a particular value represents a type. Its docstring begins with:
def _type_check(arg, msg, is_argument=True, module=None, *, allow_special_forms=False):
"""Check that the argument is a type, and return it (internal helper).
In Python 3.11b1 this function no longer errors on various kinds of non-types:
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=11, micro=0, releaselevel='beta', serial=1)
>>> import typing
>>> typing._type_check(5, "Expected a type.")
# no error!
>>> typing.ClassVar[5]
typing.ClassVar[5] # no error!
By contrast on Python 3.10:
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=10, micro=1, releaselevel='final', serial=0)
>>> import typing
>>> typing._type_check(5, "Expected a type.")
TypeError: Expected a type. Got 5.
>>> typing.ClassVar[5]
TypeError: typing.ClassVar accepts only single type. Got 5.
Your environment
Regression introduced somewhere between Python 3.10 and Python 3.11b1.
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibPython modules in the Lib dirPython modules in the Lib dirtopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error