Skip to content

Conversation

@cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Oct 31, 2025

Similar to last year (#17492), start by dropping support for running mypy with Python 3.9.
Users will still be able to type check 3.9 code with --python-version 3.9 until typeshed drops the support for it.

Refs #20154

@cdce8p cdce8p marked this pull request as draft October 31, 2025 23:43
@github-actions

This comment has been minimized.

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Nov 1, 2025

I can take updating ruff to get rid of the UP038 thing (edit: #20158 )

@cdce8p cdce8p force-pushed the drop-3.9 branch 2 times, most recently from 1937838 to 088c00a Compare November 1, 2025 00:33
@github-actions

This comment has been minimized.

@cdce8p cdce8p marked this pull request as ready for review November 1, 2025 01:05
Copy link
Collaborator Author

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR would be ready now. I'd recommend to look at the commits individually to make the review easier.

Comment on lines +74 to +75
if "--no-force-union-syntax" not in mypy_cmdline:
mypy_cmdline.append("--force-union-syntax")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this here temporarily. Without it the output of a lot of pythoneval test would change now that these are run with 3.10 by default.

I plan to update the test outputs to use the PEP 604 union syntax in separate PRs later.

Comment on lines +5 to +12
### Drop Support for Python 3.9

Mypy no longer supports running with Python 3.9, which has reached end-of-life.
When running mypy with Python 3.10+, it is still possible to type check code
that needs to support Python 3.9 with the `--python-version 3.9` argument.
Support for this will be dropped in the first half of 2026!

Contributed by Marc Mueller (PR [20156](https://github.com/python/mypy/pull/20156)).
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reused the changelog entry from dropping Python 3.8 here. Just adjusted the numbers :)

Comment on lines -7 to -16
filelock>=3.3.0,<3.20.0 # latest version is not available on 3.9 that we still support
filelock>=3.3.0
lxml>=5.3.0; python_version<'3.15'
psutil>=4.0
pytest>=8.1.0
pytest-xdist>=1.34.0
pytest-cov>=2.10.0
setuptools>=75.1.0
tomli>=1.1.0 # needed even on py311+ so the self check passes with --python-version 3.9
tomli>=1.1.0 # needed even on py311+ so the self check passes with --python-version 3.10
pre_commit>=3.5.0
platformdirs<4.5.0 # latest version is not available on 3.9 that we still support
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pins for filelock and platformdirs were added in #20031. This change just reverse it now that Python 3.9 will be dropped.

@cdce8p cdce8p marked this pull request as draft November 1, 2025 01:28
@cdce8p cdce8p marked this pull request as ready for review November 1, 2025 01:33
@cdce8p
Copy link
Collaborator Author

cdce8p commented Nov 1, 2025

I removed the ruff target-version update here to keep the PR smaller. Will do that in a followup when this one is merged. This will make it much easier to see the actual changes here.

@github-actions

This comment has been minimized.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

os: ubuntu-24.04-arm
toxenv: py
tox_extra_args: "-n 4"
- name: Test suite with py312-ubuntu, mypyc-compiled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be removed, is there a reason to do so?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far we've tested a subset of versions with mypyc-compiled and without. In particular

  • The oldest and latest supported versions with mypyc
  • Often the second and third oldest without => that's what I'm doing here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should also change the test_mypyc: true

@github-actions

This comment has been minimized.

@mr-c
Copy link
Contributor

mr-c commented Nov 2, 2025

Huzzah! You could cleanup tox.ini as well:

diff --git a/tox.ini b/tox.ini
index 65f67aba4..8e97590b0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,8 +2,6 @@
 minversion = 4.4.4
 skip_missing_interpreters = {env:TOX_SKIP_MISSING_INTERPRETERS:True}
 envlist =
-    py38,
-    py39,
     py310,
     py311,
     py312,

@mr-c
Copy link
Contributor

mr-c commented Nov 2, 2025

Also, for the follow-up PR with the UP (pyupgrade) fixes, I would also recommend running auto-walrus $(git ls-files | grep \.py$) or equivalent for some := walrus love ❤️ (51 files changed, 109 insertions(+), 218 deletions(-))

@cdce8p
Copy link
Collaborator Author

cdce8p commented Nov 2, 2025

Also, for the follow-up PR with the UP (pyupgrade) fixes, I would also recommend running auto-walrus $(git ls-files | grep \.py$) or equivalent for some := walrus love ❤️ (51 files changed, 109 insertions(+), 218 deletions(-))

I just looked through the suggestions. A lot of them do look good to me though my experience so far has been that this is a deeply personal matter. It's probably best to leave it up to the individual developer where to use it and as such I'd suggest we don't change existing code just for the sake of it.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2025

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

Copy link
Member

@emmatyping emmatyping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ilevkivskyi
Copy link
Member

As I mentioned in the issue, I would prefer that this is merged after 1.19 is out.

@cdce8p cdce8p marked this pull request as draft November 4, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants