Skip to content

Move Windows tests from oldest to newest version #19545

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ilevkivskyi
Copy link
Member

This is mostly to speed-up CI, but also as we discussed with Jukka this may make more sense as we want to test new features on more platforms.

This comment has been minimized.

@ilevkivskyi
Copy link
Member Author

OK, 7 tests failed, LOL: 5 tests involving --package-root and 2 mypyc tests. Not sure what is going on here, maybe those tests were previously skipped on Windows for some reason.

cc @JukkaL

@ilevkivskyi
Copy link
Member Author

I am retrying first, just in case. Just to rule out one-off fluctuation.

@ilevkivskyi
Copy link
Member Author

OK, retry did not help, but here is some data:

  • Tests with --package-root fail consistently
  • Mypyc test testRunAsyncRefCounting fails with a timeout on both runs, @JukkaL I see you added it, so you may have ideas what is going on
  • The second mypyc test now passed but another one failed with same weird error
pytest.PytestUnraisableExceptionWarning: Exception ignored in: <_io.FileIO [closed]>

Traceback (most recent call last):
File "D:\a\mypy\mypy\mypy\types.py", line 1885, in __init__
    for t, k in zip(arg_types, arg_kinds):
                ~~~^^^^^^^^^^^^^^^^^^^^^^
ResourceWarning: unclosed file <_io.FileIO name=14 mode='rb' closefd=True>

@sterliakov
Copy link
Collaborator

Any chance the ResourceWarning is related to #18145? I really know nothing about Windows quirks, that was just a quick attempt to stop recurring random CI crashes...

@emmatyping
Copy link
Member

FWIW, we used to test on the oldest Python version because there was the MSVC ABI differences. The ABI has been stable for quite a while (though may change in a few years) so I think it is fine to change it for now. If there is an ABI break we can always move the job back.

@emmatyping
Copy link
Member

I can try to take a look at the Windows failures later today. It looks like I can reproduce them locally.

@ilevkivskyi
Copy link
Member Author

@emmatyping Great, thanks!

ilevkivskyi pushed a commit that referenced this pull request Aug 4, 2025
This PR should fix the rest of the test failures in
#19545.

A change to `os.path.relpath` in 3.13 seems to have broken the handling
of Windows paths beginning with `\\`. To resolve this issue, we don't
split the drive letter off of the path and instead verify the path is on
the current drive. If it isn't it will never resolve to the package root
because that must be on the same drive as the CWD:

https://github.com/python/mypy/blob/5b03024e829940cf3c3e3d99fc6625f569d02728/mypy/main.py#L1571-L1572

Keeping the drive letter allows relpath to properly generate a relative
path and make the tests pass.

I need to investigate if the relpath change is a regression in CPython.
ilevkivskyi pushed a commit that referenced this pull request Aug 4, 2025
This is part of fixing the failed tests in
#19545

The async tests previously used many invocations of `asyncio.run`, which
likely caused issues with event loop management. The documentation for
`asyncio.run` states:
> This function cannot be called when another asyncio event loop is
running in the same thread. ...
> This function should be used as a main entry point for asyncio
programs, and should ideally only be called once.

Calling `asyncio.run` multiple times could cause the test processes to
hang for strange event loop reasons. This commit converts most test
cases to be run in a single event loop managed by the default driver,
which is now async aware.

Not all tests could be converted, e.g. the test that runs an async
function in a sync context. However, the test suite does succeed with
these changes, and these tests can be further modified if needed.
Copy link
Contributor

github-actions bot commented Aug 4, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants