Remove unnnecessary pylint configs from components [s-z]* (#98925)

This commit is contained in:
Ville Skyttä 2023-08-24 02:25:32 +03:00 committed by GitHub
parent c39f6b3bea
commit b51c0f6ddc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 55 additions and 93 deletions

View file

@ -141,7 +141,7 @@ async def async_setup_platform(
@callback
def stop_update_interval(event):
"""Properly cancel the scheduled update."""
remove_interval_update() # pylint: disable=not-callable
remove_interval_update()
hass.bus.async_listen(EVENT_HOMEASSISTANT_STOP, stop_update_interval)
async_at_start(hass, start_update_interval)
@ -171,7 +171,7 @@ def async_track_time_interval_backoff(
def remove_listener() -> None:
"""Remove interval listener."""
if remove:
remove() # pylint: disable=not-callable
remove()
return remove_listener

View file

@ -29,7 +29,6 @@ CONF_SENDER_NAME = "sender_name"
DEFAULT_SENDER_NAME = "Home Assistant"
# pylint: disable=no-value-for-parameter
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_API_KEY): cv.string,

View file

@ -110,14 +110,12 @@ class SIAHub:
self.sia_client.accounts = self.sia_accounts
return
# the new client class method creates a subclass based on protocol, hence the type ignore
self.sia_client = (
SIAClient( # pylint: disable=abstract-class-instantiated # type: ignore
host="",
port=self._port,
accounts=self.sia_accounts,
function=self.async_create_and_fire_event,
protocol=CommunicationsProtocol(self._protocol),
)
self.sia_client = SIAClient(
host="",
port=self._port,
accounts=self.sia_accounts,
function=self.async_create_and_fire_event,
protocol=CommunicationsProtocol(self._protocol),
)
def _load_options(self) -> None:

View file

@ -3,7 +3,7 @@ from datetime import timedelta
import ipaddress
import logging
from pysmarty import Smarty # pylint: disable=import-error
from pysmarty import Smarty
import voluptuous as vol
from homeassistant.const import CONF_HOST, CONF_NAME, Platform

View file

@ -3,7 +3,7 @@ from __future__ import annotations
import logging
from pysmarty import Smarty # pylint: disable=import-error
from pysmarty import Smarty
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,

View file

@ -5,7 +5,7 @@ import logging
import math
from typing import Any
from pysmarty import Smarty # pylint: disable=import-error
from pysmarty import Smarty
from homeassistant.components.fan import FanEntity, FanEntityFeature
from homeassistant.core import HomeAssistant, callback

View file

@ -4,7 +4,7 @@ from __future__ import annotations
import datetime as dt
import logging
from pysmarty import Smarty # pylint: disable=import-error
from pysmarty import Smarty
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
from homeassistant.const import UnitOfTemperature

View file

@ -192,9 +192,7 @@ class SmhiWeather(WeatherEntity):
async def retry_update(self, _: datetime) -> None:
"""Retry refresh weather forecast."""
await self.async_update( # pylint: disable=unexpected-keyword-arg
no_throttle=True
)
await self.async_update(no_throttle=True)
@property
def forecast(self) -> list[Forecast] | None:

View file

@ -3,7 +3,7 @@ import asyncio
from datetime import timedelta
import logging
import gammu # pylint: disable=import-error
import gammu
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry

View file

@ -1,7 +1,7 @@
"""Config flow for SMS integration."""
import logging
import gammu # pylint: disable=import-error
import gammu
import voluptuous as vol
from homeassistant import config_entries, core, exceptions

View file

@ -1,8 +1,8 @@
"""The sms gateway to interact with a GSM modem."""
import logging
import gammu # pylint: disable=import-error
from gammu.asyncworker import GammuAsyncWorker # pylint: disable=import-error
import gammu
from gammu.asyncworker import GammuAsyncWorker
from homeassistant.core import callback

View file

@ -3,7 +3,7 @@ from __future__ import annotations
import logging
import gammu # pylint: disable=import-error
import gammu
from homeassistant.components.notify import ATTR_DATA, BaseNotificationService
from homeassistant.const import CONF_TARGET

View file

@ -56,7 +56,6 @@ DEFAULT_ENCRYPTION = "starttls"
ENCRYPTION_OPTIONS = ["tls", "starttls", "none"]
# pylint: disable=no-value-for-parameter
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_RECIPIENT): vol.All(cv.ensure_list, [vol.Email()]),

View file

@ -153,7 +153,7 @@ async def async_register_callback(
@bind_hass
async def async_get_discovery_info_by_udn_st( # pylint: disable=invalid-name
async def async_get_discovery_info_by_udn_st(
hass: HomeAssistant, udn: str, st: str
) -> SsdpServiceInfo | None:
"""Fetch the discovery info cache."""
@ -162,7 +162,7 @@ async def async_get_discovery_info_by_udn_st( # pylint: disable=invalid-name
@bind_hass
async def async_get_discovery_info_by_st( # pylint: disable=invalid-name
async def async_get_discovery_info_by_st(
hass: HomeAssistant, st: str
) -> list[SsdpServiceInfo]:
"""Fetch all the entries matching the st."""
@ -575,7 +575,7 @@ class Scanner:
info_desc = await self._async_get_description_dict(location)
return discovery_info_from_headers_and_description(headers, info_desc)
async def async_get_discovery_info_by_udn_st( # pylint: disable=invalid-name
async def async_get_discovery_info_by_udn_st(
self, udn: str, st: str
) -> SsdpServiceInfo | None:
"""Return discovery_info for a udn and st."""
@ -583,9 +583,7 @@ class Scanner:
return await self._async_headers_to_discovery_info(headers)
return None
async def async_get_discovery_info_by_st( # pylint: disable=invalid-name
self, st: str
) -> list[SsdpServiceInfo]:
async def async_get_discovery_info_by_st(self, st: str) -> list[SsdpServiceInfo]:
"""Return matching discovery_infos for a st."""
return [
await self._async_headers_to_discovery_info(headers)

View file

@ -141,7 +141,7 @@ class LogEntry:
self.root_cause = None
if record.exc_info:
self.exception = "".join(traceback.format_exception(*record.exc_info))
_, _, tb = record.exc_info # pylint: disable=invalid-name
_, _, tb = record.exc_info
# Last line of traceback contains the root cause of the exception
if traceback.extract_tb(tb):
self.root_cause = str(traceback.extract_tb(tb)[-1])

View file

@ -56,10 +56,7 @@ def setup_platform(
try:
token = auth.get_token(email, password)
except requests.exceptions.HTTPError as http_error:
if (
http_error.response.status_code
== requests.codes.unauthorized # pylint: disable=no-member
):
if http_error.response.status_code == requests.codes.unauthorized:
_LOGGER.error("Invalid credentials")
return
@ -121,8 +118,8 @@ class TankUtilitySensor(SensorEntity):
data = tank_monitor.get_device_data(self._token, self.device)
except requests.exceptions.HTTPError as http_error:
if http_error.response.status_code in (
requests.codes.unauthorized, # pylint: disable=no-member
requests.codes.bad_request, # pylint: disable=no-member
requests.codes.unauthorized,
requests.codes.bad_request,
):
_LOGGER.info("Getting new token")
self._token = auth.get_token(self._email, self._password, force=True)

View file

@ -15,7 +15,7 @@ from homeassistant.const import (
)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.template import Template
from homeassistant.helpers.template_entity import ( # noqa: F401 pylint: disable=unused-import
from homeassistant.helpers.template_entity import ( # noqa: F401
TEMPLATE_ENTITY_BASE_SCHEMA,
TemplateEntity,
make_template_entity_base_schema,

View file

@ -80,7 +80,6 @@ async def async_attach_trigger(
return
if delay_cancel:
# pylint: disable-next=not-callable
delay_cancel()
delay_cancel = None
@ -156,7 +155,6 @@ async def async_attach_trigger(
"""Remove state listeners async."""
unsub()
if delay_cancel:
# pylint: disable-next=not-callable
delay_cancel()
return async_remove

View file

@ -9,7 +9,7 @@ import time
import numpy as np
from PIL import Image, ImageDraw, UnidentifiedImageError
import tensorflow as tf # pylint: disable=import-error
import tensorflow as tf
import voluptuous as vol
from homeassistant.components.image_processing import (
@ -148,7 +148,7 @@ def setup_platform(
try:
# Display warning that PIL will be used if no OpenCV is found.
import cv2 # noqa: F401 pylint: disable=unused-import, import-outside-toplevel
import cv2 # noqa: F401 pylint: disable=import-outside-toplevel
except ImportError:
_LOGGER.warning(
"No OpenCV library found. TensorFlow will process image with "

View file

@ -234,10 +234,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
class DeviceListener(TuyaDeviceListener):
"""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__(
self,
hass: HomeAssistant,

View file

@ -43,7 +43,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.data.setdefault(DOMAIN, {})
udn = entry.data[CONFIG_ENTRY_UDN]
st = entry.data[CONFIG_ENTRY_ST] # pylint: disable=invalid-name
st = entry.data[CONFIG_ENTRY_ST]
usn = f"{udn}::{st}"
# Register device discovered-callback.

View file

@ -1,10 +1,8 @@
"""Support for IBM Watson TTS integration."""
import logging
from ibm_cloud_sdk_core.authenticators import ( # pylint: disable=import-error
IAMAuthenticator,
)
from ibm_watson import TextToSpeechV1 # pylint: disable=import-error
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_watson import TextToSpeechV1
import voluptuous as vol
from homeassistant.components.tts import PLATFORM_SCHEMA, Provider

View file

@ -267,10 +267,8 @@ class XiaomiDevice(Entity):
self.parse_data(device["data"], device["raw_data"])
self.parse_voltage(device["data"])
if hasattr(self, "_data_key") and self._data_key: # pylint: disable=no-member
self._unique_id = (
f"{self._data_key}{self._sid}" # pylint: disable=no-member
)
if hasattr(self, "_data_key") and self._data_key:
self._unique_id = f"{self._data_key}{self._sid}"
else:
self._unique_id = f"{self._type}{self._sid}"

View file

@ -449,14 +449,11 @@ class XiaomiPhilipsBulb(XiaomiPhilipsGenericLight):
if ATTR_BRIGHTNESS in kwargs and ATTR_COLOR_TEMP in kwargs:
_LOGGER.debug(
(
"Setting brightness and color temperature: "
"%s %s%%, %s mireds, %s%% cct"
),
"Setting brightness and color temperature: %s %s%%, %s mireds, %s%% cct",
brightness,
percent_brightness, # pylint: disable=used-before-assignment
percent_brightness,
color_temp,
percent_color_temp, # pylint: disable=used-before-assignment
percent_color_temp,
)
result = await self._try_command(
@ -832,8 +829,8 @@ class XiaomiPhilipsMoonlightLamp(XiaomiPhilipsBulb):
_LOGGER.debug(
"Setting brightness and color: %s %s%%, %s",
brightness,
percent_brightness, # pylint: disable=used-before-assignment
rgb, # pylint: disable=used-before-assignment
percent_brightness,
rgb,
)
result = await self._try_command(
@ -856,7 +853,7 @@ class XiaomiPhilipsMoonlightLamp(XiaomiPhilipsBulb):
brightness,
percent_brightness,
color_temp,
percent_color_temp, # pylint: disable=used-before-assignment
percent_color_temp,
)
result = await self._try_command(

View file

@ -198,9 +198,7 @@ async def async_send_message( # noqa: C901
_LOGGER.info("Sending file to %s", recipient)
message = self.Message(sto=recipient, stype="chat")
message["body"] = url
message["oob"][ # pylint: disable=invalid-sequence-index
"url"
] = url
message["oob"]["url"] = url
try:
message.send()
except (IqError, IqTimeout, XMPPError) as ex:

View file

@ -164,9 +164,7 @@ class BasicClusterHandler(ClusterHandler):
"""Initialize Basic cluster handler."""
super().__init__(cluster, endpoint)
if is_hue_motion_sensor(self) and self.cluster.endpoint.endpoint_id == 2:
self.ZCL_INIT_ATTRS = ( # pylint: disable=invalid-name
self.ZCL_INIT_ATTRS.copy()
)
self.ZCL_INIT_ATTRS = self.ZCL_INIT_ATTRS.copy()
self.ZCL_INIT_ATTRS["trigger_indicator"] = True
elif (
self.cluster.endpoint.manufacturer == "TexasInstruments"
@ -373,7 +371,7 @@ class OnOffClusterHandler(ClusterHandler):
except KeyError:
return
self.ZCL_INIT_ATTRS = self.ZCL_INIT_ATTRS.copy() # pylint: disable=invalid-name
self.ZCL_INIT_ATTRS = self.ZCL_INIT_ATTRS.copy()
self.ZCL_INIT_ATTRS["backlight_mode"] = True
self.ZCL_INIT_ATTRS["power_on_state"] = True

View file

@ -92,7 +92,7 @@ class TuyaClusterHandler(ClusterHandler):
"_TZE200_k6jhsr0q",
"_TZE200_9mahtqtg",
):
self.ZCL_INIT_ATTRS = { # pylint: disable=invalid-name
self.ZCL_INIT_ATTRS = {
"backlight_mode": True,
"power_on_state": True,
}
@ -109,7 +109,7 @@ class OppleRemote(ClusterHandler):
"""Initialize Opple cluster handler."""
super().__init__(cluster, endpoint)
if self.cluster.endpoint.model == "lumi.motion.ac02":
self.ZCL_INIT_ATTRS = { # pylint: disable=invalid-name
self.ZCL_INIT_ATTRS = {
"detection_interval": True,
"motion_sensitivity": True,
"trigger_indicator": True,

View file

@ -67,9 +67,7 @@ class OccupancySensing(ClusterHandler):
"""Initialize Occupancy cluster handler."""
super().__init__(cluster, endpoint)
if is_hue_motion_sensor(self):
self.ZCL_INIT_ATTRS = ( # pylint: disable=invalid-name
self.ZCL_INIT_ATTRS.copy()
)
self.ZCL_INIT_ATTRS = self.ZCL_INIT_ATTRS.copy()
self.ZCL_INIT_ATTRS["sensitivity"] = True

View file

@ -7,7 +7,7 @@ import logging
import bellows.zigbee.application
import voluptuous as vol
import zigpy.application
from zigpy.config import CONF_DEVICE_PATH # noqa: F401 # pylint: disable=unused-import
from zigpy.config import CONF_DEVICE_PATH # noqa: F401
import zigpy.types as t
import zigpy_deconz.zigbee.application
import zigpy_xbee.zigbee.application

View file

@ -16,7 +16,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.entity_registry import async_entries_for_device
from homeassistant.helpers.typing import ConfigType
from .. import ( # noqa: F401 pylint: disable=unused-import,
from .. import ( # noqa: F401
alarm_control_panel,
binary_sensor,
button,
@ -35,7 +35,7 @@ from .. import ( # noqa: F401 pylint: disable=unused-import,
from . import const as zha_const, registries as zha_regs
# importing cluster handlers updates registries
from .cluster_handlers import ( # noqa: F401 pylint: disable=unused-import,
from .cluster_handlers import ( # noqa: F401
ClusterHandler,
closures,
general,

View file

@ -27,7 +27,7 @@ ATTR_IN_CLUSTERS: Final[str] = "input_clusters"
ATTR_OUT_CLUSTERS: Final[str] = "output_clusters"
_LOGGER = logging.getLogger(__name__)
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # pylint: disable=invalid-name
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable)
class Endpoint:

View file

@ -111,7 +111,7 @@ class ZHADeviceScannerEntity(ScannerEntity, ZhaEntity):
return self._battery_level
@property # type: ignore[misc]
def device_info( # pylint: disable=overridden-final-method
def device_info(
self,
) -> DeviceInfo:
"""Return device info."""

View file

@ -1112,13 +1112,13 @@ class LightGroup(BaseLight, ZhaGroupEntity):
super().__init__(entity_ids, unique_id, group_id, zha_device, **kwargs)
group = self.zha_device.gateway.get_group(self._group_id)
self._GROUP_SUPPORTS_EXECUTE_IF_OFF = True # pylint: disable=invalid-name
self._GROUP_SUPPORTS_EXECUTE_IF_OFF = True
for member in group.members:
# Ensure we do not send group commands that violate the minimum transition
# time of any members.
if member.device.manufacturer in DEFAULT_MIN_TRANSITION_MANUFACTURERS:
self._DEFAULT_MIN_TRANSITION_TIME = ( # pylint: disable=invalid-name
self._DEFAULT_MIN_TRANSITION_TIME = (
MinTransitionLight._DEFAULT_MIN_TRANSITION_TIME
)

View file

@ -228,7 +228,7 @@ class Battery(Sensor):
return cls(unique_id, zha_device, cluster_handlers, **kwargs)
@staticmethod
def formatter(value: int) -> int | None: # pylint: disable=arguments-differ
def formatter(value: int) -> int | None:
"""Return the state of the entity."""
# per zcl specs battery percent is reported at 200% ¯\_(ツ)_/¯
if not isinstance(value, numbers.Number) or value == -1:

View file

@ -1,7 +1,5 @@
"""The tests for sensor recorder platform."""
from collections.abc import Callable
# pylint: disable=invalid-name
from datetime import datetime, timedelta
import math
from statistics import mean

View file

@ -422,7 +422,7 @@ async def test_broker_regenerates_token(hass: HomeAssistant, config_entry) -> No
broker.connect()
assert stored_action
await stored_action(None) # pylint:disable=not-callable
await stored_action(None)
assert token.refresh.call_count == 1
assert config_entry.data[CONF_REFRESH_TOKEN] == token.refresh_token

View file

@ -102,7 +102,6 @@ async def test_states_non_default_timezone(hass: HomeAssistant) -> None:
assert device.state == "2017-05-17T20:54:00"
# pylint: disable=no-member
async def test_timezone_intervals(hass: HomeAssistant) -> None:
"""Test date sensor behavior in a timezone besides UTC."""
hass.config.set_time_zone("America/New_York")

View file

@ -71,14 +71,12 @@ async def test_sync_turn_on(hass: HomeAssistant) -> None:
setattr(water_heater, "turn_on", MagicMock())
await water_heater.async_turn_on()
# pylint: disable-next=no-member
assert water_heater.turn_on.call_count == 1
# Test with async_turn_on method defined
setattr(water_heater, "async_turn_on", AsyncMock())
await water_heater.async_turn_on()
# pylint: disable-next=no-member
assert water_heater.async_turn_on.call_count == 1
@ -91,12 +89,10 @@ async def test_sync_turn_off(hass: HomeAssistant) -> None:
setattr(water_heater, "turn_off", MagicMock())
await water_heater.async_turn_off()
# pylint: disable-next=no-member
assert water_heater.turn_off.call_count == 1
# Test with async_turn_off method defined
setattr(water_heater, "async_turn_off", AsyncMock())
await water_heater.async_turn_off()
# pylint: disable-next=no-member
assert water_heater.async_turn_off.call_count == 1

View file

@ -296,7 +296,6 @@ async def test_auth_sending_unknown_type_disconnects(
auth_msg = await ws.receive_json()
assert auth_msg["type"] == TYPE_AUTH_REQUIRED
# pylint: disable-next=protected-access
await ws._writer._send_frame(b"1" * 130, 0x30)
auth_msg = await ws.receive()
assert auth_msg.type == WSMsgType.close