mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add pylint plugin to check for calls to base implementation (#100432)
This commit is contained in:
@@ -11,13 +11,11 @@ import pytest
|
||||
BASE_PATH = Path(__file__).parents[2]
|
||||
|
||||
|
||||
@pytest.fixture(name="hass_enforce_type_hints", scope="session")
|
||||
def hass_enforce_type_hints_fixture() -> ModuleType:
|
||||
"""Fixture to provide a requests mocker."""
|
||||
module_name = "hass_enforce_type_hints"
|
||||
def _load_plugin_from_file(module_name: str, file: str) -> ModuleType:
|
||||
"""Load plugin from file path."""
|
||||
spec = spec_from_file_location(
|
||||
module_name,
|
||||
str(BASE_PATH.joinpath("pylint/plugins/hass_enforce_type_hints.py")),
|
||||
str(BASE_PATH.joinpath(file)),
|
||||
)
|
||||
assert spec and spec.loader
|
||||
|
||||
@@ -27,6 +25,15 @@ def hass_enforce_type_hints_fixture() -> ModuleType:
|
||||
return module
|
||||
|
||||
|
||||
@pytest.fixture(name="hass_enforce_type_hints", scope="session")
|
||||
def hass_enforce_type_hints_fixture() -> ModuleType:
|
||||
"""Fixture to provide a requests mocker."""
|
||||
return _load_plugin_from_file(
|
||||
"hass_enforce_type_hints",
|
||||
"pylint/plugins/hass_enforce_type_hints.py",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(name="linter")
|
||||
def linter_fixture() -> UnittestLinter:
|
||||
"""Fixture to provide a requests mocker."""
|
||||
@@ -44,16 +51,10 @@ def type_hint_checker_fixture(hass_enforce_type_hints, linter) -> BaseChecker:
|
||||
@pytest.fixture(name="hass_imports", scope="session")
|
||||
def hass_imports_fixture() -> ModuleType:
|
||||
"""Fixture to provide a requests mocker."""
|
||||
module_name = "hass_imports"
|
||||
spec = spec_from_file_location(
|
||||
module_name, str(BASE_PATH.joinpath("pylint/plugins/hass_imports.py"))
|
||||
return _load_plugin_from_file(
|
||||
"hass_imports",
|
||||
"pylint/plugins/hass_imports.py",
|
||||
)
|
||||
assert spec and spec.loader
|
||||
|
||||
module = module_from_spec(spec)
|
||||
sys.modules[module_name] = module
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
@pytest.fixture(name="imports_checker")
|
||||
@@ -62,3 +63,20 @@ def imports_checker_fixture(hass_imports, linter) -> BaseChecker:
|
||||
type_hint_checker = hass_imports.HassImportsFormatChecker(linter)
|
||||
type_hint_checker.module = "homeassistant.components.pylint_test"
|
||||
return type_hint_checker
|
||||
|
||||
|
||||
@pytest.fixture(name="hass_enforce_super_call", scope="session")
|
||||
def hass_enforce_super_call_fixture() -> ModuleType:
|
||||
"""Fixture to provide a requests mocker."""
|
||||
return _load_plugin_from_file(
|
||||
"hass_enforce_super_call",
|
||||
"pylint/plugins/hass_enforce_super_call.py",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(name="super_call_checker")
|
||||
def super_call_checker_fixture(hass_enforce_super_call, linter) -> BaseChecker:
|
||||
"""Fixture to provide a requests mocker."""
|
||||
super_call_checker = hass_enforce_super_call.HassEnforceSuperCallChecker(linter)
|
||||
super_call_checker.module = "homeassistant.components.pylint_test"
|
||||
return super_call_checker
|
||||
|
||||
Reference in New Issue
Block a user