Skip to content

Commit 3131b58

Browse files
committed
Merge remote-tracking branch 'upstream/master' into literal-addition
2 parents 4972202 + 21587f0 commit 3131b58

File tree

173 files changed

+3553
-1508
lines changed

Some content is hidden

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

173 files changed

+3553
-1508
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 0 deletions
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

.github/workflows/mypy_primer.yml

Lines changed: 1 addition & 0 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:

.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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ jobs:
126126
toxenv: lint
127127

128128
name: ${{ matrix.name }}
129+
timeout-minutes: 60
129130
env:
130131
TOX_SKIP_MISSING_INTERPRETERS: False
131132
# Rich (pip) -- Disable color for windows + pytest
@@ -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)

.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: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
exclude: '^(mypyc/external/)|(mypy/typeshed/)|misc/typeshed_patches' # Exclude all vendored code from lints
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.5.0 # must match test-requirements.txt
4+
rev: v4.5.0
55
hooks:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
88
- repo: https://github.com/psf/black-pre-commit-mirror
9-
rev: 24.8.0 # must match test-requirements.txt
9+
rev: 24.8.0
1010
hooks:
1111
- id: black
1212
exclude: '^(test-data/)'
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.6.9 # must match test-requirements.txt
14+
rev: v0.6.9
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: 83 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

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

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
# General information about the project.
5353
project = "mypy"
54-
copyright = "2012-2022 Jukka Lehtosalo and mypy contributors"
54+
copyright = "2012-%Y Jukka Lehtosalo and mypy contributors"
5555

5656
# The version info for the project you're documenting, acts as replacement for
5757
# |version| and |release|, also used in various other places throughout the

0 commit comments

Comments
 (0)