Fix testAsync, test_stdlibsamples and testSrcPEP420Packages with Python 3.10#11017
Fix testAsync, test_stdlibsamples and testSrcPEP420Packages with Python 3.10#11017JelleZijlstra merged 3 commits intopython:masterfrom
Conversation
JelleZijlstra
left a comment
There was a problem hiding this comment.
Thank you for these fixes!
Separate commits are fine; we'll squash them on merge.
| # cmd: mypy -p anamespace --namespace-packages | ||
| [file mypy.ini] | ||
| \[mypy]] | ||
| \[mypy] |
There was a problem hiding this comment.
I'm guessing this was just a typo.
mypyc/test-data/run-misc.test
Outdated
| loop = asyncio.get_event_loop() | ||
| result = loop.run_until_complete(f()) | ||
|
|
||
| result = asyncio.run(f()) |
There was a problem hiding this comment.
Unfortunately asyncio.run doesn't exist yet in 3.6 which we still support. You may have to put an if sys.version_info >= (3, 7) check here.
There was a problem hiding this comment.
Thanks for the feedback. I have updated the first commit, however there is a typing problem which I don't really understand and which I have not been able to reproduce by running mypyc on a test file:
mypy.errors.CompileError: native.py:14: error: Unsupported left operand type for >= ("Tuple[int, int, int, str, int]")
I tried to slice sys.version_info[:2] but it did not change anything. Is it because mypyc cannot compare tuples? Should I use sys.hexversion?
There was a problem hiding this comment.
That sounds like a problem with the fixtures being used in the test. I'm not sure there is an easy solution. :(
There was a problem hiding this comment.
Can you elaborate? What fixtures?
The following is not pretty but works:
if sys.version_info[0] >= 3 and sys.version_info[1] >= 7:There was a problem hiding this comment.
I mean the fixtures in https://github.com/python/mypy/tree/master/test-data/unit/fixtures, which are used instead of typeshed's builtins.pyi in mypy unit tests.
If what you wrote works I'm fine with it, but I suspect it won't typecheck in 3.6. I'm not really familiar with mypyc tests though.
There was a problem hiding this comment.
Weirdly the second comparison doesn't cause a problem, do you know why?
I ran tests with 3.6 with this Dockerfile:
FROM python:3.6
RUN git clone --branch py310 --single-branch https://github.com/sbraz/mypy
WORKDIR mypy
RUN pip install -r test-requirements.txt
RUN pytest -vv mypyc/test/test_run.py
This comment has been minimized.
This comment has been minimized.
The test would previously yield "DeprecationWarning: There is no current event loop".
by accounting for the move from collections to collections.abc.
Before this change, the test would yield "mypy.ini: No [mypy] section in config file" because of the double closing bracket. This is caused by a fix for https://bugs.python.org/issue38741 that is included in Python 3.10: python/cpython@1cc6769
This comment has been minimized.
This comment has been minimized.
|
The mypy-primer output here is suspicious, since this diff should only touch tests. I'm going to close and re-enable to see what happens. |
JelleZijlstra
left a comment
There was a problem hiding this comment.
No mypy-primer output now, so this is fine to merge.
|
Thank you for your contributions! |
…on 3.10 (#11017) * tests: make testAsync work with Python 3.10 The test would previously yield "DeprecationWarning: There is no current event loop". * tests: fix test_stdlibsamples with Python 3.10 by accounting for the move from collections to collections.abc. * tests: fix testSrcPEP420Packages with Python 3.10 Before this change, the test would yield "mypy.ini: No [mypy] section in config file" because of the double closing bracket. This is caused by a fix for https://bugs.python.org/issue38741 that is included in Python 3.10: python/cpython@1cc6769
Description
Hi,
This fixes 3 failing tests with Python 3.10:
I have included details about the problems I encountered with Python 3.10 in each commit message.
test_stdlibsamplesis trivial.asyncioso I am not 100% sure about the fix fortestAsync.testSrcPEP420Packages, I don't really understand why there were two closing brackets in the first place.Please let me know if I should squash the commits but since they tacke different issues I thought it best to leave them this way.
Test Plan
I ran each of the 3 tests with Python 3.8 to 3.10 to make sure I didn't break anything, I guess the CI will double-check that.