From b230562c76ce8c3b5c724ba89ee3f7cfb55ce1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 25 Jul 2019 09:08:20 +0300 Subject: [PATCH] Mypy config cleanups (#25475) * Move file specific config to inline comments * Disallow untyped defs by default everywhere --- homeassistant/config_entries.py | 3 +++ homeassistant/util/yaml/dumper.py | 2 ++ homeassistant/util/yaml/loader.py | 2 ++ mypy.ini | 16 +--------------- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index f6a541063c5..48d67b61b90 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -14,6 +14,9 @@ from homeassistant.exceptions import HomeAssistantError, ConfigEntryNotReady from homeassistant.setup import async_setup_component, async_process_deps_reqs from homeassistant.util.decorator import Registry + +# mypy: allow-untyped-defs + _LOGGER = logging.getLogger(__name__) _UNDEF = object() diff --git a/homeassistant/util/yaml/dumper.py b/homeassistant/util/yaml/dumper.py index d8f766c6c2b..4f025a9a596 100644 --- a/homeassistant/util/yaml/dumper.py +++ b/homeassistant/util/yaml/dumper.py @@ -5,6 +5,8 @@ import yaml from .objects import NodeListClass +# mypy: allow-untyped-calls, no-warn-return-any + def dump(_dict: dict) -> str: """Dump YAML to a string and remove null.""" return yaml.safe_dump( diff --git a/homeassistant/util/yaml/loader.py b/homeassistant/util/yaml/loader.py index 7d228490c4c..d5d25c13652 100644 --- a/homeassistant/util/yaml/loader.py +++ b/homeassistant/util/yaml/loader.py @@ -24,6 +24,8 @@ from .const import _SECRET_NAMESPACE, SECRET_YAML from .objects import NodeListClass, NodeStrClass +# mypy: allow-untyped-calls, no-warn-return-any + _LOGGER = logging.getLogger(__name__) __SECRET_CACHE = {} # type: Dict[str, JSON_TYPE] diff --git a/mypy.ini b/mypy.ini index 0732110fd92..c354f39b9f2 100644 --- a/mypy.ini +++ b/mypy.ini @@ -3,6 +3,7 @@ python_version = 3.5 check_untyped_defs = true disallow_incomplete_defs = true disallow_untyped_calls = true +disallow_untyped_defs = true follow_imports = silent ignore_missing_imports = true no_implicit_optional = true @@ -13,18 +14,3 @@ warn_return_any = true warn_unreachable = true warn_unused_configs = true warn_unused_ignores = true - -[mypy-homeassistant.*] -disallow_untyped_defs = true - -[mypy-homeassistant.config_entries] -disallow_untyped_defs = false - -[mypy-homeassistant.util.yaml.dumper] -warn_return_any = false -disallow_untyped_calls = false - -[mypy-homeassistant.util.yaml.loader] -warn_return_any = false -disallow_untyped_calls = false -