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

(🐞) Sus impostor tuple in dict literal error message #15973

Open
KotlinIsland opened this issue Aug 27, 2023 · 4 comments
Open

(🐞) Sus impostor tuple in dict literal error message #15973

KotlinIsland opened this issue Aug 27, 2023 · 4 comments
Labels
bug mypy got something wrong topic-disallow-any The disallow-any-* family of flags topic-usability

Comments

@KotlinIsland
Copy link
Contributor

from typing import Any

any: Any
{"a": any}  # error: Expression type contains "Any" (has type "tuple[str, Any]")  [misc]

tuple[str, Any]

@KotlinIsland KotlinIsland added the bug mypy got something wrong label Aug 27, 2023
@sobolevn
Copy link
Member

I cannot reproduce this error with default settings, but I think that you mean --disallow-any-expr:

» mypy ex.py --disallow-any-expr
ex.py:4: error: Expression type contains "Any" (has type "tuple[str, Any]")  [misc]
ex.py:4: error: Expression has type "Any" 

So, the problem is that the error message is shown twice, isn't it?

@KotlinIsland
Copy link
Contributor Author

KotlinIsland commented Aug 28, 2023

So, the problem is that the error message is shown twice, isn't it?

Well, I can see two expressions that contain Any, any and {"a": any}, but neither of these expressions are a tuple.

@sobolevn
Copy link
Member

When checking {"a": any} mypy represents it as a tuple of key and value, which is kinda what it is.

@AlexWaygood AlexWaygood added the topic-disallow-any The disallow-any-* family of flags label Aug 28, 2023
@KotlinIsland
Copy link
Contributor Author

When checking {"a": any} mypy represents it as a tuple of key and value, which is kinda what it is.

Yeah, that does make sense that mypy would, as an implementation detail, model this as a tuple. But in reality it's not, so the error message here doesn't make Any sense.

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-disallow-any The disallow-any-* family of flags topic-usability
Projects
None yet
Development

No branches or pull requests

4 participants