-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix testAsync, test_stdlibsamples and testSrcPEP420Packages with Python 3.10 #11017
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
Conversation
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.
Thank you for these fixes!
Separate commits are fine; we'll squash them on merge.
@@ -791,7 +791,7 @@ c.py:2: error: Argument 1 to "bar" has incompatible type "str"; expected "int" | |||
[case testSrcPEP420Packages] | |||
# cmd: mypy -p anamespace --namespace-packages | |||
[file mypy.ini] | |||
\[mypy]] | |||
\[mypy] |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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!
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. |
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.
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_stdlibsamples
is trivial.asyncio
so 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.