Bug report
Bug description:
The following example raises a TypeError: Some type variables (T) are not listed in Generic[U]:
class Bar[T, S=T]: ...
class Baz[U](Bar[U]): ...
Full Traceback
Traceback (most recent call last):
File "/home/rscholz/Downloads/tmp.py", line 3, in <module>
class Baz[U](Bar[U]): ...
File "/home/rscholz/Downloads/tmp.py", line 3, in <generic parameters of Baz>
class Baz[U](Bar[U]): ...
File "/usr/lib/python3.13/typing.py", line 1288, in _generic_init_subclass
raise TypeError(f"Some type variables ({s_vars}) are"
f" not listed in Generic[{s_args}]")
TypeError: Some type variables (T) are not listed in Generic[U]
The PEP states that
non-overridden defaults should be substituted in, and type parameters with such defaults can be further specialised down the line.
And the typing spec uses similar phrasing, which makes me believe this is a bug. In the example above, I'd expect that Baz[U] is a Bar[U, U] by substitution + default.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Bug report
Bug description:
The following example raises a
TypeError: Some type variables (T) are not listed in Generic[U]:Full Traceback
The PEP states that
And the typing spec uses similar phrasing, which makes me believe this is a bug. In the example above, I'd expect that
Baz[U]is aBar[U, U]by substitution + default.CPython versions tested on:
3.14
Operating systems tested on:
Linux