From 911b159281088d927a474a8b3d56dae630325be8 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 26 Mar 2022 00:34:12 +0100 Subject: [PATCH] Cleanup after pylint update (#68657) --- homeassistant/backports/enum.py | 2 +- homeassistant/components/androidtv/media_player.py | 1 - homeassistant/components/apcupsd/__init__.py | 1 - homeassistant/components/apcupsd/sensor.py | 1 - homeassistant/components/decora/light.py | 1 - homeassistant/components/deluge/__init__.py | 2 +- homeassistant/components/deluge/config_flow.py | 2 +- homeassistant/components/deluge/coordinator.py | 4 ++-- homeassistant/components/esphome/__init__.py | 1 - homeassistant/components/fan/__init__.py | 2 -- homeassistant/components/google/api.py | 6 +++--- homeassistant/components/google_pubsub/__init__.py | 4 +--- .../components/here_travel_time/__init__.py | 10 ++++------ homeassistant/components/isy994/light.py | 1 - homeassistant/components/light/__init__.py | 8 ++------ homeassistant/components/limitlessled/light.py | 1 - homeassistant/components/minio/minio_helper.py | 1 - homeassistant/components/mqtt/__init__.py | 2 +- homeassistant/components/plex/config_flow.py | 4 +--- homeassistant/components/plex/media_browser.py | 6 +++--- homeassistant/components/recorder/purge.py | 8 +++----- homeassistant/components/recorder/statistics.py | 2 +- homeassistant/components/recorder/util.py | 12 +++--------- homeassistant/components/solax/__init__.py | 2 +- homeassistant/components/spotify/media_player.py | 1 - homeassistant/components/switch_as_x/fan.py | 1 - homeassistant/components/synology_dsm/__init__.py | 2 -- homeassistant/components/vlc_telnet/media_player.py | 1 - homeassistant/components/websocket_api/decorators.py | 1 - homeassistant/config_entries.py | 2 +- homeassistant/helpers/helper_config_entry_flow.py | 1 - 31 files changed, 29 insertions(+), 64 deletions(-) diff --git a/homeassistant/backports/enum.py b/homeassistant/backports/enum.py index 1b5a6507847..9a96704a836 100644 --- a/homeassistant/backports/enum.py +++ b/homeassistant/backports/enum.py @@ -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: """ diff --git a/homeassistant/components/androidtv/media_player.py b/homeassistant/components/androidtv/media_player.py index 19cae59a1b4..8e4b04cb507 100644 --- a/homeassistant/components/androidtv/media_player.py +++ b/homeassistant/components/androidtv/media_player.py @@ -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 diff --git a/homeassistant/components/apcupsd/__init__.py b/homeassistant/components/apcupsd/__init__.py index a032430e1bc..7cbf33f8b47 100644 --- a/homeassistant/components/apcupsd/__init__.py +++ b/homeassistant/components/apcupsd/__init__.py @@ -1,5 +1,4 @@ """Support for APCUPSd via its Network Information Server (NIS).""" -# pylint: disable=import-error from datetime import timedelta import logging diff --git a/homeassistant/components/apcupsd/sensor.py b/homeassistant/components/apcupsd/sensor.py index 2fae17ac922..b7e7366796b 100644 --- a/homeassistant/components/apcupsd/sensor.py +++ b/homeassistant/components/apcupsd/sensor.py @@ -1,5 +1,4 @@ """Support for APCUPSd sensors.""" -# pylint: disable=import-error from __future__ import annotations import logging diff --git a/homeassistant/components/decora/light.py b/homeassistant/components/decora/light.py index e29222c8eee..f4b48ccb01b 100644 --- a/homeassistant/components/decora/light.py +++ b/homeassistant/components/decora/light.py @@ -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 diff --git a/homeassistant/components/deluge/__init__.py b/homeassistant/components/deluge/__init__.py index d8d6945be2a..2253eee43d5 100644 --- a/homeassistant/components/deluge/__init__.py +++ b/homeassistant/components/deluge/__init__.py @@ -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 diff --git a/homeassistant/components/deluge/config_flow.py b/homeassistant/components/deluge/config_flow.py index a15c0608029..fc0dd5ff300 100644 --- a/homeassistant/components/deluge/config_flow.py +++ b/homeassistant/components/deluge/config_flow.py @@ -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" diff --git a/homeassistant/components/deluge/coordinator.py b/homeassistant/components/deluge/coordinator.py index 36c2d5d2240..0ac97e77674 100644 --- a/homeassistant/components/deluge/coordinator.py +++ b/homeassistant/components/deluge/coordinator.py @@ -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" diff --git a/homeassistant/components/esphome/__init__.py b/homeassistant/components/esphome/__init__.py index fd9b5dfd6d2..eba60a3d5a1 100644 --- a/homeassistant/components/esphome/__init__.py +++ b/homeassistant/components/esphome/__init__.py @@ -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) diff --git a/homeassistant/components/fan/__init__.py b/homeassistant/components/fan/__init__.py index 5ed4420c592..89de0cabb10 100644 --- a/homeassistant/components/fan/__init__.py +++ b/homeassistant/components/fan/__init__.py @@ -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, diff --git a/homeassistant/components/google/api.py b/homeassistant/components/google/api.py index c279aefef88..10b4a35e25f 100644 --- a/homeassistant/components/google/api.py +++ b/homeassistant/components/google/api.py @@ -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()), diff --git a/homeassistant/components/google_pubsub/__init__.py b/homeassistant/components/google_pubsub/__init__.py index cf1b6da704f..22b7b358dbc 100644 --- a/homeassistant/components/google_pubsub/__init__.py +++ b/homeassistant/components/google_pubsub/__init__.py @@ -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() diff --git a/homeassistant/components/here_travel_time/__init__.py b/homeassistant/components/here_travel_time/__init__.py index 9bee2fff9a1..dde0b28632e 100644 --- a/homeassistant/components/here_travel_time/__init__.py +++ b/homeassistant/components/here_travel_time/__init__.py @@ -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"] diff --git a/homeassistant/components/isy994/light.py b/homeassistant/components/isy994/light.py index 640442c3f19..13df6d513b7 100644 --- a/homeassistant/components/isy994/light.py +++ b/homeassistant/components/isy994/light.py @@ -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: diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 36588704c85..5e8bf473da3 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -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 diff --git a/homeassistant/components/limitlessled/light.py b/homeassistant/components/limitlessled/light.py index e45a4a2ced0..35bfafd602d 100644 --- a/homeassistant/components/limitlessled/light.py +++ b/homeassistant/components/limitlessled/light.py @@ -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 diff --git a/homeassistant/components/minio/minio_helper.py b/homeassistant/components/minio/minio_helper.py index 4f10da10998..cc7b7f8a3e7 100644 --- a/homeassistant/components/minio/minio_helper.py +++ b/homeassistant/components/minio/minio_helper.py @@ -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 ) diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 48da8fd7e73..22d99d1b7be 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -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__) diff --git a/homeassistant/components/plex/config_flow.py b/homeassistant/components/plex/config_flow.py index dffbd7a1930..7baee63477a 100644 --- a/homeassistant/components/plex/config_flow.py +++ b/homeassistant/components/plex/config_flow.py @@ -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() diff --git a/homeassistant/components/plex/media_browser.py b/homeassistant/components/plex/media_browser.py index 4b2bb502d69..59895c0d613 100644 --- a/homeassistant/components/plex/media_browser.py +++ b/homeassistant/components/plex/media_browser.py @@ -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], diff --git a/homeassistant/components/recorder/purge.py b/homeassistant/components/recorder/purge.py index a15d22810f4..532aef3c53d 100644 --- a/homeassistant/components/recorder/purge.py +++ b/homeassistant/components/recorder/purge.py @@ -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") diff --git a/homeassistant/components/recorder/statistics.py b/homeassistant/components/recorder/statistics.py index f01190097df..2ad2530fb83 100644 --- a/homeassistant/components/recorder/statistics.py +++ b/homeassistant/components/recorder/statistics.py @@ -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")) diff --git a/homeassistant/components/recorder/util.py b/homeassistant/components/recorder/util.py index 487b8dd22f7..9d12f1d7473 100644 --- a/homeassistant/components/recorder/util.py +++ b/homeassistant/components/recorder/util.py @@ -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 diff --git a/homeassistant/components/solax/__init__.py b/homeassistant/components/solax/__init__.py index 2f9d4509dd2..3915f414d0e 100644 --- a/homeassistant/components/solax/__init__.py +++ b/homeassistant/components/solax/__init__.py @@ -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 diff --git a/homeassistant/components/spotify/media_player.py b/homeassistant/components/spotify/media_player.py index 2b62fdd78c4..3e77c5893c0 100644 --- a/homeassistant/components/spotify/media_player.py +++ b/homeassistant/components/spotify/media_player.py @@ -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 diff --git a/homeassistant/components/switch_as_x/fan.py b/homeassistant/components/switch_as_x/fan.py index e87f49b1b7b..5ebc8902d06 100644 --- a/homeassistant/components/switch_as_x/fan.py +++ b/homeassistant/components/switch_as_x/fan.py @@ -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, diff --git a/homeassistant/components/synology_dsm/__init__.py b/homeassistant/components/synology_dsm/__init__.py index 0503094d1cd..8eed02118c0 100644 --- a/homeassistant/components/synology_dsm/__init__.py +++ b/homeassistant/components/synology_dsm/__init__.py @@ -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 diff --git a/homeassistant/components/vlc_telnet/media_player.py b/homeassistant/components/vlc_telnet/media_player.py index 99b37f97e0c..5b7c5fbb524 100644 --- a/homeassistant/components/vlc_telnet/media_player.py +++ b/homeassistant/components/vlc_telnet/media_player.py @@ -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 diff --git a/homeassistant/components/websocket_api/decorators.py b/homeassistant/components/websocket_api/decorators.py index 296271c7cfd..223c09eb5fd 100644 --- a/homeassistant/components/websocket_api/decorators.py +++ b/homeassistant/components/websocket_api/decorators.py @@ -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 diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 0e94aa458a3..e10574bdc4a 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -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, diff --git a/homeassistant/helpers/helper_config_entry_flow.py b/homeassistant/helpers/helper_config_entry_flow.py index 16471c13e41..d835b74cd54 100644 --- a/homeassistant/helpers/helper_config_entry_flow.py +++ b/homeassistant/helpers/helper_config_entry_flow.py @@ -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: