From 8db222587839d5fcd18311e4b36fdc7822274b44 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 15 Jun 2022 07:30:13 +0000 Subject: [PATCH] Add checks for lock --- pylint/plugins/hass_enforce_type_hints.py | 38 ++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 85914df4eb4..b726374dc6f 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -443,9 +443,9 @@ _CLASS_MATCH: dict[str, list[ClassTypeHintMatch]] = { ), ], } -# Properties are normally checked by mypy, and will only be checked -# by pylint when --ignore-missing-annotations is False -_PROPERTY_MATCH: dict[str, list[ClassTypeHintMatch]] = { +# Overriden properties and functions are normally checked by mypy, and will only +# be checked by pylint when --ignore-missing-annotations is False +_INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { "lock": [ ClassTypeHintMatch( base_class="LockEntity", @@ -474,6 +474,36 @@ _PROPERTY_MATCH: dict[str, list[ClassTypeHintMatch]] = { function_name="is_jammed", return_type=["bool", None], ), + TypeHintMatch( + function_name="lock", + kwargs_type="Any", + return_type=None, + ), + TypeHintMatch( + function_name="async_lock", + kwargs_type="Any", + return_type=None, + ), + TypeHintMatch( + function_name="unlock", + kwargs_type="Any", + return_type=None, + ), + TypeHintMatch( + function_name="async_unlock", + kwargs_type="Any", + return_type=None, + ), + TypeHintMatch( + function_name="open", + kwargs_type="Any", + return_type=None, + ), + TypeHintMatch( + function_name="async_open", + kwargs_type="Any", + return_type=None, + ), ], ), ], @@ -660,7 +690,7 @@ class HassTypeHintChecker(BaseChecker): # type: ignore[misc] self._class_matchers.extend(class_matches) if not self.linter.config.ignore_missing_annotations and ( - property_matches := _PROPERTY_MATCH.get(module_platform) + property_matches := _INHERITANCE_MATCH.get(module_platform) ): self._class_matchers.extend(property_matches)