mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
bpo-46553: allow bare typing.ClassVar annotations (#30983)
These are used in the wild and covered by dataclasses unit tests. Several static type checkers support this pattern.
This commit is contained in:
parent
45faf151c6
commit
5445e173e7
3 changed files with 7 additions and 2 deletions
|
|
@ -173,7 +173,7 @@ def _type_check(arg, msg, is_argument=True, module=None, *, allow_special_forms=
|
|||
if (isinstance(arg, _GenericAlias) and
|
||||
arg.__origin__ in invalid_generic_forms):
|
||||
raise TypeError(f"{arg} is not valid as type argument")
|
||||
if arg in (Any, NoReturn, Final):
|
||||
if arg in (Any, NoReturn, ClassVar, Final):
|
||||
return arg
|
||||
if isinstance(arg, _SpecialForm) or arg in (Generic, Protocol):
|
||||
raise TypeError(f"Plain {arg} is not valid as type argument")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue