Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ typing._Final.__init_subclass__
typing\.Protocol
typing(_extensions)?\._TypedDict
typing(_extensions)?\.Any.*
typing(_extensions)?\.Generic
typing(_extensions)?\.TypedDict
typing_extensions\.ParamSpec.*
typing_extensions\.TypeVar.*
Expand Down
15 changes: 14 additions & 1 deletion stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ class _SpecialForm(_Final):
def __ror__(self, other: Any) -> _SpecialForm: ...

Union: _SpecialForm
Generic: _SpecialForm
Protocol: _SpecialForm
Callable: _SpecialForm
Type: _SpecialForm
Expand Down Expand Up @@ -440,6 +439,20 @@ Annotated: _SpecialForm
# Predefined type variables.
AnyStr = TypeVar("AnyStr", str, bytes) # noqa: Y001

@type_check_only
class _Generic:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just class Generic: without the type[] part? It's a class at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, pyright was complaining a lot without this workaround 😕

if sys.version_info < (3, 12):
__slots__ = ()

if sys.version_info >= (3, 10):
@classmethod
def __class_getitem__(cls, args: TypeVar | ParamSpec | tuple[TypeVar | ParamSpec, ...]) -> _Final: ...
else:
@classmethod
def __class_getitem__(cls, args: TypeVar | tuple[TypeVar, ...]) -> _Final: ...

Generic: type[_Generic]

class _ProtocolMeta(ABCMeta):
if sys.version_info >= (3, 12):
def __init__(cls, *args: Any, **kwargs: Any) -> None: ...
Expand Down
Loading