mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 20:55:10 +02:00
Enable RUF021 (#135832)
This commit is contained in:
committed by
GitHub
parent
85b4be2f16
commit
b4f4b06f29
@@ -55,10 +55,14 @@ class TypeHintMatch:
|
||||
"""Confirm if function should be checked."""
|
||||
return (
|
||||
self.function_name == node.name
|
||||
or self.has_async_counterpart
|
||||
and node.name == f"async_{self.function_name}"
|
||||
or self.function_name.endswith("*")
|
||||
and node.name.startswith(self.function_name[:-1])
|
||||
or (
|
||||
self.has_async_counterpart
|
||||
and node.name == f"async_{self.function_name}"
|
||||
)
|
||||
or (
|
||||
self.function_name.endswith("*")
|
||||
and node.name.startswith(self.function_name[:-1])
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -2998,8 +3002,8 @@ def _is_valid_type(
|
||||
isinstance(node, nodes.Subscript)
|
||||
and isinstance(node.value, nodes.Name)
|
||||
and node.value.name in _KNOWN_GENERIC_TYPES
|
||||
or isinstance(node, nodes.Name)
|
||||
and node.name.endswith(_KNOWN_GENERIC_TYPES_TUPLE)
|
||||
) or (
|
||||
isinstance(node, nodes.Name) and node.name.endswith(_KNOWN_GENERIC_TYPES_TUPLE)
|
||||
):
|
||||
return True
|
||||
|
||||
|
@@ -268,9 +268,8 @@ class HassImportsFormatChecker(BaseChecker):
|
||||
self, current_package: str, node: nodes.ImportFrom
|
||||
) -> None:
|
||||
"""Check for improper 'from ._ import _' invocations."""
|
||||
if (
|
||||
node.level <= 1
|
||||
or not current_package.startswith("homeassistant.components.")
|
||||
if node.level <= 1 or (
|
||||
not current_package.startswith("homeassistant.components.")
|
||||
and not current_package.startswith("tests.components.")
|
||||
):
|
||||
return
|
||||
|
Reference in New Issue
Block a user