Skip to content

Commit

Permalink
Fix typecheck failures in master (#2777)
Browse files Browse the repository at this point in the history
* Add missing type hints to check_type_completeness

* Test_windows is not currently typed
  • Loading branch information
TeamSpen210 authored Aug 28, 2023
1 parent 4c53941 commit 7f78303
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ module = [
"trio/_core/_tests/test_thread_cache",
"trio/_core/_tests/test_tutil",
"trio/_core/_tests/test_unbounded_queue",
"trio/_core/_tests/test_windows",
"trio/_core/_tests/tutil",
"trio/_tests/pytest_plugin",
"trio/_tests/test_abc",
Expand Down
15 changes: 11 additions & 4 deletions trio/_tests/check_type_completeness.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
import json
import subprocess
import sys
from collections.abc import Mapping
from pathlib import Path

# the result file is not marked in MANIFEST.in so it's not included in the package
failed = False


def get_result_file_name(platform: str):
def get_result_file_name(platform: str) -> Path:
return Path(__file__).parent / f"verify_types_{platform.lower()}.json"


# TODO: consider checking manually without `--ignoreexternal`, and/or
# removing it from the below call later on.
def run_pyright(platform: str):
def run_pyright(platform: str) -> subprocess.CompletedProcess[bytes]:
return subprocess.run(
[
"pyright",
Expand All @@ -33,7 +34,13 @@ def run_pyright(platform: str):
)


def check_less_than(key, current_dict, last_dict, /, invert=False):
def check_less_than(
key: str,
current_dict: Mapping[str, float],
last_dict: Mapping[str, float],
/,
invert: bool = False,
) -> None:
global failed
current = current_dict[key]
last = last_dict[key]
Expand All @@ -57,7 +64,7 @@ def check_less_than(key, current_dict, last_dict, /, invert=False):
)


def check_zero(key, current_dict):
def check_zero(key: str, current_dict: Mapping[str, float]) -> None:
global failed
if current_dict[key] != 0:
failed = True
Expand Down

0 comments on commit 7f78303

Please sign in to comment.