Skip to content

Commit 5f488e2

Browse files
authored
Run a type check on scripts and most of misc in CI (#13458)
1 parent 551f8f4 commit 5f488e2

9 files changed

+14
-11
lines changed

misc/actions_stubs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def apply_all(
4141
break
4242

4343

44-
def confirm(resp: bool = False, **kargs) -> bool:
44+
def confirm(resp: bool = False, **kargs: Any) -> bool:
4545
kargs["rest"] = "to this {f2}/*{e2}".format(**kargs) if kargs.get("f2") else ""
4646
prompt = "{act} all files {rec}matching this expression {f1}/*{e1} {rest}".format(**kargs)
4747
prompt.format(**kargs)

misc/analyze_cache.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(
3030
self.meta_size = meta_size
3131

3232
@property
33-
def total_size(self):
33+
def total_size(self) -> int:
3434
return self.data_size + self.meta_size
3535

3636

@@ -75,7 +75,7 @@ def pluck(name: str, chunks: Iterable[JsonDict]) -> Iterable[JsonDict]:
7575
return (chunk for chunk in chunks if chunk[".class"] == name)
7676

7777

78-
def report_counter(counter: Counter, amount: int | None = None) -> None:
78+
def report_counter(counter: Counter[str], amount: int | None = None) -> None:
7979
for name, count in counter.most_common(amount):
8080
print(f" {count: <8} {name}")
8181
print()
@@ -167,6 +167,7 @@ def main() -> None:
167167
if "build.*.json" in chunk.filename:
168168
build = chunk
169169
break
170+
assert build is not None
170171
original = json.dumps(build.data, sort_keys=True)
171172
print(f"Size of build.data.json, in kilobytes: {len(original) / 1024:.3f}")
172173

misc/async_matrix.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def decorated_host_coroutine(func) -> None:
106106
# Main driver.
107107

108108

109-
def main():
109+
def main() -> None:
110110
verbose = "-v" in sys.argv
111111
for host in [
112112
plain_host_generator,

misc/convert-cache.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import argparse
1616

17-
from mypy.metastore import FilesystemMetadataStore, SqliteMetadataStore
17+
from mypy.metastore import FilesystemMetadataStore, MetadataStore, SqliteMetadataStore
1818

1919

2020
def main() -> None:
@@ -37,7 +37,8 @@ def main() -> None:
3737
input_dir = args.input_dir
3838
output_dir = args.output_dir or input_dir
3939
if args.to_sqlite:
40-
input, output = FilesystemMetadataStore(input_dir), SqliteMetadataStore(output_dir)
40+
input: MetadataStore = FilesystemMetadataStore(input_dir)
41+
output: MetadataStore = SqliteMetadataStore(output_dir)
4142
else:
4243
input, output = SqliteMetadataStore(input_dir), FilesystemMetadataStore(output_dir)
4344

misc/incremental_checker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import time
4646
from argparse import ArgumentParser, Namespace, RawDescriptionHelpFormatter
4747
from typing import Any, Dict, Tuple
48-
from typing_extensions import TypeAlias as _TypeAlias
48+
from typing_extensions import Final, TypeAlias as _TypeAlias
4949

5050
CACHE_PATH: Final = ".incremental_checker_cache.json"
5151
MYPY_REPO_URL: Final = "https://github.com/python/mypy.git"

misc/touch_checker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def teardown() -> None:
7979
stream.write(copy)
8080

8181
# Re-run to reset cache
82-
execute(["python3", "-m", "mypy", "-i", "mypy"]),
82+
execute(["python3", "-m", "mypy", "-i", "mypy"])
8383

8484
return setup, teardown
8585

misc/variadics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def expand_template(
3737
print(s)
3838

3939

40-
def main():
40+
def main() -> None:
4141
prelude(LIMIT, BOUND)
4242

4343
# map()

scripts/find_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def process_output(output: str, filename: str, start_line: int) -> tuple[str | N
6868
return None, True # finding no reveal_type is an error
6969

7070

71-
def main():
71+
def main() -> None:
7272
filename, start_line_str, start_col_str, end_line_str, end_col_str, *mypy_and_args = sys.argv[
7373
1:
7474
]

tox.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ commands =
5656
description = type check ourselves
5757
commands =
5858
python -m mypy --config-file mypy_self_check.ini -p mypy -p mypyc
59-
python -m mypy --config-file mypy_self_check.ini misc/proper_plugin.py
59+
python -m mypy --config-file mypy_self_check.ini scripts
60+
python -m mypy --config-file mypy_self_check.ini misc --exclude misc/fix_annotate.py --exclude misc/async_matrix.py
6061

6162
[testenv:docs]
6263
description = invoke sphinx-build to build the HTML docs

0 commit comments

Comments
 (0)