Skip to content

Commit becbde1

Browse files
Merge branch 'master' into pos_only-in-stubgen
2 parents 45d661a + b38413d commit becbde1

File tree

559 files changed

+28228
-9000
lines changed

Some content is hidden

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

559 files changed

+28228
-9000
lines changed

.github/ISSUE_TEMPLATE/crash.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ labels: "crash"
1515

1616
**Traceback**
1717

18-
```
18+
```python-traceback
1919
(Insert traceback and other messages from mypy here -- use `--show-traceback`.)
2020
```
2121

@@ -25,6 +25,11 @@ labels: "crash"
2525
appreciated. We also very much appreciate it if you try to narrow the
2626
source down to a small stand-alone example.)
2727

28+
```python
29+
# Ideally, a small sample program that demonstrates the problem.
30+
# Or even better, a reproducible playground link https://mypy-play.net/ (use the "Gist" button)
31+
```
32+
2833
**Your Environment**
2934

3035
<!-- Include as many relevant details about the environment you experienced the bug in -->

.github/workflows/docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
# so it's important to do the docs build on all PRs touching mypy/errorcodes.py
1313
# in case somebody's adding a new error code without any docs
1414
- 'mypy/errorcodes.py'
15+
# Part of the documentation is automatically generated from the options
16+
# definitions in mypy/main.py
17+
- 'mypy/main.py'
1518
- 'mypyc/doc/**'
1619
- '**/*.rst'
1720
- '**/*.md'

.github/workflows/mypy_primer.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
--debug \
6868
--additional-flags="--debug-serialize" \
6969
--output concise \
70+
--mypy-install-librt \
7071
| tee diff_${{ matrix.shard-index }}.txt
7172
) || [ $? -eq 1 ]
7273
- if: ${{ matrix.shard-index == 0 }}

.github/workflows/test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ jobs:
3737
toxenv: py
3838
tox_extra_args: "-n 4"
3939
test_mypyc: true
40-
- name: Test suite with py39-windows-64
41-
python: '3.9'
42-
os: windows-latest
43-
toxenv: py39
44-
tox_extra_args: "-n 4"
4540
- name: Test suite with py310-ubuntu
4641
python: '3.10'
4742
os: ubuntu-24.04-arm
@@ -64,6 +59,11 @@ jobs:
6459
toxenv: py
6560
tox_extra_args: "-n 4"
6661
test_mypyc: true
62+
- name: Test suite with py313-windows-64
63+
python: '3.13'
64+
os: windows-latest
65+
toxenv: py
66+
tox_extra_args: "-n 4"
6767

6868
- name: Test suite with py314-dev-ubuntu
6969
python: '3.14-dev'

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ repos:
4141
# actionlint has a shellcheck integration which extracts shell scripts in `run:` steps from GitHub Actions
4242
# and checks these with shellcheck. This is arguably its most useful feature,
4343
# but the integration only works if shellcheck is installed
44-
- "github.com/wasilibs/go-shellcheck/cmd/shellcheck@v0.10.0"
44+
- "github.com/wasilibs/go-shellcheck/cmd/shellcheck@v0.11.1"
4545
- repo: https://github.com/woodruffw/zizmor-pre-commit
4646
rev: v1.5.2
4747
hooks:

CHANGELOG.md

Lines changed: 504 additions & 8 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ Mypy can be integrated into popular IDEs:
142142
- Emacs: using [Flycheck](https://github.com/flycheck/)
143143
- Sublime Text: [SublimeLinter-contrib-mypy](https://github.com/fredcallaway/SublimeLinter-contrib-mypy)
144144
- PyCharm: [mypy plugin](https://github.com/dropbox/mypy-PyCharm-plugin)
145+
- IDLE: [idlemypyextension](https://github.com/CoolCat467/idlemypyextension)
145146
- pre-commit: use [pre-commit mirrors-mypy](https://github.com/pre-commit/mirrors-mypy), although
146147
note by default this will limit mypy's ability to analyse your third party dependencies.
147148

docs/requirements-docs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
-r ../mypy-requirements.txt
12
sphinx>=8.1.0
23
furo>=2022.3.4
34
myst-parser>=4.0.0

docs/source/command_line.rst

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ definitions or calls.
372372

373373
.. option:: --untyped-calls-exclude
374374

375-
This flag allows to selectively disable :option:`--disallow-untyped-calls`
375+
This flag allows one to selectively disable :option:`--disallow-untyped-calls`
376376
for functions and methods defined in specific packages, modules, or classes.
377377
Note that each exclude entry acts as a prefix. For example (assuming there
378378
are no type annotations for ``third_party_lib`` available):
@@ -562,7 +562,7 @@ potentially problematic or redundant in some way.
562562

563563
.. option:: --deprecated-calls-exclude
564564

565-
This flag allows to selectively disable :ref:`deprecated<code-deprecated>` warnings
565+
This flag allows one to selectively disable :ref:`deprecated<code-deprecated>` warnings
566566
for functions and methods defined in specific packages, modules, or classes.
567567
Note that each exclude entry acts as a prefix. For example (assuming ``foo.A.func`` is deprecated):
568568

@@ -728,9 +728,22 @@ of the above sections.
728728
if text != b'other bytes': # Error: non-overlapping equality check!
729729
...
730730
731-
assert text is not None # OK, check against None is allowed as a special case.
731+
assert text is not None # OK, check against None is allowed
732732
733733
734+
.. option:: --strict-equality-for-none
735+
736+
This flag extends :option:`--strict-equality <mypy --strict-equality>` for checks
737+
against ``None``:
738+
739+
.. code-block:: python
740+
741+
text: str
742+
assert text is not None # Error: non-overlapping identity check!
743+
744+
Note that :option:`--strict-equality-for-none <mypy --strict-equality-for-none>`
745+
only works in combination with :option:`--strict-equality <mypy --strict-equality>`.
746+
734747
.. option:: --strict-bytes
735748

736749
By default, mypy treats ``bytearray`` and ``memoryview`` as subtypes of ``bytes`` which
@@ -812,6 +825,14 @@ of the above sections.
812825
Note: the exact list of flags enabled by running :option:`--strict` may change
813826
over time.
814827

828+
.. include:: strict_list.rst
829+
..
830+
The above file is autogenerated and included during html generation.
831+
(That's an include directive, and this is a comment.)
832+
It would be fine to generate it at some other time instead,
833+
theoretically, but we already had a convenient hook during html gen.
834+
835+
815836
.. option:: --disable-error-code
816837

817838
This flag allows disabling one or multiple error codes globally.
@@ -1234,12 +1255,18 @@ Miscellaneous
12341255
stub packages were found, they are installed and then another run
12351256
is performed.
12361257

1237-
.. option:: --junit-xml JUNIT_XML
1258+
.. option:: --junit-xml JUNIT_XML_OUTPUT_FILE
12381259

12391260
Causes mypy to generate a JUnit XML test result document with
12401261
type checking results. This can make it easier to integrate mypy
12411262
with continuous integration (CI) tools.
12421263

1264+
.. option:: --junit-format {global,per_file}
1265+
1266+
If --junit-xml is set, specifies format.
1267+
global (default): single test with all errors;
1268+
per_file: one test entry per file with failures.
1269+
12431270
.. option:: --find-occurrences CLASS.MEMBER
12441271

12451272
This flag will make mypy print out all usages of a class member

docs/source/common_issues.rst

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ daemon <mypy_daemon>`, which can speed up incremental mypy runtimes by
218218
a factor of 10 or more. :ref:`Remote caching <remote-cache>` can
219219
make cold mypy runs several times faster.
220220

221+
Furthermore: as of `mypy 1.13 <https://mypy-lang.blogspot.com/2024/10/mypy-113-released.html>`_,
222+
mypy allows use of the orjson library for handling the cache instead of the stdlib json, for
223+
improved performance. You can ensure the presence of orjson using the faster-cache extra:
224+
225+
python3 -m pip install -U mypy[faster-cache]
226+
227+
Mypy may depend on orjson by default in the future.
228+
221229
Types of empty collections
222230
--------------------------
223231

@@ -505,11 +513,15 @@ to see the types of all local variables at once. Example:
505513
# b: builtins.str
506514
.. note::
507515

508-
``reveal_type`` and ``reveal_locals`` are only understood by mypy and
509-
don't exist in Python. If you try to run your program, you'll have to
510-
remove any ``reveal_type`` and ``reveal_locals`` calls before you can
511-
run your code. Both are always available and you don't need to import
512-
them.
516+
``reveal_type`` and ``reveal_locals`` are handled specially by mypy during
517+
type checking, and don't have to be defined or imported.
518+
519+
However, if you want to run your code,
520+
you'll have to remove any ``reveal_type`` and ``reveal_locals``
521+
calls from your program or else Python will give you an error at runtime.
522+
523+
Alternatively, you can import ``reveal_type`` from ``typing_extensions``
524+
or ``typing`` (on Python 3.11 and newer)
513525

514526
.. _silencing-linters:
515527

@@ -719,7 +731,7 @@ This example demonstrates both safe and unsafe overrides:
719731
720732
class NarrowerReturn(A):
721733
# A more specific return type is fine
722-
def test(self, t: Sequence[int]) -> List[str]: # OK
734+
def test(self, t: Sequence[int]) -> list[str]: # OK
723735
...
724736
725737
class GeneralizedReturn(A):
@@ -734,7 +746,7 @@ not necessary:
734746
.. code-block:: python
735747
736748
class NarrowerArgument(A):
737-
def test(self, t: List[int]) -> Sequence[str]: # type: ignore[override]
749+
def test(self, t: list[int]) -> Sequence[str]: # type: ignore[override]
738750
...
739751
740752
.. _unreachable:

0 commit comments

Comments
 (0)