11# Mypy Release Notes
22
3- ## Next release
3+ ## Next Release
44
5- ### Performance improvements
5+ ### Different Property Getter and Setter Types
66
7- Mypy may be 5-30% faster. This improvement comes largely from tuning the performance of the
8- garbage collector.
7+ Mypy now supports using different types for property getter and setter.
8+ ``` python
9+ class A :
10+ value: int
11+
12+ @ property
13+ def f (self ) -> int :
14+ return self .value
15+ @f.setter
16+ def f (self , x : str | int ) -> None :
17+ try :
18+ self .value = int (x)
19+ except ValueError :
20+ raise Exception (f " ' { x} ' is not a valid value for 'f' " )
21+ ```
22+
23+ Contributed by Ivan Levkivskyi (PR [ 18510] ( https://github.com/python/mypy/pull/18510 ) )
24+
25+ ### Selectively Disable Deprecated Warnings
26+
27+ It's now possible to selectively disable warnings generated from
28+ [ ` warnings.deprecated ` ] ( https://docs.python.org/3/library/warnings.html#warnings.deprecated )
29+ using the [ ` --deprecated-calls-exclude ` ] ( https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-deprecated-calls-exclude )
30+ option.
31+
32+ ``` python
33+ # mypy --enable-error-code deprecated
34+ # --deprecated-calls-exclude=foo.A
35+ import foo
36+
37+ foo.A().func() # OK, the deprecated warning is ignored
38+
39+ # file foo.py
40+ from typing_extensions import deprecated
41+ class A :
42+ @deprecated (" Use A.func2 instead" )
43+ def func (self ): pass
44+ ```
45+
46+ Contributed by Marc Mueller (PR [ 18641] ( https://github.com/python/mypy/pull/18641 ) )
47+
48+ ## Mypy 1.15
49+
50+ We’ve just uploaded mypy 1.15 to the Python Package Index ([ PyPI] ( https://pypi.org/project/mypy/ ) ).
51+ Mypy is a static type checker for Python. This release includes new features, performance
52+ improvements and bug fixes. You can install it as follows:
53+
54+ python3 -m pip install -U mypy
955
10- Contributed by Jukka Lehtosalo (PR [ 18306] ( https://github.com/python/mypy/pull/18306 ) ).
56+ You can read the full documentation for this release on [ Read the Docs] ( http://mypy.readthedocs.io ) .
57+
58+ ### Performance Improvements
59+
60+ Mypy is up to 40% faster in some use cases. This improvement comes largely from tuning the performance
61+ of the garbage collector. Additionally, the release includes several micro-optimizations that may
62+ be impactful for large projects.
1163
12- ### Mypyc accelerated mypy wheels for aarch64
64+ Contributed by Jukka Lehtosalo
65+ - PR [ 18306] ( https://github.com/python/mypy/pull/18306 )
66+ - PR [ 18302] ( https://github.com/python/mypy/pull/18302 )
67+ - PR [ 18298] ( https://github.com/python/mypy/pull/18298 )
68+ - PR [ 18299] ( https://github.com/python/mypy/pull/18299 )
1369
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.
70+ ### Mypyc Accelerated Mypy Wheels for ARM Linux
71+
72+ For best performance, mypy can be compiled to C extension modules using mypyc. This makes
73+ mypy 3-5x faster than when interpreted with pure Python. We now build and upload mypyc
74+ accelerated mypy wheels for ` manylinux_aarch64 ` to PyPI, making it easy for Linux users on
75+ ARM platforms to realise this speedup -- just ` pip install ` the latest mypy.
1876
1977Contributed by Christian Bundy and Marc Mueller
2078(PR [ mypy_mypyc-wheels#76] ( https://github.com/mypyc/mypy_mypyc-wheels/pull/76 ) ,
2179PR [ mypy_mypyc-wheels#89] ( https://github.com/mypyc/mypy_mypyc-wheels/pull/89 ) ).
2280
2381### ` --strict-bytes `
2482
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** .
83+ By default, mypy treats ` bytearray ` and ` memoryview ` values as assignable to the ` bytes `
84+ type, for historical reasons. Use the ` --strict-bytes ` flag to disable this
85+ behavior. [ PEP 688] ( https://peps.python.org/pep-0688 ) specified the removal of this
86+ special case. The flag will be enabled by default in ** mypy 2.0** .
2887
29- Contributed by Ali Hamdan (PR [ 18137 ] ( https://github.com/python/mypy/pull/18263/ ) ) and
88+ Contributed by Ali Hamdan (PR [ 18263 ] ( https://github.com/python/mypy/pull/18263 ) ) and
3089Shantanu Jain (PR [ 13952] ( https://github.com/python/mypy/pull/13952 ) ).
3190
32- ### Improvements to reachability analysis and partial type handling in loops
91+ ### Improvements to Reachability Analysis and Partial Type Handling in Loops
3392
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.
93+ This change results in mypy better modelling control flow within loops and hence detecting
94+ several previously ignored issues . In some cases, this change may require additional
95+ explicit variable annotations .
3796
3897Contributed by Christoph Tyralla (PR [ 18180] ( https://github.com/python/mypy/pull/18180 ) ,
39- [ PR ] ( https://github.com/python/mypy/pull/18433 ) ).
98+ PR [ 18433 ] ( https://github.com/python/mypy/pull/18433 ) ).
4099
41- (Speaking of partial types, another reminder that mypy plans on enabling ` --local-partial-types `
42- by default in ** mypy 2.0** ).
100+ (Speaking of partial types, remember that we plan to enable ` --local-partial-types `
101+ by default in ** mypy 2.0** .)
43102
44- ### Better discovery of configuration files
103+ ### Better Discovery of Configuration Files
45104
46105Mypy will now walk up the filesystem (up until a repository or file system root) to discover
47106configuration files. See the
48107[ mypy configuration file documentation] ( https://mypy.readthedocs.io/en/stable/config_file.html )
49108for more details.
50109
51110Contributed 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 )
111+ (PR [ 16965] ( https://github.com/python/mypy/pull/16965 ) , PR [ 18482] ( https://github.com/python/mypy/pull/18482 ) )
53112
54- ### Better line numbers for decorators and slice expressions
113+ ### Better Line Numbers for Decorators and Slice Expressions
55114
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.
115+ Mypy now uses more correct line numbers for decorators and slice expressions. In some cases,
116+ you may have to change the location of a ` # type: ignore ` comment.
58117
59118Contributed by Shantanu Jain (PR [ 18392] ( https://github.com/python/mypy/pull/18392 ) ,
60119PR [ 18397] ( https://github.com/python/mypy/pull/18397 ) ).
@@ -68,6 +127,103 @@ Support for this will be dropped in the first half of 2025!
68127
69128Contributed by Marc Mueller (PR [ 17492] ( https://github.com/python/mypy/pull/17492 ) ).
70129
130+ ### Mypyc Improvements
131+
132+ * Fix ` __init__ ` for classes with ` @attr.s(slots=True) ` (Advait Dixit, PR [ 18447] ( https://github.com/python/mypy/pull/18447 ) )
133+ * Report error for nested class instead of crashing (Valentin Stanciu, PR [ 18460] ( https://github.com/python/mypy/pull/18460 ) )
134+ * Fix ` InitVar ` for dataclasses (Advait Dixit, PR [ 18319] ( https://github.com/python/mypy/pull/18319 ) )
135+ * Remove unnecessary mypyc files from wheels (Marc Mueller, PR [ 18416] ( https://github.com/python/mypy/pull/18416 ) )
136+ * Fix issues with relative imports (Advait Dixit, PR [ 18286] ( https://github.com/python/mypy/pull/18286 ) )
137+ * Add faster primitive for some list get item operations (Jukka Lehtosalo, PR [ 18136] ( https://github.com/python/mypy/pull/18136 ) )
138+ * Fix iteration over ` NamedTuple ` objects (Advait Dixit, PR [ 18254] ( https://github.com/python/mypy/pull/18254 ) )
139+ * Mark mypyc package with ` py.typed ` (bzoracler, PR [ 18253] ( https://github.com/python/mypy/pull/18253 ) )
140+ * Fix list index while checking for ` Enum ` class (Advait Dixit, PR [ 18426] ( https://github.com/python/mypy/pull/18426 ) )
141+
142+ ### Stubgen Improvements
143+
144+ * Improve dataclass init signatures (Marc Mueller, PR [ 18430] ( https://github.com/python/mypy/pull/18430 ) )
145+ * Preserve ` dataclass_transform ` decorator (Marc Mueller, PR [ 18418] ( https://github.com/python/mypy/pull/18418 ) )
146+ * Fix ` UnpackType ` for 3.11+ (Marc Mueller, PR [ 18421] ( https://github.com/python/mypy/pull/18421 ) )
147+ * Improve ` self ` annotations (Marc Mueller, PR [ 18420] ( https://github.com/python/mypy/pull/18420 ) )
148+ * Print ` InspectError ` traceback in stubgen ` walk_packages ` when verbose is specified (Gareth, PR [ 18224] ( https://github.com/python/mypy/pull/18224 ) )
149+
150+ ### Stubtest Improvements
151+
152+ * Fix crash with numpy array default values (Ali Hamdan, PR [ 18353] ( https://github.com/python/mypy/pull/18353 ) )
153+ * Distinguish metaclass attributes from class attributes (Stephen Morton, PR [ 18314] ( https://github.com/python/mypy/pull/18314 ) )
154+
155+ ### Fixes to Crashes
156+
157+ * Prevent crash with ` Unpack ` of a fixed tuple in PEP695 type alias (Stanislav Terliakov, PR [ 18451] ( https://github.com/python/mypy/pull/18451 ) )
158+ * Fix crash with ` --cache-fine-grained --cache-dir=/dev/null ` (Shantanu, PR [ 18457] ( https://github.com/python/mypy/pull/18457 ) )
159+ * Prevent crashing when ` match ` arms use name of existing callable (Stanislav Terliakov, PR [ 18449] ( https://github.com/python/mypy/pull/18449 ) )
160+ * Gracefully handle encoding errors when writing to stdout (Brian Schubert, PR [ 18292] ( https://github.com/python/mypy/pull/18292 ) )
161+ * Prevent crash on generic NamedTuple with unresolved typevar bound (Stanislav Terliakov, PR [ 18585] ( https://github.com/python/mypy/pull/18585 ) )
162+
163+ ### Documentation Updates
164+
165+ * Add inline tabs to documentation (Marc Mueller, PR [ 18262] ( https://github.com/python/mypy/pull/18262 ) )
166+ * Document any ` TYPE_CHECKING ` name works (Shantanu, PR [ 18443] ( https://github.com/python/mypy/pull/18443 ) )
167+ * Update documentation to not mention 3.8 where possible (sobolevn, PR [ 18455] ( https://github.com/python/mypy/pull/18455 ) )
168+ * Mention ` ignore_errors ` in exclude documentation (Shantanu, PR [ 18412] ( https://github.com/python/mypy/pull/18412 ) )
169+ * Add ` Self ` misuse to common issues (Shantanu, PR [ 18261] ( https://github.com/python/mypy/pull/18261 ) )
170+
171+ ### Other Notable Fixes and Improvements
172+
173+ * Fix literal context for ternary expressions (Ivan Levkivskyi, PR [ 18545] ( https://github.com/python/mypy/pull/18545 ) )
174+ * Ignore ` dataclass.__replace__ ` LSP violations (Marc Mueller, PR [ 18464] ( https://github.com/python/mypy/pull/18464 ) )
175+ * Bind ` self ` to the class being defined when checking multiple inheritance (Stanislav Terliakov, PR [ 18465] ( https://github.com/python/mypy/pull/18465 ) )
176+ * Fix attribute type resolution with multiple inheritance (Stanislav Terliakov, PR [ 18415] ( https://github.com/python/mypy/pull/18415 ) )
177+ * Improve security of our GitHub Actions (sobolevn, PR [ 18413] ( https://github.com/python/mypy/pull/18413 ) )
178+ * Unwrap ` type[Union[...]] ` when solving type variable constraints (Stanislav Terliakov, PR [ 18266] ( https://github.com/python/mypy/pull/18266 ) )
179+ * Allow ` Any ` to match sequence patterns in match/case (Stanislav Terliakov, PR [ 18448] ( https://github.com/python/mypy/pull/18448 ) )
180+ * Fix parent generics mapping when overriding generic attribute with property (Stanislav Terliakov, PR [ 18441] ( https://github.com/python/mypy/pull/18441 ) )
181+ * Add dedicated error code for explicit ` Any ` (Shantanu, PR [ 18398] ( https://github.com/python/mypy/pull/18398 ) )
182+ * Reject invalid ` ParamSpec ` locations (Stanislav Terliakov, PR [ 18278] ( https://github.com/python/mypy/pull/18278 ) )
183+ * Stop suggesting stubs that have been removed from typeshed (Shantanu, PR [ 18373] ( https://github.com/python/mypy/pull/18373 ) )
184+ * Allow inverting ` --local-partial-types ` (Shantanu, PR [ 18377] ( https://github.com/python/mypy/pull/18377 ) )
185+ * Allow to use ` Final ` and ` ClassVar ` after Python 3.13 (정승원, PR [ 18358] ( https://github.com/python/mypy/pull/18358 ) )
186+ * Update suggestions to include latest stubs in typeshed (Shantanu, PR [ 18366] ( https://github.com/python/mypy/pull/18366 ) )
187+ * Fix ` --install-types ` masking failure details (wyattscarpenter, PR [ 17485] ( https://github.com/python/mypy/pull/17485 ) )
188+ * Reject promotions when checking against protocols (Christoph Tyralla, PR [ 18360] ( https://github.com/python/mypy/pull/18360 ) )
189+ * Don't erase type object arguments in diagnostics (Shantanu, PR [ 18352] ( https://github.com/python/mypy/pull/18352 ) )
190+ * Clarify status in ` dmypy status ` output (Kcornw, PR [ 18331] ( https://github.com/python/mypy/pull/18331 ) )
191+ * Disallow no-argument generic aliases when using PEP 613 explicit aliases (Brian Schubert, PR [ 18173] ( https://github.com/python/mypy/pull/18173 ) )
192+ * Suppress errors for unreachable branches in conditional expressions (Brian Schubert, PR [ 18295] ( https://github.com/python/mypy/pull/18295 ) )
193+ * Do not allow ` ClassVar ` and ` Final ` in ` TypedDict ` and ` NamedTuple ` (sobolevn, PR [ 18281] ( https://github.com/python/mypy/pull/18281 ) )
194+ * Report error if not enough or too many types provided to ` TypeAliasType ` (bzoracler, PR [ 18308] ( https://github.com/python/mypy/pull/18308 ) )
195+ * Use more precise context for ` TypedDict ` plugin errors (Brian Schubert, PR [ 18293] ( https://github.com/python/mypy/pull/18293 ) )
196+ * Use more precise context for invalid type argument errors (Brian Schubert, PR [ 18290] ( https://github.com/python/mypy/pull/18290 ) )
197+ * Do not allow ` type[] ` to contain ` Literal ` types (sobolevn, PR [ 18276] ( https://github.com/python/mypy/pull/18276 ) )
198+ * Allow bytearray/bytes comparisons with ` --strict-bytes ` (Jukka Lehtosalo, PR [ 18255] ( https://github.com/python/mypy/pull/18255 ) )
199+
200+ ### Acknowledgements
201+
202+ Thanks to all mypy contributors who contributed to this release:
203+
204+ - Advait Dixit
205+ - Ali Hamdan
206+ - Brian Schubert
207+ - bzoracler
208+ - Cameron Matsui
209+ - Christoph Tyralla
210+ - Gareth
211+ - Ivan Levkivskyi
212+ - Jukka Lehtosalo
213+ - Kcornw
214+ - Marc Mueller
215+ - Mikhail f. Shiryaev
216+ - Shantanu
217+ - sobolevn
218+ - Stanislav Terliakov
219+ - Stephen Morton
220+ - Valentin Stanciu
221+ - Viktor Szépe
222+ - wyattscarpenter
223+ - 정승원
224+
225+ I’d also like to thank my employer, Dropbox, for supporting mypy development.
226+
71227## Mypy 1.14
72228
73229We’ve just uploaded mypy 1.14 to the Python Package Index ([ PyPI] ( https://pypi.org/project/mypy/ ) ).
0 commit comments