Skip to content

Avoid placeholders in virtual dep aliases - #74

Merged
delfick merged 1 commit into
mainfrom
lazier-virtual-dep-aliases
Jul 14, 2026
Merged

delfick merged 1 commit into
mainfrom
lazier-virtual-dep-aliases

Conversation

@delfick

@delfick delfick commented Jul 10, 2026 •

Copy link
Copy Markdown
Owner

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


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.

@delfick
delfick force-pushed the lazier-virtual-dep-aliases branch 2 times, most recently from 1c7e1c6 to efceb18 Compare July 10, 2026 23:55
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
delfick force-pushed the lazier-virtual-dep-aliases branch from efceb18 to d1b85f3 Compare July 11, 2026 00:22
@delfick
delfick merged commit fbdd6b2 into main Jul 14, 2026
11 checks passed
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.

2 participants