Skip to content

Conversation

@ilevkivskyi
Copy link
Member

Fixes #20326

Type variables with forward references in upper bound are known to be problematic. Existing mechanisms to work with them implicitly assumed that they are used in the same module where they are defined, which is not necessarily the case for "old-style" type variables that can be imported.

Note that the simplification I made in semanal_typeargs.py would be probably sufficient to fix this, but that would be papering over the real issue, so I am making a bit more principled fix.

@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@ilevkivskyi ilevkivskyi merged commit 25cf74b into python:master Dec 1, 2025
20 checks passed
@ilevkivskyi ilevkivskyi deleted the fix-tvar-defer-other-mod branch December 1, 2025 14:06
hauntsaninja pushed a commit that referenced this pull request Dec 13, 2025
Fixes #20326

Type variables with forward references in upper bound are known to be
problematic. Existing mechanisms to work with them implicitly assumed
that they are used in the same module where they are defined, which is
not necessarily the case for "old-style" type variables that can be
imported.

Note that the simplification I made in `semanal_typeargs.py` would be
probably sufficient to fix this, but that would be papering over the
real issue, so I am making a bit more principled fix.
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.

mypy INTERNAL ERROR in subtyping

2 participants