1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Add flexibility to HassEnforceClassModule (#125739)

* Add flexibility to HassEnforceClassModule

* Adjust
This commit is contained in:
epenet
2024-09-11 15:11:03 +02:00
committed by GitHub
parent 1d3f431628
commit c33ba541b0
2 changed files with 38 additions and 5 deletions

View File

@@ -68,11 +68,14 @@ class HassEnforceClassModule(BaseChecker):
# we only want to check components
if not root_name.startswith("homeassistant.components."):
return
parts = root_name.split(".")
current_module = parts[3] if len(parts) > 3 else ""
ancestors: list[ClassDef] | None = None
for match in _MODULES:
if root_name.endswith(f".{match.expected_module}"):
# Allow module.py and module/sub_module.py
if current_module == match.expected_module:
continue
if ancestors is None: