Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
(mypy-0.641, Python 3.6.7)
from typing import Optional def test_1(inp1: Optional[int] = None, inp2: Optional[int] = None) -> None: if any(attribute is None for attribute in (inp1, inp2)): pass else: if inp1 <= 0: print('<=0')
I am expecting type checking for the above function to work the same as for the one below:
def test_2(inp1: Optional[int] = None, inp2: Optional[int] = None) -> None: if inp1 is None or inp2 is None: pass else: if inp1 <= 0: print('<=0')
i.e. in the else block, the None case should be excluded and inp1 type should be inferred as int. Instead, mypy says (only for test_1()):
else
None
inp1
int
mypy
test_1()
mypytest.py:7: error: Unsupported operand types for >= ("int" and "None") mypytest.py:7: note: Left operand is of type "Optional[int]"
Is this something which should be easily fixed, or am I overlooking some edge cases?
The text was updated successfully, but these errors were encountered:
This is similar to #2980, and probably also low priority, since this form is not used often.
Also #4573 is related.
Sorry, something went wrong.
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
(mypy-0.641, Python 3.6.7)
I am expecting type checking for the above function to work the same as for the one below:
i.e. in the
else
block, theNone
case should be excluded andinp1
type should be inferred asint
. Instead,mypy
says (only fortest_1()
):Is this something which should be easily fixed, or am I overlooking some edge cases?
The text was updated successfully, but these errors were encountered: