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

Union of dicts fail #10135

Closed
socketpair opened this issue Feb 25, 2021 · 3 comments
Closed

Union of dicts fail #10135

socketpair opened this issue Feb 25, 2021 · 3 comments
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code

Comments

@socketpair
Copy link

https://mypy-play.net/?mypy=latest&python=3.9&gist=6770a34c37170183d0fefe8b1444aa27

from typing import Dict, Union

def fun() -> Union[Dict[str, int], Dict[int, float]]:
    return {}
error: Incompatible return value type (got "Dict[<nothing>, <nothing>]", expected "Union[Dict[str, int], Dict[int, float]]")
@socketpair socketpair added the bug mypy got something wrong label Feb 25, 2021
@socketpair
Copy link
Author

I guess, {} should be Dict[Any, Any] and not Dict[<nothing>, <nothing>]

@srittau
Copy link
Contributor

srittau commented Feb 26, 2021

There is prior discussion in python/typeshed#4846 and a PR in python/typeshed#4987.

@JukkaL JukkaL added the false-positive mypy gave an error on correct code label Mar 5, 2021
@AlexWaygood AlexWaygood added the topic-join-v-union Using join vs. using unions label Apr 1, 2022
@hauntsaninja hauntsaninja removed the topic-join-v-union Using join vs. using unions label May 13, 2023
@socketpair
Copy link
Author

Not reproduced anymore, so closing.

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

No branches or pull requests

5 participants