Skip to content

Commit e356348

Browse files
committed
Merge remote-tracking branch 'upstream/master' into new-new
2 parents b921130 + e53693b commit e356348

132 files changed

Lines changed: 4145 additions & 1210 deletions

File tree

Some content is hidden

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

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
with:
4545
python-version: '3.12'
4646
- name: Install tox
47-
run: pip install tox==4.26.0
47+
run: pip install tox==4.53.1
4848
- name: Setup tox environment
4949
run: tox run -e ${{ env.TOXENV }} --notest
5050
- name: Test

.github/workflows/test.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ jobs:
5959
toxenv: py
6060
tox_extra_args: "-n 4"
6161
test_mypyc: true
62+
- name: Test suite with py315-ubuntu, mypyc-compiled
63+
python: '3.15'
64+
os: ubuntu-24.04-arm
65+
toxenv: py
66+
tox_extra_args: "-n 4"
67+
test_mypyc: true
6268
- name: Test suite with py314t-ubuntu, mypyc-compiled
6369
python: '3.14t'
6470
os: ubuntu-24.04-arm
@@ -196,6 +202,7 @@ jobs:
196202
if: ${{ !(matrix.debug_build || endsWith(matrix.python, '-dev')) }}
197203
with:
198204
python-version: ${{ matrix.python }}
205+
allow-prereleases: true
199206

200207
- name: Install tox
201208
run: |
@@ -206,7 +213,7 @@ jobs:
206213
echo debug build; python -c 'import sysconfig; print(bool(sysconfig.get_config_var("Py_DEBUG")))'
207214
echo os.cpu_count; python -c 'import os; print(os.cpu_count())'
208215
echo os.sched_getaffinity; python -c 'import os; print(len(getattr(os, "sched_getaffinity", lambda *args: [])(0)))'
209-
pip install tox==4.26.0
216+
pip install tox==4.53.1
210217
211218
- name: Compiled with mypyc
212219
if: ${{ matrix.test_mypyc }}
@@ -271,7 +278,7 @@ jobs:
271278
default: 3.11.1
272279
command: python -c "import platform; print(f'{platform.architecture()=} {platform.machine()=}');"
273280
- name: Install tox
274-
run: pip install tox==4.26.0
281+
run: pip install tox==4.53.1
275282
- name: Setup tox environment
276283
run: tox run -e py --notest
277284
- name: Test

CHANGELOG.md

Lines changed: 221 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,99 @@
22

33
## Next Release
44

