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