-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Support '# mypy: ' comments for inline configuration #6839
Conversation
a6e5f14
to
9b15343
Compare
9b15343
to
c85d6d4
Compare
Implements line configuration using '# mypy: ' comments, following the blueprint I proposed in #2938. It currently finds them just using a regex which means it is possible to pick up a directive spuriously in a string literal or something but honestly I am just not worried about that in practice. Examples of what it looks like in the tests. Fixes #2938. Thoughts?
340834d
to
096ec21
Compare
General idea looks solid to me. Probably worth adding some tests for invalid I didn't do a proper review (yet). |
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 is great! Two nits; and one thing that saddens me a little, but I'll leave it up to you to decide whether to do anything about the error line number or not.
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.
Thanks! This will be a great usabilitiy boost. I just have two random comments.
[case testInlineError1] | ||
# mypy: invalid-whatever | ||
[out] | ||
main: error: Unrecognized option: invalid_whatever = True |
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 would add more tests for the cases when user did something wrong:
- what if there is extra spaces around
=
? - what if
;
used as a separator? - what if a user forgot to quote a flag value that has commas?
etc.
I am happy with how this all looks now. Currently we produce an error on a skip-file directive. We could make it actually skip in a follow-up PR. |
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.
Looking forward to this!
Implements line configuration using '# mypy: ' comments, following the the discussion in python#2938. It currently finds them in a pretty primitive manner which means it is possible to pick up a directive spuriously in a string literal or something but honestly I am just not worried about that in practice. Documentation to come in a follow-up PR. Fixes python#2938.
Implements line configuration using '# mypy: ' comments, following the
blueprint I proposed in #2938.
It currently finds them just using a regex which means it is possible to pick
up a directive spuriously in a string literal or something but honestly I am
just not worried about that in practice.
Examples of what it looks like in the tests.
Still needs documentation.
Fixes #2938.
Thoughts?
(This is stacked on #6838 so can't be merged yet)