Skip to content

Commit 735a6ba

Browse files
authored
Merge branch 'master' into fix-enum-truthyness
2 parents 91059f8 + 3b00002 commit 735a6ba

File tree

261 files changed

+9593
-5541
lines changed

Some content is hidden

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

261 files changed

+9593
-5541
lines changed

.github/workflows/docs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ concurrency:
2828
jobs:
2929
docs:
3030
runs-on: ubuntu-latest
31+
timeout-minutes: 10
3132
env:
3233
TOXENV: docs
3334
TOX_SKIP_MISSING_INTERPRETERS: False
@@ -38,7 +39,7 @@ jobs:
3839
with:
3940
python-version: '3.12'
4041
- name: Install tox
41-
run: pip install tox==4.11.0
42+
run: pip install tox==4.21.2
4243
- name: Setup tox environment
4344
run: tox run -e ${{ env.TOXENV }} --notest
4445
- name: Test

.github/workflows/mypy_primer.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
matrix:
3333
shard-index: [0, 1, 2, 3, 4]
3434
fail-fast: false
35+
timeout-minutes: 60
3536
steps:
3637
- uses: actions/checkout@v4
3738
with:
@@ -69,18 +70,35 @@ jobs:
6970
--output concise \
7071
| tee diff_${{ matrix.shard-index }}.txt
7172
) || [ $? -eq 1 ]
72-
- name: Upload mypy_primer diff
73-
uses: actions/upload-artifact@v3
74-
with:
75-
name: mypy_primer_diffs
76-
path: diff_${{ matrix.shard-index }}.txt
77-
- if: ${{ matrix.shard-index }} == 0
73+
- if: ${{ matrix.shard-index == 0 }}
7874
name: Save PR number
7975
run: |
8076
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
81-
- if: ${{ matrix.shard-index }} == 0
82-
name: Upload PR number
83-
uses: actions/upload-artifact@v3
77+
- if: ${{ matrix.shard-index == 0 }}
78+
name: Upload mypy_primer diff + PR number
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: mypy_primer_diffs-${{ matrix.shard-index }}
82+
path: |
83+
diff_${{ matrix.shard-index }}.txt
84+
pr_number.txt
85+
- name: Upload mypy_primer diff
86+
uses: actions/upload-artifact@v4
87+
if: ${{ matrix.shard-index != 0 }}
88+
with:
89+
name: mypy_primer_diffs-${{ matrix.shard-index }}
90+
path: diff_${{ matrix.shard-index }}.txt
91+
92+
join_artifacts:
93+
name: Join artifacts
94+
runs-on: ubuntu-latest
95+
needs: [mypy_primer]
96+
permissions:
97+
contents: read
98+
steps:
99+
- name: Merge artifacts
100+
uses: actions/upload-artifact/merge@v4
84101
with:
85102
name: mypy_primer_diffs
86-
path: pr_number.txt
103+
pattern: mypy_primer_diffs-*
104+
delete-merged: true

.github/workflows/mypy_primer_comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1919
steps:
2020
- name: Download diffs
21-
uses: actions/github-script@v6
21+
uses: actions/github-script@v7
2222
with:
2323
script: |
2424
const fs = require('fs');

.github/workflows/sync_typeshed.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
name: Sync typeshed
1515
if: github.repository == 'python/mypy'
1616
runs-on: ubuntu-latest
17+
timeout-minutes: 10
1718
steps:
1819
- uses: actions/checkout@v4
1920
with:

.github/workflows/test.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ jobs:
126126
toxenv: lint
127127

128128
name: ${{ matrix.name }}
129+
timeout-minutes: 60
129130
env:
130131
TOX_SKIP_MISSING_INTERPRETERS: False
131-
# Rich (pip)
132-
FORCE_COLOR: 1
132+
# Rich (pip) -- Disable color for windows + pytest
133+
FORCE_COLOR: ${{ !(startsWith(matrix.os, 'windows-') && startsWith(matrix.toxenv, 'py')) && 1 || 0 }}
133134
# Tox
134135
PY_COLORS: 1
135136
# Mypy (see https://github.com/python/mypy/issues/7771)
@@ -183,7 +184,7 @@ jobs:
183184
echo debug build; python -c 'import sysconfig; print(bool(sysconfig.get_config_var("Py_DEBUG")))'
184185
echo os.cpu_count; python -c 'import os; print(os.cpu_count())'
185186
echo os.sched_getaffinity; python -c 'import os; print(len(getattr(os, "sched_getaffinity", lambda *args: [])(0)))'
186-
pip install setuptools==68.2.2 tox==4.11.0
187+
pip install setuptools==75.1.0 tox==4.21.2
187188
188189
- name: Compiled with mypyc
189190
if: ${{ matrix.test_mypyc }}
@@ -205,6 +206,7 @@ jobs:
205206
python_32bits:
206207
runs-on: ubuntu-latest
207208
name: Test mypyc suite with 32-bit Python
209+
timeout-minutes: 60
208210
env:
209211
TOX_SKIP_MISSING_INTERPRETERS: False
210212
# Rich (pip)
@@ -243,7 +245,7 @@ jobs:
243245
default: 3.11.1
244246
command: python -c "import platform; print(f'{platform.architecture()=} {platform.machine()=}');"
245247
- name: Install tox
246-
run: pip install setuptools==68.2.2 tox==4.11.0
248+
run: pip install setuptools==75.1.0 tox==4.21.2
247249
- name: Setup tox environment
248250
run: tox run -e py --notest
249251
- name: Test

.github/workflows/test_stubgenc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
# Check stub file generation for a small pybind11 project
2626
# (full text match is required to pass)
2727
runs-on: ubuntu-latest
28+
timeout-minutes: 10
2829
steps:
2930

3031
- uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,28 @@ repos:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
88
- repo: https://github.com/psf/black-pre-commit-mirror
9-
rev: 24.1.1 # must match test-requirements.txt
9+
rev: 24.8.0 # must match test-requirements.txt
1010
hooks:
1111
- id: black
1212
exclude: '^(test-data/)'
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.2.0 # must match test-requirements.txt
14+
rev: v0.6.9 # must match test-requirements.txt
1515
hooks:
1616
- id: ruff
1717
args: [--exit-non-zero-on-fix]
18+
- repo: https://github.com/python-jsonschema/check-jsonschema
19+
rev: 0.29.4
20+
hooks:
21+
- id: check-dependabot
22+
- id: check-github-workflows
23+
- repo: https://github.com/rhysd/actionlint
24+
rev: v1.7.3
25+
hooks:
26+
- id: actionlint
27+
args: [
28+
-ignore=property "debug_build" is not defined,
29+
-ignore=property "allow_failure" is not defined,
30+
-ignore=SC2(046|086),
31+
]
1832
ci:
1933
autoupdate_schedule: quarterly

CHANGELOG.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,89 @@
22

33
## Next release
44

