-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Incorrect __init__ signature for classes inheriting from Generic #12655
Copy link
Copy link
Open
Description
Correct __init__ signature:
In [21]: class C:
...: """A docstring."""
...: def __init__(self, a: float, b:int, c:str):
...: pass
...:
In [22]: C?
Init signature: C(a: float, b: int, c: str)
Docstring: A docstring.
Type: type
Subclasses: Incorrect signature when inheriting from Generic:
In [23]: from typing import Generic, TypeVar
In [24]: T = TypeVar('T')
In [25]: class C(Generic[T]):
...: """A docstring."""
...: def __init__(self, a: float, b:int, c:str):
...: pass
...:
In [26]: C?
Init signature: C(*args, **kwds)
Docstring: A docstring.
Type: type
Subclasses: help does work correctly in this case:
In [27]: help(C)
Help on class C in module __main__:
class C(typing.Generic)
| C(*args, **kwds)
|
| A docstring.
|
| Method resolution order:
| C
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__(self, a: float, b: int, c: str)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
<SNIP>Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels