Skip to content

spread dict not used to infer type #11691

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
DetachHead opened this issue Dec 9, 2021 · 2 comments
Closed

spread dict not used to infer type #11691

DetachHead opened this issue Dec 9, 2021 · 2 comments
Labels
bug mypy got something wrong topic-typed-dict

Comments

@DetachHead
Copy link
Contributor

foo: dict[type, str] = {int: ""}

{**foo, str: ""}
# mypy seems to interpret it as this, where the error makes sense:
{str: ""}.update(foo)
main.py:3: error: Argument 1 to "update" of "dict" has incompatible type "Dict[type, str]"; expected "Mapping[Type[str], str]"
main.py:4: error: Argument 1 to "update" of "dict" has incompatible type "Dict[type, str]"; expected "Mapping[Type[str], str]"

https://mypy-play.net/?mypy=master&python=3.10&gist=c5a3a39b154395b6d26de54050834ac4&flags=strict

@DetachHead DetachHead added the bug mypy got something wrong label Dec 9, 2021
@DetachHead
Copy link
Contributor Author

l: list[set[str]] = []

[*l, {1}]

it doesn't happen on a single * spread

@ilevkivskyi
Copy link
Member

This now works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-typed-dict
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants