Remove unnnecessary pylint configs from core (#98704)

pull/98854/head
Ville Skyttä 2023-08-23 00:12:12 +03:00 committed by GitHub
parent e9af99e469
commit 6399d74c15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 27 additions and 63 deletions

View File

@ -8,7 +8,7 @@ from typing import Any, Generic, Self, TypeVar, overload
_T = TypeVar("_T")
class cached_property(Generic[_T]): # pylint: disable=invalid-name
class cached_property(Generic[_T]):
"""Backport of Python 3.12's cached_property.
Includes https://github.com/python/cpython/pull/101890/files

View File

@ -257,10 +257,10 @@ CORE_CONFIG_SCHEMA = vol.All(
vol.Optional(CONF_INTERNAL_URL): cv.url,
vol.Optional(CONF_EXTERNAL_URL): cv.url,
vol.Optional(CONF_ALLOWLIST_EXTERNAL_DIRS): vol.All(
cv.ensure_list, [vol.IsDir()] # pylint: disable=no-value-for-parameter
cv.ensure_list, [vol.IsDir()]
),
vol.Optional(LEGACY_CONF_WHITELIST_EXTERNAL_DIRS): vol.All(
cv.ensure_list, [vol.IsDir()] # pylint: disable=no-value-for-parameter
cv.ensure_list, [vol.IsDir()]
),
vol.Optional(CONF_ALLOWLIST_EXTERNAL_URLS): vol.All(
cv.ensure_list, [cv.url]
@ -297,7 +297,6 @@ CORE_CONFIG_SCHEMA = vol.All(
],
_no_duplicate_auth_mfa_module,
),
# pylint: disable-next=no-value-for-parameter
vol.Optional(CONF_MEDIA_DIRS): cv.schema_with_slug_keys(vol.IsDir()),
vol.Optional(CONF_LEGACY_TEMPLATES): cv.boolean,
vol.Optional(CONF_CURRENCY): _validate_currency,

View File

@ -108,7 +108,7 @@ _P = ParamSpec("_P")
# Internal; not helpers.typing.UNDEFINED due to circular dependency
_UNDEF: dict[Any, Any] = {}
_CallableT = TypeVar("_CallableT", bound=Callable[..., Any])
CALLBACK_TYPE = Callable[[], None] # pylint: disable=invalid-name
CALLBACK_TYPE = Callable[[], None]
CORE_STORAGE_KEY = "core.config"
CORE_STORAGE_VERSION = 1
@ -847,8 +847,7 @@ class HomeAssistant:
if (
not handle.cancelled()
and (args := handle._args) # pylint: disable=protected-access
# pylint: disable-next=unidiomatic-typecheck
and type(job := args[0]) is HassJob
and type(job := args[0]) is HassJob # noqa: E721
and job.cancel_on_shutdown
):
handle.cancel()

View File

@ -102,8 +102,6 @@ import homeassistant.util.dt as dt_util
from . import script_variables as script_variables_helper, template as template_helper
# pylint: disable=invalid-name
TIME_PERIOD_ERROR = "offset {} should be format 'HH:MM', 'HH:MM:SS' or 'HH:MM:SS.F'"
@ -743,7 +741,6 @@ def socket_timeout(value: Any | None) -> object:
raise vol.Invalid(f"Invalid socket timeout: {err}") from err
# pylint: disable=no-value-for-parameter
def url(
value: Any,
_schema_list: frozenset[UrlProtocolSchema] = EXTERNAL_URL_PROTOCOL_SCHEMA_LIST,
@ -1360,7 +1357,7 @@ STATE_CONDITION_ATTRIBUTE_SCHEMA = vol.Schema(
)
def STATE_CONDITION_SCHEMA(value: Any) -> dict: # pylint: disable=invalid-name
def STATE_CONDITION_SCHEMA(value: Any) -> dict:
"""Validate a state condition."""
if not isinstance(value, dict):
raise vol.Invalid("Expected a dictionary")

View File

@ -11,7 +11,7 @@ from typing import TYPE_CHECKING, Any, Final
import orjson
from homeassistant.util.file import write_utf8_file, write_utf8_file_atomic
from homeassistant.util.json import ( # pylint: disable=unused-import # noqa: F401
from homeassistant.util.json import ( # noqa: F401
JSON_DECODE_EXCEPTIONS,
JSON_ENCODE_EXCEPTIONS,
SerializationError,

View File

@ -348,7 +348,7 @@ class SchemaConfigFlowHandler(config_entries.ConfigFlow, ABC):
"""
@callback
def async_create_entry( # pylint: disable=arguments-differ
def async_create_entry(
self,
data: Mapping[str, Any],
**kwargs: Any,
@ -409,7 +409,7 @@ class SchemaOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
return _async_step
@callback
def async_create_entry( # pylint: disable=arguments-differ
def async_create_entry(
self,
data: Mapping[str, Any],
**kwargs: Any,

View File

@ -237,7 +237,6 @@ class Store(Generic[_T]):
self.minor_version,
)
if len(inspect.signature(self._async_migrate_func).parameters) == 2:
# pylint: disable-next=no-value-for-parameter
stored = await self._async_migrate_func(data["version"], data["data"])
else:
try:

View File

@ -897,7 +897,7 @@ async def async_get_integrations(
for domain in domains:
int_or_fut = cache.get(domain, _UNDEF)
# Integration is never subclassed, so we can check for type
if type(int_or_fut) is Integration: # pylint: disable=unidiomatic-typecheck
if type(int_or_fut) is Integration: # noqa: E721
results[domain] = int_or_fut
elif int_or_fut is not _UNDEF:
in_progress[domain] = cast(asyncio.Future[None], int_or_fut)

View File

@ -180,8 +180,8 @@ COLORS = {
class XYPoint:
"""Represents a CIE 1931 XY coordinate pair."""
x: float = attr.ib() # pylint: disable=invalid-name
y: float = attr.ib() # pylint: disable=invalid-name
x: float = attr.ib()
y: float = attr.ib()
@attr.s()
@ -205,9 +205,6 @@ def color_name_to_rgb(color_name: str) -> RGBColor:
return hex_value
# pylint: disable=invalid-name
def color_RGB_to_xy(
iR: int, iG: int, iB: int, Gamut: GamutType | None = None
) -> tuple[float, float]:

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from collections.abc import Callable
# pylint: disable-next=unused-import,hass-deprecated-import
# pylint: disable-next=hass-deprecated-import
from homeassistant.const import ( # noqa: F401
LENGTH,
LENGTH_CENTIMETERS,

View File

@ -11,7 +11,7 @@ import orjson
from homeassistant.exceptions import HomeAssistantError
from .file import WriteError # pylint: disable=unused-import # noqa: F401
from .file import WriteError # noqa: F401
_SENTINEL = object()
_LOGGER = logging.getLogger(__name__)

View File

@ -89,7 +89,6 @@ def vincenty(
if point1[0] == point2[0] and point1[1] == point2[1]:
return 0.0
# pylint: disable=invalid-name
U1 = math.atan((1 - FLATTENING) * math.tan(math.radians(point1[0])))
U2 = math.atan((1 - FLATTENING) * math.tan(math.radians(point2[0])))
L = math.radians(point2[1] - point1[1])

View File

@ -1,7 +1,7 @@
"""Pressure util functions."""
from __future__ import annotations
# pylint: disable-next=unused-import,hass-deprecated-import
# pylint: disable-next=hass-deprecated-import
from homeassistant.const import ( # noqa: F401
PRESSURE,
PRESSURE_BAR,

View File

@ -1,7 +1,7 @@
"""Distance util functions."""
from __future__ import annotations
# pylint: disable-next=unused-import,hass-deprecated-import
# pylint: disable-next=hass-deprecated-import
from homeassistant.const import ( # noqa: F401
SPEED,
SPEED_FEET_PER_SECOND,
@ -16,7 +16,7 @@ from homeassistant.const import ( # noqa: F401
)
from homeassistant.helpers.frame import report
from .unit_conversion import ( # pylint: disable=unused-import # noqa: F401
from .unit_conversion import ( # noqa: F401
_FOOT_TO_M as FOOT_TO_M,
_HRS_TO_SECS as HRS_TO_SECS,
_IN_TO_M as IN_TO_M,

View File

@ -1,5 +1,5 @@
"""Temperature util functions."""
# pylint: disable-next=unused-import,hass-deprecated-import
# pylint: disable-next=hass-deprecated-import
from homeassistant.const import ( # noqa: F401
TEMP_CELSIUS,
TEMP_FAHRENHEIT,

View File

@ -49,7 +49,7 @@ class _GlobalFreezeContext:
self._loop.call_soon_threadsafe(self._enter)
return self
def __exit__( # pylint: disable=useless-return
def __exit__(
self,
exc_type: type[BaseException],
exc_val: BaseException,
@ -117,7 +117,7 @@ class _ZoneFreezeContext:
self._loop.call_soon_threadsafe(self._enter)
return self
def __exit__( # pylint: disable=useless-return
def __exit__(
self,
exc_type: type[BaseException],
exc_val: BaseException,

View File

@ -1,7 +1,7 @@
"""Volume conversion util functions."""
from __future__ import annotations
# pylint: disable-next=unused-import,hass-deprecated-import
# pylint: disable-next=hass-deprecated-import
from homeassistant.const import ( # noqa: F401
UNIT_NOT_RECOGNIZED_TEMPLATE,
VOLUME,

View File

@ -28,7 +28,7 @@ from .objects import Input, NodeDictClass, NodeListClass, NodeStrClass
# mypy: allow-untyped-calls, no-warn-return-any
JSON_TYPE = list | dict | str # pylint: disable=invalid-name
JSON_TYPE = list | dict | str
_DictT = TypeVar("_DictT", bound=dict)
_LOGGER = logging.getLogger(__name__)

View File

@ -120,18 +120,6 @@ fail-on = [
[tool.pylint.BASIC]
class-const-naming-style = "any"
good-names = [
"_",
"ev",
"ex",
"fp",
"i",
"id",
"j",
"k",
"Run",
"ip",
]
[tool.pylint."MESSAGES CONTROL"]
# Reasons disabled:

View File

@ -254,12 +254,8 @@ INTEGRATION_MANIFEST_SCHEMA = vol.Schema(
}
)
],
vol.Required("documentation"): vol.All(
vol.Url(), documentation_url # pylint: disable=no-value-for-parameter
),
vol.Optional(
"issue_tracker"
): vol.Url(), # pylint: disable=no-value-for-parameter
vol.Required("documentation"): vol.All(vol.Url(), documentation_url),
vol.Optional("issue_tracker"): vol.Url(),
vol.Optional("quality_scale"): vol.In(SUPPORTED_QUALITY_SCALES),
vol.Optional("requirements"): [str],
vol.Optional("dependencies"): [str],

View File

@ -40,7 +40,7 @@ def printc(the_color, *args):
def validate_requirements_ok():
"""Validate requirements, returns True of ok."""
# pylint: disable-next=import-error,import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from gen_requirements_all import main as req_main
return req_main(True) == 0

View File

@ -681,7 +681,6 @@ def ensure_auth_manager_loaded(auth_mgr):
class MockModule:
"""Representation of a fake module."""
# pylint: disable=invalid-name
def __init__(
self,
domain=None,
@ -756,7 +755,6 @@ class MockPlatform:
__name__ = "homeassistant.components.light.bla"
__file__ = "homeassistant/components/blah/light"
# pylint: disable=invalid-name
def __init__(
self,
setup_platform=None,

View File

@ -1221,7 +1221,7 @@ def test_enum() -> None:
schema("value3")
def test_socket_timeout(): # pylint: disable=invalid-name
def test_socket_timeout():
"""Test socket timeout validator."""
schema = vol.Schema(cv.socket_timeout)

View File

@ -11,7 +11,7 @@ import voluptuous as vol
# To prevent circular import when running just this file
from homeassistant import exceptions
from homeassistant.auth.permissions import PolicyPermissions
import homeassistant.components # noqa: F401, pylint: disable=unused-import
import homeassistant.components # noqa: F401
from homeassistant.const import (
ATTR_ENTITY_ID,
ENTITY_MATCH_ALL,

View File

@ -311,7 +311,6 @@ def test_remove_lib_on_upgrade(
mock_open = mock.mock_open()
with patch("homeassistant.config.open", mock_open, create=True):
opened_file = mock_open.return_value
# pylint: disable=no-member
opened_file.readline.return_value = ha_version
hass.config.path = mock.Mock()
config_util.process_ha_config_upgrade(hass)
@ -335,7 +334,6 @@ def test_remove_lib_on_upgrade_94(
mock_open = mock.mock_open()
with patch("homeassistant.config.open", mock_open, create=True):
opened_file = mock_open.return_value
# pylint: disable=no-member
opened_file.readline.return_value = ha_version
hass.config.path = mock.Mock()
config_util.process_ha_config_upgrade(hass)
@ -356,7 +354,6 @@ def test_process_config_upgrade(hass: HomeAssistant) -> None:
config_util, "__version__", "0.91.0"
):
opened_file = mock_open.return_value
# pylint: disable=no-member
opened_file.readline.return_value = ha_version
config_util.process_ha_config_upgrade(hass)
@ -372,7 +369,6 @@ def test_config_upgrade_same_version(hass: HomeAssistant) -> None:
mock_open = mock.mock_open()
with patch("homeassistant.config.open", mock_open, create=True):
opened_file = mock_open.return_value
# pylint: disable=no-member
opened_file.readline.return_value = ha_version
config_util.process_ha_config_upgrade(hass)
@ -386,7 +382,6 @@ def test_config_upgrade_no_file(hass: HomeAssistant) -> None:
mock_open.side_effect = [FileNotFoundError(), mock.DEFAULT, mock.DEFAULT]
with patch("homeassistant.config.open", mock_open, create=True):
opened_file = mock_open.return_value
# pylint: disable=no-member
config_util.process_ha_config_upgrade(hass)
assert opened_file.write.call_count == 1
assert opened_file.write.call_args == mock.call(__version__)

View File

@ -31,7 +31,6 @@ GAMUT_INVALID_4 = color_util.GamutType(
)
# pylint: disable=invalid-name
def test_color_RGB_to_xy_brightness() -> None:
"""Test color_RGB_to_xy_brightness."""
assert color_util.color_RGB_to_xy_brightness(0, 0, 0) == (0, 0, 0)

View File

@ -354,8 +354,6 @@ def load_yaml(fname, string, secrets=None):
class TestSecrets(unittest.TestCase):
"""Test the secrets parameter in the yaml utility."""
# pylint: disable=invalid-name
def setUp(self):
"""Create & load secrets file."""
config_dir = get_test_config_dir()