-
-
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
Allow error codes to be disabled inline #9989
Comments
As a workaround, you can put |
Thanks, @JelleZijlstra - that works for me. |
You can also skip the annotation on the second assignment: flag = True
if flag:
var: str = 'foo'
else:
var = 'bar' |
This seems to be a dupe of #6233 unless you want to describe how error codes should be disabled inline. If you are not aware you can use |
I agree. I'm not sure exactly what's being proposed here. |
Feature
I have some code like this:
mypy
complains about the redefinition ofvar
:I would like
mypy
to not complain about this as long as the types are the same, or "compatible" by some definition.Needless to say, the code within my
if..else
blocks is more complex than assigning a literal - in one case each branch has atry..except
block, so I can't just use a ternary.Pitch
The project I'm currently working on is a web app that uses feature flags. We therefore often have code blocks like the one above, and we would like
mypy
to not complain about this type of structure.The text was updated successfully, but these errors were encountered: