Skip to content

Drop support for Python 3.9 #10405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/primer-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
timeout-minutes: 5
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
outputs:
python-key: ${{ steps.generate-python-key.outputs.key }}
steps:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
needs: prepare-tests-linux
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- name: Check out code from GitHub
uses: actions/checkout@v4.2.2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/primer_run_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
timeout-minutes: 45
strategy:
matrix:
python-version: ["3.9", "3.13"]
python-version: ["3.10", "3.13"]
batches: [4]
batchIdx: [0, 1, 2, 3]
steps:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/primer_run_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
timeout-minutes: 45
strategy:
matrix:
python-version: ["3.9", "3.13"]
python-version: ["3.10", "3.13"]
batches: [4]
batchIdx: [0, 1, 2, 3]
steps:
Expand Down Expand Up @@ -217,7 +217,8 @@ jobs:
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
- name: Upload PR number
if:
startsWith(steps.python.outputs.python-version, '3.9') && matrix.batchIdx == 0
startsWith(steps.python.outputs.python-version, '3.10') && matrix.batchIdx ==
0
uses: actions/upload-artifact@v4.6.2
with:
name: pr_number
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
include:
- os: macos-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "pypy-3.9"
python-version: "3.10"
- os: ubuntu-latest
python-version: "pypy-3.10"
- os: ubuntu-latest
Expand Down Expand Up @@ -190,7 +188,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- name: Set temp directory
run: echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ What is Pylint?
---------------

Pylint is a `static code analyser`_ for Python 2 or 3. The latest version supports Python
3.9.0 and above.
3.10.0 and above.

.. _`static code analyser`: https://en.wikipedia.org/wiki/Static_code_analysis

Expand Down
4 changes: 4 additions & 0 deletions doc/whatsnew/fragments/10405.other
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Remove support for launching pylint with Python 3.9.
Code that supports Python 3.9 can still be linted with the ``--py-version=3.9`` setting.

Refs #10405
2 changes: 1 addition & 1 deletion pylint/checkers/base/basic_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ def visit_with(self, node: nodes.With) -> None:
# to one AST "With" node with multiple items
pairs = node.items
if pairs:
for prev_pair, pair in zip(pairs, pairs[1:]):
for prev_pair, pair in itertools.pairwise(pairs):
if isinstance(prev_pair[1], nodes.AssignName) and (
pair[1] is None and not isinstance(pair[0], nodes.Call)
):
Expand Down
4 changes: 2 additions & 2 deletions pylint/checkers/classes/class_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from functools import cached_property
from itertools import chain, zip_longest
from re import Pattern
from typing import TYPE_CHECKING, Any, NamedTuple, Union
from typing import TYPE_CHECKING, Any, NamedTuple, TypeAlias

import astroid
from astroid import bases, nodes, util
Expand Down Expand Up @@ -46,7 +46,7 @@
from pylint.lint.pylinter import PyLinter


_AccessNodes = Union[nodes.Attribute, nodes.AssignAttr]
_AccessNodes: TypeAlias = nodes.Attribute | nodes.AssignAttr

INVALID_BASE_CLASSES = {"bool", "range", "slice", "memoryview"}
ALLOWED_PROPERTIES = {"bultins.property", "functools.cached_property"}
Expand Down
4 changes: 2 additions & 2 deletions pylint/checkers/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from collections import defaultdict
from collections.abc import ItemsView, Sequence
from functools import cached_property
from typing import TYPE_CHECKING, Any, Union
from typing import TYPE_CHECKING, Any

import astroid
from astroid import nodes
Expand Down Expand Up @@ -43,7 +43,7 @@

# The dictionary with Any should actually be a _ImportTree again
# but mypy doesn't support recursive types yet
_ImportTree = dict[str, Union[list[dict[str, Any]], list[str]]]
_ImportTree = dict[str, list[dict[str, Any]] | list[str]]

DEPRECATED_MODULES = {
(0, 0, 0): {"tkinter.tix", "fpectl"},
Expand Down
4 changes: 2 additions & 2 deletions pylint/checkers/refactoring/refactoring_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from collections.abc import Iterator
from functools import cached_property, reduce
from re import Pattern
from typing import TYPE_CHECKING, Any, NamedTuple, Union, cast
from typing import TYPE_CHECKING, Any, NamedTuple, TypeAlias, cast

import astroid
from astroid import bases, nodes
Expand All @@ -27,7 +27,7 @@
from pylint.lint import PyLinter


NodesWithNestedBlocks = Union[nodes.Try, nodes.While, nodes.For, nodes.If]
NodesWithNestedBlocks: TypeAlias = nodes.Try | nodes.While | nodes.For | nodes.If

KNOWN_INFINITE_ITERATORS = {"itertools.count", "itertools.cycle"}
BUILTIN_EXIT_FUNCS = frozenset(("quit", "exit"))
Expand Down
4 changes: 2 additions & 2 deletions pylint/checkers/symilar.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from collections.abc import Callable, Generator, Iterable, Sequence
from io import BufferedIOBase, BufferedReader, BytesIO
from itertools import chain
from typing import TYPE_CHECKING, NamedTuple, NewType, NoReturn, TextIO, Union
from typing import TYPE_CHECKING, NamedTuple, NewType, NoReturn, TextIO, TypeAlias

import astroid
from astroid import nodes
Expand Down Expand Up @@ -79,7 +79,7 @@ class LineSpecifs(NamedTuple):
IndexToLines_T = dict[Index, "SuccessiveLinesLimits"]

# The types the streams read by pylint can take. Originating from astroid.nodes.Module.stream() and open()
STREAM_TYPES = Union[TextIO, BufferedReader, BytesIO]
STREAM_TYPES: TypeAlias = TextIO | BufferedReader | BytesIO


class CplSuccessiveLinesLimits:
Expand Down
21 changes: 10 additions & 11 deletions pylint/checkers/typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from collections.abc import Callable, Iterable
from functools import cached_property, lru_cache, singledispatch
from re import Pattern
from typing import TYPE_CHECKING, Any, Literal, Union
from typing import TYPE_CHECKING, Any, Literal, TypeAlias

import astroid
import astroid.exceptions
Expand Down Expand Up @@ -49,20 +49,19 @@
supports_membership_test,
supports_setitem,
)
from pylint.constants import PY310_PLUS
from pylint.interfaces import HIGH, INFERENCE
from pylint.typing import MessageDefinitionTuple

if TYPE_CHECKING:
from pylint.lint import PyLinter

CallableObjects = Union[
bases.BoundMethod,
bases.UnboundMethod,
nodes.FunctionDef,
nodes.Lambda,
nodes.ClassDef,
]
CallableObjects: TypeAlias = (
bases.BoundMethod
| bases.UnboundMethod
| nodes.FunctionDef
| nodes.Lambda
| nodes.ClassDef
)

STR_FORMAT = {"builtins.str.format"}
ASYNCIO_COROUTINE = "asyncio.coroutines.coroutine"
Expand Down Expand Up @@ -796,7 +795,7 @@ def _is_c_extension(module_node: InferenceResult) -> bool:

def _is_invalid_isinstance_type(arg: nodes.NodeNG) -> bool:
# Return True if we are sure that arg is not a type
if PY310_PLUS and isinstance(arg, nodes.BinOp) and arg.op == "|":
if isinstance(arg, nodes.BinOp) and arg.op == "|":
return any(
_is_invalid_isinstance_type(elt) and not is_none(elt)
for elt in (arg.left, arg.right)
Expand All @@ -811,7 +810,7 @@ def _is_invalid_isinstance_type(arg: nodes.NodeNG) -> bool:
return False
if isinstance(inferred, astroid.Instance) and inferred.qname() == BUILTIN_TUPLE:
return False
if PY310_PLUS and isinstance(inferred, bases.UnionType):
if isinstance(inferred, bases.UnionType):
return any(
_is_invalid_isinstance_type(elt) and not is_none(elt)
for elt in (inferred.left, inferred.right)
Expand Down
7 changes: 1 addition & 6 deletions pylint/config/_pylint_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
import sys
from collections.abc import Callable
from pathlib import Path
from typing import Literal, TypeVar

if sys.version_info >= (3, 10):
from typing import ParamSpec
else:
from typing_extensions import ParamSpec
from typing import Literal, ParamSpec, TypeVar

_P = ParamSpec("_P")
_ReturnValueT = TypeVar("_ReturnValueT", bool, str)
Expand Down
22 changes: 11 additions & 11 deletions pylint/config/argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
from collections.abc import Callable, Sequence
from glob import glob
from re import Pattern
from typing import Any, Literal, Union
from typing import Any, Literal

from pylint import interfaces
from pylint import utils as pylint_utils
from pylint.config.callback_actions import _CallbackAction
from pylint.config.deprecation_actions import _NewNamesAction, _OldNamesAction

_ArgumentTypes = Union[
str,
int,
float,
bool,
Pattern[str],
Sequence[str],
Sequence[Pattern[str]],
tuple[int, ...],
]
_ArgumentTypes = (
str
| int
| float
| bool
| Pattern[str]
| Sequence[str]
| Sequence[Pattern[str]]
| tuple[int, ...]
)
"""List of possible argument types."""


Expand Down
1 change: 0 additions & 1 deletion pylint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from pylint.__pkginfo__ import __version__
from pylint.typing import MessageTypesFullName

PY310_PLUS = sys.version_info[:2] >= (3, 10)
PY311_PLUS = sys.version_info[:2] >= (3, 11)
PY312_PLUS = sys.version_info[:2] >= (3, 12)
PY314_PLUS = sys.version_info[:2] >= (3, 14)
Expand Down
8 changes: 1 addition & 7 deletions pylint/extensions/code_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

from __future__ import annotations

import sys
from typing import TYPE_CHECKING, cast
from typing import TYPE_CHECKING, TypeGuard, cast

from astroid import nodes

Expand All @@ -16,11 +15,6 @@
if TYPE_CHECKING:
from pylint.lint import PyLinter

if sys.version_info >= (3, 10):
from typing import TypeGuard
else:
from typing_extensions import TypeGuard


class CodeStyleChecker(BaseChecker):
"""Checkers that can improve code consistency.
Expand Down
44 changes: 22 additions & 22 deletions pylint/extensions/mccabe.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, TypeVar, Union
from typing import TYPE_CHECKING, Any, TypeAlias, TypeVar

from astroid import nodes
from mccabe import PathGraph as Mccabe_PathGraph
Expand All @@ -20,28 +20,28 @@
if TYPE_CHECKING:
from pylint.lint import PyLinter

_StatementNodes = Union[
nodes.Assert,
nodes.Assign,
nodes.AugAssign,
nodes.Delete,
nodes.Raise,
nodes.Yield,
nodes.Import,
nodes.Call,
nodes.Subscript,
nodes.Pass,
nodes.Continue,
nodes.Break,
nodes.Global,
nodes.Return,
nodes.Expr,
nodes.Await,
]

_SubGraphNodes = Union[nodes.If, nodes.Try, nodes.For, nodes.While]
_StatementNodes: TypeAlias = (
nodes.Assert
| nodes.Assign
| nodes.AugAssign
| nodes.Delete
| nodes.Raise
| nodes.Yield
| nodes.Import
| nodes.Call
| nodes.Subscript
| nodes.Pass
| nodes.Continue
| nodes.Break
| nodes.Global
| nodes.Return
| nodes.Expr
| nodes.Await
)

_SubGraphNodes: TypeAlias = nodes.If | nodes.Try | nodes.For | nodes.While
_AppendableNodeT = TypeVar(
"_AppendableNodeT", bound=Union[_StatementNodes, nodes.While, nodes.FunctionDef]
"_AppendableNodeT", bound=_StatementNodes | nodes.While | nodes.FunctionDef
)


Expand Down
3 changes: 1 addition & 2 deletions pylint/pyreverse/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import traceback
from abc import ABC, abstractmethod
from collections.abc import Callable, Sequence
from typing import Optional

import astroid
from astroid import nodes
Expand All @@ -24,7 +23,7 @@
from pylint.pyreverse import utils

_WrapperFuncT = Callable[
[Callable[[str], nodes.Module], str, bool], Optional[nodes.Module]
[Callable[[str], nodes.Module], str, bool], nodes.Module | None
]


Expand Down
6 changes: 3 additions & 3 deletions pylint/pyreverse/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import subprocess
import sys
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, Optional, Union
from typing import TYPE_CHECKING, Any

import astroid
from astroid import nodes
Expand All @@ -23,9 +23,9 @@

_CallbackT = Callable[
[nodes.NodeNG],
Union[tuple[ClassDiagram], tuple[PackageDiagram, ClassDiagram], None],
tuple[ClassDiagram] | tuple[PackageDiagram, ClassDiagram] | None,
]
_CallbackTupleT = tuple[Optional[_CallbackT], Optional[_CallbackT]]
_CallbackTupleT = tuple[_CallbackT | None, _CallbackT | None]


RCFILE = ".pyreverserc"
Expand Down
Loading
Loading