Skip to content

Commit c8fad69

Browse files
committed
Remove Python3.9 support from CI and tests
Part of #13782
1 parent c013563 commit c8fad69

File tree

10 files changed

+44
-34
lines changed

10 files changed

+44
-34
lines changed

.github/workflows/daily.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
strategy:
3636
matrix:
3737
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
38-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
38+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
3939
fail-fast: false
4040

4141
steps:

.github/workflows/meta_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
with:
6666
version: PATH
6767
python-platform: ${{ matrix.python-platform }}
68-
python-version: "3.9" # Oldest version supported for running scripts and tests
68+
python-version: "3.10" # Oldest version supported for running scripts and tests
6969
project: ./pyrightconfig.scripts_and_tests.json
7070
stubsabot-dry-run:
7171
name: Stubsabot dry run

.github/workflows/stubtest_stdlib.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
strategy:
3232
matrix:
3333
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
34-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
34+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
3535
fail-fast: false
3636

3737
steps:

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
strategy:
4343
matrix:
4444
platform: ["linux", "win32", "darwin"]
45-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
45+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
4646
fail-fast: false
4747
steps:
4848
- uses: actions/checkout@v6
@@ -84,7 +84,7 @@ jobs:
8484
strategy:
8585
matrix:
8686
python-platform: ["Linux", "Windows", "Darwin"]
87-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
87+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
8888
fail-fast: false
8989
steps:
9090
- uses: actions/checkout@v6

tests/README.md

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
This directory contains several tests:
2+
23
- `tests/mypy_test.py`
3-
tests the stubs with [mypy](https://github.com/python/mypy/)
4+
tests the stubs with [mypy](https://github.com/python/mypy/)
45
- `tests/pyright_test.py` tests the stubs with
5-
[pyright](https://github.com/microsoft/pyright).
6+
[pyright](https://github.com/microsoft/pyright).
67
- `tests/regr_test.py` runs mypy against the test cases for typeshed's
7-
stubs, guarding against accidental regressions.
8+
stubs, guarding against accidental regressions.
89
- `tests/check_typeshed_structure.py` checks that typeshed's directory
9-
structure and metadata files are correct.
10+
structure and metadata files are correct.
1011
- `tests/stubtest_stdlib.py` checks standard library stubs against the
11-
objects at runtime.
12+
objects at runtime.
1213
- `tests/stubtest_third_party.py` checks third-party stubs against the
13-
objects at runtime.
14+
objects at runtime.
1415
- `tests/typecheck_typeshed.py` runs mypy against typeshed's own code
15-
in the `tests` and `scripts` directories.
16+
in the `tests` and `scripts` directories.
1617

1718
To run the tests, follow the [setup instructions](../CONTRIBUTING.md#preparing-the-environment)
18-
in the `CONTRIBUTING.md` document. In particular, you have to run with Python 3.9+.
19+
in the `CONTRIBUTING.md` document.
1920

2021
In order for `pyright_test` to work correctly, some third-party stubs
2122
may require extra dependencies external to typeshed to be installed in your virtual environment
2223
prior to running the test.
2324
You can list or install all of a stubs package's external dependencies using the following script:
25+
2426
```bash
2527
(.venv)$ python tests/get_external_stub_requirements.py <third_party_stub> # List external dependencies for <third_party_stub>
2628
(.venv)$ python tests/get_external_stub_requirements.py <third_party_stub1> <third_party_stub2> # List external dependencies for <third_party_stub1> and <third_party_stub2>
@@ -31,6 +33,7 @@ You can list or install all of a stubs package's external dependencies using the
3133
## Run all tests for a specific stub
3234

3335
Run using:
36+
3437
```bash
3538
(.venv)$ python3 tests/runtests.py <stdlib-or-stubs>/<stub-to-test>
3639
```
@@ -48,9 +51,10 @@ whether or not the test passes will depend on the exact version of Python
4851
you're using, as well as various other details regarding your local environment.
4952
For more information, see the docs on [`stubtest_stdlib.py`](#stubtest_stdlibpy) below.
5053

51-
## mypy\_test.py
54+
## mypy_test.py
5255

5356
Run using:
57+
5458
```bash
5559
(.venv)$ python3 tests/mypy_test.py
5660
```
@@ -65,11 +69,12 @@ imported but doesn't check whether stubs match their implementation
6569
Run `python tests/mypy_test.py --help` for information on the various configuration options
6670
for this script.
6771

68-
## pyright\_test.py
72+
## pyright_test.py
6973

7074
This test requires [Node.js](https://nodejs.org) to be installed. Although
7175
typeshed runs pyright in CI, it does not currently use this script. However,
7276
this script uses the same pyright version and configuration as the CI.
77+
7378
```bash
7479
(.venv)$ python3 tests/pyright_test.py # Check all files
7580
(.venv)$ python3 tests/pyright_test.py stdlib/sys.pyi # Check one file
@@ -81,7 +86,7 @@ checks that would typically fail on incomplete stubs (such as `Unknown` checks).
8186
In typeshed's CI, pyright is run with these configuration settings on a subset of
8287
the stubs in typeshed (including the standard library).
8388

84-
## regr\_test.py
89+
## regr_test.py
8590

8691
This test runs mypy against the test cases for typeshed's stdlib and third-party
8792
stubs. See [the REGRESSION.md document](./REGRESSION.md)
@@ -90,18 +95,20 @@ for more information about what
9095
these test cases are for and how they work. Run `python tests/regr_test.py --help`
9196
for information on the various configuration options.
9297

93-
## check\_typeshed\_structure.py
98+
## check_typeshed_structure.py
9499

95100
This checks that typeshed's directory structure and metadata files are correct.
96101

97102
Run using:
103+
98104
```bash
99105
$ python3 tests/check_typeshed_structure.py
100106
```
101107

102-
## stubtest\_stdlib.py
108+
## stubtest_stdlib.py
103109

104110
Run using
111+
105112
```bash
106113
(.venv)$ python3 tests/stubtest_stdlib.py
107114
```
@@ -116,7 +123,7 @@ test it automatically (or
116123
[running the test via Github Actions](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow#running-a-workflow)
117124
on your typeshed fork).
118125

119-
As a convenience, stubtest\_stdlib.py will look for local-only allowlist files
126+
As a convenience, stubtest_stdlib.py will look for local-only allowlist files
120127
and use those if they are present. Only version-specific local allowlists are supported.
121128
An example local allowlist file is
122129
`stdlib/@tests/stubtest_allowlists/py312.txt.local`. Use caution when taking advantage of this feature;
@@ -130,13 +137,14 @@ can add to the allowlists for each affected Python version in
130137
`stdlib/@tests/stubtest_allowlists`. Please file issues for stubtest false positives
131138
at [mypy](https://github.com/python/mypy/issues).
132139

133-
## stubtest\_third\_party.py
140+
## stubtest_third_party.py
134141

135142
:warning: This script downloads and executes arbitrary code from PyPI. Only run
136143
this script locally if you know you can trust the packages you're running
137144
stubtest on.
138145

139146
Run using
147+
140148
```bash
141149
(.venv)$ python3 tests/stubtest_third_party.py
142150
```
@@ -151,6 +159,7 @@ check on the command line:
151159

152160
If you have the runtime package installed in your local virtual environment, you can also run stubtest
153161
directly, with
162+
154163
```bash
155164
(.venv)$ MYPYPATH=<path-to-module-stubs> python3 -m mypy.stubtest \
156165
--custom-typeshed-dir <path-to-typeshed> \
@@ -177,7 +186,7 @@ considered "incomplete".
177186
You can help make typeshed's stubs more complete by removing
178187
`ignore_missing_stub = true` from the `tests/METADATA.toml` file for a
179188
third-party stubs distribution, running stubtest, and then adding things that
180-
stubtest reports to be missing to the stub. However, note that not *everything*
189+
stubtest reports to be missing to the stub. However, note that not _everything_
181190
that stubtest reports to be missing should necessarily be added to the stub.
182191
For some implementation details, it is often better to add allowlist entries
183192
for missing objects rather than trying to match the runtime in every detail.
@@ -199,9 +208,10 @@ For Django stubs specifically, you'll need to create a `django_settings.py` file
199208
that contains the Django settings required by the plugin. This file will be referenced by the plugin
200209
configuration to properly validate Django-specific types during stubtest execution.
201210

202-
## typecheck\_typeshed.py
211+
## typecheck_typeshed.py
203212

204213
Run using
214+
205215
```bash
206216
(.venv)$ python3 tests/typecheck_typeshed.py
207217
```

tests/REGRESSION.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ the annotations correctly. Examples of tests like these are
2525
Other test cases, such as the samples for `ExitStack` in
2626
`stdlib/@tests/test_cases/check_contextlib.py` and the samples for `LogRecord`
2727
in `stdlib/@tests/test_cases/check_logging.py`, do not relate to
28-
stubs where the annotations are particularly complex, but they *do* relate to
28+
stubs where the annotations are particularly complex, but they _do_ relate to
2929
stubs where decisions have been taken that might be slightly unusual. These
3030
test cases serve a different purpose: to check that type checkers do not emit
3131
false-positive errors for idiomatic usage of these classes.
@@ -65,7 +65,7 @@ mypy's
6565
[`--warn-unused-ignores`](https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-warn-unused-ignores)
6666
setting and pyright's
6767
[`reportUnnecessaryTypeIgnoreComment`](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#type-check-diagnostics-settings)
68-
setting) to test instances where a type checker *should* emit some kind of
68+
setting) to test instances where a type checker _should_ emit some kind of
6969
error, if the stubs are correct. Both settings are enabled by default for
7070
all `@tests/test_cases/` subdirectories in typeshed.
7171

@@ -121,13 +121,13 @@ Some tests will only pass on mypy
121121
with a specific Python version passed on the command line to the `tests/regr_test.py` script.
122122
To mark a test-case file as being skippable on lower versions of Python,
123123
append `-py3*` to the filename.
124-
For example, if `foo` is a stdlib feature that's new in Python 3.11,
124+
For example, if `foo` is a stdlib feature that's new in Python 3.14,
125125
test cases for `foo` should be put in a file named
126-
`stdlib/@tests/test_cases/check_foo-py311.py`.
126+
`stdlib/@tests/test_cases/check_foo-py314.py`.
127127
This means that mypy will only run the test case
128-
if `--python-version 3.11`, `--python-version 3.12`, etc.
128+
if `--python-version 3.14`, `--python-version 3.15`, etc.
129129
is passed on the command line to `tests/regr_test.py`,
130-
but it _won't_ run the test case if e.g. `--python-version 3.9`
130+
but it _won't_ run the test case if e.g. `--python-version 3.13`
131131
is passed on the command line.
132132

133133
However, `if sys.version_info >= (3, target):` is still required for `pyright`

tests/mypy_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
print_error("Cannot import mypy. Did you install it?")
4545
sys.exit(1)
4646

47-
SUPPORTED_VERSIONS = ["3.14", "3.13", "3.12", "3.11", "3.10", "3.9"]
47+
SUPPORTED_VERSIONS = ["3.14", "3.13", "3.12", "3.11", "3.10"]
4848
SUPPORTED_PLATFORMS = ("linux", "win32", "darwin")
4949
DIRECTORIES_TO_TEST = [STDLIB_PATH, STUBS_PATH]
5050

tests/regr_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
TYPESHED = "typeshed"
4242

4343
SUPPORTED_PLATFORMS = ["linux", "darwin", "win32"]
44-
SUPPORTED_VERSIONS = ["3.14", "3.13", "3.12", "3.11", "3.10", "3.9"]
44+
SUPPORTED_VERSIONS = ["3.14", "3.13", "3.12", "3.11", "3.10"]
4545

4646

4747
def distribution_with_test_cases(distribution_name: str) -> DistributionTests:
@@ -213,8 +213,8 @@ def run_testcases(
213213

214214
flags.extend(["--custom-typeshed-dir", str(custom_typeshed)])
215215

216-
# If the test-case filename ends with -py39,
217-
# only run the test if --python-version was set to 3.9 or higher (for example)
216+
# If the test-case filename ends with -py314,
217+
# only run the test if --python-version was set to 3.14 or higher (for example)
218218
for path in new_test_case_dir.rglob("*.py"):
219219
if match := re.fullmatch(r".*-py3(\d{1,2})", path.stem):
220220
minor_version_required = int(match[1])

tests/runtests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def main() -> None:
5050
parser.add_argument(
5151
"--python-version",
5252
default=None,
53-
choices=("3.9", "3.10", "3.11", "3.12", "3.13", "3.14"),
53+
choices=("3.10", "3.11", "3.12", "3.13", "3.14"),
5454
# We're using the oldest fully supported version because it's the most likely to produce errors
5555
# due to unsupported syntax, feature, or bug in a tool.
5656
help="Target Python version for the test (defaults to oldest supported Python version).",

tests/typecheck_typeshed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
ReturnCode: TypeAlias = int
1515

1616
SUPPORTED_PLATFORMS = ("linux", "darwin", "win32")
17-
SUPPORTED_VERSIONS = ("3.14", "3.13", "3.12", "3.11", "3.10", "3.9")
17+
SUPPORTED_VERSIONS = ("3.14", "3.13", "3.12", "3.11", "3.10")
1818
LOWEST_SUPPORTED_VERSION = min(SUPPORTED_VERSIONS, key=lambda x: int(x.split(".")[1]))
1919
DIRECTORIES_TO_TEST = ("scripts", "tests")
2020
EMPTY: list[str] = []

0 commit comments

Comments
 (0)