-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix error reporting context for missing generic type arguments #7100
Conversation
I wasn't able to fully test this out internally because I ran into some other issues but one thing I noticed is this makes aliases like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me, modulo my concern about Foo = List
style aliases
@@ -2369,7 +2369,9 @@ def check_and_set_up_type_alias(self, s: AssignmentStmt) -> bool: | |||
# so we need to replace it with non-explicit Anys. | |||
res = make_any_non_explicit(res) | |||
no_args = isinstance(res, Instance) and not res.args | |||
fix_instance_types(res, self.fail) | |||
fix_instance_types(res, self.fail, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be done conditionally only when no_args
, maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, aliases like A = List
should be allowed even with the flag, will fix it now.
@msullivan I fixed the errors you reported, could you please try again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thanks for this.
Fixes #7077
The logic of the fix is quite straightforward: emit the error immediately when we fix an instance type, and not in a traversal after the main pass. Note that I fix this only for the new analyser, because the old one will be anyway deprecated soon.
This causes a bit of code churn because we need to pass the flags to several functions, but the logic should not change much. I didn't add many new tests, since we have a bunch of existing tests. It would probably make sense to play with this, suggestions for more tests are very welcome.