mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Cleanup after pylint update (#68657)
This commit is contained in:
parent
d645e80ccd
commit
911b159281
@ -23,7 +23,7 @@ class StrEnum(str, Enum):
|
||||
return str(self.value)
|
||||
|
||||
@staticmethod
|
||||
def _generate_next_value_( # pylint: disable=arguments-differ # https://github.com/PyCQA/pylint/issues/5371
|
||||
def _generate_next_value_(
|
||||
name: str, start: int, count: int, last_values: list[Any]
|
||||
) -> Any:
|
||||
"""
|
||||
|
@ -187,7 +187,6 @@ def adb_decorator(override_available=False):
|
||||
@functools.wraps(func)
|
||||
async def _adb_exception_catcher(self, *args, **kwargs):
|
||||
"""Call an ADB-related method and catch exceptions."""
|
||||
# pylint: disable=protected-access
|
||||
if not self.available and not override_available:
|
||||
return None
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
"""Support for APCUPSd via its Network Information Server (NIS)."""
|
||||
# pylint: disable=import-error
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
"""Support for APCUPSd sensors."""
|
||||
# pylint: disable=import-error
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
@ -70,7 +70,6 @@ def retry(method):
|
||||
"Decora connect error for device %s. Reconnecting",
|
||||
device.name,
|
||||
)
|
||||
# pylint: disable=protected-access
|
||||
device._switch.connect()
|
||||
|
||||
return wrapper_retry
|
||||
|
@ -43,7 +43,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
await hass.async_add_executor_job(api.connect)
|
||||
except (
|
||||
ConnectionRefusedError,
|
||||
socket.timeout, # pylint:disable=no-member
|
||||
socket.timeout,
|
||||
SSLError,
|
||||
) as ex:
|
||||
raise ConfigEntryNotReady("Connection to Deluge Daemon failed") from ex
|
||||
|
@ -114,7 +114,7 @@ class DelugeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
await self.hass.async_add_executor_job(api.connect)
|
||||
except (
|
||||
ConnectionRefusedError,
|
||||
socket.timeout, # pylint:disable=no-member
|
||||
socket.timeout,
|
||||
SSLError,
|
||||
):
|
||||
return "cannot_connect"
|
||||
|
@ -53,12 +53,12 @@ class DelugeDataUpdateCoordinator(DataUpdateCoordinator):
|
||||
)
|
||||
except (
|
||||
ConnectionRefusedError,
|
||||
socket.timeout, # pylint:disable=no-member
|
||||
socket.timeout,
|
||||
SSLError,
|
||||
FailedToReconnectException,
|
||||
) as ex:
|
||||
raise UpdateFailed(f"Connection to Deluge Daemon Lost: {ex}") from ex
|
||||
except Exception as ex: # pylint:disable=broad-except
|
||||
except Exception as ex:
|
||||
if type(ex).__name__ == "BadLoginError":
|
||||
raise ConfigEntryAuthFailed(
|
||||
"Credentials for Deluge client are not valid"
|
||||
|
@ -633,7 +633,6 @@ def esphome_state_property(func: _PropT) -> _PropT:
|
||||
@property # type: ignore[misc]
|
||||
@functools.wraps(func)
|
||||
def _wrapper(self): # type: ignore[no-untyped-def]
|
||||
# pylint: disable=protected-access
|
||||
if not self._has_state:
|
||||
return None
|
||||
val = func(self)
|
||||
|
@ -239,7 +239,6 @@ class FanEntity(ToggleEntity):
|
||||
"""Set the direction of the fan."""
|
||||
await self.hass.async_add_executor_job(self.set_direction, direction)
|
||||
|
||||
# pylint: disable=arguments-differ
|
||||
def turn_on(
|
||||
self,
|
||||
percentage: int | None = None,
|
||||
@ -249,7 +248,6 @@ class FanEntity(ToggleEntity):
|
||||
"""Turn on the fan."""
|
||||
raise NotImplementedError()
|
||||
|
||||
# pylint: disable=arguments-differ
|
||||
async def async_turn_on(
|
||||
self,
|
||||
percentage: int | None = None,
|
||||
|
@ -194,7 +194,7 @@ class GoogleCalendarService:
|
||||
service = await self._async_get_service()
|
||||
|
||||
def _list_calendars() -> list[dict[str, Any]]:
|
||||
cal_list = service.calendarList() # pylint: disable=no-member
|
||||
cal_list = service.calendarList()
|
||||
return cal_list.list().execute()["items"]
|
||||
|
||||
return await self._hass.async_add_executor_job(_list_calendars)
|
||||
@ -206,7 +206,7 @@ class GoogleCalendarService:
|
||||
service = await self._async_get_service()
|
||||
|
||||
def _create_event() -> dict[str, Any]:
|
||||
events = service.events() # pylint: disable=no-member
|
||||
events = service.events()
|
||||
return events.insert(calendarId=calendar_id, body=event).execute()
|
||||
|
||||
return await self._hass.async_add_executor_job(_create_event)
|
||||
@ -223,7 +223,7 @@ class GoogleCalendarService:
|
||||
service = await self._async_get_service()
|
||||
|
||||
def _list_events() -> tuple[list[dict[str, Any]], str | None]:
|
||||
events = service.events() # pylint: disable=no-member
|
||||
events = service.events()
|
||||
result = events.list(
|
||||
calendarId=calendar_id,
|
||||
timeMin=_api_time_format(start_time if start_time else dt.now()),
|
||||
|
@ -54,9 +54,7 @@ def setup(hass: HomeAssistant, yaml_config: ConfigType) -> bool:
|
||||
|
||||
publisher = PublisherClient.from_service_account_json(service_principal_path)
|
||||
|
||||
topic_path = publisher.topic_path( # pylint: disable=no-member
|
||||
project_id, topic_name
|
||||
)
|
||||
topic_path = publisher.topic_path(project_id, topic_name)
|
||||
|
||||
encoder = DateTimeJSONEncoder()
|
||||
|
||||
|
@ -110,16 +110,14 @@ class HereTravelTimeDataUpdateCoordinator(DataUpdateCoordinator):
|
||||
departure=departure,
|
||||
)
|
||||
|
||||
_LOGGER.debug(
|
||||
"Raw response is: %s", response.response # pylint: disable=no-member
|
||||
)
|
||||
_LOGGER.debug("Raw response is: %s", response.response)
|
||||
|
||||
attribution: str | None = None
|
||||
if "sourceAttribution" in response.response: # pylint: disable=no-member
|
||||
if "sourceAttribution" in response.response:
|
||||
attribution = build_hass_attribution(
|
||||
response.response.get("sourceAttribution")
|
||||
) # pylint: disable=no-member
|
||||
route: list = response.response["route"] # pylint: disable=no-member
|
||||
)
|
||||
route: list = response.response["route"]
|
||||
summary: dict = route[0]["summary"]
|
||||
waypoint: list = route[0]["waypoint"]
|
||||
distance: float = summary["distance"]
|
||||
|
@ -91,7 +91,6 @@ class ISYLightEntity(ISYNodeEntity, LightEntity, RestoreEntity):
|
||||
self._last_brightness = self._node.status
|
||||
super().async_on_update(event)
|
||||
|
||||
# pylint: disable=arguments-differ
|
||||
async def async_turn_on(self, brightness: int | None = None, **kwargs: Any) -> None:
|
||||
"""Send the turn on command to the ISY994 light device."""
|
||||
if self._restore_light_state and brightness is None and self._last_brightness:
|
||||
|
@ -295,9 +295,7 @@ def filter_turn_on_params(light, params):
|
||||
if not supported_features & SUPPORT_WHITE_VALUE:
|
||||
params.pop(ATTR_WHITE_VALUE, None)
|
||||
|
||||
supported_color_modes = (
|
||||
light._light_internal_supported_color_modes # pylint:disable=protected-access
|
||||
)
|
||||
supported_color_modes = light._light_internal_supported_color_modes
|
||||
if not brightness_supported(supported_color_modes):
|
||||
params.pop(ATTR_BRIGHTNESS, None)
|
||||
if COLOR_MODE_COLOR_TEMP not in supported_color_modes:
|
||||
@ -368,9 +366,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
|
||||
):
|
||||
profiles.apply_default(light.entity_id, light.is_on, params)
|
||||
|
||||
legacy_supported_color_modes = (
|
||||
light._light_internal_supported_color_modes # pylint: disable=protected-access
|
||||
)
|
||||
legacy_supported_color_modes = light._light_internal_supported_color_modes
|
||||
supported_color_modes = light.supported_color_modes
|
||||
# Backwards compatibility: if an RGBWW color is specified, convert to RGB + W
|
||||
# for legacy lights
|
||||
|
@ -189,7 +189,6 @@ def state(new_state):
|
||||
|
||||
def wrapper(self, **kwargs):
|
||||
"""Wrap a group state change."""
|
||||
# pylint: disable=protected-access
|
||||
|
||||
pipeline = Pipeline()
|
||||
transition_time = DEFAULT_TRANSITION
|
||||
|
@ -42,7 +42,6 @@ def get_minio_notification_response(
|
||||
):
|
||||
"""Start listening to minio events. Copied from minio-py."""
|
||||
query = {"prefix": prefix, "suffix": suffix, "events": events}
|
||||
# pylint: disable=protected-access
|
||||
return minio_client._url_open(
|
||||
"GET", bucket_name=bucket_name, query=query, preload_content=False
|
||||
)
|
||||
|
@ -111,7 +111,7 @@ from .util import _VALID_QOS_SCHEMA, valid_publish_topic, valid_subscribe_topic
|
||||
if TYPE_CHECKING:
|
||||
# Only import for paho-mqtt type checking here, imports are done locally
|
||||
# because integrations should be able to optionally rely on MQTT.
|
||||
import paho.mqtt.client as mqtt # pylint: disable=import-outside-toplevel
|
||||
import paho.mqtt.client as mqtt
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -98,9 +98,7 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self.client_id = None
|
||||
self._manual = False
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input=None, errors=None
|
||||
): # pylint: disable=arguments-differ
|
||||
async def async_step_user(self, user_input=None, errors=None):
|
||||
"""Handle a flow initialized by the user."""
|
||||
if user_input is not None:
|
||||
return await self.async_step_plex_website_auth()
|
||||
|
@ -329,7 +329,7 @@ def library_section_payload(section):
|
||||
children_media_class = ITEM_TYPE_MEDIA_CLASS[section.TYPE]
|
||||
except KeyError as err:
|
||||
raise UnknownMediaType(f"Unknown type received: {section.TYPE}") from err
|
||||
server_id = section._server.machineIdentifier # pylint: disable=protected-access
|
||||
server_id = section._server.machineIdentifier
|
||||
return BrowseMedia(
|
||||
title=section.title,
|
||||
media_class=MEDIA_CLASS_DIRECTORY,
|
||||
@ -362,7 +362,7 @@ def hub_payload(hub):
|
||||
media_content_id = f"{hub.librarySectionID}/{hub.hubIdentifier}"
|
||||
else:
|
||||
media_content_id = f"server/{hub.hubIdentifier}"
|
||||
server_id = hub._server.machineIdentifier # pylint: disable=protected-access
|
||||
server_id = hub._server.machineIdentifier
|
||||
payload = {
|
||||
"title": hub.title,
|
||||
"media_class": MEDIA_CLASS_DIRECTORY,
|
||||
@ -376,7 +376,7 @@ def hub_payload(hub):
|
||||
|
||||
def station_payload(station):
|
||||
"""Create response payload for a music station."""
|
||||
server_id = station._server.machineIdentifier # pylint: disable=protected-access
|
||||
server_id = station._server.machineIdentifier
|
||||
return BrowseMedia(
|
||||
title=station.title,
|
||||
media_class=ITEM_TYPE_MEDIA_CLASS[station.type],
|
||||
|
@ -204,7 +204,7 @@ def _evict_purged_states_from_old_states_cache(
|
||||
) -> None:
|
||||
"""Evict purged states from the old states cache."""
|
||||
# Make a map from old_state_id to entity_id
|
||||
old_states = instance._old_states # pylint: disable=protected-access
|
||||
old_states = instance._old_states
|
||||
old_state_reversed = {
|
||||
old_state.state_id: entity_id
|
||||
for entity_id, old_state in old_states.items()
|
||||
@ -221,9 +221,7 @@ def _evict_purged_attributes_from_attributes_cache(
|
||||
) -> None:
|
||||
"""Evict purged attribute ids from the attribute ids cache."""
|
||||
# Make a map from attributes_id to the attributes json
|
||||
state_attributes_ids = (
|
||||
instance._state_attributes_ids # pylint: disable=protected-access
|
||||
)
|
||||
state_attributes_ids = instance._state_attributes_ids
|
||||
state_attributes_ids_reversed = {
|
||||
attributes_id: attributes
|
||||
for attributes, attributes_id in state_attributes_ids.items()
|
||||
@ -378,7 +376,7 @@ def _purge_filtered_events(
|
||||
_purge_event_ids(session, event_ids)
|
||||
if EVENT_STATE_CHANGED in excluded_event_types:
|
||||
session.query(StateAttributes).delete(synchronize_session=False)
|
||||
instance._state_attributes_ids = {} # pylint: disable=protected-access
|
||||
instance._state_attributes_ids = {}
|
||||
|
||||
|
||||
@retryable_database_job("purge")
|
||||
|
@ -448,7 +448,7 @@ def compile_hourly_statistics(
|
||||
}
|
||||
|
||||
# Get last hour's last sum
|
||||
if instance._db_supports_row_number: # pylint: disable=[protected-access]
|
||||
if instance._db_supports_row_number:
|
||||
subquery = (
|
||||
session.query(*QUERY_STATISTICS_SUMMARY_SUM)
|
||||
.filter(StatisticsShortTerm.start >= bindparam("start_time"))
|
||||
|
@ -359,9 +359,7 @@ def setup_connection_for_dialect(
|
||||
version = _extract_version_from_server_response(version_string)
|
||||
|
||||
if version and version < MIN_VERSION_SQLITE_ROWNUM:
|
||||
instance._db_supports_row_number = ( # pylint: disable=[protected-access]
|
||||
False
|
||||
)
|
||||
instance._db_supports_row_number = False
|
||||
if not version or version < MIN_VERSION_SQLITE:
|
||||
_warn_unsupported_version(
|
||||
version or version_string, "SQLite", MIN_VERSION_SQLITE
|
||||
@ -383,18 +381,14 @@ def setup_connection_for_dialect(
|
||||
|
||||
if is_maria_db:
|
||||
if version and version < MIN_VERSION_MARIA_DB_ROWNUM:
|
||||
instance._db_supports_row_number = ( # pylint: disable=[protected-access]
|
||||
False
|
||||
)
|
||||
instance._db_supports_row_number = False
|
||||
if not version or version < MIN_VERSION_MARIA_DB:
|
||||
_warn_unsupported_version(
|
||||
version or version_string, "MariaDB", MIN_VERSION_MARIA_DB
|
||||
)
|
||||
else:
|
||||
if version and version < MIN_VERSION_MYSQL_ROWNUM:
|
||||
instance._db_supports_row_number = ( # pylint: disable=[protected-access]
|
||||
False
|
||||
)
|
||||
instance._db_supports_row_number = False
|
||||
if not version or version < MIN_VERSION_MYSQL:
|
||||
_warn_unsupported_version(
|
||||
version or version_string, "MySQL", MIN_VERSION_MYSQL
|
||||
|
@ -21,7 +21,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
entry.data[CONF_PASSWORD],
|
||||
)
|
||||
await api.get_data()
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
except Exception as err:
|
||||
raise ConfigEntryNotReady from err
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = api
|
||||
|
@ -96,7 +96,6 @@ def spotify_exception_handler(func):
|
||||
"""
|
||||
|
||||
def wrapper(self, *args, **kwargs):
|
||||
# pylint: disable=protected-access
|
||||
try:
|
||||
result = func(self, *args, **kwargs)
|
||||
self._attr_available = True
|
||||
|
@ -49,7 +49,6 @@ class FanSwitch(BaseToggleEntity, FanEntity):
|
||||
"""
|
||||
return self._attr_is_on
|
||||
|
||||
# pylint: disable=arguments-differ
|
||||
async def async_turn_on(
|
||||
self,
|
||||
percentage: int | None = None,
|
||||
|
@ -98,14 +98,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
SynologyDSMLoginPermissionDeniedException,
|
||||
) as err:
|
||||
if err.args[0] and isinstance(err.args[0], dict):
|
||||
# pylint: disable=no-member
|
||||
details = err.args[0].get(EXCEPTION_DETAILS, EXCEPTION_UNKNOWN)
|
||||
else:
|
||||
details = EXCEPTION_UNKNOWN
|
||||
raise ConfigEntryAuthFailed(f"reason: {details}") from err
|
||||
except (SynologyDSMLoginFailedException, SynologyDSMRequestException) as err:
|
||||
if err.args[0] and isinstance(err.args[0], dict):
|
||||
# pylint: disable=no-member
|
||||
details = err.args[0].get(EXCEPTION_DETAILS, EXCEPTION_UNKNOWN)
|
||||
else:
|
||||
details = EXCEPTION_UNKNOWN
|
||||
|
@ -88,7 +88,6 @@ def catch_vlc_errors(
|
||||
except CommandError as err:
|
||||
LOGGER.error("Command error: %s", err)
|
||||
except ConnectError as err:
|
||||
# pylint: disable=protected-access
|
||||
if self._available:
|
||||
LOGGER.error("Connection error: %s", err)
|
||||
self._available = False
|
||||
|
@ -132,7 +132,6 @@ def websocket_command(
|
||||
|
||||
def decorate(func: const.WebSocketCommandHandler) -> const.WebSocketCommandHandler:
|
||||
"""Decorate ws command function."""
|
||||
# pylint: disable=protected-access
|
||||
func._ws_schema = messages.BASE_COMMAND_MESSAGE_SCHEMA.extend(schema) # type: ignore[attr-defined]
|
||||
func._ws_command = command # type: ignore[attr-defined]
|
||||
return func
|
||||
|
@ -1455,7 +1455,7 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||
return await self.async_step_discovery(dataclasses.asdict(discovery_info))
|
||||
|
||||
@callback
|
||||
def async_create_entry( # pylint: disable=arguments-differ
|
||||
def async_create_entry(
|
||||
self,
|
||||
*,
|
||||
title: str,
|
||||
|
@ -230,7 +230,6 @@ class HelperConfigFlowHandler(config_entries.ConfigFlow):
|
||||
|
||||
return _async_step
|
||||
|
||||
# pylint: disable-next=no-self-use
|
||||
@abstractmethod
|
||||
@callback
|
||||
def async_config_entry_title(self, options: Mapping[str, Any]) -> str:
|
||||
|
Loading…
x
Reference in New Issue
Block a user