From b3401580ab30dd0d99eda870c2613f7b7c38f79b Mon Sep 17 00:00:00 2001 From: David Bonnes Date: Sun, 21 Apr 2024 21:04:46 +0100 Subject: [PATCH] mypy --- pyproject.toml | 1 - tests/tests/helpers.py | 2 +- tests/tests/test_schedules.py | 2 +- tests/tests/test_schemas.py | 13 +++++-------- tests/tests/test_systems.py | 10 +++++----- tests/tests_rf/conftest.py | 2 +- tests/tests_rf/test_v1_apis.py | 2 +- tests/tests_rf/test_v1_xxxx.py | 2 +- 8 files changed, 15 insertions(+), 19 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e73ec99..99ce63d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,7 +104,6 @@ disable_error_code = [ "arg-type", # 7 "index", # 18 - "no-untyped-def", # 16 "type-arg", # 15 ] diff --git a/tests/tests/helpers.py b/tests/tests/helpers.py index ca0316b..4bc4547 100644 --- a/tests/tests/helpers.py +++ b/tests/tests/helpers.py @@ -14,7 +14,7 @@ TEST_DIR = Path(__file__).resolve().parent -def _test_schema(folder: Path, schema: vol.Schema, file_name: str): +def _test_schema(folder: Path, schema: vol.Schema, file_name: str) -> None: if not Path(folder).joinpath(file_name).is_file(): pytest.skip(f"No {file_name} in: {folder.name}") diff --git a/tests/tests/test_schedules.py b/tests/tests/test_schedules.py index 3f27fb0..3f61b66 100644 --- a/tests/tests/test_schedules.py +++ b/tests/tests/test_schedules.py @@ -25,7 +25,7 @@ def _test_schedule_schema(file_name: str, schema: vol.Schema) -> dict: - def read_dict_from_file(file_name: str): + def read_dict_from_file(file_name: str) -> dict: with open(WORK_DIR.joinpath(file_name)) as f: data: dict = json.load(f) return data diff --git a/tests/tests/test_schemas.py b/tests/tests/test_schemas.py index 1097b92..d3931d2 100644 --- a/tests/tests/test_schemas.py +++ b/tests/tests/test_schemas.py @@ -44,8 +44,8 @@ class GatewayStub: location = None -def pytest_generate_tests(metafunc: pytest.Metafunc): - def id_fnc(folder_path: Path): +def pytest_generate_tests(metafunc: pytest.Metafunc) -> None: + def id_fnc(folder_path: Path) -> str: return folder_path.name folders = [ @@ -54,10 +54,7 @@ def id_fnc(folder_path: Path): metafunc.parametrize("folder", sorted(folders), ids=id_fnc) -# Use pytest --log-cli-level=WARNING to see the output - - -def test_config_refresh(folder: Path): +def test_config_refresh(folder: Path) -> None: """Test the loading a config, then an update_status() on top of that.""" if not Path(folder).joinpath(CONFIG_FILE_NAME).is_file(): @@ -86,7 +83,7 @@ def test_config_refresh(folder: Path): loc._update_status(status) -def test_config_schemas(folder: Path): +def test_config_schemas(folder: Path) -> None: """Test the config schema for a location.""" if not Path(folder).joinpath(CONFIG_FILE_NAME).is_file(): @@ -101,7 +98,7 @@ def test_config_schemas(folder: Path): _ = SCH_TEMPERATURE_CONTROL_SYSTEM(tcs_config) -def test_status_schemas(folder: Path): +def test_status_schemas(folder: Path) -> None: """Test the status schema for a location.""" if not Path(folder).joinpath(STATUS_FILE_NAME).is_file(): diff --git a/tests/tests/test_systems.py b/tests/tests/test_systems.py index 922e967..91266b1 100644 --- a/tests/tests/test_systems.py +++ b/tests/tests/test_systems.py @@ -16,8 +16,8 @@ WORK_DIR = f"{TEST_DIR}/systems" -def pytest_generate_tests(metafunc: pytest.Metafunc): - def id_fnc(folder_path: Path): +def pytest_generate_tests(metafunc: pytest.Metafunc) -> None: + def id_fnc(folder_path: Path) -> str: return folder_path.name folders = [ @@ -26,17 +26,17 @@ def id_fnc(folder_path: Path): metafunc.parametrize("folder", sorted(folders), ids=id_fnc) -def test_user_account(folder: Path): +def test_user_account(folder: Path) -> None: """Test the user account schema against the corresponding JSON.""" _test_schema(folder, SCH_USER_ACCOUNT, "user_account.json") -def test_user_locations(folder: Path): +def test_user_locations(folder: Path) -> None: """Test the user locations config schema against the corresponding JSON.""" _test_schema(folder, SCH_FULL_CONFIG, "user_locations.json") -def test_location_status(folder: Path): +def test_location_status(folder: Path) -> None: """Test the location status schema against the corresponding JSON.""" for p in Path(folder).glob("status_*.json"): _test_schema(folder, SCH_LOCN_STATUS, p.name) diff --git a/tests/tests_rf/conftest.py b/tests/tests_rf/conftest.py index e119e48..2f46aff 100644 --- a/tests/tests_rf/conftest.py +++ b/tests/tests_rf/conftest.py @@ -19,7 +19,7 @@ @pytest.fixture(autouse=True) -def patches_for_tests(monkeypatch: pytest.MonkeyPatch): +def patches_for_tests(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr("evohomeasync2.base.aiohttp", aiohttp) monkeypatch.setattr("evohomeasync2.broker.aiohttp", aiohttp) diff --git a/tests/tests_rf/test_v1_apis.py b/tests/tests_rf/test_v1_apis.py index 0f8819f..1792e73 100644 --- a/tests/tests_rf/test_v1_apis.py +++ b/tests/tests_rf/test_v1_apis.py @@ -15,7 +15,7 @@ _LOGGER = logging.getLogger(__name__) -async def _test_client_apis(evo: evohome.EvohomeClient): +async def _test_client_apis(evo: evohome.EvohomeClient) -> None: """Instantiate a client, and logon to the vendor API.""" user_data = await evo._populate_user_data() diff --git a/tests/tests_rf/test_v1_xxxx.py b/tests/tests_rf/test_v1_xxxx.py index 2c417a2..898b73f 100644 --- a/tests/tests_rf/test_v1_xxxx.py +++ b/tests/tests_rf/test_v1_xxxx.py @@ -44,7 +44,7 @@ async def _test_url_locations(evo: evohome.EvohomeClient) -> None: ) -async def _test_client_apis(evo: evohome.EvohomeClient): +async def _test_client_apis(evo: evohome.EvohomeClient) -> None: """Instantiate a client, and logon to the vendor API.""" user_data = await evo._populate_user_data()