Skip to content
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

"SupportsInt" doesn't work with Union types #2330

Closed
sangsta opened this issue Oct 25, 2016 · 5 comments
Closed

"SupportsInt" doesn't work with Union types #2330

sangsta opened this issue Oct 25, 2016 · 5 comments
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal topic-union-types

Comments

@sangsta
Copy link

sangsta commented Oct 25, 2016

The following shouldn't be an error:
error: Argument 1 to "int" has incompatible type "Union[unicode, int]"; expected "SupportsInt"

@ddfisher
Copy link
Collaborator

In particular, you can repro this for Python 2 with:

from typing import Union
x = 0  # type: Union[int, unicode]
int(x)

@elazarg
Copy link
Contributor

elazarg commented Oct 25, 2016

I would guess it is another example of #2128 and the general overloading/Union problem.

@nolanlum
Copy link

nolanlum commented Feb 9, 2018

FYI this is still an issue in Python 3.6:

error: Argument 1 to "int" has incompatible type "Union[int, str]"; expected "SupportsInt"

@emmatyping
Copy link
Collaborator

Yes, this is an issue in mypy's union deduction checks, and is independent of Python version.

@JukkaL JukkaL added the false-positive mypy gave an error on correct code label May 19, 2018
@ilevkivskyi
Copy link
Member

This issue is now fixed (example correctly passes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal topic-union-types
Projects
None yet
Development

No branches or pull requests

8 participants