Skip to content

Assignment into unpacked tuple including ignored variables unexpectedly errors #4621

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
rotemdan opened this issue Feb 22, 2018 · 2 comments
Closed

Comments

@rotemdan
Copy link

Sorry if duplicate! I couldn't find anything similar:
(using mypy 0.560)

from typing import Tuple

def getTuple() -> Tuple[str, str, int]:
    return ('Hello', 'World', 123)
	
(s, _, _) = getTuple() # Error: Incompatible types in assignment 
                       # (expression has type "int", variable has type "str")

Seems like the unpacked tuple is inferred as (str, str, str). For this case I would assume it would infer (str, str, int) or (str, Any, Any) .

For comparison, in the more general case:

(s1, s2 , i) = getTuple()

The receiving tuple is inferred as (str, str, int).

@ilevkivskyi
Copy link
Member

Sorry for this! We have heard about this often so the priority has been raised to high.

Closing as duplicate of #465

@rotemdan
Copy link
Author

Thanks for the quick response! Sorry I couldn't find the duplicate. I didn't search with the right keywords, I guess.

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