Repository navigation
Avoid placeholders in virtual dep aliases - #74
Merged
Merged
Conversation
delfick
force-pushed
the
lazier-virtual-dep-aliases
branch
2 times, most recently
from
July 10, 2026 23:55
1c7e1c6 to
efceb18
Compare
With the update to mypy 2.2 we found a new problem where the way mypy resolves placeholder types in TypeVars was conflicting with the way the virtual dependency aliases worked. I thought I was stuck, but I found a solution! When this plugin was made I wasn't able to use the `type` keyword, but now I can and it appears because the type keyword makes something that only exists at static time I can use it to create my aliases and then import the modules they depend on after they are defined. It appears this is enough to remove the recursive nature of how these aliases currently work (because the aliases need to be defined before they are referenced sometimes) Note that this change is incompatible with mypy before 2.2 and django-stubs before 6.0.5 and so this package has those versions as a new floor
delfick
force-pushed
the
lazier-virtual-dep-aliases
branch
from
July 11, 2026 00:22
efceb18 to
d1b85f3
Compare
allanlewis
approved these changes
Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the update to mypy 2.2 we found a new problem where the way mypy resolves placeholder types in TypeVars was conflicting with the way the virtual dependency aliases worked.
I thought I was stuck, but I found a solution!
When this plugin was made I wasn't able to use the
typekeyword, but now I can and it appears because the type keyword makes something that only exists at static time I can use it to create my aliases and then import the modules they depend on after they are defined.It appears this is enough to remove the recursive nature of how these aliases currently work (because the aliases need to be defined before they are referenced sometimes)
Note that this change is incompatible with mypy before 2.2 and django-stubs before 6.0.5 and so this package has those versions as a new floor
AI Disclosure: NONE: I actively avoid LLMs: No LLM or any other machine learning technique or product was used during the ideation, creation or description of this change.