-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Do not use Any
in NamedTuple()
constructor
#6489
Conversation
While working on python/mypy#11206 I've found that this test now fails: https://github.com/python/mypy/blob/cee5d3e9a29f43a10a8eeca760976657bf1689c9/test-data/unit/check-flags.test#L1177-L1185 Looks like `object` is better suited here. `Literal[1]` is also an object, `Union[int, str]` is an object as well. So, it should always work (I've tested that the current `mypy` agrees with me). And no `Any` related problems.
This comment has been minimized.
This comment has been minimized.
This doesn't seem correct to me. The following fails at runtime: NamedTuple("Foo", [("abc", 123)])
NamedTuple("Foo", None, abc=123) |
@srittau For example, from typing import NamedTuple
Foo = NamedTuple("Foo", [("abc", 123)])
Bar = NamedTuple("Bar", None, abc=123) Output:
But, I would like to drop an extra comment on |
Maybe if you added a comment clarifying that the stub is "deliberately incorrect" here? 🙂 Something like:
|
I think we should just keep |
As I said in #6489 (comment), I will attach @AlexWaygood's comment. Maybe this would be good enough 🙂 |
I'm hesitant to make "wrong" changes to typeshed to benefit a single type checker. Sometimes this is unavoidable, but I'd like to see other avenues explored first. I'd be interested what other maintainers think, though. Cc @JelleZijlstra @hauntsaninja @Akuli |
To me, it seems unlikely that anyone actually wants to use mypy with |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Agree with @srittau. |
While working on python/mypy#11206 I've found that this test now fails: https://github.com/python/mypy/blob/cee5d3e9a29f43a10a8eeca760976657bf1689c9/test-data/unit/check-flags.test#L1177-L1185
Looks like
object
is better suited here.Literal[1]
is also an object,Union[int, str]
is an object as well.So, it should always work (I've tested that the current
mypy
agrees with me). And noAny
related problems.