Skip to content

Mistype of empty tuples #4090

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

Closed
rtpg opened this issue Oct 10, 2017 · 4 comments
Closed

Mistype of empty tuples #4090

rtpg opened this issue Oct 10, 2017 · 4 comments

Comments

@rtpg
Copy link
Contributor

rtpg commented Oct 10, 2017

Perhaps I'm missing some subtlety here but mypy complains about two usages for empty tuples that I do not believe are invalid:

print( ()  + (2,3,))
foo = True
print( ((1,2,) if foo else ()) + (2,3,))

This gives:

my_test.py:1: error: Unsupported operand types for + ("Tuple[]" and "Tuple[int, int]")
my_test.py:3: error: Unsupported left operand type for + ("object")

Typing this out, it feels like it might be an issue with generics. This started getting reported in 0.530 for me.

@JelleZijlstra
Copy link
Member

I think this is an old issue, #224. Your description makes it sound like this is a regression in 0.530 though, can you confirm that? If so, this should be high priority to fix.

@rtpg
Copy link
Contributor Author

rtpg commented Oct 10, 2017

This was not getting caught by our CI with 0.521, but an instance of this started getting caught in 0.530 so I believe it is a regression.

@gvanrossum
Copy link
Member

I tried to bisect this and found it still occurs back with version 0.501, so don't think this is a regression. Probably there was some other reason why the real code that you were checking passed (perhaps some other bug make mypy ignore some code).

FWIW the example I tried was:

a = () + (1,2)

This gives two errors:

__tmp__.py:1: error: Unsupported operand types for + ("tuple" and "Tuple[int, int]")
__tmp__.py:1: error: Need type annotation for variable

@ilevkivskyi
Copy link
Member

Since this is not a regression, I propose to close this as a duplicate of #224

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants