From e87c1eb45a06df459f4a6d96fac39fa44769f0cb Mon Sep 17 00:00:00 2001 From: Spencer Brown Date: Thu, 24 Aug 2023 14:22:54 +1000 Subject: [PATCH 1/3] Add missing type hints to check_type_completeness --- trio/_tests/check_type_completeness.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/trio/_tests/check_type_completeness.py b/trio/_tests/check_type_completeness.py index 00d519c8a8..c4e5ffb9d8 100755 --- a/trio/_tests/check_type_completeness.py +++ b/trio/_tests/check_type_completeness.py @@ -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", @@ -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, object], + last_dict: Mapping[str, object], + /, + invert: bool = False, +) -> None: global failed current = current_dict[key] last = last_dict[key] @@ -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, object]) -> None: global failed if current_dict[key] != 0: failed = True From aeaf2d6cad2b061d048805775498f4b749dafa16 Mon Sep 17 00:00:00 2001 From: Spencer Brown Date: Sun, 27 Aug 2023 09:04:01 +1000 Subject: [PATCH 2/3] Test_windows is not currently typed --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 24be2d07bf..08ac6fa1f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", From a8411036f73324067828e1995f84b2bfce602c8d Mon Sep 17 00:00:00 2001 From: Spencer Brown Date: Sun, 27 Aug 2023 12:15:15 +1000 Subject: [PATCH 3/3] Be more specific here, these are floats --- trio/_tests/check_type_completeness.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trio/_tests/check_type_completeness.py b/trio/_tests/check_type_completeness.py index c4e5ffb9d8..1352926be3 100755 --- a/trio/_tests/check_type_completeness.py +++ b/trio/_tests/check_type_completeness.py @@ -36,8 +36,8 @@ def run_pyright(platform: str) -> subprocess.CompletedProcess[bytes]: def check_less_than( key: str, - current_dict: Mapping[str, object], - last_dict: Mapping[str, object], + current_dict: Mapping[str, float], + last_dict: Mapping[str, float], /, invert: bool = False, ) -> None: @@ -64,7 +64,7 @@ def check_less_than( ) -def check_zero(key: str, current_dict: Mapping[str, object]) -> None: +def check_zero(key: str, current_dict: Mapping[str, float]) -> None: global failed if current_dict[key] != 0: failed = True