5+
### Change to enum membership semantics
6+
7+
As per the updated [typing specification for enums](https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members),
8+
enum members must be left unannotated.
9+
10+
```python
11+
class Pet(Enum):
12+
CAT = 1 # Member attribute
13+
DOG = 2 # Member attribute
14+
WOLF: int = 3 # New error: Enum members must be left unannotated
15+
16+
species: str # Considered a non-member attribute
17+
```
18+
19+
In particular, the specification change can result in issues in type stubs (`.pyi` files), since
20+
historically it was common to leave the value absent:
21+
22+
```python
23+
# In a type stub (.pyi file)
24+
25+
class Pet(Enum):
26+
# Change in semantics: previously considered members, now non-member attributes
27+
CAT: int
28+
DOG: int
29+
30+
# Mypy will now issue a warning if it detects this situation in type stubs:
31+
# > Detected enum "Pet" in a type stub with zero members.
32+
# > There is a chance this is due to a recent change in the semantics of enum membership.
33+
# > If so, use `member = value` to mark an enum member, instead of `member: type`
34+
35+
class Pet(Enum):
36+
# As per the specification, you should now do one of the following:
37+
DOG = 1 # Member attribute with value 1 and known type
38+
WOLF = cast(int, ...) # Member attribute with unknown value but known type
39+
LION = ... # Member attribute with unknown value and unknown type
40+
```
41+
42+
Contributed by Terence Honles in PR [17207](https://github.com/python/mypy/pull/17207) and
43+
Shantanu Jain in PR [18068](https://github.com/python/mypy/pull/18068).
44+
45+
## Mypy 1.13
46+
47+
We’ve just uploaded mypy 1.13 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).
48+
Mypy is a static type checker for Python. You can install it as follows:
49+
50+
python3 -m pip install -U mypy
51+
52+
You can read the full documentation for this release on [Read the Docs](http://mypy.readthedocs.io).
53+
54+
Note that unlike typical releases, Mypy 1.13 does not have any changes to type checking semantics
55+
from 1.12.1.
56+
57+
### Improved performance
58+
59+
Mypy 1.13 contains several performance improvements. Users can expect mypy to be 5-20% faster.
60+
In environments with long search paths (such as environments using many editable installs), mypy
61+
can be significantly faster, e.g. 2.2x faster in the use case targeted by these improvements.
62+
63+
Mypy 1.13 allows use of the `orjson` library for handling the cache instead of the stdlib `json`,
64+
for improved performance. You can ensure the presence of `orjson` using the `faster-cache` extra:
65+
66+
python3 -m pip install -U mypy[faster-cache]
67+
68+
Mypy may depend on `orjson` by default in the future.
69+
70+
These improvements were contributed by Shantanu.
71+
72+
List of changes:
73+
* Significantly speed up file handling error paths (Shantanu, PR [17920](https://github.com/python/mypy/pull/17920))
74+
* Use fast path in modulefinder more often (Shantanu, PR [17950](https://github.com/python/mypy/pull/17950))
75+
* Let mypyc optimise os.path.join (Shantanu, PR [17949](https://github.com/python/mypy/pull/17949))
76+
* Make is_sub_path faster (Shantanu, PR [17962](https://github.com/python/mypy/pull/17962))
77+
* Speed up stubs suggestions (Shantanu, PR [17965](https://github.com/python/mypy/pull/17965))
78+
* Use sha1 for hashing (Shantanu, PR [17953](https://github.com/python/mypy/pull/17953))
79+
* Use orjson instead of json, when available (Shantanu, PR [17955](https://github.com/python/mypy/pull/17955))
80+
* Add faster-cache extra, test in CI (Shantanu, PR [17978](https://github.com/python/mypy/pull/17978))
81+
82+
### Acknowledgements
83+
Thanks to all mypy contributors who contributed to this release:
84+
85+
- Shantanu Jain
86+
- Jukka Lehtosalo
87+
588
## Mypy 1.12
689

790
We’ve just uploaded mypy 1.12 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)). Mypy is a static type
@@ -255,11 +338,18 @@ This feature was contributed by Ivan Levkivskyi (PR [17457](https://github.com/p
255338
* Improvements to `functools.partial` of types (Shantanu, PR [17898](https://github.com/python/mypy/pull/17898))
256339
* Make ReadOnly TypedDict items covariant (Jukka Lehtosalo, PR [17904](https://github.com/python/mypy/pull/17904))
257340
* Fix union callees with `functools.partial` (Jukka Lehtosalo, PR [17903](https://github.com/python/mypy/pull/17903))
341+
* Improve handling of generic functions with `functools.partial` (Ivan Levkivskyi, PR [17925](https://github.com/python/mypy/pull/17925))
258342

259343
### Typeshed Updates
260344

261345
Please see [git log](https://github.com/python/typeshed/commits/main?after=91a58b07cdd807b1d965e04ba85af2adab8bf924+0&branch=main&path=stdlib) for full list of standard library typeshed stub changes.
262346

347+
### Mypy 1.12.1
348+
* Fix crash when showing partially analyzed type in error message (Ivan Levkivskyi, PR [17961](https://github.com/python/mypy/pull/17961))
349+
* Fix iteration over union (when self type is involved) (Shantanu, PR [17976](https://github.com/python/mypy/pull/17976))
350+
* Fix type object with type var default in union context (Jukka Lehtosalo, PR [17991](https://github.com/python/mypy/pull/17991))
351+
* Revert change to `os.path` stubs affecting use of `os.PathLike[Any]` (Shantanu, PR [17995](https://github.com/python/mypy/pull/17995))
352+
263353
### Acknowledgements
264354
Thanks to all mypy contributors who contributed to this release:
265355

@@ -502,6 +592,15 @@ Mypyc now supports the new syntax for generics introduced in Python 3.12 (see ab
502592

503593
Please see [git log](https://github.com/python/typeshed/commits/main?after=6dda799d8ad1d89e0f8aad7ac41d2d34bd838ace+0&branch=main&path=stdlib) for full list of standard library typeshed stub changes.
504594

595+
### Mypy 1.11.1
596+
* Fix `RawExpressionType.accept` crash with `--cache-fine-grained` (Anders Kaseorg, PR [17588](https://github.com/python/mypy/pull/17588))
597+
* Fix PEP 604 isinstance caching (Shantanu, PR [17563](https://github.com/python/mypy/pull/17563))
598+
* Fix `typing.TypeAliasType` being undefined on python < 3.12 (Nikita Sobolev, PR [17558](https://github.com/python/mypy/pull/17558))
599+
* Fix `types.GenericAlias` lookup crash (Shantanu, PR [17543](https://github.com/python/mypy/pull/17543))
600+
601+
### Mypy 1.11.2
602+
* Alternative fix for a union-like literal string (Ivan Levkivskyi, PR [17639](https://github.com/python/mypy/pull/17639))
603+
* Unwrap `TypedDict` item types before storing (Ivan Levkivskyi, PR [17640](https://github.com/python/mypy/pull/17640))
505604

506605
### Acknowledgements
507606
Thanks to all mypy contributors who contributed to this release:

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ However, if you wish to do so, you can run the full test suite
6565
like this:
6666

6767
```bash
68-
python3 runtests.py
68+
python runtests.py
6969
```
7070

7171
Some useful commands for running specific tests include:
7272

7373
```bash
7474
# Use mypy to check mypy's own code
75-
python3 runtests.py self
75+
python runtests.py self
7676
# or equivalently:
77-
python3 -m mypy --config-file mypy_self_check.ini -p mypy
77+
python -m mypy --config-file mypy_self_check.ini -p mypy
7878

7979
# Run a single test from the test suite
8080
pytest -n0 -k 'test_name'
@@ -117,7 +117,7 @@ tox -e dev --override testenv:dev.allowlist_externals+=env -- env # inspect the
117117
```
118118

119119
If you don't already have `tox` installed, you can use a virtual environment as
120-
described above to install `tox` via `pip` (e.g., ``python3 -m pip install tox``).
120+
described above to install `tox` via `pip` (e.g., ``python -m pip install tox``).
121121

122122
## First time contributors
123123

docs/requirements-docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
sphinx>=5.1.0
1+
sphinx>=8.1.0
22
furo>=2022.3.4
33
myst-parser>=4.0.0

0 commit comments

Comments
 (0)