-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Migrate core to use ErrorMessage class #12004
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
Migrate core to use ErrorMessage class #12004
Conversation
Well, it seems like |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
cff782e
to
2110701
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@sobolevn would you be able to review this? |
This comment has been minimized.
This comment has been minimized.
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 am basically fine with these changes!
My concerns:
- Merging this will make many other PRs to have merge conflicts
- Some existing PRs add raw-text errors. We need to somehow catch this. Maybe using a custom mypy plugin? Similar to one we have with
isinstance
- We now associate message contents with variable names, this might get out of sync quite quickly
I totally need a second opinion on that!
@@ -5148,8 +5132,9 @@ def in_checked_function(self) -> bool: | |||
# no regular functions. | |||
return True | |||
|
|||
# TODO(tushar): remove `str` type and `code` property from here |
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.
Plugins might rely on msg: str
, so no need to delete it.
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.
Yeah, you're right. But I think it's a better model in the long term, for plugins to define a set of ErrorMessage objects somewhere in their files, instead of doing inline messages. For the same reasons as why we're doing it in mypy.
Could consider a deprecation cycle and enforcing this on plugins too!
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.
Could consider a deprecation cycle
As far as I know, we never did something like this before.
The merge conflicts will be easy fixes, and will teach the contributors about the new error message model, I think that's a good thing
It's fine to change variable name and message text together. When issue codes (unique identifier for each message) are added to ErrorMessage objects, only they need to remain constant for a relatively long time. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This seems invasive enough that I'd want to get @JukkaL's signoff. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Friendly bump, it's been a year since I first started these set of PRs, and I really want to finish this refactor, to be able to add support for issue codes to mypy. |
I'm redoing this PR in a bunch of granular versions instead, starting with #14753. Hope that will make it easier to get reviewed. |
Description
Migrates
fastparse.py
andfastparse2.py
,semanal.py
,semanal_*.py
andtypeanal.py
to use theErrorMessage
class.The initial plan was to do only
fastparse
andfastparse2
, but because of how intertwined the core files are, all of these had to be done in one go.This is a continuation of the discussion on #10947.
Notes:
fail
method ofSemanticAnalyzer
andSemanticAnalyzerCoreInterface
still implements themsg: str
code instead of only supportingmsg: ErrorMessage
, because all the plugins that implementSemanticAnalyzerCoreInterface
have yet to be migrated. I could do them in the same PR but the PR is already huge."Mypy doesn't support match stataments"
) was not moved to the message registry as it seems temporary.