Skip to content

Fix swapping TypeVars with defaults. #19449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

randolf-scholz
Copy link
Contributor

@randolf-scholz randolf-scholz commented Jul 15, 2025

Changed the logic for recursion guards of TypeVarType: Instead of always substituting repl = repl.accept(self), and situationally updating repl.default = repl.default.accept(self) if the result is a TypeVarType, we now always update repl.default = repl.default.accept(self) a priori and then only choose the expanded repl.accept(self) if the result is a concrete type.

PS: closed earlier PRs #19447, since it contained debugging changes and #19448 because it didn't solve #19362.

This comment has been minimized.

@cdce8p cdce8p added the topic-pep-696 TypeVar defaults label Jul 16, 2025
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-pep-696 TypeVar defaults
Projects
None yet
2 participants