Update pylint to 2.13.0 (#68656)
This commit is contained in:
parent
225f7a989b
commit
53245c6523
20 changed files with 53 additions and 55 deletions
|
@ -75,6 +75,8 @@ class AlexaCapability:
|
||||||
https://developer.amazon.com/docs/device-apis/message-guide.html
|
https://developer.amazon.com/docs/device-apis/message-guide.html
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# pylint: disable=no-self-use
|
||||||
|
|
||||||
supported_locales = {"en-US"}
|
supported_locales = {"en-US"}
|
||||||
|
|
||||||
def __init__(self, entity: State, instance: str | None = None) -> None:
|
def __init__(self, entity: State, instance: str | None = None) -> None:
|
||||||
|
@ -86,28 +88,23 @@ class AlexaCapability:
|
||||||
"""Return the Alexa API name of this interface."""
|
"""Return the Alexa API name of this interface."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@staticmethod
|
def properties_supported(self) -> list[dict]:
|
||||||
def properties_supported() -> list[dict]:
|
|
||||||
"""Return what properties this entity supports."""
|
"""Return what properties this entity supports."""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
def properties_proactively_reported(self) -> bool:
|
||||||
def properties_proactively_reported() -> bool:
|
|
||||||
"""Return True if properties asynchronously reported."""
|
"""Return True if properties asynchronously reported."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
def properties_retrievable(self) -> bool:
|
||||||
def properties_retrievable() -> bool:
|
|
||||||
"""Return True if properties can be retrieved."""
|
"""Return True if properties can be retrieved."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
def properties_non_controllable(self) -> bool | None:
|
||||||
def properties_non_controllable() -> bool | None:
|
|
||||||
"""Return True if non controllable."""
|
"""Return True if non controllable."""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
def get_property(self, name):
|
||||||
def get_property(name):
|
|
||||||
"""Read and return a property.
|
"""Read and return a property.
|
||||||
|
|
||||||
Return value should be a dict, or raise UnsupportedProperty.
|
Return value should be a dict, or raise UnsupportedProperty.
|
||||||
|
@ -117,13 +114,11 @@ class AlexaCapability:
|
||||||
"""
|
"""
|
||||||
raise UnsupportedProperty(name)
|
raise UnsupportedProperty(name)
|
||||||
|
|
||||||
@staticmethod
|
def supports_deactivation(self):
|
||||||
def supports_deactivation():
|
|
||||||
"""Applicable only to scenes."""
|
"""Applicable only to scenes."""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
def capability_proactively_reported(self):
|
||||||
def capability_proactively_reported():
|
|
||||||
"""Return True if the capability is proactively reported.
|
"""Return True if the capability is proactively reported.
|
||||||
|
|
||||||
Set properties_proactively_reported() for proactively reported properties.
|
Set properties_proactively_reported() for proactively reported properties.
|
||||||
|
@ -131,16 +126,14 @@ class AlexaCapability:
|
||||||
"""
|
"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
def capability_resources(self):
|
||||||
def capability_resources():
|
|
||||||
"""Return the capability object.
|
"""Return the capability object.
|
||||||
|
|
||||||
Applicable to ToggleController, RangeController, and ModeController interfaces.
|
Applicable to ToggleController, RangeController, and ModeController interfaces.
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
def configuration(self):
|
||||||
def configuration():
|
|
||||||
"""Return the configuration object.
|
"""Return the configuration object.
|
||||||
|
|
||||||
Applicable to the ThermostatController, SecurityControlPanel, ModeController, RangeController,
|
Applicable to the ThermostatController, SecurityControlPanel, ModeController, RangeController,
|
||||||
|
@ -148,8 +141,7 @@ class AlexaCapability:
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
def configurations(self):
|
||||||
def configurations():
|
|
||||||
"""Return the configurations object.
|
"""Return the configurations object.
|
||||||
|
|
||||||
The plural configurations object is different that the singular configuration object.
|
The plural configurations object is different that the singular configuration object.
|
||||||
|
@ -157,31 +149,29 @@ class AlexaCapability:
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
def inputs(self):
|
||||||
def inputs():
|
|
||||||
"""Applicable only to media players."""
|
"""Applicable only to media players."""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
def semantics(self):
|
||||||
def semantics():
|
|
||||||
"""Return the semantics object.
|
"""Return the semantics object.
|
||||||
|
|
||||||
Applicable to ToggleController, RangeController, and ModeController interfaces.
|
Applicable to ToggleController, RangeController, and ModeController interfaces.
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
def supported_operations(self):
|
||||||
def supported_operations():
|
|
||||||
"""Return the supportedOperations object."""
|
"""Return the supportedOperations object."""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
def camera_stream_configurations(self):
|
||||||
def camera_stream_configurations():
|
|
||||||
"""Applicable only to CameraStreamController."""
|
"""Applicable only to CameraStreamController."""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def serialize_discovery(self):
|
def serialize_discovery(self):
|
||||||
"""Serialize according to the Discovery API."""
|
"""Serialize according to the Discovery API."""
|
||||||
|
# pylint: disable=assignment-from-none
|
||||||
|
# Methods may be overridden and return a value.
|
||||||
result = {"type": "AlexaInterface", "interface": self.name(), "version": "3"}
|
result = {"type": "AlexaInterface", "interface": self.name(), "version": "3"}
|
||||||
|
|
||||||
if (instance := self.instance) is not None:
|
if (instance := self.instance) is not None:
|
||||||
|
|
|
@ -200,6 +200,8 @@ class AlexaCapabilityResource:
|
||||||
https://developer.amazon.com/docs/device-apis/resources-and-assets.html#capability-resources
|
https://developer.amazon.com/docs/device-apis/resources-and-assets.html#capability-resources
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# pylint: disable=no-self-use
|
||||||
|
|
||||||
def __init__(self, labels):
|
def __init__(self, labels):
|
||||||
"""Initialize an Alexa resource."""
|
"""Initialize an Alexa resource."""
|
||||||
self._resource_labels = []
|
self._resource_labels = []
|
||||||
|
@ -210,13 +212,11 @@ class AlexaCapabilityResource:
|
||||||
"""Return capabilityResources object serialized for an API response."""
|
"""Return capabilityResources object serialized for an API response."""
|
||||||
return self.serialize_labels(self._resource_labels)
|
return self.serialize_labels(self._resource_labels)
|
||||||
|
|
||||||
@staticmethod
|
def serialize_configuration(self):
|
||||||
def serialize_configuration():
|
|
||||||
"""Return ModeResources, PresetResources friendlyNames serialized for an API response."""
|
"""Return ModeResources, PresetResources friendlyNames serialized for an API response."""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
def serialize_labels(self, resources):
|
||||||
def serialize_labels(resources):
|
|
||||||
"""Return resource label objects for friendlyNames serialized for an API response."""
|
"""Return resource label objects for friendlyNames serialized for an API response."""
|
||||||
labels = []
|
labels = []
|
||||||
for label in resources:
|
for label in resources:
|
||||||
|
|
|
@ -188,7 +188,9 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
await self.async_set_unique_id(device.mac.hex())
|
await self.async_set_unique_id(device.mac.hex())
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Failed to authenticate to the device at %s: %s", device.host[0], err_msg
|
"Failed to authenticate to the device at %s: %s",
|
||||||
|
device.host[0],
|
||||||
|
err_msg, # pylint: disable=used-before-assignment
|
||||||
)
|
)
|
||||||
return self.async_show_form(step_id="auth", errors=errors)
|
return self.async_show_form(step_id="auth", errors=errors)
|
||||||
|
|
||||||
|
@ -251,7 +253,9 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return await self.async_step_finish()
|
return await self.async_step_finish()
|
||||||
|
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Failed to unlock the device at %s: %s", device.host[0], err_msg
|
"Failed to unlock the device at %s: %s",
|
||||||
|
device.host[0],
|
||||||
|
err_msg, # pylint: disable=used-before-assignment
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -80,7 +80,7 @@ async def async_setup(hass: HomeAssistant, hass_config: ConfigType) -> bool:
|
||||||
except UnidentifiedImageError as ex:
|
except UnidentifiedImageError as ex:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Bad image from %s '%s' provided, are you sure it's an image? %s",
|
"Bad image from %s '%s' provided, are you sure it's an image? %s",
|
||||||
image_type,
|
image_type, # pylint: disable=used-before-assignment
|
||||||
image_reference,
|
image_reference,
|
||||||
ex,
|
ex,
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
# pylint: disable-next=deprecated-typing-alias
|
|
||||||
# Issue with Python 3.9.0 and 3.9.1 with collections.abc.Callable
|
# Issue with Python 3.9.0 and 3.9.1 with collections.abc.Callable
|
||||||
# https://bugs.python.org/issue42965
|
# https://bugs.python.org/issue42965
|
||||||
from typing import Any, Callable, NamedTuple, Optional
|
from typing import Any, Callable, NamedTuple, Optional
|
||||||
|
|
|
@ -202,12 +202,12 @@ class HorizonDevice(MediaPlayerEntity):
|
||||||
try:
|
try:
|
||||||
self._client.connect()
|
self._client.connect()
|
||||||
self._client.authorize()
|
self._client.authorize()
|
||||||
except AuthenticationError as msg:
|
except AuthenticationError as msg2:
|
||||||
_LOGGER.error("Authentication to %s failed: %s", self._name, msg)
|
_LOGGER.error("Authentication to %s failed: %s", self._name, msg2)
|
||||||
return
|
return
|
||||||
except OSError as msg:
|
except OSError as msg2:
|
||||||
# occurs if horizon box is offline
|
# occurs if horizon box is offline
|
||||||
_LOGGER.error("Reconnect to %s failed: %s", self._name, msg)
|
_LOGGER.error("Reconnect to %s failed: %s", self._name, msg2)
|
||||||
return
|
return
|
||||||
|
|
||||||
self._send(key=key, channel=channel)
|
self._send(key=key, channel=channel)
|
||||||
|
|
|
@ -365,10 +365,10 @@ class HomeAssistantHTTP:
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
context = self._create_emergency_ssl_context()
|
context = self._create_emergency_ssl_context()
|
||||||
except OSError as error:
|
except OSError as error2:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Could not create an emergency self signed ssl certificate: %s",
|
"Could not create an emergency self signed ssl certificate: %s",
|
||||||
error,
|
error2,
|
||||||
)
|
)
|
||||||
context = None
|
context = None
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -288,8 +288,8 @@ class IcloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self._with_family,
|
self._with_family,
|
||||||
)
|
)
|
||||||
return await self.async_step_verification_code(None, errors)
|
return await self.async_step_verification_code(None, errors)
|
||||||
except PyiCloudFailedLoginException as error:
|
except PyiCloudFailedLoginException as error_login:
|
||||||
_LOGGER.error("Error logging into iCloud service: %s", error)
|
_LOGGER.error("Error logging into iCloud service: %s", error_login)
|
||||||
self.api = None
|
self.api = None
|
||||||
errors = {CONF_PASSWORD: "invalid_auth"}
|
errors = {CONF_PASSWORD: "invalid_auth"}
|
||||||
return self._show_setup_form(user_input, errors, "user")
|
return self._show_setup_form(user_input, errors, "user")
|
||||||
|
|
|
@ -528,8 +528,6 @@ class LazyState(State):
|
||||||
|
|
||||||
__slots__ = [
|
__slots__ = [
|
||||||
"_row",
|
"_row",
|
||||||
"entity_id",
|
|
||||||
"state",
|
|
||||||
"_attributes",
|
"_attributes",
|
||||||
"_last_changed",
|
"_last_changed",
|
||||||
"_last_updated",
|
"_last_updated",
|
||||||
|
|
|
@ -209,7 +209,6 @@ def setup_platform(
|
||||||
_LOGGER.debug("Credentials correct and site is active")
|
_LOGGER.debug("Credentials correct and site is active")
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
_LOGGER.error("Missing details data in solaredge status")
|
_LOGGER.error("Missing details data in solaredge status")
|
||||||
_LOGGER.debug("Status is: %s", status)
|
|
||||||
return
|
return
|
||||||
except (ConnectTimeout, HTTPError):
|
except (ConnectTimeout, HTTPError):
|
||||||
_LOGGER.error("Could not retrieve details from SolarEdge API")
|
_LOGGER.error("Could not retrieve details from SolarEdge API")
|
||||||
|
|
|
@ -188,6 +188,7 @@ class SonosDiscoveryManager:
|
||||||
_ = soco.volume
|
_ = soco.volume
|
||||||
return soco
|
return soco
|
||||||
except NotSupportedException as exc:
|
except NotSupportedException as exc:
|
||||||
|
# pylint: disable-next=used-before-assignment
|
||||||
_LOGGER.debug("Device %s is not supported, ignoring: %s", uid, exc)
|
_LOGGER.debug("Device %s is not supported, ignoring: %s", uid, exc)
|
||||||
self.data.discovery_ignored.add(ip_address)
|
self.data.discovery_ignored.add(ip_address)
|
||||||
except (OSError, SoCoException) as ex:
|
except (OSError, SoCoException) as ex:
|
||||||
|
|
|
@ -234,6 +234,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
class DeviceListener(TuyaDeviceListener):
|
class DeviceListener(TuyaDeviceListener):
|
||||||
"""Device Update Listener."""
|
"""Device Update Listener."""
|
||||||
|
|
||||||
|
# pylint: disable=arguments-differ
|
||||||
|
# Library incorrectly defines methods as 'classmethod'
|
||||||
|
# https://github.com/tuya/tuya-iot-python-sdk/pull/48
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
|
|
@ -98,6 +98,8 @@ if TYPE_CHECKING:
|
||||||
from ..entity import ZhaEntity
|
from ..entity import ZhaEntity
|
||||||
from .store import ZhaStorage
|
from .store import ZhaStorage
|
||||||
|
|
||||||
|
# pylint: disable-next=broken-collections-callable
|
||||||
|
# Safe inside TYPE_CHECKING block
|
||||||
_LogFilterType = Union[Filter, Callable[[LogRecord], int]]
|
_LogFilterType = Union[Filter, Callable[[LogRecord], int]]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
|
@ -231,7 +231,7 @@ class Battery(Sensor):
|
||||||
return cls(unique_id, zha_device, channels, **kwargs)
|
return cls(unique_id, zha_device, channels, **kwargs)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def formatter(value: int) -> int:
|
def formatter(value: int) -> int: # pylint: disable=arguments-differ
|
||||||
"""Return the state of the entity."""
|
"""Return the state of the entity."""
|
||||||
# per zcl specs battery percent is reported at 200% ¯\_(ツ)_/¯
|
# per zcl specs battery percent is reported at 200% ¯\_(ツ)_/¯
|
||||||
if not isinstance(value, numbers.Number) or value == -1:
|
if not isinstance(value, numbers.Number) or value == -1:
|
||||||
|
@ -391,8 +391,7 @@ class Illuminance(Sensor):
|
||||||
_attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT
|
_attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT
|
||||||
_unit = LIGHT_LUX
|
_unit = LIGHT_LUX
|
||||||
|
|
||||||
@staticmethod
|
def formatter(self, value: int) -> float:
|
||||||
def formatter(value: int) -> float:
|
|
||||||
"""Convert illumination data."""
|
"""Convert illumination data."""
|
||||||
return round(pow(10, ((value - 1) / 10000)), 1)
|
return round(pow(10, ((value - 1) / 10000)), 1)
|
||||||
|
|
||||||
|
|
|
@ -1187,7 +1187,7 @@ async def _old_conf_migrator(old_config: dict[str, Any]) -> dict[str, Any]:
|
||||||
class ConfigFlow(data_entry_flow.FlowHandler):
|
class ConfigFlow(data_entry_flow.FlowHandler):
|
||||||
"""Base class for config flows with some helpers."""
|
"""Base class for config flows with some helpers."""
|
||||||
|
|
||||||
def __init_subclass__(cls, domain: str | None = None, **kwargs: Any) -> None:
|
def __init_subclass__(cls, *, domain: str | None = None, **kwargs: Any) -> None:
|
||||||
"""Initialize a subclass, register if possible."""
|
"""Initialize a subclass, register if possible."""
|
||||||
super().__init_subclass__(**kwargs)
|
super().__init_subclass__(**kwargs)
|
||||||
if domain is not None:
|
if domain is not None:
|
||||||
|
|
|
@ -101,7 +101,7 @@ block_async_io.enable()
|
||||||
|
|
||||||
_T = TypeVar("_T")
|
_T = TypeVar("_T")
|
||||||
_R = TypeVar("_R")
|
_R = TypeVar("_R")
|
||||||
_R_co = TypeVar("_R_co", covariant=True) # pylint: disable=invalid-name
|
_R_co = TypeVar("_R_co", covariant=True)
|
||||||
# Internal; not helpers.typing.UNDEFINED due to circular dependency
|
# Internal; not helpers.typing.UNDEFINED due to circular dependency
|
||||||
_UNDEF: dict[Any, Any] = {}
|
_UNDEF: dict[Any, Any] = {}
|
||||||
_CallableT = TypeVar("_CallableT", bound=Callable[..., Any])
|
_CallableT = TypeVar("_CallableT", bound=Callable[..., Any])
|
||||||
|
|
|
@ -181,7 +181,6 @@ class HelperConfigFlowHandler(config_entries.ConfigFlow):
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
# pylint: disable-next=arguments-differ
|
|
||||||
def __init_subclass__(cls, **kwargs: Any) -> None:
|
def __init_subclass__(cls, **kwargs: Any) -> None:
|
||||||
"""Initialize a subclass."""
|
"""Initialize a subclass."""
|
||||||
super().__init_subclass__(**kwargs)
|
super().__init_subclass__(**kwargs)
|
||||||
|
|
|
@ -67,7 +67,6 @@ good-names = [
|
||||||
"j",
|
"j",
|
||||||
"k",
|
"k",
|
||||||
"Run",
|
"Run",
|
||||||
"T",
|
|
||||||
"ip",
|
"ip",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ freezegun==1.2.1
|
||||||
mock-open==1.4.0
|
mock-open==1.4.0
|
||||||
mypy==0.942
|
mypy==0.942
|
||||||
pre-commit==2.17.0
|
pre-commit==2.17.0
|
||||||
pylint==2.12.2
|
pylint==2.13.0
|
||||||
pipdeptree==2.2.1
|
pipdeptree==2.2.1
|
||||||
pylint-strict-informational==0.1
|
pylint-strict-informational==0.1
|
||||||
pytest-aiohttp==0.3.0
|
pytest-aiohttp==0.3.0
|
||||||
|
|
|
@ -137,6 +137,10 @@ def test_invalid_discovery_info(
|
||||||
msg_id="hass-argument-type",
|
msg_id="hass-argument-type",
|
||||||
node=discovery_info_node,
|
node=discovery_info_node,
|
||||||
args=(4, "DiscoveryInfoType | None"),
|
args=(4, "DiscoveryInfoType | None"),
|
||||||
|
line=6,
|
||||||
|
col_offset=4,
|
||||||
|
end_line=6,
|
||||||
|
end_col_offset=41,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
type_hint_checker.visit_asyncfunctiondef(func_node)
|
type_hint_checker.visit_asyncfunctiondef(func_node)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue