Skip to content

Commit 6cc86fd

Browse files
Merge branch 'main' into recursion-advice
2 parents f5fd113 + 9787d53 commit 6cc86fd

64 files changed

Lines changed: 1354 additions & 610 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/backport.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
environment:
1616
name: Backport
17+
deployment: false
1718
# Only react to merged PRs for security reasons.
1819
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
1920
if: >
@@ -25,15 +26,15 @@ jobs:
2526
)
2627
)
2728
steps:
28-
- uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
29+
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
2930
id: app-token
3031
with:
31-
app-id: ${{ vars.BACKPORT_APP_ID }}
32+
client-id: ${{ vars.BACKPORT_CLIENT_ID }}
3233
private-key: ${{ secrets.PRIVATE_KEY }}
3334
permission-contents: write # push branch to Github
3435
permission-pull-requests: write # create PR / add comment for manual backport
3536
permission-workflows: write # modify files in .github/workflows
36-
- uses: pylint-dev/backport@6accae9e09c5ad1bc3a0b56adf37c45357e7bcdc # v2.1.3
37+
- uses: pylint-dev/backport@3adad52e5a8ba2ea731c32037442d507eed68b4c # v2.1.8
3738
with:
3839
github_token: ${{ steps.app-token.outputs.token }}
3940
user_name: ${{ vars.BACKPORT_USER_NAME }}

