-
-
Notifications
You must be signed in to change notification settings - Fork 296
Add additional flags to mypy
config and update type: ignore
's
#1248
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
Conversation
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.
Smell like progress !
no_implicit_optional = True | ||
warn_redundant_casts = True | ||
warn_unused_ignores = True | ||
show_error_codes = 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 think it's |
I don't think that requires you to specify the error you're ignoring in a |
Ho, sorry I misunderstood your question. I think this is not yet in mypy : python/mypy#11509 |
tests/unittest_protocols.py
Outdated
match_mapping: nodes.MatchMapping = assign_stmts.pattern # type: ignore | ||
match_mapping: nodes.MatchMapping = assign_stmts.pattern |
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.
The type: ignores
here are only unused since the method isn't annotated and thus not type checked.
setup.cfg
Outdated
@@ -65,6 +65,10 @@ skip_glob = tests/testdata | |||
|
|||
[mypy] | |||
scripts_are_modules = True | |||
no_implicit_optional = True | |||
warn_redundant_casts = True | |||
warn_unused_ignores = 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 remove warn_unused_ignores = True
just for now. It isn't an issue at the moment. Instead it's more likely to cause false positives (see comment above). Other false-positives are the two type: ignores
in rebuilder.py
. They are only necessary in Python 3.9+, thus when checked with 3.8 they are marked as unnecessary.
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.
Look like mypy has the same problem than us for useless-suppression. We could mimic how they handle 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.
Look like mypy has the same problem than us for useless-suppression. We could mimic how they handle it ?
We already do ;) They don't handle 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.
I mean they have an option to activate it or not with warn_unused_ignores = True
, like we do when we enable useless-suppression, but do you know how they handle discrepancies that appear between python interpreter when unused ignores are activated ?
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.
If the code is evaluated, they emit an error. I.e. not if it's guarded behind a if sys.version_info
check what is quite common when using typing.
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Steps
Description
@cdce8p I think these are the flags we can turn on right now without much trouble.
I also added an error code to every single
type: ignore
currently in the code.I couldn't find anything about it online, but do you know if there is a way to require error codes in these ignore messages?
Type of Changes
Related Issue