Skip to content

Commit 271e457

Browse files
Merge branch 'master' into for-map
2 parents 9a0707c + 16cd4c5 commit 271e457

Some content is hidden

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

76 files changed

+3109
-1020
lines changed

.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 }}

CHANGELOG.md

Lines changed: 322 additions & 0 deletions
Large diffs are not rendered by default.

docs/source/command_line.rst

Lines changed: 9 additions & 3 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

@@ -1255,12 +1255,18 @@ Miscellaneous
12551255
stub packages were found, they are installed and then another run
12561256
is performed.
12571257

1258-
.. option:: --junit-xml JUNIT_XML
1258+
.. option:: --junit-xml JUNIT_XML_OUTPUT_FILE
12591259

12601260
Causes mypy to generate a JUnit XML test result document with
12611261
type checking results. This can make it easier to integrate mypy
12621262
with continuous integration (CI) tools.
12631263

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+
12641270
.. option:: --find-occurrences CLASS.MEMBER
12651271

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

docs/source/config_file.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,15 @@ These options may only be set in the global section (``[mypy]``).
11531153
type checking results. This can make it easier to integrate mypy
11541154
with continuous integration (CI) tools.
11551155

1156+
.. confval:: junit_format
1157+
1158+
:type: string
1159+
:default: ``global``
1160+
1161+
If junit_xml is set, specifies format.
1162+
global (default): single test with all errors;
1163+
per_file: one test entry per file with failures.
1164+
11561165
.. confval:: scripts_are_modules
11571166

11581167
:type: boolean

docs/source/error_code_list.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,8 +1032,8 @@ Warn about top level await expressions [top-level-await]
10321032
This error code is separate from the general ``[syntax]`` errors, because in
10331033
some environments (e.g. IPython) a top level ``await`` is allowed. In such
10341034
environments a user may want to use ``--disable-error-code=top-level-await``,
1035-
that allows to still have errors for other improper uses of ``await``, for
1036-
example:
1035+
which allows one to still have errors for other improper uses of ``await``,
1036+
for example:
10371037

10381038
.. code-block:: python
10391039

docs/source/mypy_daemon.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,16 +252,16 @@ command.
252252
Statically inspect expressions
253253
******************************
254254

255-
The daemon allows to get declared or inferred type of an expression (or other
255+
The daemon allows one to get the declared or inferred type of an expression (or other
256256
information about an expression, such as known attributes or definition location)
257-
using ``dmypy inspect LOCATION`` command. The location of the expression should be
257+
using the ``dmypy inspect LOCATION`` command. The location of the expression should be
258258
specified in the format ``path/to/file.py:line:column[:end_line:end_column]``.
259259
Both line and column are 1-based. Both start and end position are inclusive.
260260
These rules match how mypy prints the error location in error messages.
261261

262262
If a span is given (i.e. all 4 numbers), then only an exactly matching expression
263263
is inspected. If only a position is given (i.e. 2 numbers, line and column), mypy
264-
will inspect all *expressions*, that include this position, starting from the
264+
will inspect all expressions that include this position, starting from the
265265
innermost one.
266266

267267
Consider this Python code snippet:

misc/analyze_cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def extract(chunks: Iterable[JsonDict]) -> Iterable[JsonDict]:
4141
if isinstance(chunk, dict):
4242
yield chunk
4343
yield from extract(chunk.values())
44-
elif isinstance(chunk, list):
44+
elif isinstance(chunk, list): # type: ignore[unreachable] #TODO: is this actually unreachable, or are our types wrong?
4545
yield from extract(chunk)
4646

4747
yield from extract([chunk.data for chunk in chunks])
@@ -93,7 +93,7 @@ def compress(chunk: JsonDict) -> JsonDict:
9393
def helper(chunk: JsonDict) -> JsonDict:
9494
nonlocal counter
9595
if not isinstance(chunk, dict):
96-
return chunk
96+
return chunk # type: ignore[unreachable] #TODO: is this actually unreachable, or are our types wrong?
9797

9898
if len(chunk) <= 2:
9999
return chunk
@@ -124,7 +124,7 @@ def decompress(chunk: JsonDict) -> JsonDict:
124124

125125
def helper(chunk: JsonDict) -> JsonDict:
126126
if not isinstance(chunk, dict):
127-
return chunk
127+
return chunk # type: ignore[unreachable] #TODO: is this actually unreachable, or are our types wrong?
128128
if ".id" in chunk:
129129
return cache[chunk[".id"]]
130130

misc/profile_check.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,22 @@ def check_requirements() -> None:
7878
if sys.platform != "linux":
7979
# TODO: How to make this work on other platforms?
8080
sys.exit("error: Only Linux is supported")
81-
82-
try:
83-
subprocess.run(["perf", "-h"], capture_output=True)
84-
except (subprocess.CalledProcessError, FileNotFoundError):
85-
print("error: The 'perf' profiler is not installed")
86-
sys.exit(1)
87-
88-
try:
89-
subprocess.run(["clang", "--version"], capture_output=True)
90-
except (subprocess.CalledProcessError, FileNotFoundError):
91-
print("error: The clang compiler is not installed")
92-
sys.exit(1)
93-
94-
if not os.path.isfile("mypy_self_check.ini"):
95-
print("error: Run this in the mypy repository root")
96-
sys.exit(1)
81+
else: # fun fact/todo: we have to use else here, because of https://github.com/python/mypy/issues/10773
82+
try:
83+
subprocess.run(["perf", "-h"], capture_output=True)
84+
except (subprocess.CalledProcessError, FileNotFoundError):
85+
print("error: The 'perf' profiler is not installed")
86+
sys.exit(1)
87+
88+
try:
89+
subprocess.run(["clang", "--version"], capture_output=True)
90+
except (subprocess.CalledProcessError, FileNotFoundError):
91+
print("error: The clang compiler is not installed")
92+
sys.exit(1)
93+
94+
if not os.path.isfile("mypy_self_check.ini"):
95+
print("error: Run this in the mypy repository root")
96+
sys.exit(1)
9797

9898

9999
def main() -> None:

0 commit comments

Comments
 (0)