Adjust pylint checks for notify get_service (#77606)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
This commit is contained in:
epenet
2022-09-07 09:44:15 +02:00
committed by GitHub
co-authored by Marc Mueller
parent a82484d7a7
commit 9fb0b3995c
2 changed files with 63 additions and 8 deletions
+29
View File
@@ -1011,3 +1011,32 @@ def test_vacuum_entity(linter: UnittestLinter, type_hint_checker: BaseChecker) -
with assert_no_messages(linter):
type_hint_checker.visit_classdef(class_node)
def test_notify_get_service(
linter: UnittestLinter, type_hint_checker: BaseChecker
) -> None:
"""Ensure valid hints are accepted for async_get_service."""
func_node = astroid.extract_node(
"""
class BaseNotificationService():
pass
async def async_get_service( #@
hass: HomeAssistant,
config: ConfigType,
discovery_info: DiscoveryInfoType | None = None,
) -> CustomNotificationService:
pass
class CustomNotificationService(BaseNotificationService):
pass
""",
"homeassistant.components.pylint_test.notify",
)
type_hint_checker.visit_module(func_node.parent)
with assert_no_messages(
linter,
):
type_hint_checker.visit_asyncfunctiondef(func_node)