Skip to content

Commit 1e2ee6f

Browse files
authored
Merge branch 'master' into fix-crash
2 parents 0f88fa1 + f44a60d commit 1e2ee6f

File tree

364 files changed

+10761
-4211
lines changed

Some content is hidden

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

364 files changed

+10761
-4211
lines changed

.github/workflows/build_wheels.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ on:
66
tags: ['*']
77

88
permissions:
9-
contents: write
9+
contents: read
1010

1111
jobs:
1212
build-wheels:
1313
if: github.repository == 'python/mypy'
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17+
with:
18+
persist-credentials: false
1719
- uses: actions/setup-python@v5
1820
with:
1921
python-version: '3.11'

.github/workflows/docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535
VERIFY_MYPY_ERROR_CODES: 1
3636
steps:
3737
- uses: actions/checkout@v4
38+
with:
39+
persist-credentials: false
3840
- uses: actions/setup-python@v5
3941
with:
4042
python-version: '3.12'

.github/workflows/mypy_primer.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ jobs:
2626
mypy_primer:
2727
name: Run mypy_primer
2828
runs-on: ubuntu-latest
29-
permissions:
30-
contents: read
3129
strategy:
3230
matrix:
3331
shard-index: [0, 1, 2, 3, 4]
@@ -38,9 +36,10 @@ jobs:
3836
with:
3937
path: mypy_to_test
4038
fetch-depth: 0
39+
persist-credentials: false
4140
- uses: actions/setup-python@v5
4241
with:
43-
python-version: "3.12"
42+
python-version: "3.13"
4443
- name: Install dependencies
4544
run: |
4645
python -m pip install -U pip
@@ -74,9 +73,9 @@ jobs:
7473
name: Save PR number
7574
run: |
7675
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
77-
- if: ${{ matrix.shard-index == 0 }}
78-
name: Upload mypy_primer diff + PR number
76+
- name: Upload mypy_primer diff + PR number
7977
uses: actions/upload-artifact@v4
78+
if: ${{ matrix.shard-index == 0 }}
8079
with:
8180
name: mypy_primer_diffs-${{ matrix.shard-index }}
8281
path: |
@@ -93,8 +92,6 @@ jobs:
9392
name: Join artifacts
9493
runs-on: ubuntu-latest
9594
needs: [mypy_primer]
96-
permissions:
97-
contents: read
9895
steps:
9996
- name: Merge artifacts
10097
uses: actions/upload-artifact/merge@v4

.github/workflows/mypy_primer_comment.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
name: Comment with mypy_primer diff
22

3-
on:
3+
on: # zizmor: ignore[dangerous-triggers]
44
workflow_run:
55
workflows:
66
- Run mypy_primer
77
types:
88
- completed
99

10-
permissions:
11-
contents: read
12-
pull-requests: write
10+
permissions: {}
1311

1412
jobs:
1513
comment:
1614
name: Comment PR from mypy_primer
1715
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
pull-requests: write
1819
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1920
steps:
2021
- name: Download diffs
@@ -48,7 +49,7 @@ jobs:
4849
with:
4950
github-token: ${{ secrets.GITHUB_TOKEN }}
5051
script: |
51-
const MAX_CHARACTERS = 30000
52+
const MAX_CHARACTERS = 50000
5253
const MAX_CHARACTERS_PER_PROJECT = MAX_CHARACTERS / 3
5354
5455
const fs = require('fs')

.github/workflows/sync_typeshed.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ on:
55
schedule:
66
- cron: "0 0 1,15 * *"
77

8-
permissions:
9-
contents: write
10-
pull-requests: write
8+
permissions: {}
119

1210
jobs:
1311
sync_typeshed:
1412
name: Sync typeshed
1513
if: github.repository == 'python/mypy'
1614
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
pull-requests: write
1718
timeout-minutes: 10
1819
steps:
1920
- uses: actions/checkout@v4
2021
with:
2122
fetch-depth: 0
23+
persist-credentials: true # needed to `git push` the PR branch
2224
# TODO: use whatever solution ends up working for
2325
# https://github.com/python/typeshed/issues/8434
2426
- uses: actions/setup-python@v5

.github/workflows/test.yml

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,57 +33,49 @@ jobs:
3333
# the oldest and newest supported Python versions
3434
- name: Test suite with py39-ubuntu, mypyc-compiled
3535
python: '3.9'
36-
arch: x64
37-
os: ubuntu-latest
36+
os: ubuntu-24.04-arm
3837
toxenv: py
3938
tox_extra_args: "-n 4"
4039
test_mypyc: true
4140
- name: Test suite with py39-windows-64
4241
python: '3.9'
43-
arch: x64
4442
os: windows-latest
4543
toxenv: py39
4644
tox_extra_args: "-n 4"
4745
- name: Test suite with py310-ubuntu
4846
python: '3.10'
49-
arch: x64
50-
os: ubuntu-latest
47+
os: ubuntu-24.04-arm
5148
toxenv: py
5249
tox_extra_args: "-n 4"
5350
- name: Test suite with py311-ubuntu, mypyc-compiled
5451
python: '3.11'
55-
arch: x64
56-
os: ubuntu-latest
52+
os: ubuntu-24.04-arm
5753
toxenv: py
5854
tox_extra_args: "-n 4"
5955
test_mypyc: true
6056
- name: Test suite with py312-ubuntu, mypyc-compiled
6157
python: '3.12'
62-
arch: x64
63-
os: ubuntu-latest
58+
os: ubuntu-24.04-arm
6459
toxenv: py
6560
tox_extra_args: "-n 4"
6661
test_mypyc: true
6762
- name: Test suite with py313-ubuntu, mypyc-compiled
6863
python: '3.13'
69-
arch: x64
70-
os: ubuntu-latest
64+
os: ubuntu-24.04-arm
7165
toxenv: py
7266
tox_extra_args: "-n 4"
7367
test_mypyc: true
7468

7569
# - name: Test suite with py314-dev-ubuntu
7670
# python: '3.14-dev'
77-
# arch: x64
78-
# os: ubuntu-latest
71+
# os: ubuntu-24.04-arm
7972
# toxenv: py
8073
# tox_extra_args: "-n 4"
8174
# allow_failure: true
8275
# test_mypyc: true
8376

8477
- name: mypyc runtime tests with py39-macos
8578
python: '3.9.21'
86-
arch: x64
8779
# TODO: macos-13 is the last one to support Python 3.9, change it to macos-latest when updating the Python version
8880
os: macos-13
8981
toxenv: py
@@ -93,20 +85,17 @@ jobs:
9385
# - https://github.com/python/mypy/pull/17822
9486
# - name: mypyc runtime tests with py38-debug-build-ubuntu
9587
# python: '3.9.21'
96-
# arch: x64
9788
# os: ubuntu-latest
9889
# toxenv: py
9990
# tox_extra_args: "-n 4 mypyc/test/test_run.py mypyc/test/test_external.py"
10091
# debug_build: true
10192

10293
- name: Type check our own code (py39-ubuntu)
10394
python: '3.9'
104-
arch: x64
10595
os: ubuntu-latest
10696
toxenv: type
10797
- name: Type check our own code (py39-windows-64)
10898
python: '3.9'
109-
arch: x64
11099
os: windows-latest
111100
toxenv: type
112101

@@ -115,7 +104,6 @@ jobs:
115104
# to ensure the tox env works as expected
116105
- name: Formatting and code style with Black + ruff
117106
python: '3.10'
118-
arch: x64
119107
os: ubuntu-latest
120108
toxenv: lint
121109

@@ -136,6 +124,8 @@ jobs:
136124

137125
steps:
138126
- uses: actions/checkout@v4
127+
with:
128+
persist-credentials: false
139129

140130
- name: Debug build
141131
if: ${{ matrix.debug_build }}
@@ -167,7 +157,6 @@ jobs:
167157
if: ${{ !(matrix.debug_build || endsWith(matrix.python, '-dev')) }}
168158
with:
169159
python-version: ${{ matrix.python }}
170-
architecture: ${{ matrix.arch }}
171160

172161
- name: Install tox
173162
run: |
@@ -217,6 +206,8 @@ jobs:
217206
CC: i686-linux-gnu-gcc
218207
steps:
219208
- uses: actions/checkout@v4
209+
with:
210+
persist-credentials: false
220211
- name: Install 32-bit build dependencies
221212
run: |
222213
sudo dpkg --add-architecture i386 && \

.github/workflows/test_stubgenc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
steps:
3030

3131
- uses: actions/checkout@v4
32+
with:
33+
persist-credentials: false
3234

3335
- name: Setup 🐍 3.9
3436
uses: actions/setup-python@v5

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ venv/
1717
test-data/packages/.pip_lock
1818
dmypy.json
1919
.dmypy.json
20+
/.mypyc_test_output
2021

2122
# Packages
2223
*.egg

.pre-commit-config.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,44 @@ repos:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
88
- repo: https://github.com/psf/black-pre-commit-mirror
9-
rev: 24.10.0
9+
rev: 25.1.0
1010
hooks:
1111
- id: black
1212
exclude: '^(test-data/)'
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.8.4
14+
rev: v0.8.6
1515
hooks:
1616
- id: ruff
1717
args: [--exit-non-zero-on-fix]
1818
- repo: https://github.com/python-jsonschema/check-jsonschema
19-
rev: 0.30.0
19+
rev: 0.31.0
2020
hooks:
21-
- id: check-dependabot
2221
- id: check-github-workflows
22+
- id: check-github-actions
23+
- id: check-readthedocs
2324
- repo: https://github.com/rhysd/actionlint
24-
rev: v1.7.4
25+
rev: v1.7.7
2526
hooks:
2627
- id: actionlint
2728
args: [
2829
-ignore=property "debug_build" is not defined,
2930
-ignore=property "allow_failure" is not defined,
3031
-ignore=SC2(046|086),
3132
]
33+
additional_dependencies:
34+
# actionlint has a shellcheck integration which extracts shell scripts in `run:` steps from GitHub Actions
35+
# and checks these with shellcheck. This is arguably its most useful feature,
36+
# but the integration only works if shellcheck is installed
37+
- "github.com/wasilibs/go-shellcheck/cmd/[email protected]"
38+
- repo: https://github.com/woodruffw/zizmor-pre-commit
39+
rev: v1.0.1
40+
hooks:
41+
- id: zizmor
42+
# Should be the last one:
43+
- repo: meta
44+
hooks:
45+
- id: check-hooks-apply
46+
- id: check-useless-excludes
47+
3248
ci:
3349
autoupdate_schedule: quarterly

CHANGELOG.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,71 @@
22

33
## Next release
44

5-
...
5+
### Performance improvements
6+
7+
Mypy may be 5-30% faster. This improvement comes largely from tuning the performance of the
8+
garbage collector.
9+
10+
Contributed by Jukka Lehtosalo (PR [18306](https://github.com/python/mypy/pull/18306)).
11+
12+
### Mypyc accelerated mypy wheels for aarch64
13+
14+
Mypy can compile itself to C extension modules using mypyc. This makes mypy 3-5x faster
15+
than if mypy is interpreted with pure Python. We now build and upload mypyc accelerated
16+
mypy wheels for `manylinux_aarch64` to PyPI, making it easy for users on such platforms
17+
to realise this speedup.
18+
19+
Contributed by Christian Bundy and Marc Mueller
20+
(PR [mypy_mypyc-wheels#76](https://github.com/mypyc/mypy_mypyc-wheels/pull/76),
21+
PR [mypy_mypyc-wheels#89](https://github.com/mypyc/mypy_mypyc-wheels/pull/89)).
22+
23+
### `--strict-bytes`
24+
25+
By default, mypy treats an annotation of ``bytes`` as permitting ``bytearray`` and ``memoryview``.
26+
[PEP 688](https://peps.python.org/pep-0688) specified the removal of this special case.
27+
Use this flag to disable this behavior. `--strict-bytes` will be enabled by default in **mypy 2.0**.
28+
29+
Contributed by Ali Hamdan (PR [18137](https://github.com/python/mypy/pull/18263/)) and
30+
Shantanu Jain (PR [13952](https://github.com/python/mypy/pull/13952)).
31+
32+
### Improvements to reachability analysis and partial type handling in loops
33+
34+
This change results in mypy better modelling control flow within loops and hence detecting several
35+
issues it previously did not detect. In some cases, this change may require use of an additional
36+
explicit annotation of a variable.
37+
38+
Contributed by Christoph Tyralla (PR [18180](https://github.com/python/mypy/pull/18180),
39+
[PR](https://github.com/python/mypy/pull/18433)).
40+
41+
(Speaking of partial types, another reminder that mypy plans on enabling `--local-partial-types`
42+
by default in **mypy 2.0**).
43+
44+
### Better discovery of configuration files
45+
46+
Mypy will now walk up the filesystem (up until a repository or file system root) to discover
47+
configuration files. See the
48+
[mypy configuration file documentation](https://mypy.readthedocs.io/en/stable/config_file.html)
49+
for more details.
50+
51+
Contributed by Mikhail Shiryaev and Shantanu Jain
52+
(PR [16965](https://github.com/python/mypy/pull/16965), PR [18482](https://github.com/python/mypy/pull/18482)
53+
54+
### Better line numbers for decorators and slice expressions
55+
56+
Mypy now uses more correct line numbers for decorators and slice expressions. In some cases, this
57+
may necessitate changing the location of a `# type: ignore` comment.
58+
59+
Contributed by Shantanu Jain (PR [18392](https://github.com/python/mypy/pull/18392),
60+
PR [18397](https://github.com/python/mypy/pull/18397)).
61+
62+
### Drop Support for Python 3.8
63+
64+
Mypy no longer supports running with Python 3.8, which has reached end-of-life.
65+
When running mypy with Python 3.9+, it is still possible to type check code
66+
that needs to support Python 3.8 with the `--python-version 3.8` argument.
67+
Support for this will be dropped in the first half of 2025!
68+
69+
Contributed by Marc Mueller (PR [17492](https://github.com/python/mypy/pull/17492)).
670

771
## Mypy 1.14
872

0 commit comments

Comments
 (0)