bpo-39168: Remove the __new__ method of typing.Generic by ZackerySpytz · Pull Request #21327 · python/cpython · GitHub
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
2 changes: 0 additions & 2 deletions Lib/test/test_typing.py
10 changes: 0 additions & 10 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,16 +894,6 @@ def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
__slots__ = ()
_is_protocol = False

def __new__(cls, *args, **kwds):
if cls in (Generic, Protocol):
raise TypeError(f"Type {cls.__name__} cannot be instantiated; "
"it can be used only as a base class")
if super().__new__ is object.__new__ and cls.__init__ is not object.__init__:
obj = super().__new__(cls)
else:
obj = super().__new__(cls, *args, **kwds)
return obj

@_tp_cache
def __class_getitem__(cls, params):
if not isinstance(params, tuple):
Expand Down