Skip to content

Commit f27aa23

Browse files
committed
Drop support for running with Python 3.9
1 parent d6e9c31 commit f27aa23

22 files changed

+55
-113
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,18 @@ jobs:
3131
include:
3232
# Make sure to run mypyc compiled unit tests for both
3333
# the oldest and newest supported Python versions
34-
- name: Test suite with py39-ubuntu, mypyc-compiled
35-
python: '3.9'
36-
os: ubuntu-24.04-arm
37-
toxenv: py
38-
tox_extra_args: "-n 4"
39-
test_mypyc: true
40-
- name: Test suite with py310-ubuntu
34+
- name: Test suite with py310-ubuntu, mypyc-compiled
4135
python: '3.10'
4236
os: ubuntu-24.04-arm
4337
toxenv: py
4438
tox_extra_args: "-n 4"
39+
test_mypyc: true
4540
- name: Test suite with py311-ubuntu
4641
python: '3.11'
4742
os: ubuntu-24.04-arm
4843
toxenv: py
4944
tox_extra_args: "-n 4"
50-
- name: Test suite with py312-ubuntu, mypyc-compiled
45+
- name: Test suite with py312-ubuntu
5146
python: '3.12'
5247
os: ubuntu-24.04-arm
5348
toxenv: py
@@ -101,12 +96,12 @@ jobs:
10196
# tox_extra_args: "-n 4 mypyc/test/test_run.py mypyc/test/test_external.py"
10297
# debug_build: true
10398

104-
- name: Type check our own code (py39-ubuntu)
105-
python: '3.9'
99+
- name: Type check our own code (py310-ubuntu)
100+
python: '3.10'
106101
os: ubuntu-latest
107102
toxenv: type
108-
- name: Type check our own code (py39-windows-64)
109-
python: '3.9'
103+
- name: Type check our own code (py310-windows-64)
104+
python: '3.10'
110105
os: windows-latest
111106
toxenv: type
112107

.github/workflows/test_stubgenc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ jobs:
3232
with:
3333
persist-credentials: false
3434

35-
- name: Setup 🐍 3.9
35+
- name: Setup 🐍 3.10
3636
uses: actions/setup-python@v5
3737
with:
38-
python-version: 3.9
38+
python-version: '3.10'
3939

4040
- name: Test stubgenc
4141
run: misc/test-stubgenc.sh

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## Next Release
44

5+
### Drop Support for Python 3.9
6+
7+
Mypy no longer supports running with Python 3.9, which has reached end-of-life.
8+
When running mypy with Python 3.10+, it is still possible to type check code
9+
that needs to support Python 3.9 with the `--python-version 3.9` argument.
10+
Support for this will be dropped in the first half of 2026!
11+
12+
Contributed by Marc Mueller (PR [20156](https://github.com/python/mypy/pull/20156)).
13+
514
## Mypy 1.18.1
615

716
We’ve just uploaded mypy 1.18.1 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ hash -r # This resets shell PATH cache, not necessary on Windows
5151
```
5252

5353
> **Note**
54-
> You'll need Python 3.9 or higher to install all requirements listed in
54+
> You'll need Python 3.10 or higher to install all requirements listed in
5555
> test-requirements.txt
5656
5757
### Running tests

docs/source/getting_started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ may not make much sense otherwise.
1616
Installing and running mypy
1717
***************************
1818

19-
Mypy requires Python 3.9 or later to run. You can install mypy using pip:
19+
Mypy requires Python 3.10 or later to run. You can install mypy using pip:
2020

2121
.. code-block:: shell
2222

mypy/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Earliest fully supported Python 3.x version. Used as the default Python
77
# version in tests. Mypy wheels should be built starting with this version,
88
# and CI tests should be run on this version (and later versions).
9-
PYTHON3_VERSION: Final = (3, 9)
9+
PYTHON3_VERSION: Final = (3, 10)
1010

1111
# Earliest Python 3.x version supported via --python-version 3.x. To run
1212
# mypy, at least version PYTHON3_VERSION is needed.

mypy/test/meta/test_parse_data.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ def test_bad_ge_version_check(self) -> None:
5050
"""
5151
[case abc]
5252
s: str
53-
[out version>=3.9]
53+
[out version>=3.10]
5454
abc
5555
"""
5656
)
5757

5858
# Assert
59-
assert "version>=3.9 always true since minimum runtime version is (3, 9)" in actual.stdout
59+
assert (
60+
"version>=3.10 always true since minimum runtime version is (3, 10)" in actual.stdout
61+
)
6062

6163
def test_bad_eq_version_check(self) -> None:
6264
# Act
@@ -70,4 +72,6 @@ def test_bad_eq_version_check(self) -> None:
7072
)
7173

7274
# Assert
73-
assert "version==3.7 always false since minimum runtime version is (3, 9)" in actual.stdout
75+
assert (
76+
"version==3.7 always false since minimum runtime version is (3, 10)" in actual.stdout
77+
)

mypy/test/testpythoneval.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ def test_python_evaluation(testcase: DataDrivenTestCase, cache_dir: str) -> None
7171
return
7272
mypy_cmdline.extend(additional_flags)
7373

74+
if "--no-force-union-syntax" not in mypy_cmdline:
75+
mypy_cmdline.append("--force-union-syntax")
76+
7477
# Write the program to a file.
7578
program = "_" + testcase.name + ".py"
7679
program_path = os.path.join(test_temp_dir, program)

mypy/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,10 @@ def get_unique_redefinition_name(name: str, existing: Container[str]) -> str:
482482
def check_python_version(program: str) -> None:
483483
"""Report issues with the Python used to run mypy, dmypy, or stubgen"""
484484
# Check for known bad Python versions.
485-
if sys.version_info[:2] < (3, 9): # noqa: UP036, RUF100
485+
if sys.version_info[:2] < (3, 10): # noqa: UP036, RUF100
486486
sys.exit(
487-
"Running {name} with Python 3.8 or lower is not supported; "
488-
"please upgrade to 3.9 or newer".format(name=program)
487+
"Running {name} with Python 3.9 or lower is not supported; "
488+
"please upgrade to 3.10 or newer".format(name=program)
489489
)
490490

491491

mypy_self_check.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ show_traceback = True
77
pretty = True
88
always_false = MYPYC
99
plugins = mypy.plugins.proper_plugin
10-
python_version = 3.9
10+
python_version = 3.10
1111
exclude = mypy/typeshed/|mypyc/test-data/|mypyc/lib-rt/
1212
enable_error_code = ignore-without-code,redundant-expr
1313
enable_incomplete_feature = PreciseTupleTypes

0 commit comments

Comments
 (0)