-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
stubtest: fix literal type construction #11931
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
stubtest: fix literal type construction #11931
Conversation
Literal[b] was not properly checked by stubtestLiteral[bytes] was not properly checked by stubtest
|
Failure! Now I will try to fix it. |
|
Done! CC @hauntsaninja |
| and isinstance(right, mypy.types.Instance) | ||
| and right.type.fullname == "builtins.bool" | ||
| ): | ||
| # Pretend Literal[0, 1] is a subtype of bool to avoid unhelpful errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I am almost sure that it does not work anymore, because bool() now is Union[Literal[False], Literal[True]].
I can address this in a new PR.
|
Looks like mypyc-compiled mypy fails. Here's the reason why: https://github.com/python/mypy/blame/e8cf960e8579e5cee2db27212efad4870e5106bd/mypy/stubtest.py#L1032-L1041 Any ideas? |
|
Looking, I can push a fix to your branch! |
|
Let's wait for my new solution to build. Maybe I've found a good workaround. But,
Yes, |
|
Oh just saw your message. Our fixes are quite similar. We should be able to change enum handling as well and get rid of that hacky try catch completely (what I pushed isn't quite right). I also collate the tests... it makes running stubtest tests much faster (since each test method involves writing files to disk) |
sobolevn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Literal[bytes] was not properly checked by stubtest|
As a result, this should be fixed as well https://github.com/python/typeshed/blob/032e6ee90cbb938259a2aa2183966502de19108e/tests/stubtest_allowlists/py3_common.txt#L108 :-) |
|
Awesome! I will send a PR to fix it, when new mypy will be out! |
Co-authored-by: hauntsaninja <>
Co-authored-by: hauntsaninja <>
I've started with a new unit test that illustrates the problem.
Closes python/typeshed#6845