From e20fae1bcafe35dd6c777b02b8d9bd30c9523b35 Mon Sep 17 00:00:00 2001 From: Artem Sorokin Date: Fri, 18 Aug 2023 08:41:19 +0300 Subject: [PATCH] CI: Add type checking --- .github/workflows/ci.yml | 8 ++++ pyproject.toml | 83 +++++++++++++++++++++++++++++++++++ tests/requirements_2023.7.txt | 1 + 3 files changed, 92 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88049a3e..b48bc896 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,14 @@ jobs: run: | pip install -r tests/requirements_${{ matrix.ha-version }}.txt + # https://github.com/python/mypy/issues/8545 + - name: Fix homeassistant type checking + run: | + python -c 'from pathlib import Path; import homeassistant; (Path(homeassistant.__file__).parent / Path("py.typed")).touch()' + + - name: Type checking + run: mypy . + - name: Test with pytest run: pytest --cov-report xml --cov diff --git a/pyproject.toml b/pyproject.toml index a7518c37..eb1f7c00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,3 +29,86 @@ exclude_also = [ omit = [ "tests/*" ] + +[tool.mypy] +python_version = 3.11 +plugins = ["pydantic.mypy"] +follow_imports_for_stubs = true +local_partial_types = true +strict_equality = true +warn_redundant_casts = true +warn_unused_ignores = true +check_untyped_defs = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +warn_return_any = true +warn_unreachable = true + +[tool.pydantic-mypy] +init_forbid_extra = true +init_typed = true +warn_required_dynamic_aliases = true +warn_untyped_fields = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.config_flow" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.cloud" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.cloud_stream" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.notifier" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.smart_home" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.entity" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.http" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.helpers" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.prop" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.prop_custom" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.prop_event" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.prop_float" +ignore_errors = true + +[[tool.mypy.overrides]] +module= "custom_components.yandex_smart_home.config_validation" +ignore_errors = true + +[[tool.mypy.overrides]] +module = "tests.*" +ignore_errors = true diff --git a/tests/requirements_2023.7.txt b/tests/requirements_2023.7.txt index 0da5037f..6a505b62 100644 --- a/tests/requirements_2023.7.txt +++ b/tests/requirements_2023.7.txt @@ -2,3 +2,4 @@ pytest-homeassistant-custom-component==0.13.42 aiohttp-cors==0.7.0 home_assistant_intents==2023.7.24 hassil==1.2.0 +mypy==1.4.1