Skip to content

Conversation

@sterliakov
Copy link
Collaborator

Fixes #19185. Fixes #19186.

Replaces #19382 (not closing that yet, need to extract another part related to applytype from there to another PR).

When a TypeVar defaults to another TypeVar, that default should already be in scope. Fortunately we already analyze them in the correct order, so the active scope has all the necessary information. This fixes the namespace drift problem because the bound typevars are already adjusted to use the correct namespace, and we do not need to touch their global definitions.

I am not super happy about making TypeVarLikeScope impure here - any suggestions? Would passing self.msg to every bind_new call look saner?

@github-actions

This comment has been minimized.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re pureness: maybe we can pass msg into bind_new and have the TypeVarLikeDefaultFixer store messages that we report in bind_new?

edit: oops, didn't see you suggested that. yeah i think that might be nicer!

@github-actions
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

Projects

None yet

2 participants