5-
### Enabling `--local-partial-types` by Default
5+
## Mypy 2.1
6+
7+
We’ve just uploaded mypy 2.1.0 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).
8+
Mypy is a static type checker for Python. This release includes new features, performance
9+
improvements and bug fixes. You can install it as follows:
10+
11+
python3 -m pip install -U mypy
12+
13+
You can read the full documentation for this release on [Read the Docs](http://mypy.readthedocs.io).
14+
15+
### librt.vecs: Fast Growable Array Type for Mypyc
16+
17+
The new `librt.vecs` module provides an efficient growable array type `vec` that is
18+
optimized for mypyc use. It provides fast, packed arrays with integer and floating point
19+
value types, which can be **several times faster** than `list`, and tens of times faster
20+
than `array.array` in code compiled using mypyc. It also supports nested `vec` objects and
21+
non-value-type items, such as ``vec[vec[str]]``.
22+
23+
Refer to the [documentation](https://mypyc.readthedocs.io/en/latest/librt_vecs.html) for
24+
the details.
25+
26+
Contributed by Jukka Lehtosalo.
27+
28+
### librt.random: Fast Pseudo-Random Number Generation
29+
30+
The new `librt.random` module provides fast pseudo-random number generation that is
31+
optimized for code compiled using mypyc. It can be 3x to 10x faster than the stdlib
32+
`random` module in compiled code.
33+
34+
Refer to the [documentation](https://mypyc.readthedocs.io/en/latest/librt_random.html) for
35+
the details.
36+
37+
Contributed by Jukka Lehtosalo (PR [21433](https://github.com/python/mypy/pull/21433)).
38+
39+
### Mypyc Improvements
40+
41+
- Make compilation order with multiple files consistent (Piotr Sawicki, PR [21419](https://github.com/python/mypy/pull/21419))
42+
- Fix crash on accessing `StopAsyncIteration` (Piotr Sawicki, PR [21406](https://github.com/python/mypy/pull/21406))
43+
- Fix incremental compilation with `separate` flag (Vaggelis Danias, PR [21299](https://github.com/python/mypy/pull/21299))
44+
45+
### Fixes to Crashes
46+
47+
- Fix crash on partial type with `--allow-redefinition` and `global` declaration (Jukka Lehtosalo, PR [21428](https://github.com/python/mypy/pull/21428))
48+
- Fix broken awaitable generator patching (Ivan Levkivskyi, PR [21435](https://github.com/python/mypy/pull/21435))
49+
50+
### Changes to Messages
51+
52+
- Fix function call error message for small number of arguments (sobolevn, PR [21432](https://github.com/python/mypy/pull/21432))
53+
54+
### Other Notable Fixes and Improvements
55+
56+
- Rely on typeshed stubs for `slice` typing (Ivan Levkivskyi, PR [21401](https://github.com/python/mypy/pull/21401))
57+
- Improve negative narrowing for membership checks on tuples (Shantanu, PR [21456](https://github.com/python/mypy/pull/21456))
58+
- Narrow match captures based on previous cases (Shantanu, PR [21405](https://github.com/python/mypy/pull/21405))
59+
- Fix nondeterminism in overload resolution (Shantanu, PR [21455](https://github.com/python/mypy/pull/21455))
60+
- Respect file config comments for stale modules (Adam Turner, PR [21444](https://github.com/python/mypy/pull/21444))
61+
- Fix JSON output mode for syntax errors in parallel mode (Adam Turner, PR [21434](https://github.com/python/mypy/pull/21434))
62+
- Fix type variable with values as a supertype (Ivan Levkivskyi, PR [21431](https://github.com/python/mypy/pull/21431))
63+
- Add support for configuring `--num-workers` with an environment variable (Kevin Kannammalil, PR [21407](https://github.com/python/mypy/pull/21407))
64+
- Respect JSON output mode for syntax errors (Adam Turner, PR [21386](https://github.com/python/mypy/pull/21386))
65+
- Analyze `TypedDict` decorators (Pranav Manglik, PR [21267](https://github.com/python/mypy/pull/21267))
66+
67+
### Typeshed Updates
68+
69+
Please see [git log](https://github.com/python/typeshed/commits/main?after=e4d32e01bee44241a5e7c33298c261175b9f1bdb+0&branch=main&path=stdlib) for full list of standard library typeshed stub changes.
70+
71+
### Acknowledgements
72+
73+
Thanks to all mypy contributors who contributed to this release:
74+
75+
- Adam Turner
76+
- Ivan Levkivskyi
77+
- Jukka Lehtosalo
78+
- Kevin Kannammalil
79+
- Piotr Sawicki
80+
- Shantanu
81+
- sobolevn
82+
- Vaggelis Danias
83+
84+
I’d also like to thank my employer, Dropbox, for supporting mypy development.
85+
86+
## Mypy 2.0
87+
88+
We’ve just uploaded mypy 2.0.0 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).
89+
Mypy is a static type checker for Python. This release includes new features, performance
90+
improvements and bug fixes. There are also changes to options and defaults.
91+
You can install it as follows:
92+
93+
python3 -m pip install -U mypy
94+
95+
You can read the full documentation for this release on [Read the Docs](http://mypy.readthedocs.io).
96+
97+
### Enable `--local-partial-types` by Default
698

799
This flag affects the inference of types based on assignments in other scopes.
8100
For now, explicitly disabling this continues to be supported, but this support will be removed
@@ -11,7 +103,7 @@ in mypy, like the daemon or the new implementation of flexible redefinitions.
11103

12104
Contributed by Ivan Levkivskyi, Jukka Lehtosalo, Shantanu in [PR 21163](https://github.com/python/mypy/pull/21163).
13105

14-
### Enabling `--strict-bytes` by Default
106+
### Enable `--strict-bytes` by Default
15107

16108
Per [PEP 688](https://peps.python.org/pep-0688), mypy no longer treats `bytearray` and `memoryview`
17109
values as assignable to the `bytes` type.
@@ -72,6 +164,25 @@ in future mypy releases.
72164
Contributed by Ivan Levkivskyi, with additional contributions from Emma Smith and Jukka
73165
Lehtosalo.
74166

167+
Recent related changes since the last release:
168+
169+
- Freeze garbage collection in parallel workers for 4-5% speedup (Ivan Levkivskyi, PR [21302](https://github.com/python/mypy/pull/21302))
170+
- Expose `--num-workers` and `--native-parser` (Ivan Levkivskyi, PR [21387](https://github.com/python/mypy/pull/21387))
171+
- Split type checking into interface and implementation in parallel workers (Ivan Levkivskyi, PR [21119](https://github.com/python/mypy/pull/21119))
172+
- Batch module groups for parallel processing (Ivan Levkivskyi, PR [21287](https://github.com/python/mypy/pull/21287))
173+
- Optimize parallel worker startup (Ivan Levkivskyi, PR [21203](https://github.com/python/mypy/pull/21203))
174+
- Parse files in parallel when possible (Ivan Levkivskyi, PR [21175](https://github.com/python/mypy/pull/21175))
175+
- Use parallel parsing at all stages (Ivan Levkivskyi, PR [21266](https://github.com/python/mypy/pull/21266))
176+
- Fix sequential bottleneck in parallel parsing (Jukka Lehtosalo, PR [21291](https://github.com/python/mypy/pull/21291))
177+
- Fail fast when a user tries to generate reports with parallel workers (Ivan Levkivskyi, PR [21341](https://github.com/python/mypy/pull/21341))
178+
- Partially support old NumPy plugin in parallel type checking (Ivan Levkivskyi, PR [21324](https://github.com/python/mypy/pull/21324))
179+
- Handle reachability consistently in parallel type checking (Ivan Levkivskyi, PR [21322](https://github.com/python/mypy/pull/21322))
180+
- Always respect `@no_type_check` in parallel type checking (Ivan Levkivskyi, PR [21320](https://github.com/python/mypy/pull/21320))
181+
- Minor fixes in parallel checking (Ivan Levkivskyi, PR [21319](https://github.com/python/mypy/pull/21319))
182+
- Fix plugin logic in parallel type checking (Ivan Levkivskyi, PR [21252](https://github.com/python/mypy/pull/21252))
183+
- Fix Windows IPC race condition when using parallel checking (Jukka Lehtosalo, PR [21228](https://github.com/python/mypy/pull/21228))
184+
- Report parallel worker exit status on receive failure (Jukka Lehtosalo, PR [21224](https://github.com/python/mypy/pull/21224))
185+
75186
### Drop Support for Targeting Python 3.9
76187

77188
Mypy no longer supports type checking code with `--python-version 3.9`.
@@ -111,6 +222,114 @@ the details.
111222

112223
Contributed by Jukka Lehtosalo.
113224

225+
### Mypyc Improvements
226+
227+
- Document `librt.time` (Jukka Lehtosalo, PR [21372](https://github.com/python/mypy/pull/21372))
228+
- Mark `librt.time.time()` non-experimental (Ivan Levkivskyi, PR [21310](https://github.com/python/mypy/pull/21310))
229+
- Fix `librt.time` primitive now that it is no longer experimental (Ivan Levkivskyi, PR [21318](https://github.com/python/mypy/pull/21318))
230+
- Fix `librt` API/ABI version checks (Jukka Lehtosalo, PR [21311](https://github.com/python/mypy/pull/21311))
231+
- Generate more type methods for classes with attribute dictionaries (Piotr Sawicki, PR [21290](https://github.com/python/mypy/pull/21290))
232+
- Fix reference counting for tuple items during deallocation (Shantanu, PR [21245](https://github.com/python/mypy/pull/21245))
233+
- Release new instances when `__init__` raises (Shantanu, PR [21248](https://github.com/python/mypy/pull/21248))
234+
- Fix `@property` getter memory leak (Vaggelis Danias, PR [21230](https://github.com/python/mypy/pull/21230))
235+
- Fix semantics for walrus expression in tuple (Shantanu, PR [21249](https://github.com/python/mypy/pull/21249))
236+
- Fix crash on import errors during cleanup (Shantanu, PR [21247](https://github.com/python/mypy/pull/21247))
237+
- Fix reference leak in str index (Shantanu, PR [21251](https://github.com/python/mypy/pull/21251))
238+
- Fix memory leak in integer true division (Shantanu, PR [21246](https://github.com/python/mypy/pull/21246))
239+
- Fix reference leaks in `list.clear()`/`dict.clear()` (Shantanu, PR [21244](https://github.com/python/mypy/pull/21244))
240+
- Resolve type aliases in function specialization (esarp, PR [21233](https://github.com/python/mypy/pull/21233))
241+
- Report an error if an acyclic class inherits from non-acyclic (Piotr Sawicki, PR [21227](https://github.com/python/mypy/pull/21227))
242+
- Fix `b64decode` to match new CPython behavior (Piotr Sawicki, PR [21200](https://github.com/python/mypy/pull/21200))
243+
244+
### Fixes to Crashes
245+
246+
- Fix crash when a file does not exist during semantic analysis (Ivan Levkivskyi, PR [21379](https://github.com/python/mypy/pull/21379))
247+
- Fix parallel worker crash on syntax error (Ivan Levkivskyi, PR [21202](https://github.com/python/mypy/pull/21202))
248+
249+
### Changes to Messages
250+
251+
- Improve error messages for unexpected keyword arguments in overloaded functions (Kevin Kannammalil, PR [20592](https://github.com/python/mypy/pull/20592))
252+
- Don't suggest `Foo[...]` when `Foo(arg=...)` is used in annotation (Yosof Badr, PR [21238](https://github.com/python/mypy/pull/21238))
253+
- Mention what codes are actually ignored in "not covered by type: ignore comment" note (wyattscarpenter, PR [19904](https://github.com/python/mypy/pull/19904))
254+
- Improve error messages when positional argument is missing (Kevin Kannammalil, PR [20591](https://github.com/python/mypy/pull/20591))
255+
- Improve "name is not defined" errors with fuzzy matching (Kevin Kannammalil, PR [20693](https://github.com/python/mypy/pull/20693))
256+
- Add suggestions for misspelled module imports (Kevin Kannammalil, PR [20695](https://github.com/python/mypy/pull/20695))
257+
258+
### Performance Improvements
259+
260+
- Replace `NamedTuple` with faster regular classes in hot paths (Shantanu, PR [21326](https://github.com/python/mypy/pull/21326))
261+
- Avoid calling best-match suggestions unless the message is shown (Ivan Levkivskyi, PR [21307](https://github.com/python/mypy/pull/21307))
262+
- Order cases in native parser based on AST node frequency (Jukka Lehtosalo, PR [21219](https://github.com/python/mypy/pull/21219))
263+
264+
### Stubtest Improvements
265+
266+
- Basic support for unpack kwargs (Shantanu, PR [21024](https://github.com/python/mypy/pull/21024))
267+
- Fix false positive for properties with a deleter (Pranav Manglik, PR [21259](https://github.com/python/mypy/pull/21259))
268+
269+
### Documentation Updates
270+
271+
- Rename "value restriction" to "value-constrained type variable" (Leo Ji, PR [21112](https://github.com/python/mypy/pull/21112))
272+
- Clarify that invariant-by-default applies to legacy `TypeVar` syntax (Leo Ji, PR [21108](https://github.com/python/mypy/pull/21108))
273+
274+
### Improvements to the Native Parser
275+
276+
The new native parser is still experimental.
277+
278+
- Make new parser consistent with the old one (Ivan Levkivskyi, PR [21377](https://github.com/python/mypy/pull/21377))
279+
- Support `--package-root` with the native parser (Ivan Levkivskyi, PR [21321](https://github.com/python/mypy/pull/21321))
280+
- Improve call expressions in type annotations with the native parser (Jukka Lehtosalo, PR [21300](https://github.com/python/mypy/pull/21300))
281+
- Depend on `ast-serialize` by default (Jukka Lehtosalo, PR [21297](https://github.com/python/mypy/pull/21297))
282+
283+
### Other Notable Fixes and Improvements
284+
285+
- Fix narrowing for `AbstractSet` and `Mapping` (Shantanu, PR [21352](https://github.com/python/mypy/pull/21352))
286+
- Preserve gradual guarantee when narrowing `Any` union via equality (Shantanu, PR [21368](https://github.com/python/mypy/pull/21368))
287+
- Make type variable upper bound narrowing symmetric (Ivan Levkivskyi, PR [21350](https://github.com/python/mypy/pull/21350))
288+
- Behave consistently when type-checking a stub package directly (Ivan Levkivskyi, PR [21330](https://github.com/python/mypy/pull/21330))
289+
- Add support for `Final[...]` in dataclasses (Ivan Levkivskyi, PR [21334](https://github.com/python/mypy/pull/21334))
290+
- Narrow more sequence parents (Shantanu, PR [21327](https://github.com/python/mypy/pull/21327))
291+
- Better narrowing for enums and other types with known equality (Shantanu, PR [21281](https://github.com/python/mypy/pull/21281))
292+
- Fix pathspec error (Ivan Levkivskyi, PR [21296](https://github.com/python/mypy/pull/21296))
293+
- Use sharding for the SQLite cache (Jukka Lehtosalo, PR [21292](https://github.com/python/mypy/pull/21292))
294+
- Limit type inference context fallback to the walrus operator only (Ivan Levkivskyi, PR [21294](https://github.com/python/mypy/pull/21294))
295+
- Support `.git/info/exclude` for `--exclude-gitignore` (RogerJinIS, PR [21286](https://github.com/python/mypy/pull/21286))
296+
- Let `--allow-redefinition` widen a global in a function with `None` initialization (Jukka Lehtosalo, PR [21285](https://github.com/python/mypy/pull/21285))
297+
- Delete Python 2 extra (Shantanu, PR [18374](https://github.com/python/mypy/pull/18374))
298+
- No longer narrow final globals in functions (Ivan Levkivskyi, PR [21241](https://github.com/python/mypy/pull/21241))
299+
- Narrow unions containing `Any` in conditional branches (Shantanu, PR [21231](https://github.com/python/mypy/pull/21231))
300+
- Propagate narrowing within chained comparisons (Shantanu, PR [21160](https://github.com/python/mypy/pull/21160))
301+
- Add proper lazy deserialization (Ivan Levkivskyi, PR [21198](https://github.com/python/mypy/pull/21198))
302+
- Add `install_types` to options affecting cache (Brian Schubert, PR [21070](https://github.com/python/mypy/pull/21070))
303+
- Narrow `Any` in conditional type checks (Shantanu, PR [21167](https://github.com/python/mypy/pull/21167))
304+
- Fix exception handler target location in new parser (Ivan Levkivskyi, PR [21185](https://github.com/python/mypy/pull/21185))
305+
- Improve traceback display (Shantanu, PR [21155](https://github.com/python/mypy/pull/21155))
306+
- Include two more files in the sdist: `CREDITS` and the typeshed `README` (Michael R. Crusoe, PR [21131](https://github.com/python/mypy/pull/21131))
307+
308+
### Typeshed Updates
309+
310+
Please see [git log](https://github.com/python/typeshed/commits/main?after=c5e47faeda2cf9d233f91bc1dc95814b0cc7ccba+0&branch=main&path=stdlib) for full list of standard library typeshed stub changes.
311+
312+
### Acknowledgements
313+
314+
Thanks to all mypy contributors who contributed to this release:
315+
- Brian Schubert
316+
- Ethan Sarp
317+
- Ivan Levkivskyi
318+
- Jukka Lehtosalo
319+
- Kevin Kannammalil
320+
- Leo Ji
321+
- Marc Mueller
322+
- Michael R. Crusoe
323+
- Piotr Sawicki
324+
- Pranav Manglik
325+
- RogerJinIS
326+
- Shantanu
327+
- Vaggelis Danias
328+
- wyattscarpenter
329+
- Yosof Badr
330+
331+
I’d also like to thank my employer, Dropbox, for supporting mypy development.
332+
114333
## Mypy 1.20
115334

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

docs/source/error_code_list2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ Example:
550550
Check that overrides of mutable attributes are safe [mutable-override]
551551
----------------------------------------------------------------------
552552

553-
`mutable-override` will enable the check for unsafe overrides of mutable attributes.
553+
``mutable-override`` will enable the check for unsafe overrides of mutable attributes.
554554
For historical reasons, and because this is a relatively common pattern in Python,
555555
this check is not enabled by default. The example below is unsafe, and will be
556556
flagged when this error code is enabled:

0 commit comments

Comments
 (0)