.github/workflows/ci.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
- 2.*
7+
- maintenance/**
88
pull_request:
99
workflow_dispatch:
1010

@@ -43,7 +43,7 @@ jobs:
4343
- &cache-python
4444
name: Restore Python virtual environment
4545
id: cache-venv
46-
uses: actions/cache@v5.0.3
46+
uses: actions/cache@v5.0.5
4747
with:
4848
path: venv
4949
key: >-
@@ -63,7 +63,7 @@ jobs:
6363
hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT
6464
- name: Restore pre-commit environment
6565
id: cache-precommit
66-
uses: actions/cache@v5.0.3
66+
uses: actions/cache@v5.0.5
6767
with:
6868
path: ${{ env.PRE_COMMIT_CACHE }}
6969
key: >-
@@ -85,7 +85,8 @@ jobs:
8585
strategy:
8686
fail-fast: false
8787
matrix:
88-
python-version: &matrix-python-version ["3.10", "3.11", "3.12", "3.13", "3.14"]
88+
python-version:
89+
&matrix-python-version ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15-dev"]
8990
outputs:
9091
python-key: ${{ steps.generate-python-key.outputs.key }}
9192
steps:
@@ -122,7 +123,7 @@ jobs:
122123
. venv/bin/activate
123124
pytest --cov
124125
- name: Upload coverage artifact
125-
uses: &actions-upload-artifact actions/upload-artifact@v6.0.0
126+
uses: &actions-upload-artifact actions/upload-artifact@v7.0.1
126127
with:
127128
name: coverage-linux-${{ matrix.python-version }}
128129
path: .coverage
@@ -136,7 +137,7 @@ jobs:
136137
strategy:
137138
fail-fast: false
138139
matrix:
139-
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
140+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15-dev"]
140141
steps:
141142
- name: Set temp directory
142143
run: echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
@@ -226,12 +227,12 @@ jobs:
226227
- name: Install dependencies
227228
run: pip install -U -r requirements_minimal.txt
228229
- name: Download all coverage artifacts
229-
uses: actions/download-artifact@v7.0.0
230+
uses: actions/download-artifact@v8.0.1
230231
- name: Combine Linux coverage results
231232
run: |
232233
coverage combine coverage-linux*/.coverage
233234
coverage xml -o coverage-linux.xml
234-
- uses: &actions-codecov codecov/codecov-action@v5
235+
- uses: &actions-codecov codecov/codecov-action@v6
235236
with:
236237
token: ${{ secrets.CODECOV_TOKEN }}
237238
fail_ci_if_error: true

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: |
3535
python -m build
3636
- name: Upload release assets
37-
uses: actions/upload-artifact@v6.0.0
37+
uses: actions/upload-artifact@v7.0.1
3838
with:
3939
name: release-assets
4040
path: dist/
@@ -50,7 +50,7 @@ jobs:
5050
id-token: write
5151
steps:
5252
- name: Download release assets
53-
uses: actions/download-artifact@v7.0.0
53+
uses: actions/download-artifact@v8.0.1
5454
with:
5555
name: release-assets
5656
path: dist/
@@ -67,13 +67,13 @@ jobs:
6767
id-token: write
6868
steps:
6969
- name: Download release assets
70-
uses: actions/download-artifact@v7.0.0
70+
uses: actions/download-artifact@v8.0.1
7171
with:
7272
name: release-assets
7373
path: dist/
7474
- name: Sign the dists with Sigstore and upload assets to Github release
7575
if: github.event_name == 'release'
76-
uses: sigstore/gh-action-sigstore-python@v3.2.0
76+
uses: sigstore/gh-action-sigstore-python@v3.3.0
7777
with:
7878
inputs: |
7979
./dist/*.tar.gz

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
- id: end-of-file-fixer
1111
exclude: tests/testdata
1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: "v0.15.0"
13+
rev: "v0.15.13"
1414
hooks:
1515
- id: ruff-check
1616
args: ["--fix"]
@@ -33,7 +33,7 @@ repos:
3333
- id: black-disable-checker
3434
exclude: tests/test_nodes_lineno.py
3535
- repo: https://github.com/psf/black-pre-commit-mirror
36-
rev: 26.1.0
36+
rev: 26.5.0
3737
hooks:
3838
- id: black
3939
args: [--safe, --quiet]
@@ -68,19 +68,19 @@ repos:
6868
]
6969
stages: [manual]
7070
- repo: https://github.com/pre-commit/mirrors-mypy
71-
rev: v1.19.1
71+
rev: v2.1.0
7272
hooks:
7373
- id: mypy
7474
language: python
7575
pass_filenames: false
7676
require_serial: true
7777
additional_dependencies: ["types-typed-ast"]
7878
- repo: https://github.com/rbubley/mirrors-prettier
79-
rev: v3.8.1
79+
rev: v3.8.3
8080
hooks:
8181
- id: prettier
8282
args: [--prose-wrap=always, --print-width=88]
8383
- repo: https://github.com/tox-dev/pyproject-fmt
84-
rev: "v2.15.0"
84+
rev: "v2.21.2"
8585
hooks:
8686
- id: pyproject-fmt

CONTRIBUTORS.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ Contributors
3838
- Artem Yurchenko <44875844+temyurchenko@users.noreply.github.com>
3939
- David Liu <david@cs.toronto.edu>
4040
- Alexandre Fayolle <alexandre.fayolle@logilab.fr>
41-
- Eevee (Alex Munroe) <amunroe@yelp.com>
4241
- Emmanuel Ferdman <emmanuelferdman@gmail.com>
42+
- Eevee (Alex Munroe) <amunroe@yelp.com>
4343
- David Gilman <davidgilman1@gmail.com>
4444
- Zen Lee <53538590+zenlyj@users.noreply.github.com>
4545
- Tushar Sadhwani <tushar.sadhwani000@gmail.com>
@@ -48,6 +48,7 @@ Contributors
4848
- Hugo van Kemenade <hugovk@users.noreply.github.com>
4949
- Calen Pennington <calen.pennington@gmail.com>
5050
- Antonio <antonio@zoftko.com>
51+
- Fridayworks <aifriday700@gmail.com>
5152
- Akhil Kamat <akhil.kamat@gmail.com>
5253
- Tim Martin <tim@asymptotic.co.uk>
5354
- Phil Schaf <flying-sheep@web.de>
@@ -106,11 +107,13 @@ Contributors
106107
- David Euresti <github@euresti.com>
107108
- David Douard <david.douard@logilab.fr>
108109
- David Cain <davidjosephcain@gmail.com>
110+
- Casey Jones <731937+doctorcolossus@users.noreply.github.com>
109111
- Anthony Truchet <anthony.truchet@logilab.fr>
110112
- Anthony Sottile <asottile@umich.edu>
111113
- Alexander Shadchin <alexandr.shadchin@gmail.com>
112114
- wgehalo <wgehalo@gmail.com>
113115
- tejaschauhan36912 <59693377+tejaschauhan36912@users.noreply.github.com>
116+
- sergiochan <yuheng9211@qq.com>
114117
- rr- <rr-@sakuya.pl>
115118
- raylu <lurayl@gmail.com>
116119
- plucury <plucury@gmail.com>
@@ -162,6 +165,7 @@ Contributors
162165
- Jörg Thalheim <Mic92@users.noreply.github.com>
163166
- Jérome Perrin <perrinjerome@gmail.com>
164167
- JulianJvn <128477611+JulianJvn@users.noreply.github.com>
168+
- Joshix-1 <57299889+Joshix-1@users.noreply.github.com>
165169
- Josef Kemetmüller <josef.kemetmueller@gmail.com>
166170
- Jonathan Striebel <jstriebel@users.noreply.github.com>
167171
- John Belmonte <john@neggie.net>

ChangeLog

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,150 @@ Release date: TBA
1212

1313
Closes #2974
1414

15+
* Shorten ``import astroid`` by deferring imports only needed on cold paths.
16+
``logging`` (used by ``modutils`` and ``raw_building`` solely to report
17+
stderr/stdout captured while importing a module) and ``pprint`` (used only
18+
to format debug ``__repr__`` / ``repr_tree`` output) are now imported
19+
lazily, and ``astroid.exceptions`` imports ``astroid.typing`` under
20+
``TYPE_CHECKING``.
21+
22+
* Fix ``AttributeError`` crash in ``starred_assigned_stmts`` when a starred
23+
unpacking target is an attribute (e.g. ``for *o.attr, x in ...``) rather
24+
than a simple name.
25+
26+
Closes #2646
27+
28+
* Wrap assignment expressions (``:=``) in parentheses when emitting
29+
``as_string`` output so the rendered code remains syntactically valid in
30+
contexts such as comparisons, where Python requires the walrus expression
31+
to be parenthesized.
32+
33+
Closes #2668
34+
35+
* Catch ``MemoryError``/``RecursionError`` (and ``ValueError``) when validating
36+
type comments with ``ast.parse``. Pathological type comments produced by
37+
fuzzers (e.g. ``# type: i{{{{{{{...``) previously crashed parsing with a
38+
``MemoryError`` or ``RecursionError`` depending on the runtime; astroid now
39+
treats them as invalid type comments and skips them, mirroring the f-string
40+
fix from #2762.
41+
42+
Closes #2993
43+
44+
* Fix ``TypeError`` in ``brain_random`` when ``random.sample`` is called with a
45+
sequence containing nodes whose ``__init__`` does not accept ``lineno``
46+
(e.g. ``Module``). The clone helper now filters init params to those the
47+
class actually accepts.
48+
49+
Closes #3043
50+
51+
* Fix ``RecursionError`` in ``_compute_mro()`` when circular class hierarchies
52+
are created through runtime name rebinding. Circular bases are now resolved
53+
to the original class instead of recursing.
54+
55+
Closes #3023
56+
Closes pylint-dev/pylint#10821
57+
58+
* Changed `block_range` to consider `else` its own block, allowing `pylint` to apply
59+
disables to just the block.
60+
61+
References pylint-dev/pylint#872
62+
63+
* Fix uncaught ``TokenError`` when building a class or function whose source
64+
slice is malformed. ``tokenize.generate_tokens`` may raise (e.g. on an
65+
unterminated bracket on Python < 3.12); position computation now treats such
66+
a node as having no position information instead of crashing.
67+
68+
Closes #2527
69+
70+
* ``str()`` of a constant argument now infers the actual string value instead
71+
of always inferring ``""``. When every inference path of the argument
72+
resolves to ``Const`` values that stringify to the same string, ``infer_str``
73+
returns that string; otherwise it keeps falling back to ``Const("")``.
74+
75+
Closes #2994
76+
77+
* Fix ``AttributeError`` crash when looking up a special method on a class
78+
whose explicit metaclass infers to a non-class node (e.g. a function). Such
79+
a metaclass has no MRO, so the dunder lookup now raises
80+
``AttributeInferenceError`` instead of crashing.
81+
82+
Closes #3063
83+
84+
* Fix ``AttributeError`` crash in ``ClassDef.getitem`` when ``__class_getitem__``
85+
resolves to a non-callable node (e.g. an ``AssignName``). ``getitem`` now
86+
raises ``AstroidTypeError`` in that case, consistent with its documented
87+
behaviour.
88+
89+
Closes #3064
90+
91+
* Fix ``DuplicateBasesError`` crash in the enum brain when inferring an enum
92+
class with duplicate bases (e.g. ``class C(enum.Enum, enum.Enum)``).
93+
``infer_enum_class`` now catches ``MroError`` and leaves such a malformed
94+
class untransformed.
95+
96+
Closes #3065
97+
98+
* Fix ``InferenceError`` crash in ``ClassDef.slots()`` when ``__slots__`` is
99+
declared as an annotation without a value (e.g. ``__slots__: None``). Such a
100+
``__slots__`` cannot be inferred, so ``slots()`` now returns ``None``.
101+
102+
Closes #3067
103+
104+
105+
What's New in astroid 4.1.2?
106+
Release date: 2026-03-22
107+
108+
* Fix crash accessing property `fset` in generic classes with type annotations.
109+
Closes #2996
110+
111+
* Fix infinite recursion caused by cyclic inference in ``Constraint``.
112+
113+
* Fix ``RecursionError`` in ``_compute_mro()`` when circular class hierarchies
114+
are created through runtime name rebinding. Circular bases are now resolved
115+
to the original class instead of recursing.
116+
117+
Closes #2967
118+
Closes pylint-dev/pylint#10821
119+
120+
* Fix ``DuplicateBasesError`` crash in dataclass transform when a class has
121+
duplicate bases in its MRO (e.g., ``Protocol`` appearing both directly and
122+
indirectly). Catch ``MroError`` at ``.mro()`` call sites in
123+
``brain_dataclasses.py``, consistent with the existing pattern elsewhere.
124+
125+
Closes #2628
126+
127+
* Fix ``FunctionModel`` returning descriptor attributes for builtin functions.
128+
129+
Closes #2743
130+
131+
* Catch ``MemoryError`` when inferring f-strings with extremely large format
132+
widths (e.g. ``f'{0:11111111111}'``) so that inference yields ``Uninferable``
133+
instead of crashing.
134+
135+
Closes #2762
136+
137+
* Fix ``ValueError`` in ``__str__``/``repr`` and error messages when nodes have
138+
extreme values (very long identifiers or large integers). Clamp pprint width
139+
to a minimum of 1 and truncate oversized values in error messages.
140+
141+
Closes #2764
142+
15143

16144
What's New in astroid 4.1.1?
17145
============================
18-
Release date: TBA
146+
Release date: 2026-02-22
19147

20148
* Let `UnboundMethodModel` inherit from `FunctionModel` to improve inference of
21149
dunder methods for unbound methods.
22150

151+
Refs #2741
152+
23153
* Filter ``Unknown`` from ``UnboundMethod`` and ``Super`` special attribute
24154
lookup to prevent placeholder nodes from leaking during inference.
25155

156+
Refs #2741
157+
158+
26159
What's New in astroid 4.1.0?
27160
============================
28161
Release date: 2026-02-08

astroid/__pkginfo__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE
33
# Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt
44

5-
__version__ = "4.2.0-dev0"
5+
__version__ = "4.2.0b3"
66
version = __version__

0 commit comments

Comments
 (0)