Rename HassEnforceCoordinatorModule (#125592)
parent
4c59bae1d2
commit
7e2e3c4780
|
@ -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__(
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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__(
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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__(
|
||||
|
|
|
@ -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))
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
Loading…
Reference in New Issue