Skip to content

Commit 1666841

Browse files
authored
Merge branch 'master' into call_del
2 parents d4e5f40 + 7c0c4b4 commit 1666841

File tree

148 files changed

+5210
-2127
lines changed

Some content is hidden

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

148 files changed

+5210
-2127
lines changed

.github/workflows/mypy_primer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
persist-credentials: false
4040
- uses: actions/setup-python@v5
4141
with:
42-
python-version: "3.12"
42+
python-version: "3.13"
4343
- name: Install dependencies
4444
run: |
4545
python -m pip install -U pip

.github/workflows/test.yml

Lines changed: 6 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

@@ -169,7 +157,6 @@ jobs:
169157
if: ${{ !(matrix.debug_build || endsWith(matrix.python, '-dev')) }}
170158
with:
171159
python-version: ${{ matrix.python }}
172-
architecture: ${{ matrix.arch }}
173160

174161
- name: Install tox
175162
run: |

.pre-commit-config.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ 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/)'
@@ -22,7 +22,7 @@ repos:
2222
- id: check-github-actions
2323
- id: check-readthedocs
2424
- repo: https://github.com/rhysd/actionlint
25-
rev: v1.7.6
25+
rev: v1.7.7
2626
hooks:
2727
- id: actionlint
2828
args: [
@@ -39,6 +39,14 @@ repos:
3939
rev: v1.0.1
4040
hooks:
4141
- id: zizmor
42+
- repo: local
43+
hooks:
44+
- id: bad-pr-link
45+
name: Bad PR link
46+
description: Detect PR links text that don't match their URL
47+
language: pygrep
48+
entry: '\[(\d+)\]\(https://github.com/python/mypy/pull/(?!\1/?\))\d+/?\)'
49+
files: CHANGELOG.md
4250
# Should be the last one:
4351
- repo: meta
4452
hooks:

CHANGELOG.md

Lines changed: 141 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,78 @@
11
# Mypy Release Notes
22

3-
## Next release
3+
## Next Release
44

5-
### Performance improvements
5+
...
6+
7+
## Mypy 1.15
8+
9+
We’ve just uploaded mypy 1.15 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).
10+
Mypy is a static type checker for Python. This release includes new features, performance
11+
improvements and bug fixes. You can install it as follows:
12+
13+
python3 -m pip install -U mypy
14+
15+
You can read the full documentation for this release on [Read the Docs](http://mypy.readthedocs.io).
16+
17+
### Performance Improvements
618

7-
Mypy may be 5-30% faster. This improvement comes largely from tuning the performance of the
8-
garbage collector.
19+
Mypy is up to 40% faster in some use cases. This improvement comes largely from tuning the performance
20+
of the garbage collector. Additionally, the release includes several micro-optimizations that may
21+
be impactful for large projects.
922

10-
Contributed by Jukka Lehtosalo (PR [18306](https://github.com/python/mypy/pull/18306)).
23+
Contributed by Jukka Lehtosalo
24+
- PR [18306](https://github.com/python/mypy/pull/18306)
25+
- PR [18302](https://github.com/python/mypy/pull/18302)
26+
- PR [18298](https://github.com/python/mypy/pull/18298)
27+
- PR [18299](https://github.com/python/mypy/pull/18299)
1128

12-
### Mypyc accelerated mypy wheels for aarch64
29+
### Mypyc Accelerated Mypy Wheels for ARM Linux
1330

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.
31+
For best performance, mypy can be compiled to C extension modules using mypyc. This makes
32+
mypy 3-5x faster than when interpreted with pure Python. We now build and upload mypyc
33+
accelerated mypy wheels for `manylinux_aarch64` to PyPI, making it easy for Linux users on
34+
ARM platforms to realise this speedup -- just `pip install` the latest mypy.
1835

1936
Contributed by Christian Bundy and Marc Mueller
2037
(PR [mypy_mypyc-wheels#76](https://github.com/mypyc/mypy_mypyc-wheels/pull/76),
2138
PR [mypy_mypyc-wheels#89](https://github.com/mypyc/mypy_mypyc-wheels/pull/89)).
2239

2340
### `--strict-bytes`
2441

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**.
42+
By default, mypy treats `bytearray` and `memoryview` values as assignable to the `bytes`
43+
type, for historical reasons. Use the `--strict-bytes` flag to disable this
44+
behavior. [PEP 688](https://peps.python.org/pep-0688) specified the removal of this
45+
special case. The flag will be enabled by default in **mypy 2.0**.
2846

29-
Contributed by Ali Hamdan (PR [18137](https://github.com/python/mypy/pull/18263/)) and
47+
Contributed by Ali Hamdan (PR [18263](https://github.com/python/mypy/pull/18263)) and
3048
Shantanu Jain (PR [13952](https://github.com/python/mypy/pull/13952)).
3149

32-
### Improvements to reachability analysis and partial type handling in loops
50+
### Improvements to Reachability Analysis and Partial Type Handling in Loops
3351

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.
52+
This change results in mypy better modelling control flow within loops and hence detecting
53+
several previously ignored issues. In some cases, this change may require additional
54+
explicit variable annotations.
3755

3856
Contributed by Christoph Tyralla (PR [18180](https://github.com/python/mypy/pull/18180),
39-
[PR](https://github.com/python/mypy/pull/18433)).
57+
PR [18433](https://github.com/python/mypy/pull/18433)).
4058

41-
(Speaking of partial types, another reminder that mypy plans on enabling `--local-partial-types`
42-
by default in **mypy 2.0**).
59+
(Speaking of partial types, remember that we plan to enable `--local-partial-types`
60+
by default in **mypy 2.0**.)
4361

44-
### Better discovery of configuration files
62+
### Better Discovery of Configuration Files
4563

4664
Mypy will now walk up the filesystem (up until a repository or file system root) to discover
4765
configuration files. See the
4866
[mypy configuration file documentation](https://mypy.readthedocs.io/en/stable/config_file.html)
4967
for more details.
5068

5169
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)
70+
(PR [16965](https://github.com/python/mypy/pull/16965), PR [18482](https://github.com/python/mypy/pull/18482))
5371

54-
### Better line numbers for decorators and slice expressions
72+
### Better Line Numbers for Decorators and Slice Expressions
5573

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.
74+
Mypy now uses more correct line numbers for decorators and slice expressions. In some cases,
75+
you may have to change the location of a `# type: ignore` comment.
5876

5977
Contributed by Shantanu Jain (PR [18392](https://github.com/python/mypy/pull/18392),
6078
PR [18397](https://github.com/python/mypy/pull/18397)).
@@ -68,6 +86,103 @@ Support for this will be dropped in the first half of 2025!
6886

6987
Contributed by Marc Mueller (PR [17492](https://github.com/python/mypy/pull/17492)).
7088

89+
### Mypyc Improvements
90+
91+
* Fix `__init__` for classes with `@attr.s(slots=True)` (Advait Dixit, PR [18447](https://github.com/python/mypy/pull/18447))
92+
* Report error for nested class instead of crashing (Valentin Stanciu, PR [18460](https://github.com/python/mypy/pull/18460))
93+
* Fix `InitVar` for dataclasses (Advait Dixit, PR [18319](https://github.com/python/mypy/pull/18319))
94+
* Remove unnecessary mypyc files from wheels (Marc Mueller, PR [18416](https://github.com/python/mypy/pull/18416))
95+
* Fix issues with relative imports (Advait Dixit, PR [18286](https://github.com/python/mypy/pull/18286))
96+
* Add faster primitive for some list get item operations (Jukka Lehtosalo, PR [18136](https://github.com/python/mypy/pull/18136))
97+
* Fix iteration over `NamedTuple` objects (Advait Dixit, PR [18254](https://github.com/python/mypy/pull/18254))
98+
* Mark mypyc package with `py.typed` (bzoracler, PR [18253](https://github.com/python/mypy/pull/18253))
99+
* Fix list index while checking for `Enum` class (Advait Dixit, PR [18426](https://github.com/python/mypy/pull/18426))
100+
101+
### Stubgen Improvements
102+
103+
* Improve dataclass init signatures (Marc Mueller, PR [18430](https://github.com/python/mypy/pull/18430))
104+
* Preserve `dataclass_transform` decorator (Marc Mueller, PR [18418](https://github.com/python/mypy/pull/18418))
105+
* Fix `UnpackType` for 3.11+ (Marc Mueller, PR [18421](https://github.com/python/mypy/pull/18421))
106+
* Improve `self` annotations (Marc Mueller, PR [18420](https://github.com/python/mypy/pull/18420))
107+
* Print `InspectError` traceback in stubgen `walk_packages` when verbose is specified (Gareth, PR [18224](https://github.com/python/mypy/pull/18224))
108+
109+
### Stubtest Improvements
110+
111+
* Fix crash with numpy array default values (Ali Hamdan, PR [18353](https://github.com/python/mypy/pull/18353))
112+
* Distinguish metaclass attributes from class attributes (Stephen Morton, PR [18314](https://github.com/python/mypy/pull/18314))
113+
114+
### Fixes to Crashes
115+
116+
* Prevent crash with `Unpack` of a fixed tuple in PEP695 type alias (Stanislav Terliakov, PR [18451](https://github.com/python/mypy/pull/18451))
117+
* Fix crash with `--cache-fine-grained --cache-dir=/dev/null` (Shantanu, PR [18457](https://github.com/python/mypy/pull/18457))
118+
* Prevent crashing when `match` arms use name of existing callable (Stanislav Terliakov, PR [18449](https://github.com/python/mypy/pull/18449))
119+
* Gracefully handle encoding errors when writing to stdout (Brian Schubert, PR [18292](https://github.com/python/mypy/pull/18292))
120+
* Prevent crash on generic NamedTuple with unresolved typevar bound (Stanislav Terliakov, PR [18585](https://github.com/python/mypy/pull/18585))
121+
122+
### Documentation Updates
123+
124+
* Add inline tabs to documentation (Marc Mueller, PR [18262](https://github.com/python/mypy/pull/18262))
125+
* Document any `TYPE_CHECKING` name works (Shantanu, PR [18443](https://github.com/python/mypy/pull/18443))
126+
* Update documentation to not mention 3.8 where possible (sobolevn, PR [18455](https://github.com/python/mypy/pull/18455))
127+
* Mention `ignore_errors` in exclude documentation (Shantanu, PR [18412](https://github.com/python/mypy/pull/18412))
128+
* Add `Self` misuse to common issues (Shantanu, PR [18261](https://github.com/python/mypy/pull/18261))
129+
130+
### Other Notable Fixes and Improvements
131+
132+
* Fix literal context for ternary expressions (Ivan Levkivskyi, PR [18545](https://github.com/python/mypy/pull/18545))
133+
* Ignore `dataclass.__replace__` LSP violations (Marc Mueller, PR [18464](https://github.com/python/mypy/pull/18464))
134+
* Bind `self` to the class being defined when checking multiple inheritance (Stanislav Terliakov, PR [18465](https://github.com/python/mypy/pull/18465))
135+
* Fix attribute type resolution with multiple inheritance (Stanislav Terliakov, PR [18415](https://github.com/python/mypy/pull/18415))
136+
* Improve security of our GitHub Actions (sobolevn, PR [18413](https://github.com/python/mypy/pull/18413))
137+
* Unwrap `type[Union[...]]` when solving type variable constraints (Stanislav Terliakov, PR [18266](https://github.com/python/mypy/pull/18266))
138+
* Allow `Any` to match sequence patterns in match/case (Stanislav Terliakov, PR [18448](https://github.com/python/mypy/pull/18448))
139+
* Fix parent generics mapping when overriding generic attribute with property (Stanislav Terliakov, PR [18441](https://github.com/python/mypy/pull/18441))
140+
* Add dedicated error code for explicit `Any` (Shantanu, PR [18398](https://github.com/python/mypy/pull/18398))
141+
* Reject invalid `ParamSpec` locations (Stanislav Terliakov, PR [18278](https://github.com/python/mypy/pull/18278))
142+
* Stop suggesting stubs that have been removed from typeshed (Shantanu, PR [18373](https://github.com/python/mypy/pull/18373))
143+
* Allow inverting `--local-partial-types` (Shantanu, PR [18377](https://github.com/python/mypy/pull/18377))
144+
* Allow to use `Final` and `ClassVar` after Python 3.13 (정승원, PR [18358](https://github.com/python/mypy/pull/18358))
145+
* Update suggestions to include latest stubs in typeshed (Shantanu, PR [18366](https://github.com/python/mypy/pull/18366))
146+
* Fix `--install-types` masking failure details (wyattscarpenter, PR [17485](https://github.com/python/mypy/pull/17485))
147+
* Reject promotions when checking against protocols (Christoph Tyralla, PR [18360](https://github.com/python/mypy/pull/18360))
148+
* Don't erase type object arguments in diagnostics (Shantanu, PR [18352](https://github.com/python/mypy/pull/18352))
149+
* Clarify status in `dmypy status` output (Kcornw, PR [18331](https://github.com/python/mypy/pull/18331))
150+
* Disallow no-argument generic aliases when using PEP 613 explicit aliases (Brian Schubert, PR [18173](https://github.com/python/mypy/pull/18173))
151+
* Suppress errors for unreachable branches in conditional expressions (Brian Schubert, PR [18295](https://github.com/python/mypy/pull/18295))
152+
* Do not allow `ClassVar` and `Final` in `TypedDict` and `NamedTuple` (sobolevn, PR [18281](https://github.com/python/mypy/pull/18281))
153+
* Report error if not enough or too many types provided to `TypeAliasType` (bzoracler, PR [18308](https://github.com/python/mypy/pull/18308))
154+
* Use more precise context for `TypedDict` plugin errors (Brian Schubert, PR [18293](https://github.com/python/mypy/pull/18293))
155+
* Use more precise context for invalid type argument errors (Brian Schubert, PR [18290](https://github.com/python/mypy/pull/18290))
156+
* Do not allow `type[]` to contain `Literal` types (sobolevn, PR [18276](https://github.com/python/mypy/pull/18276))
157+
* Allow bytearray/bytes comparisons with `--strict-bytes` (Jukka Lehtosalo, PR [18255](https://github.com/python/mypy/pull/18255))
158+
159+
### Acknowledgements
160+
161+
Thanks to all mypy contributors who contributed to this release:
162+
163+
- Advait Dixit
164+
- Ali Hamdan
165+
- Brian Schubert
166+
- bzoracler
167+
- Cameron Matsui
168+
- Christoph Tyralla
169+
- Gareth
170+
- Ivan Levkivskyi
171+
- Jukka Lehtosalo
172+
- Kcornw
173+
- Marc Mueller
174+
- Mikhail f. Shiryaev
175+
- Shantanu
176+
- sobolevn
177+
- Stanislav Terliakov
178+
- Stephen Morton
179+
- Valentin Stanciu
180+
- Viktor Szépe
181+
- wyattscarpenter
182+
- 정승원
183+
184+
I’d also like to thank my employer, Dropbox, for supporting mypy development.
185+
71186
## Mypy 1.14
72187

73188
We’ve just uploaded mypy 1.14 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).

docs/source/command_line.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,8 @@ of the above sections.
692692
.. option:: --extra-checks
693693

694694
This flag enables additional checks that are technically correct but may be
695-
impractical in real code. In particular, it prohibits partial overlap in
696-
``TypedDict`` updates, and makes arguments prepended via ``Concatenate``
697-
positional-only. For example:
695+
impractical. In particular, it prohibits partial overlap in ``TypedDict`` updates,
696+
and makes arguments prepended via ``Concatenate`` positional-only. For example:
698697

699698
.. code-block:: python
700699
@@ -717,6 +716,13 @@ of the above sections.
717716
bad: Bad = {"a": 0, "b": "no"}
718717
test(bad, bar)
719718
719+
In future more checks may be added to this flag if:
720+
721+
* The corresponding use cases are rare, thus not justifying a dedicated
722+
strictness flag.
723+
724+
* The new check cannot be supported as an opt-in error code.
725+
720726
.. option:: --strict
721727

722728
This flag mode enables all optional error checking flags. You can see the

0 commit comments

Comments
 (0)