-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
This code (from https://discuss.python.org/t/type-object-cls-has-no-attribute-parameters/104276/4 ):
class Base:
def __init_subclass__(cls) -> None:
pass
class Sub[T](Base): pass
class SubSub(Sub[object]): pass
Fails with an inscrutable error about cls.__parameters__
not existing, because super().__init_subclass__()
was not called.
Let's produce a clearer error message in this case so it's easier to debug for the next person.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-139905: Provide suggestion in error message if
Generic.__init_subclass__
was not called #139943 - gh-139905: better error msg when subclassing
GenericAlias
without calling__init_subclass__
#139949 - [3.14] gh-139905: Provide suggestion in error message if
Generic.__init_subclass__
was not called (GH-139943) #139955 - [3.13] gh-139905: Provide suggestion in error message if
Generic.__init_subclass__
was not called (GH-139943) #139956
AlexWaygood, Jumpedia and BrenBarn
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error