-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
stubtest: fix literal type construction #11931
Conversation
Literal[b]
was not properly checked by stubtest
Literal[bytes]
was not properly checked by stubtest
Failure!
Link: https://github.com/python/mypy/runs/4736271970?check_suite_focus=true Now I will try to fix it. |
Done! CC @hauntsaninja |
@@ -942,6 +942,15 @@ def is_subtype_helper(left: mypy.types.Type, right: mypy.types.Type) -> 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) |
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