mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Update pylint to 2.16.0 (#87083)
This commit is contained in:
parent
bd6a4d10ea
commit
07a3046d11
@ -429,6 +429,7 @@ class FritzBoxTools(update_coordinator.DataUpdateCoordinator[None]):
|
||||
self.fritz_hosts.get_mesh_topology
|
||||
)
|
||||
):
|
||||
# pylint: disable=broad-exception-raised
|
||||
raise Exception("Mesh supported but empty topology reported")
|
||||
except FritzActionError:
|
||||
self.mesh_role = MeshRoles.SLAVE
|
||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
from collections.abc import Awaitable, Callable, Mapping
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any, NamedTuple, Union
|
||||
from typing import Any, NamedTuple
|
||||
|
||||
from ismartgate import (
|
||||
AbstractGateApi,
|
||||
@ -46,7 +46,7 @@ class StateData(NamedTuple):
|
||||
|
||||
|
||||
class DeviceDataUpdateCoordinator(
|
||||
DataUpdateCoordinator[Union[GogoGate2InfoResponse, ISmartGateInfoResponse]]
|
||||
DataUpdateCoordinator[GogoGate2InfoResponse | ISmartGateInfoResponse]
|
||||
):
|
||||
"""Manages polling for state changes from the device."""
|
||||
|
||||
|
@ -239,7 +239,7 @@ class PulseCounter(GEMSensor):
|
||||
return 3600
|
||||
|
||||
# Config schema should have ensured it is one of the above values
|
||||
raise Exception(
|
||||
raise RuntimeError(
|
||||
f"Invalid value for time unit: {self._time_unit}. Expected one of"
|
||||
f" {UnitOfTime.SECONDS}, {UnitOfTime.MINUTES}, or {UnitOfTime.HOURS}"
|
||||
)
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import datetime, time, timedelta
|
||||
import logging
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
import here_routing
|
||||
from here_routing import (
|
||||
@ -163,7 +163,7 @@ class HERERoutingDataUpdateCoordinator(DataUpdateCoordinator[HERETravelTimeData]
|
||||
|
||||
|
||||
class HERETransitDataUpdateCoordinator(
|
||||
DataUpdateCoordinator[Optional[HERETravelTimeData]]
|
||||
DataUpdateCoordinator[HERETravelTimeData | None]
|
||||
):
|
||||
"""HERETravelTime DataUpdateCoordinator."""
|
||||
|
||||
|
@ -154,7 +154,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
icloud_account = account
|
||||
|
||||
if icloud_account is None:
|
||||
raise Exception(
|
||||
raise ValueError(
|
||||
f"No iCloud account with username or name {account_identifier}"
|
||||
)
|
||||
return icloud_account
|
||||
|
@ -324,7 +324,7 @@ class IcloudAccount:
|
||||
if slugify(device.name.replace(" ", "", 99)) == name_slug:
|
||||
result.append(device)
|
||||
if not result:
|
||||
raise Exception(f"No device with name {name}")
|
||||
raise ValueError(f"No device with name {name}")
|
||||
return result
|
||||
|
||||
@property
|
||||
|
@ -58,6 +58,7 @@ class InsteonDimmerEntity(InsteonEntity, LightEntity):
|
||||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn light on."""
|
||||
brightness: int | None = None
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
brightness = int(kwargs[ATTR_BRIGHTNESS])
|
||||
elif self._insteon_device_group.group == 1:
|
||||
|
@ -92,7 +92,6 @@ async def async_attach_trigger(
|
||||
"""Handle the release of the LiteJet switch's button."""
|
||||
nonlocal cancel_pressed_more_than, pressed_time
|
||||
nonlocal held_less_than, held_more_than
|
||||
# pylint: disable=not-callable
|
||||
if cancel_pressed_more_than is not None:
|
||||
cancel_pressed_more_than()
|
||||
cancel_pressed_more_than = None
|
||||
|
@ -17,6 +17,7 @@ from homeassistant.components.light import (
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
@ -287,11 +288,11 @@ class PhilipsTVLightEntity(
|
||||
}
|
||||
|
||||
if not await self._tv.setAmbilightCached(data):
|
||||
raise Exception("Failed to set ambilight color")
|
||||
raise HomeAssistantError("Failed to set ambilight color")
|
||||
|
||||
if effect.style != self._tv.ambilight_mode:
|
||||
if not await self._tv.setAmbilightMode(effect.style):
|
||||
raise Exception("Failed to set ambilight mode")
|
||||
raise HomeAssistantError("Failed to set ambilight mode")
|
||||
|
||||
async def _set_ambilight_expert_config(
|
||||
self, effect: AmbilightEffect, hs_color: tuple[float, float], brightness: int
|
||||
@ -325,7 +326,7 @@ class PhilipsTVLightEntity(
|
||||
config["tuning"] = 0
|
||||
|
||||
if not await self._tv.setAmbilightCurrentConfiguration(config):
|
||||
raise Exception("Failed to set ambilight mode")
|
||||
raise HomeAssistantError("Failed to set ambilight mode")
|
||||
|
||||
async def _set_ambilight_config(self, effect: AmbilightEffect):
|
||||
"""Set ambilight via current configuration."""
|
||||
@ -336,7 +337,7 @@ class PhilipsTVLightEntity(
|
||||
}
|
||||
|
||||
if await self._tv.setAmbilightCurrentConfiguration(config) is False:
|
||||
raise Exception("Failed to set ambilight mode")
|
||||
raise HomeAssistantError("Failed to set ambilight mode")
|
||||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the bulb on."""
|
||||
@ -345,7 +346,7 @@ class PhilipsTVLightEntity(
|
||||
attr_effect = kwargs.get(ATTR_EFFECT, self.effect)
|
||||
|
||||
if not self._tv.on:
|
||||
raise Exception("TV is not available")
|
||||
raise HomeAssistantError("TV is not available")
|
||||
|
||||
effect = AmbilightEffect.from_str(attr_effect)
|
||||
|
||||
@ -383,10 +384,10 @@ class PhilipsTVLightEntity(
|
||||
"""Turn of ambilight."""
|
||||
|
||||
if not self._tv.on:
|
||||
raise Exception("TV is not available")
|
||||
raise HomeAssistantError("TV is not available")
|
||||
|
||||
if await self._tv.setAmbilightMode("internal") is False:
|
||||
raise Exception("Failed to set ambilight mode")
|
||||
raise HomeAssistantError("Failed to set ambilight mode")
|
||||
|
||||
await self._set_ambilight_config(AmbilightEffect(EFFECT_MODE, "OFF", ""))
|
||||
|
||||
|
@ -212,6 +212,7 @@ class StarlineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self._captcha_image = data["captchaImg"]
|
||||
return self._async_form_auth_captcha(error)
|
||||
|
||||
# pylint: disable=broad-exception-raised
|
||||
raise Exception(data)
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
_LOGGER.error("Error auth user: %s", err)
|
||||
|
@ -128,11 +128,13 @@ class TwitchSensor(SensorEntity):
|
||||
elif "status" in subs and subs["status"] == 404:
|
||||
self._attr_extra_state_attributes[ATTR_SUBSCRIPTION] = False
|
||||
elif "error" in subs:
|
||||
raise Exception(
|
||||
f"Error response on check_user_subscription: {subs['error']}"
|
||||
_LOGGER.error(
|
||||
"Error response on check_user_subscription: %s", subs["error"]
|
||||
)
|
||||
return
|
||||
else:
|
||||
raise Exception("Unknown error response on check_user_subscription")
|
||||
_LOGGER.error("Unknown error response on check_user_subscription")
|
||||
return
|
||||
|
||||
follows = self._client.get_users_follows(
|
||||
from_id=user, to_id=self.unique_id
|
||||
|
@ -452,9 +452,9 @@ class XiaomiPhilipsBulb(XiaomiPhilipsGenericLight):
|
||||
"%s %s%%, %s mireds, %s%% cct"
|
||||
),
|
||||
brightness,
|
||||
percent_brightness,
|
||||
percent_brightness, # pylint: disable=used-before-assignment
|
||||
color_temp,
|
||||
percent_color_temp,
|
||||
percent_color_temp, # pylint: disable=used-before-assignment
|
||||
)
|
||||
|
||||
result = await self._try_command(
|
||||
@ -830,8 +830,8 @@ class XiaomiPhilipsMoonlightLamp(XiaomiPhilipsBulb):
|
||||
_LOGGER.debug(
|
||||
"Setting brightness and color: %s %s%%, %s",
|
||||
brightness,
|
||||
percent_brightness,
|
||||
rgb,
|
||||
percent_brightness, # pylint: disable=used-before-assignment
|
||||
rgb, # pylint: disable=used-before-assignment
|
||||
)
|
||||
|
||||
result = await self._try_command(
|
||||
@ -854,7 +854,7 @@ class XiaomiPhilipsMoonlightLamp(XiaomiPhilipsBulb):
|
||||
brightness,
|
||||
percent_brightness,
|
||||
color_temp,
|
||||
percent_color_temp,
|
||||
percent_color_temp, # pylint: disable=used-before-assignment
|
||||
)
|
||||
|
||||
result = await self._try_command(
|
||||
|
@ -13,7 +13,7 @@ from collections.abc import Awaitable, Callable
|
||||
import logging
|
||||
import secrets
|
||||
import time
|
||||
from typing import Any, Optional, cast
|
||||
from typing import Any, cast
|
||||
|
||||
from aiohttp import client, web
|
||||
import async_timeout
|
||||
@ -541,7 +541,7 @@ def _encode_jwt(hass: HomeAssistant, data: dict) -> str:
|
||||
@callback
|
||||
def _decode_jwt(hass: HomeAssistant, encoded: str) -> dict | None:
|
||||
"""JWT encode data."""
|
||||
secret = cast(Optional[str], hass.data.get(DATA_JWT_SECRET))
|
||||
secret: str | None = hass.data.get(DATA_JWT_SECRET)
|
||||
|
||||
if secret is None:
|
||||
return None
|
||||
|
@ -161,11 +161,11 @@ good-names = [
|
||||
# wrong-import-order - isort guards this
|
||||
# consider-using-f-string - str.format sometimes more readable
|
||||
# ---
|
||||
# Enable once current issues are fixed:
|
||||
# consider-using-namedtuple-or-dataclass (Pylint CodeStyle extension)
|
||||
# consider-using-assignment-expr (Pylint CodeStyle extension)
|
||||
# Pylint CodeStyle plugin
|
||||
# consider-using-namedtuple-or-dataclass - too opinionated
|
||||
# consider-using-assignment-expr - decision to use := better left to devs
|
||||
# ---
|
||||
# Temporary for the Python 3.10 update
|
||||
# Temporary for the Python 3.10 update, remove with mypy v1.0
|
||||
# consider-alternative-union-syntax
|
||||
disable = [
|
||||
"format",
|
||||
@ -212,9 +212,9 @@ expected-line-ending-format = "LF"
|
||||
|
||||
[tool.pylint.EXCEPTIONS]
|
||||
overgeneral-exceptions = [
|
||||
"BaseException",
|
||||
"Exception",
|
||||
"HomeAssistantError",
|
||||
"builtins.BaseException",
|
||||
"builtins.Exception",
|
||||
# "homeassistant.exceptions.HomeAssistantError", # too many issues
|
||||
]
|
||||
|
||||
[tool.pylint.TYPING]
|
||||
|
@ -7,14 +7,14 @@
|
||||
|
||||
-c homeassistant/package_constraints.txt
|
||||
-r requirements_test_pre_commit.txt
|
||||
astroid==2.12.14
|
||||
astroid==2.14.1
|
||||
codecov==2.1.12
|
||||
coverage==7.0.5
|
||||
freezegun==1.2.2
|
||||
mock-open==1.4.0
|
||||
mypy==0.991
|
||||
pre-commit==3.0.0
|
||||
pylint==2.15.10
|
||||
pylint==2.16.0
|
||||
pylint-per-file-ignores==1.1.0
|
||||
pipdeptree==2.3.1
|
||||
pytest-asyncio==0.20.2
|
||||
|
Loading…
x
Reference in New Issue
Block a user