Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run a type check on scripts and most of misc in CI #13458

Merged
merged 1 commit into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Run a type check on scripts and most of misc in CI
  • Loading branch information
AlexWaygood committed Aug 20, 2022
commit 049dfb8a030051d3a4415604ef322acbd2fd64c0
2 changes: 1 addition & 1 deletion misc/actions_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def apply_all(
break


def confirm(resp: bool = False, **kargs) -> bool:
def confirm(resp: bool = False, **kargs: Any) -> bool:
kargs["rest"] = "to this {f2}/*{e2}".format(**kargs) if kargs.get("f2") else ""
prompt = "{act} all files {rec}matching this expression {f1}/*{e1} {rest}".format(**kargs)
prompt.format(**kargs)
Expand Down
5 changes: 3 additions & 2 deletions misc/analyze_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(
self.meta_size = meta_size

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


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


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

Expand Down
2 changes: 1 addition & 1 deletion misc/async_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async def decorated_host_coroutine(func) -> None:
# Main driver.


def main():
def main() -> None:
verbose = "-v" in sys.argv
for host in [
plain_host_generator,
Expand Down
5 changes: 3 additions & 2 deletions misc/convert-cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import argparse

from mypy.metastore import FilesystemMetadataStore, SqliteMetadataStore
from mypy.metastore import FilesystemMetadataStore, MetadataStore, SqliteMetadataStore


def main() -> None:
Expand All @@ -37,7 +37,8 @@ def main() -> None:
input_dir = args.input_dir
output_dir = args.output_dir or input_dir
if args.to_sqlite:
input, output = FilesystemMetadataStore(input_dir), SqliteMetadataStore(output_dir)
input: MetadataStore = FilesystemMetadataStore(input_dir)
output: MetadataStore = SqliteMetadataStore(output_dir)
else:
input, output = SqliteMetadataStore(input_dir), FilesystemMetadataStore(output_dir)

Expand Down
2 changes: 1 addition & 1 deletion misc/incremental_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import time
from argparse import ArgumentParser, Namespace, RawDescriptionHelpFormatter
from typing import Any, Dict, Tuple
from typing_extensions import TypeAlias as _TypeAlias
from typing_extensions import Final, TypeAlias as _TypeAlias

CACHE_PATH: Final = ".incremental_checker_cache.json"
MYPY_REPO_URL: Final = "https://github.com/python/mypy.git"
Expand Down
2 changes: 1 addition & 1 deletion misc/touch_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def teardown() -> None:
stream.write(copy)

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

return setup, teardown

Expand Down
2 changes: 1 addition & 1 deletion misc/variadics.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def expand_template(
print(s)


def main():
def main() -> None:
prelude(LIMIT, BOUND)

# map()
Expand Down
2 changes: 1 addition & 1 deletion scripts/find_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def process_output(output: str, filename: str, start_line: int) -> tuple[str | N
return None, True # finding no reveal_type is an error


def main():
def main() -> None:
filename, start_line_str, start_col_str, end_line_str, end_col_str, *mypy_and_args = sys.argv[
1:
]
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ commands =
description = type check ourselves
commands =
python -m mypy --config-file mypy_self_check.ini -p mypy -p mypyc
python -m mypy --config-file mypy_self_check.ini misc/proper_plugin.py
python -m mypy --config-file mypy_self_check.ini scripts
python -m mypy --config-file mypy_self_check.ini misc --exclude misc/fix_annotate.py --exclude misc/async_matrix.py

[testenv:docs]
description = invoke sphinx-build to build the HTML docs
Expand Down