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

Ternary operator assignment reports type error #6757

Closed
eugene-makunin opened this issue May 3, 2019 · 1 comment
Closed

Ternary operator assignment reports type error #6757

eugene-makunin opened this issue May 3, 2019 · 1 comment

Comments

@eugene-makunin
Copy link

Hi guys! I have this code:

def foo(field: Union[str, Tuple[str, ...]]) -> None:
    fields_sequence: Sequence[str] = field if isinstance(field, tuple) else (field,)
    print(fields_sequence)

That looks fine for me but mypy reports the next error:

error: Incompatible types in assignment (expression has type "object", variable has type "Sequence[str]")

Actually, there are two tuples on both ternary operator sides. I think this is a defect.

@ilevkivskyi
Copy link
Member

Duplicate of #4975

@ilevkivskyi ilevkivskyi marked this as a duplicate of #4975 May 3, 2019
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