stubtest: fix literal type construction#11931
stubtest: fix literal type construction#11931hauntsaninja merged 7 commits intopython:masterfrom sobolevn:stubtest-failure-literal-bytes
Conversation
Literal[b] was not properly checked by stubtestLiteral[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.
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) |
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