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
When I use from __future__ import division, mypy looks for __div__ on objects instead of __truediv__. Example code:
from __future__ import division
__div__
__truediv__
from __future__ import division class ClassWithDiv(object): def __div__(self, other): # type: (ClassWithDiv) -> None return None class ClassWithTrueDiv(object): def __truediv__(self, other): # type: (ClassWithTrueDiv) -> None return None ClassWithDiv() / ClassWithDiv() ClassWithTrueDiv() / ClassWithTrueDiv()
The actual output of running mypy --py2:
mypy --py2
$ mypy --py2 test_div.py test_div.py:17: error: "ClassWithTrueDiv" has no attribute "__div__"
The expected output should be something like this:
test_div.py:16: error: "ClassWithDiv" has no attribute "__truediv__"
It would also be acceptable to give the same output as in Python 3 mode, which is:
$ mypy test_div.py test_div.py:16: error: Unsupported left operand type for / ("ClassWithDiv")
I am using mypy from Git master. Version info:
$ mypy --version mypy 0.640+dev-2244721df395ea7ccb986286a12594e2d7b097e8 $ python --version Python 3.6.5
I am not using any mypy flags besides --py2.
--py2
The text was updated successfully, but these errors were encountered:
A more obvious reproducer:
from __future__ import division reveal_type(1 / 2)
The output of this is:
$ mypy --py2 test_div2.py test_div2.py:3: error: Revealed type is 'builtins.int'
But it should be:
test_div2.py:3: error: Revealed type is 'builtins.float'
Sorry, something went wrong.
That's a good catch. Do you feel up to attempting to submit a fix as a PR?
This is actually a duplicate of #2048, so I am going to close this one, since the original has more discussion. Feel free to submit a PR.
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
When I use
from __future__ import division
, mypy looks for__div__
on objects instead of__truediv__
. Example code:The actual output of running
mypy --py2
:The expected output should be something like this:
It would also be acceptable to give the same output as in Python 3 mode, which is:
I am using mypy from Git master. Version info:
I am not using any mypy flags besides
--py2
.The text was updated successfully, but these errors were encountered: