Skip to content

Commit 6a3f385

Browse files
authored
Merge branch 'master' into negative-narrowing-with-custom-eq
2 parents 9cdfb19 + c8fad3f commit 6a3f385

Some content is hidden

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

80 files changed

+1121
-391
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 1 deletion
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/)'
@@ -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/)).

misc/gen_blog_post_html.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def convert(src: str) -> str:
9595
h = re.sub(r"`\*\*`", "<tt>**</tt>", h)
9696

9797
# Paragraphs
98-
h = re.sub(r"\n([A-Z])", r"\n<p>\1", h)
98+
h = re.sub(r"\n\n([A-Z])", r"\n\n<p>\1", h)
9999

100100
# Bullet lists
101101
h = format_lists(h)
@@ -104,6 +104,7 @@ def convert(src: str) -> str:
104104
h = format_code(h)
105105

106106
# Code fragments
107+
h = re.sub(r"``([^`]+)``", r"<tt>\1</tt>", h)
107108
h = re.sub(r"`([^`]+)`", r"<tt>\1</tt>", h)
108109

109110
# Remove **** noise
@@ -125,7 +126,9 @@ def convert(src: str) -> str:
125126
r'fixes issue <a href="https://github.com/python/mypy/issues/\1">\1</a>',
126127
h,
127128
)
128-
h = re.sub(r"#([0-9]+)", r'PR <a href="https://github.com/python/mypy/pull/\1">\1</a>', h)
129+
# Note the leading space to avoid stomping on strings that contain #\d in the middle (such as
130+
# links to PRs in other repos)
131+
h = re.sub(r" #([0-9]+)", r' PR <a href="https://github.com/python/mypy/pull/\1">\1</a>', h)
129132
h = re.sub(r"\) \(PR", ", PR", h)
130133

131134
# Markdown links

misc/generate_changelog.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ def format_changelog_entry(c: CommitInfo) -> str:
145145
s += f" (#{c.pr_number})"
146146
s += f" ({c.author})"
147147
"""
148-
s = f" * {c.title} ({c.author}"
148+
title = c.title.removesuffix(".")
149+
s = f" * {title} ({c.author}"
149150
if c.pr_number:
150151
s += f", PR [{c.pr_number}](https://github.com/python/mypy/pull/{c.pr_number})"
151152
s += ")"

0 commit comments

Comments
 (0)