Rename HassEnforceCoordinatorModule (#125592)

pull/125650/head
epenet 2024-09-10 08:40:49 +02:00 committed by GitHub
parent 4c59bae1d2
commit 7e2e3c4780
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 25 additions and 25 deletions

View File

@ -610,7 +610,7 @@ class TibberRtEntityCreator:
self._async_add_entities(new_entities)
class TibberRtDataCoordinator(DataUpdateCoordinator): # pylint: disable=hass-enforce-coordinator-module
class TibberRtDataCoordinator(DataUpdateCoordinator): # pylint: disable=hass-enforce-class-module
"""Handle Tibber realtime data."""
def __init__(

View File

@ -62,7 +62,7 @@ class ToloSaunaData(NamedTuple):
settings: ToloSettings
class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]): # pylint: disable=hass-enforce-coordinator-module
class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]): # pylint: disable=hass-enforce-class-module
"""DataUpdateCoordinator for TOLO Sauna."""
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:

View File

@ -35,7 +35,7 @@ class FirmwareUpdateStatus(NamedTuple):
firmware: OmadaFirmwareUpdate | None
class OmadaFirmwareUpdateCoodinator(OmadaCoordinator[FirmwareUpdateStatus]): # pylint: disable=hass-enforce-coordinator-module
class OmadaFirmwareUpdateCoodinator(OmadaCoordinator[FirmwareUpdateStatus]): # pylint: disable=hass-enforce-class-module
"""Coordinator for getting details about ports on a switch."""
def __init__(self, hass: HomeAssistant, omada_client: OmadaSiteClient) -> None:

View File

@ -47,7 +47,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return unload_ok
class UkraineAlarmDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): # pylint: disable=hass-enforce-coordinator-module
class UkraineAlarmDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): # pylint: disable=hass-enforce-class-module
"""Class to manage fetching Ukraine Alarm API."""
def __init__(

View File

@ -168,7 +168,7 @@ class VolvoData:
raise InvalidAuth from exc
class VolvoUpdateCoordinator(DataUpdateCoordinator[None]): # pylint: disable=hass-enforce-coordinator-module
class VolvoUpdateCoordinator(DataUpdateCoordinator[None]): # pylint: disable=hass-enforce-class-module
"""Volvo coordinator."""
def __init__(self, hass: HomeAssistant, volvo_data: VolvoData) -> None:

View File

@ -105,7 +105,7 @@ async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
await hass.config_entries.async_reload(entry.entry_id)
class MusicCastDataUpdateCoordinator(DataUpdateCoordinator[MusicCastData]): # pylint: disable=hass-enforce-coordinator-module
class MusicCastDataUpdateCoordinator(DataUpdateCoordinator[MusicCastData]): # pylint: disable=hass-enforce-class-module
"""Class to manage fetching data from the API."""
def __init__(self, hass: HomeAssistant, client: MusicCastDevice) -> None:

View File

@ -64,7 +64,7 @@ async def async_setup_entry(
config_entry.async_on_unload(unsub)
class ZHAFirmwareUpdateCoordinator(DataUpdateCoordinator[None]): # pylint: disable=hass-enforce-coordinator-module
class ZHAFirmwareUpdateCoordinator(DataUpdateCoordinator[None]): # pylint: disable=hass-enforce-class-module
"""Firmware update coordinator that broadcasts updates network-wide."""
def __init__(

View File

@ -7,15 +7,15 @@ from pylint.checkers import BaseChecker
from pylint.lint import PyLinter
class HassEnforceCoordinatorModule(BaseChecker):
class HassEnforceClassModule(BaseChecker):
"""Checker for coordinators own module."""
name = "hass_enforce_coordinator_module"
name = "hass_enforce_class_module"
priority = -1
msgs = {
"C7461": (
"Derived data update coordinator is recommended to be placed in the 'coordinator' module",
"hass-enforce-coordinator-module",
"hass-enforce-class-module",
"Used when derived data update coordinator should be placed in its own module.",
),
}
@ -31,10 +31,10 @@ class HassEnforceCoordinatorModule(BaseChecker):
is_coordinator_module = root_name.endswith(".coordinator")
for ancestor in node.ancestors():
if ancestor.name == "DataUpdateCoordinator" and not is_coordinator_module:
self.add_message("hass-enforce-coordinator-module", node=node)
self.add_message("hass-enforce-class-module", node=node)
return
def register(linter: PyLinter) -> None:
"""Register the checker."""
linter.register_checker(HassEnforceCoordinatorModule(linter))
linter.register_checker(HassEnforceClassModule(linter))

View File

@ -109,7 +109,7 @@ init-hook = """\
load-plugins = [
"pylint.extensions.code_style",
"pylint.extensions.typing",
"hass_enforce_coordinator_module",
"hass_enforce_class_module",
"hass_enforce_sorted_platforms",
"hass_enforce_super_call",
"hass_enforce_type_hints",

View File

@ -104,22 +104,22 @@ def enforce_sorted_platforms_checker_fixture(
return enforce_sorted_platforms_checker
@pytest.fixture(name="hass_enforce_coordinator_module", scope="package")
def hass_enforce_coordinator_module_fixture() -> ModuleType:
"""Fixture to the content for the hass_enforce_coordinator_module check."""
@pytest.fixture(name="hass_enforce_class_module", scope="package")
def hass_enforce_class_module_fixture() -> ModuleType:
"""Fixture to the content for the hass_enforce_class_module check."""
return _load_plugin_from_file(
"hass_enforce_coordinator_module",
"pylint/plugins/hass_enforce_coordinator_module.py",
"hass_enforce_class_module",
"pylint/plugins/hass_enforce_class_module.py",
)
@pytest.fixture(name="enforce_coordinator_module_checker")
def enforce_coordinator_module_fixture(
hass_enforce_coordinator_module, linter
hass_enforce_class_module, linter
) -> BaseChecker:
"""Fixture to provide a hass_enforce_coordinator_module checker."""
"""Fixture to provide a hass_enforce_class_module checker."""
enforce_coordinator_module_checker = (
hass_enforce_coordinator_module.HassEnforceCoordinatorModule(linter)
hass_enforce_class_module.HassEnforceClassModule(linter)
)
enforce_coordinator_module_checker.module = "homeassistant.components.pylint_test"
return enforce_coordinator_module_checker

View File

@ -1,4 +1,4 @@
"""Tests for pylint hass_enforce_coordinator_module plugin."""
"""Tests for pylint hass_enforce_class_module plugin."""
from __future__ import annotations
@ -74,7 +74,7 @@ def test_enforce_coordinator_module_bad_simple(
with assert_adds_messages(
linter,
MessageTest(
msg_id="hass-enforce-coordinator-module",
msg_id="hass-enforce-class-module",
line=5,
node=root_node.body[1],
args=None,
@ -111,7 +111,7 @@ def test_enforce_coordinator_module_bad_nested(
with assert_adds_messages(
linter,
MessageTest(
msg_id="hass-enforce-coordinator-module",
msg_id="hass-enforce-class-module",
line=5,
node=root_node.body[1],
args=None,
@ -121,7 +121,7 @@ def test_enforce_coordinator_module_bad_nested(
end_col_offset=21,
),
MessageTest(
msg_id="hass-enforce-coordinator-module",
msg_id="hass-enforce-class-module",
line=8,
node=root_node.body[2],
args=None,