diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e6c9cd1d9b3..97bc62e002c5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,24 +31,18 @@ jobs: include: # Make sure to run mypyc compiled unit tests for both # the oldest and newest supported Python versions - - name: Test suite with py38-ubuntu, mypyc-compiled - python: '3.8' + - name: Test suite with py39-ubuntu, mypyc-compiled + python: '3.9' arch: x64 os: ubuntu-latest toxenv: py tox_extra_args: "-n 4" test_mypyc: true - - name: Test suite with py38-windows-64 - python: '3.8' - arch: x64 - os: windows-latest - toxenv: py38 - tox_extra_args: "-n 4" - - name: Test suite with py39-ubuntu + - name: Test suite with py39-windows-64 python: '3.9' arch: x64 - os: ubuntu-latest - toxenv: py + os: windows-latest + toxenv: py39 tox_extra_args: "-n 4" - name: Test suite with py310-ubuntu python: '3.10' @@ -88,7 +82,7 @@ jobs: # test_mypyc: true - name: mypyc runtime tests with py39-macos - python: '3.9.18' + python: '3.9.21' arch: x64 # TODO: macos-13 is the last one to support Python 3.9, change it to macos-latest when updating the Python version os: macos-13 @@ -98,20 +92,20 @@ jobs: # - https://github.com/python/mypy/issues/17819 # - https://github.com/python/mypy/pull/17822 # - name: mypyc runtime tests with py38-debug-build-ubuntu - # python: '3.8.17' + # python: '3.9.21' # arch: x64 # os: ubuntu-latest # toxenv: py # tox_extra_args: "-n 4 mypyc/test/test_run.py mypyc/test/test_external.py" # debug_build: true - - name: Type check our own code (py38-ubuntu) - python: '3.8' + - name: Type check our own code (py39-ubuntu) + python: '3.9' arch: x64 os: ubuntu-latest toxenv: type - - name: Type check our own code (py38-windows-64) - python: '3.8' + - name: Type check our own code (py39-windows-64) + python: '3.9' arch: x64 os: windows-latest toxenv: type diff --git a/.github/workflows/test_stubgenc.yml b/.github/workflows/test_stubgenc.yml index 0652702a0fc0..115eb047556e 100644 --- a/.github/workflows/test_stubgenc.yml +++ b/.github/workflows/test_stubgenc.yml @@ -30,10 +30,10 @@ jobs: - uses: actions/checkout@v4 - - name: Setup 🐍 3.8 + - name: Setup 🐍 3.9 uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.9 - name: Test stubgenc run: misc/test-stubgenc.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 89d667dfb6ce..e782158ba21f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,7 @@ hash -r # This resets shell PATH cache, not necessary on Windows ``` > **Note** -> You'll need Python 3.8 or higher to install all requirements listed in +> You'll need Python 3.9 or higher to install all requirements listed in > test-requirements.txt ### Running tests diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index 28a4481e502e..9b510314fd8f 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -16,7 +16,7 @@ may not make much sense otherwise. Installing and running mypy *************************** -Mypy requires Python 3.8 or later to run. You can install mypy using pip: +Mypy requires Python 3.9 or later to run. You can install mypy using pip: .. code-block:: shell diff --git a/mypy/defaults.py b/mypy/defaults.py index 2bbae23d7e2d..6f309668d224 100644 --- a/mypy/defaults.py +++ b/mypy/defaults.py @@ -6,7 +6,7 @@ # Earliest fully supported Python 3.x version. Used as the default Python # version in tests. Mypy wheels should be built starting with this version, # and CI tests should be run on this version (and later versions). -PYTHON3_VERSION: Final = (3, 8) +PYTHON3_VERSION: Final = (3, 9) # Earliest Python 3.x version supported via --python-version 3.x. To run # mypy, at least version PYTHON3_VERSION is needed. diff --git a/mypy/test/meta/test_parse_data.py b/mypy/test/meta/test_parse_data.py index bff2d6977612..8c6fc1610e63 100644 --- a/mypy/test/meta/test_parse_data.py +++ b/mypy/test/meta/test_parse_data.py @@ -50,13 +50,13 @@ def test_bad_ge_version_check(self) -> None: """ [case abc] s: str - [out version>=3.8] + [out version>=3.9] abc """ ) # Assert - assert "version>=3.8 always true since minimum runtime version is (3, 8)" in actual.stdout + assert "version>=3.9 always true since minimum runtime version is (3, 9)" in actual.stdout def test_bad_eq_version_check(self) -> None: # Act @@ -70,4 +70,4 @@ def test_bad_eq_version_check(self) -> None: ) # Assert - assert "version==3.7 always false since minimum runtime version is (3, 8)" in actual.stdout + assert "version==3.7 always false since minimum runtime version is (3, 9)" in actual.stdout diff --git a/mypy/util.py b/mypy/util.py index e0a9cf9ce1b2..ef6286150e60 100644 --- a/mypy/util.py +++ b/mypy/util.py @@ -490,10 +490,10 @@ def get_unique_redefinition_name(name: str, existing: Container[str]) -> str: def check_python_version(program: str) -> None: """Report issues with the Python used to run mypy, dmypy, or stubgen""" # Check for known bad Python versions. - if sys.version_info[:2] < (3, 8): # noqa: UP036 + if sys.version_info[:2] < (3, 9): sys.exit( - "Running {name} with Python 3.7 or lower is not supported; " - "please upgrade to 3.8 or newer".format(name=program) + "Running {name} with Python 3.8 or lower is not supported; " + "please upgrade to 3.9 or newer".format(name=program) ) diff --git a/mypy_self_check.ini b/mypy_self_check.ini index 7f1f9689a757..d4c0e8445f48 100644 --- a/mypy_self_check.ini +++ b/mypy_self_check.ini @@ -6,7 +6,7 @@ show_traceback = True pretty = True always_false = MYPYC plugins = mypy.plugins.proper_plugin -python_version = 3.8 +python_version = 3.9 exclude = mypy/typeshed/|mypyc/test-data/|mypyc/lib-rt/ enable_error_code = ignore-without-code,redundant-expr enable_incomplete_feature = PreciseTupleTypes diff --git a/mypyc/doc/getting_started.rst b/mypyc/doc/getting_started.rst index adc617419ffa..f85981f08d02 100644 --- a/mypyc/doc/getting_started.rst +++ b/mypyc/doc/getting_started.rst @@ -38,7 +38,7 @@ Installation ------------ Mypyc is shipped as part of the mypy distribution. Install mypy like -this (you need Python 3.8 or later): +this (you need Python 3.9 or later): .. code-block:: diff --git a/mypyc/test/test_run.py b/mypyc/test/test_run.py index dd3c79da7b9b..8048870a79f2 100644 --- a/mypyc/test/test_run.py +++ b/mypyc/test/test_run.py @@ -320,6 +320,7 @@ def run_case_step(self, testcase: DataDrivenTestCase, incremental_step: int) -> # TODO: testDecorators1 hangs on 3.12, remove this once fixed proc.wait(timeout=30) output = proc.communicate()[0].decode("utf8") + output = output.replace(f' File "{os.getcwd()}{os.sep}', ' File "') outlines = output.splitlines() if testcase.config.getoption("--mypyc-showc"): diff --git a/pyproject.toml b/pyproject.toml index 1a7adf21c0a6..8be581b44761 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,6 @@ classifiers = [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -45,7 +44,7 @@ classifiers = [ "Topic :: Software Development", "Typing :: Typed", ] -requires-python = ">=3.8" +requires-python = ">=3.9" dependencies = [ # When changing this, also update build-system.requires and mypy-requirements.txt "typing_extensions>=4.6.0", diff --git a/setup.py b/setup.py index 180faf6d8ded..44a9a72e34e0 100644 --- a/setup.py +++ b/setup.py @@ -8,8 +8,8 @@ import sys from typing import TYPE_CHECKING, Any -if sys.version_info < (3, 8, 0): # noqa: UP036 - sys.stderr.write("ERROR: You need Python 3.8 or later to use mypy.\n") +if sys.version_info < (3, 9, 0): + sys.stderr.write("ERROR: You need Python 3.9 or later to use mypy.\n") exit(1) # we'll import stuff from the source tree, let's ensure is on the sys path diff --git a/test-data/unit/check-columns.test b/test-data/unit/check-columns.test index 0aba0cfca09c..8bb768cfe13b 100644 --- a/test-data/unit/check-columns.test +++ b/test-data/unit/check-columns.test @@ -260,7 +260,7 @@ class D(A): # N:5: def f(self) -> None [case testColumnMissingTypeParameters] -# flags: --disallow-any-generics +# flags: --python-version 3.8 --disallow-any-generics from typing import List, Callable def f(x: List) -> None: pass # E:10: Missing type parameters for generic type "List" def g(x: list) -> None: pass # E:10: Implicit generic "Any". Use "typing.List" and specify generic parameters diff --git a/test-data/unit/check-errorcodes.test b/test-data/unit/check-errorcodes.test index 10cc145d0c70..cc0227bc6664 100644 --- a/test-data/unit/check-errorcodes.test +++ b/test-data/unit/check-errorcodes.test @@ -328,7 +328,7 @@ a: A a.x = '' # E: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] [case testErrorCodeMissingTypeArg] -# flags: --disallow-any-generics +# flags: --python-version 3.8 --disallow-any-generics from typing import List, TypeVar x: List # E: Missing type parameters for generic type "List" [type-arg] y: list # E: Implicit generic "Any". Use "typing.List" and specify generic parameters [type-arg] diff --git a/test-data/unit/check-functools.test b/test-data/unit/check-functools.test index c1868b3e3d72..22159580163d 100644 --- a/test-data/unit/check-functools.test +++ b/test-data/unit/check-functools.test @@ -289,6 +289,7 @@ p1("a", "b") # TODO: false negative [builtins fixtures/dict.pyi] [case testFunctoolsPartialTypeGuard] +# flags: --python-version 3.8 import functools from typing_extensions import TypeGuard diff --git a/test-data/unit/check-generics.test b/test-data/unit/check-generics.test index 74003f824e5d..08dfb3b54b3a 100644 --- a/test-data/unit/check-generics.test +++ b/test-data/unit/check-generics.test @@ -515,6 +515,7 @@ Alias[int]("a") # E: Argument 1 to "Node" has incompatible type "str"; expected [out] [case testTypeApplicationCrash] +# flags: --python-version 3.8 import types type[int] # this was crashing, see #2302 (comment) # E: The type "Type[type]" is not generic and not indexable [builtins fixtures/tuple.pyi] @@ -1130,6 +1131,7 @@ reveal_type(Bad) # N: Revealed type is "Any" [out] [case testNoSubscriptionOfBuiltinAliases] +# flags: --python-version 3.8 from typing import List, TypeVar list[int]() # E: "list" is not subscriptable diff --git a/test-data/unit/check-incremental.test b/test-data/unit/check-incremental.test index 888b4c26a7c7..55360f15f5c5 100644 --- a/test-data/unit/check-incremental.test +++ b/test-data/unit/check-incremental.test @@ -3753,7 +3753,7 @@ import b [file b.py] -- This is a heinous hack, but we simulate having a invalid cache by clobbering -- the proto deps file with something with mtime mismatches. -[file ../.mypy_cache/3.8/@deps.meta.json.2] +[file ../.mypy_cache/3.9/@deps.meta.json.2] {"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}}} [file ../.mypy_cache/.gitignore] # Another hack to not trigger a .gitignore creation failure "false positive" @@ -3788,7 +3788,7 @@ import b [file b.py] -- This is a heinous hack, but we simulate having a invalid cache by deleting -- the proto deps file. -[delete ../.mypy_cache/3.8/@deps.meta.json.2] +[delete ../.mypy_cache/3.9/@deps.meta.json.2] [file b.py.2] # uh -- Every file should get reloaded, since the cache was invalidated diff --git a/test-data/unit/fine-grained-cache-incremental.test b/test-data/unit/fine-grained-cache-incremental.test index 00157333efd7..f622cefc5b8e 100644 --- a/test-data/unit/fine-grained-cache-incremental.test +++ b/test-data/unit/fine-grained-cache-incremental.test @@ -202,7 +202,7 @@ a.py:8: note: x: expected "int", got "str" [file b.py] -- This is a heinous hack, but we simulate having a invalid cache by clobbering -- the proto deps file with something with mtime mismatches. -[file ../.mypy_cache/3.8/@deps.meta.json.2] +[file ../.mypy_cache/3.9/@deps.meta.json.2] {"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}}} [file b.py.2] @@ -234,8 +234,8 @@ x = 10 [file p/c.py] class C: pass -[delete ../.mypy_cache/3.8/b.meta.json.2] -[delete ../.mypy_cache/3.8/p/c.meta.json.2] +[delete ../.mypy_cache/3.9/b.meta.json.2] +[delete ../.mypy_cache/3.9/p/c.meta.json.2] [out] == diff --git a/test-data/unit/fine-grained.test b/test-data/unit/fine-grained.test index 19564133e375..0f6e018fe325 100644 --- a/test-data/unit/fine-grained.test +++ b/test-data/unit/fine-grained.test @@ -10228,7 +10228,7 @@ class Base(Protocol): main:5: error: Call to abstract method "meth" of "Base" with trivial body via super() is unsafe [case testPrettyMessageSorting] -# flags: --pretty +# flags: --python-version 3.8 --pretty import a [file a.py] diff --git a/test-data/unit/parse-errors.test b/test-data/unit/parse-errors.test index 7b1078d3fa2f..33c2a6ddf5c0 100644 --- a/test-data/unit/parse-errors.test +++ b/test-data/unit/parse-errors.test @@ -55,7 +55,7 @@ file:1: error: invalid syntax [case testUnexpectedEof] if 1: [out] -file:1: error: unexpected EOF while parsing +file:1: error: expected an indented block [case testInvalidKeywordArguments1] f(x=y, z) @@ -434,7 +434,7 @@ file:1: error: invalid syntax [case testSmartQuotes] foo = β€˜bar’ [out] -file:1: error: invalid character in identifier +file:1: error: invalid character 'β€˜' (U+2018) [case testExceptCommaInPython3] try: diff --git a/test-requirements.in b/test-requirements.in index 4e53c63cc36b..767a94e5c14d 100644 --- a/test-requirements.in +++ b/test-requirements.in @@ -12,5 +12,5 @@ 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.8 +tomli>=1.1.0 # needed even on py311+ so the self check passes with --python-version 3.9 pre_commit>=3.5.0