From c075dac9163dd36aca48417a0ecee9b2bb3d4c96 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sun, 26 Mar 2023 19:54:21 +0200 Subject: [PATCH] Fix pylint plugin for tuple[float, float] returns (#90047) --- pylint/plugins/hass_enforce_type_hints.py | 2 +- tests/pylint/test_enforce_type_hints.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 9f4c806dc94..63cc5a1c6b9 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -2796,7 +2796,7 @@ def _is_valid_type( _is_valid_type(match.group(1), node.value) and isinstance(node.slice, nodes.Tuple) and all( - _is_valid_type(match.group(n + 2), node.slice.elts[n]) + _is_valid_type(match.group(n + 2), node.slice.elts[n], in_return) for n in range(len(node.slice.elts)) ) ) diff --git a/tests/pylint/test_enforce_type_hints.py b/tests/pylint/test_enforce_type_hints.py index c580658b542..9e8df452b61 100644 --- a/tests/pylint/test_enforce_type_hints.py +++ b/tests/pylint/test_enforce_type_hints.py @@ -776,7 +776,7 @@ def test_valid_long_tuple( # Set ignore option type_hint_checker.config.ignore_missing_annotations = False - class_node, _, _ = astroid.extract_node( + class_node, _, _, _ = astroid.extract_node( """ class Entity(): pass @@ -790,6 +790,12 @@ def test_valid_long_tuple( class TestLight( #@ LightEntity ): + @property + def hs_color( #@ + self + ) -> tuple[int, int]: + pass + @property def rgbw_color( #@ self