Skip to content

Tuple in ternary expression treated as object #6433

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
pdeblanc opened this issue Feb 19, 2019 · 1 comment
Closed

Tuple in ternary expression treated as object #6433

pdeblanc opened this issue Feb 19, 2019 · 1 comment

Comments

@pdeblanc
Copy link

When checking this code in mypy 0.670:

from typing import Union


a: Union[tuple, int] = 3
b = (a,) if isinstance(a, int) else a
reveal_type(b)  # builtins.object

The inferred type of b is builtins.object. It should be some kind of tuple. I believe this example is minimal in that:

  1. It works fine if I use list instead of tuple
  2. It works fine if I replace the ternary expression with if/then statements
@emmatyping
Copy link
Member

Hi, this is a duplicate of #4975

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

2 participants