Skip to content

conformance: remove questionable generic syntax test - #2368

Merged
JelleZijlstra merged 1 commit into
python:mainfrom
JelleZijlstra:generic-init-subclass
Oct 14, 2026
Merged

JelleZijlstra merged 1 commit into
python:mainfrom
JelleZijlstra:generic-init-subclass

Conversation

@JelleZijlstra

Copy link
Copy Markdown
Member

We noticed this test from a ty change that (correctly) disallows
passing Foo[T] where type[Foo[T]] is expected: Foo[T] is a
GenericAlias, not a type. But when I looked at the test, I noticed
it doesn't really make sense to use a generic here at all. __init_subclass__
is evaluated at the class level and can't possibly be generic. Probably
TypeVars should be disallowed here for the same reason they're disallowed
in ClassVars. But adding that to the spec or type checkers seems more
trouble than it's worth; for now let's just remove the dubious test.

We noticed this test from a ty change that (correctly) disallows
passing `Foo[T]` where `type[Foo[T]]` is expected: `Foo[T]` is a
`GenericAlias`, not a type. But when I looked at the test, I noticed
it doesn't really make sense to use a generic here at all. `__init_subclass__`
is evaluated at the class level and can't possibly be generic. Probably
TypeVars should be disallowed here for the same reason they're disallowed
in ClassVars. But adding that to the spec or type checkers seems more
trouble than it's worth; for now let's just remove the dubious test.
@JelleZijlstra
JelleZijlstra merged commit d06c5dd into python:main Oct 14, 2026
5 checks passed
AlexWaygood pushed a commit to astral-sh/ruff that referenced this pull request Oct 15, 2026
We update the typing conformance suite from `835b70f` to `d06c5dd`. This
includes
[python/typing#2368](python/typing#2368), which
removes the questionable generic `__init_subclass__` example that passed
`Foo[T]` to a parameter annotated as `type[Foo[T]]`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants