Skip to content

Commit 2d6b521

Browse files
cdce8phamdanal
andauthored
Drop support for running with Python 3.8 (#17492)
Similar to last year (#15566), start by dropping support for running mypy with Python 3.8. Users will still be able to type check 3.8 code with `--python-version 3.8` until typeshed drops the support for it. It's a bit early as the EOL for Python 3.8 is in ~3 months. However, since the branch for `1.11.0` has been cut already, we'd only drop the support with `1.12.0` which isn't due for another 1-2 months. Additionally dropping `3.8` now will make it easier to support `3.13` with its C-API changes and also give us enough time to cleanup the remaining 3.8 code blocks and documentation references. --------- Co-authored-by: Ali Hamdan <[email protected]>
1 parent 9ff9946 commit 2d6b521

21 files changed

+42
-45
lines changed

.github/workflows/test.yml

+11-17
Original file line numberDiff line numberDiff line change
@@ -31,24 +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 py38-ubuntu, mypyc-compiled
35-
python: '3.8'
34+
- name: Test suite with py39-ubuntu, mypyc-compiled
35+
python: '3.9'
3636
arch: x64
3737
os: ubuntu-latest
3838
toxenv: py
3939
tox_extra_args: "-n 4"
4040
test_mypyc: true
41-
- name: Test suite with py38-windows-64
42-
python: '3.8'
43-
arch: x64
44-
os: windows-latest
45-
toxenv: py38
46-
tox_extra_args: "-n 4"
47-
- name: Test suite with py39-ubuntu
41+
- name: Test suite with py39-windows-64
4842
python: '3.9'
4943
arch: x64
50-
os: ubuntu-latest
51-
toxenv: py
44+
os: windows-latest
45+
toxenv: py39
5246
tox_extra_args: "-n 4"
5347
- name: Test suite with py310-ubuntu
5448
python: '3.10'
@@ -88,7 +82,7 @@ jobs:
8882
# test_mypyc: true
8983

9084
- name: mypyc runtime tests with py39-macos
91-
python: '3.9.18'
85+
python: '3.9.21'
9286
arch: x64
9387
# TODO: macos-13 is the last one to support Python 3.9, change it to macos-latest when updating the Python version
9488
os: macos-13
@@ -98,20 +92,20 @@ jobs:
9892
# - https://github.com/python/mypy/issues/17819
9993
# - https://github.com/python/mypy/pull/17822
10094
# - name: mypyc runtime tests with py38-debug-build-ubuntu
101-
# python: '3.8.17'
95+
# python: '3.9.21'
10296
# arch: x64
10397
# os: ubuntu-latest
10498
# toxenv: py
10599
# tox_extra_args: "-n 4 mypyc/test/test_run.py mypyc/test/test_external.py"
106100
# debug_build: true
107101

108-
- name: Type check our own code (py38-ubuntu)
109-
python: '3.8'
102+
- name: Type check our own code (py39-ubuntu)
103+
python: '3.9'
110104
arch: x64
111105
os: ubuntu-latest
112106
toxenv: type
113-
- name: Type check our own code (py38-windows-64)
114-
python: '3.8'
107+
- name: Type check our own code (py39-windows-64)
108+
python: '3.9'
115109
arch: x64
116110
os: windows-latest
117111
toxenv: type

.github/workflows/test_stubgenc.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030

3131
- uses: actions/checkout@v4
3232

33-
- name: Setup 🐍 3.8
33+
- name: Setup 🐍 3.9
3434
uses: actions/setup-python@v5
3535
with:
36-
python-version: 3.8
36+
python-version: 3.9
3737

3838
- name: Test stubgenc
3939
run: misc/test-stubgenc.sh

CONTRIBUTING.md

+1-1
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.8 or higher to install all requirements listed in
54+
> You'll need Python 3.9 or higher to install all requirements listed in
5555
> test-requirements.txt
5656
5757
### Running tests

docs/source/getting_started.rst

+1-1
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.8 or later to run. You can install mypy using pip:
19+
Mypy requires Python 3.9 or later to run. You can install mypy using pip:
2020

2121
.. code-block:: shell
2222

mypy/defaults.py

+1-1
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, 8)
9+
PYTHON3_VERSION: Final = (3, 9)
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

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

5858
# Assert
59-
assert "version>=3.8 always true since minimum runtime version is (3, 8)" in actual.stdout
59+
assert "version>=3.9 always true since minimum runtime version is (3, 9)" in actual.stdout
6060

6161
def test_bad_eq_version_check(self) -> None:
6262
# Act
@@ -70,4 +70,4 @@ def test_bad_eq_version_check(self) -> None:
7070
)
7171

7272
# Assert
73-
assert "version==3.7 always false since minimum runtime version is (3, 8)" in actual.stdout
73+
assert "version==3.7 always false since minimum runtime version is (3, 9)" in actual.stdout

mypy/util.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,10 @@ def get_unique_redefinition_name(name: str, existing: Container[str]) -> str:
490490
def check_python_version(program: str) -> None:
491491
"""Report issues with the Python used to run mypy, dmypy, or stubgen"""
492492
# Check for known bad Python versions.
493-
if sys.version_info[:2] < (3, 8): # noqa: UP036
493+
if sys.version_info[:2] < (3, 9):
494494
sys.exit(
495-
"Running {name} with Python 3.7 or lower is not supported; "
496-
"please upgrade to 3.8 or newer".format(name=program)
495+
"Running {name} with Python 3.8 or lower is not supported; "
496+
"please upgrade to 3.9 or newer".format(name=program)
497497
)
498498

499499

mypy_self_check.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ show_traceback = True
66
pretty = True
77
always_false = MYPYC
88
plugins = mypy.plugins.proper_plugin
9-
python_version = 3.8
9+
python_version = 3.9
1010
exclude = mypy/typeshed/|mypyc/test-data/|mypyc/lib-rt/
1111
enable_error_code = ignore-without-code,redundant-expr
1212
enable_incomplete_feature = PreciseTupleTypes

mypyc/doc/getting_started.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Installation
3838
------------
3939

4040
Mypyc is shipped as part of the mypy distribution. Install mypy like
41-
this (you need Python 3.8 or later):
41+
this (you need Python 3.9 or later):
4242

4343
.. code-block::
4444

mypyc/test/test_run.py

+1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ def run_case_step(self, testcase: DataDrivenTestCase, incremental_step: int) ->
320320
# TODO: testDecorators1 hangs on 3.12, remove this once fixed
321321
proc.wait(timeout=30)
322322
output = proc.communicate()[0].decode("utf8")
323+
output = output.replace(f' File "{os.getcwd()}{os.sep}', ' File "')
323324
outlines = output.splitlines()
324325

325326
if testcase.config.getoption("--mypyc-showc"):

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ classifiers = [
3636
"Intended Audience :: Developers",
3737
"License :: OSI Approved :: MIT License",
3838
"Programming Language :: Python :: 3",
39-
"Programming Language :: Python :: 3.8",
4039
"Programming Language :: Python :: 3.9",
4140
"Programming Language :: Python :: 3.10",
4241
"Programming Language :: Python :: 3.11",
@@ -45,7 +44,7 @@ classifiers = [
4544
"Topic :: Software Development",
4645
"Typing :: Typed",
4746
]
48-
requires-python = ">=3.8"
47+
requires-python = ">=3.9"
4948
dependencies = [
5049
# When changing this, also update build-system.requires and mypy-requirements.txt
5150
"typing_extensions>=4.6.0",

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import sys
99
from typing import TYPE_CHECKING, Any
1010

11-
if sys.version_info < (3, 8, 0): # noqa: UP036
12-
sys.stderr.write("ERROR: You need Python 3.8 or later to use mypy.\n")
11+
if sys.version_info < (3, 9, 0):
12+
sys.stderr.write("ERROR: You need Python 3.9 or later to use mypy.\n")
1313
exit(1)
1414

1515
# we'll import stuff from the source tree, let's ensure is on the sys path

test-data/unit/check-columns.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class D(A):
260260
# N:5: def f(self) -> None
261261

262262
[case testColumnMissingTypeParameters]
263-
# flags: --disallow-any-generics
263+
# flags: --python-version 3.8 --disallow-any-generics
264264
from typing import List, Callable
265265
def f(x: List) -> None: pass # E:10: Missing type parameters for generic type "List"
266266
def g(x: list) -> None: pass # E:10: Implicit generic "Any". Use "typing.List" and specify generic parameters

test-data/unit/check-errorcodes.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ a: A
328328
a.x = '' # E: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
329329

330330
[case testErrorCodeMissingTypeArg]
331-
# flags: --disallow-any-generics
331+
# flags: --python-version 3.8 --disallow-any-generics
332332
from typing import List, TypeVar
333333
x: List # E: Missing type parameters for generic type "List" [type-arg]
334334
y: list # E: Implicit generic "Any". Use "typing.List" and specify generic parameters [type-arg]

test-data/unit/check-functools.test

+1
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ p1("a", "b") # TODO: false negative
289289
[builtins fixtures/dict.pyi]
290290

291291
[case testFunctoolsPartialTypeGuard]
292+
# flags: --python-version 3.8
292293
import functools
293294
from typing_extensions import TypeGuard
294295

test-data/unit/check-generics.test

+2
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ Alias[int]("a") # E: Argument 1 to "Node" has incompatible type "str"; expected
515515
[out]
516516

517517
[case testTypeApplicationCrash]
518+
# flags: --python-version 3.8
518519
import types
519520
type[int] # this was crashing, see #2302 (comment) # E: The type "Type[type]" is not generic and not indexable
520521
[builtins fixtures/tuple.pyi]
@@ -1130,6 +1131,7 @@ reveal_type(Bad) # N: Revealed type is "Any"
11301131
[out]
11311132

11321133
[case testNoSubscriptionOfBuiltinAliases]
1134+
# flags: --python-version 3.8
11331135
from typing import List, TypeVar
11341136

11351137
list[int]() # E: "list" is not subscriptable

test-data/unit/check-incremental.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -3753,7 +3753,7 @@ import b
37533753
[file b.py]
37543754
-- This is a heinous hack, but we simulate having a invalid cache by clobbering
37553755
-- the proto deps file with something with mtime mismatches.
3756-
[file ../.mypy_cache/3.8/@deps.meta.json.2]
3756+
[file ../.mypy_cache/3.9/@deps.meta.json.2]
37573757
{"snapshot": {"__main__": "a7c958b001a45bd6a2a320f4e53c4c16", "a": "d41d8cd98f00b204e9800998ecf8427e", "b": "d41d8cd98f00b204e9800998ecf8427e", "builtins": "c532c89da517a4b779bcf7a964478d67"}, "deps_meta": {"@root": {"path": "@root.deps.json", "mtime": 0}, "__main__": {"path": "__main__.deps.json", "mtime": 0}, "a": {"path": "a.deps.json", "mtime": 0}, "b": {"path": "b.deps.json", "mtime": 0}, "builtins": {"path": "builtins.deps.json", "mtime": 0}}}
37583758
[file ../.mypy_cache/.gitignore]
37593759
# Another hack to not trigger a .gitignore creation failure "false positive"
@@ -3788,7 +3788,7 @@ import b
37883788
[file b.py]
37893789
-- This is a heinous hack, but we simulate having a invalid cache by deleting
37903790
-- the proto deps file.
3791-
[delete ../.mypy_cache/3.8/@deps.meta.json.2]
3791+
[delete ../.mypy_cache/3.9/@deps.meta.json.2]
37923792
[file b.py.2]
37933793
# uh
37943794
-- Every file should get reloaded, since the cache was invalidated

test-data/unit/fine-grained-cache-incremental.test

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ a.py:8: note: x: expected "int", got "str"
202202
[file b.py]
203203
-- This is a heinous hack, but we simulate having a invalid cache by clobbering
204204
-- the proto deps file with something with mtime mismatches.
205-
[file ../.mypy_cache/3.8/@deps.meta.json.2]
205+
[file ../.mypy_cache/3.9/@deps.meta.json.2]
206206
{"snapshot": {"__main__": "a7c958b001a45bd6a2a320f4e53c4c16", "a": "d41d8cd98f00b204e9800998ecf8427e", "b": "d41d8cd98f00b204e9800998ecf8427e", "builtins": "c532c89da517a4b779bcf7a964478d67"}, "deps_meta": {"@root": {"path": "@root.deps.json", "mtime": 0}, "__main__": {"path": "__main__.deps.json", "mtime": 0}, "a": {"path": "a.deps.json", "mtime": 0}, "b": {"path": "b.deps.json", "mtime": 0}, "builtins": {"path": "builtins.deps.json", "mtime": 0}}}
207207

208208
[file b.py.2]
@@ -234,8 +234,8 @@ x = 10
234234
[file p/c.py]
235235
class C: pass
236236

237-
[delete ../.mypy_cache/3.8/b.meta.json.2]
238-
[delete ../.mypy_cache/3.8/p/c.meta.json.2]
237+
[delete ../.mypy_cache/3.9/b.meta.json.2]
238+
[delete ../.mypy_cache/3.9/p/c.meta.json.2]
239239

240240
[out]
241241
==

test-data/unit/fine-grained.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -10228,7 +10228,7 @@ class Base(Protocol):
1022810228
main:5: error: Call to abstract method "meth" of "Base" with trivial body via super() is unsafe
1022910229

1023010230
[case testPrettyMessageSorting]
10231-
# flags: --pretty
10231+
# flags: --python-version 3.8 --pretty
1023210232
import a
1023310233

1023410234
[file a.py]

test-data/unit/parse-errors.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ file:1: error: invalid syntax
5555
[case testUnexpectedEof]
5656
if 1:
5757
[out]
58-
file:1: error: unexpected EOF while parsing
58+
file:1: error: expected an indented block
5959

6060
[case testInvalidKeywordArguments1]
6161
f(x=y, z)
@@ -434,7 +434,7 @@ file:1: error: invalid syntax
434434
[case testSmartQuotes]
435435
foo = ‘bar’
436436
[out]
437-
file:1: error: invalid character in identifier
437+
file:1: error: invalid character '‘' (U+2018)
438438

439439
[case testExceptCommaInPython3]
440440
try:

test-requirements.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ pytest>=8.1.0
1212
pytest-xdist>=1.34.0
1313
pytest-cov>=2.10.0
1414
setuptools>=75.1.0
15-
tomli>=1.1.0 # needed even on py311+ so the self check passes with --python-version 3.8
15+
tomli>=1.1.0 # needed even on py311+ so the self check passes with --python-version 3.9
1616
pre_commit>=3.5.0

0 commit comments

Comments
 (0)