Skip to content

Commit fca1aeb

Browse files
Merge branch 'master' into warn_unreachable_strict
2 parents 8992b00 + 6feecce commit fca1aeb

File tree

577 files changed

+30661
-9742
lines changed

Some content is hidden

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

577 files changed

+30661
-9742
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
runs-on: ubuntu-latest
2929
strategy:
3030
matrix:
31-
shard-index: [0, 1, 2, 3, 4]
31+
shard-index: [0, 1, 2, 3, 4, 5]
3232
fail-fast: false
3333
timeout-minutes: 60
3434
steps:
@@ -63,10 +63,11 @@ jobs:
6363
mypy_primer \
6464
--repo mypy_to_test \
6565
--new $GITHUB_SHA --old base_commit \
66-
--num-shards 5 --shard-index ${{ matrix.shard-index }} \
66+
--num-shards 6 --shard-index ${{ matrix.shard-index }} \
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'

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
@@ -809,6 +822,14 @@ of the above sections.
809822
Note: the exact list of flags enabled by running :option:`--strict` may change
810823
over time.
811824

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

814835
This flag allows disabling one or multiple error codes globally.
@@ -1231,12 +1252,18 @@ Miscellaneous
12311252
stub packages were found, they are installed and then another run
12321253
is performed.
12331254

1234-
.. option:: --junit-xml JUNIT_XML
1255+
.. option:: --junit-xml JUNIT_XML_OUTPUT_FILE
12351256

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

1261+
.. option:: --junit-format {global,per_file}
1262+
1263+
If --junit-xml is set, specifies format.
1264+
global (default): single test with all errors;
1265+
per_file: one test entry per file with failures.
1266+
12401267
.. option:: --find-occurrences CLASS.MEMBER
12411268

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

docs/source/common_issues.rst

Lines changed: 17 additions & 5 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

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@
278278
intersphinx_mapping = {
279279
"python": ("https://docs.python.org/3", None),
280280
"attrs": ("https://www.attrs.org/en/stable/", None),
281-
"cython": ("https://docs.cython.org/en/latest", None),
281+
"cython": ("https://cython.readthedocs.io/en/stable", None),
282282
"monkeytype": ("https://monkeytype.readthedocs.io/en/latest", None),
283-
"setuptools": ("https://setuptools.readthedocs.io/en/latest", None),
283+
"setuptools": ("https://setuptools.pypa.io/en/latest", None),
284284
}
285285

286286

0 commit comments

Comments
 (0)