Skip to content

ternary of Tuple[builtins.str] / Tuple[] falling to builtins.object #5150

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
asottile opened this issue Jun 5, 2018 · 3 comments
Closed
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high

Comments

@asottile
Copy link
Contributor

asottile commented Jun 5, 2018

version

$ mypy --version
mypy 0.600

code

import sys

tty = ('--tty',) if sys.stdout.isatty() else ()
#reveal_type(tty)
#reveal_type(('--tty',))
#reveal_type(())
cmd = ('docker', 'run', *tty, 'ubuntu:bionic', 'bash')

run (without revealed types)

$ mypy test.py
test.py:7: error: List or tuple expected as variable arguments

run (with revealed types)

$ mypy test.py
test.py:4: error: Revealed type is 'builtins.object'
test.py:5: error: Revealed type is 'Tuple[builtins.str]'
test.py:6: error: Revealed type is 'Tuple[]'
test.py:7: error: List or tuple expected as variable arguments

Possibly related: #5134

@emmatyping emmatyping added bug mypy got something wrong priority-0-high false-positive mypy gave an error on correct code labels Jun 5, 2018
@emmatyping
Copy link
Member

I feel that tuple if bool else tuple should result in some kind of tuple. I'm not sure which, probably Tuple[str, ...] in this case?

@asottile
Copy link
Contributor Author

asottile commented Jun 5, 2018

I think Tuple[str, ...] would be ideal, though even the Union[...] would probably make this succeed

@ilevkivskyi
Copy link
Member

This is essentially a duplicate of #4975, we just need to produce better joins for tuple types.

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-0-high
Projects
None yet
Development

No branches or pull requests

3 participants