diff --git a/homeassistant/auth/providers/trusted_networks.py b/homeassistant/auth/providers/trusted_networks.py index 2afdbf98196..c45cca4bd1a 100644 --- a/homeassistant/auth/providers/trusted_networks.py +++ b/homeassistant/auth/providers/trusted_networks.py @@ -111,7 +111,7 @@ class TrustedNetworksAuthProvider(AuthProvider): if ( user.id in user_list or any( - [group.id in flattened_group_list for group in user.groups] + group.id in flattened_group_list for group in user.groups ) ) ] diff --git a/homeassistant/components/alexa/intent.py b/homeassistant/components/alexa/intent.py index f64031250e2..edc7ec6fa98 100644 --- a/homeassistant/components/alexa/intent.py +++ b/homeassistant/components/alexa/intent.py @@ -18,6 +18,7 @@ INTENTS_API_ENDPOINT = "/api/alexa" class SpeechType(enum.Enum): + # pylint: disable=invalid-name """The Alexa speech types.""" plaintext = "PlainText" @@ -28,6 +29,7 @@ SPEECH_MAPPINGS = {"plain": SpeechType.plaintext, "ssml": SpeechType.ssml} class CardType(enum.Enum): + # pylint: disable=invalid-name """The Alexa card types.""" simple = "Simple" diff --git a/homeassistant/components/apple_tv/config_flow.py b/homeassistant/components/apple_tv/config_flow.py index ef0a0cfe59e..ad56561ef9b 100644 --- a/homeassistant/components/apple_tv/config_flow.py +++ b/homeassistant/components/apple_tv/config_flow.py @@ -44,7 +44,7 @@ async def device_scan(identifier, loop, cache=None): return True if identifier == dev.name: return True - return any([service.identifier == identifier for service in dev.services]) + return any(service.identifier == identifier for service in dev.services) def _host_filter(): try: diff --git a/homeassistant/components/isy994/binary_sensor.py b/homeassistant/components/isy994/binary_sensor.py index 6355a9bcece..e8c08d98aa7 100644 --- a/homeassistant/components/isy994/binary_sensor.py +++ b/homeassistant/components/isy994/binary_sensor.py @@ -127,7 +127,7 @@ async def async_setup_entry( if ( device_class == DEVICE_CLASS_MOTION and device_type is not None - and any([device_type.startswith(t) for t in TYPE_INSTEON_MOTION]) + and any(device_type.startswith(t) for t in TYPE_INSTEON_MOTION) ): # Special cases for Insteon Motion Sensors I & II: # Some subnodes never report status until activated, so @@ -194,10 +194,8 @@ def _detect_device_type_and_class(node: Union[Group, Node]) -> (str, str): # Other devices (incl Insteon.) for device_class in [*BINARY_SENSOR_DEVICE_TYPES_ISY]: if any( - [ - device_type.startswith(t) - for t in set(BINARY_SENSOR_DEVICE_TYPES_ISY[device_class]) - ] + device_type.startswith(t) + for t in set(BINARY_SENSOR_DEVICE_TYPES_ISY[device_class]) ): return device_class, device_type return (None, device_type) diff --git a/homeassistant/components/isy994/helpers.py b/homeassistant/components/isy994/helpers.py index e1ab689eb7a..f9834586583 100644 --- a/homeassistant/components/isy994/helpers.py +++ b/homeassistant/components/isy994/helpers.py @@ -97,10 +97,8 @@ def _check_for_insteon_type( platforms = SUPPORTED_PLATFORMS if not single_platform else [single_platform] for platform in platforms: if any( - [ - device_type.startswith(t) - for t in set(NODE_FILTERS[platform][FILTER_INSTEON_TYPE]) - ] + device_type.startswith(t) + for t in set(NODE_FILTERS[platform][FILTER_INSTEON_TYPE]) ): # Hacky special-cases for certain devices with different platforms @@ -164,10 +162,8 @@ def _check_for_zwave_cat( platforms = SUPPORTED_PLATFORMS if not single_platform else [single_platform] for platform in platforms: if any( - [ - device_type.startswith(t) - for t in set(NODE_FILTERS[platform][FILTER_ZWAVE_CAT]) - ] + device_type.startswith(t) + for t in set(NODE_FILTERS[platform][FILTER_ZWAVE_CAT]) ): hass_isy_data[ISY994_NODES][platform].append(node) diff --git a/homeassistant/components/knx/const.py b/homeassistant/components/knx/const.py index 83ffc2557c2..1829826834c 100644 --- a/homeassistant/components/knx/const.py +++ b/homeassistant/components/knx/const.py @@ -24,6 +24,7 @@ CONF_RESET_AFTER = "reset_after" class ColorTempModes(Enum): + # pylint: disable=invalid-name """Color temperature modes for config validation.""" ABSOLUTE = "DPT-7.600" @@ -31,6 +32,7 @@ class ColorTempModes(Enum): class SupportedPlatforms(Enum): + # pylint: disable=invalid-name """Supported platforms.""" BINARY_SENSOR = "binary_sensor" diff --git a/homeassistant/components/slack/notify.py b/homeassistant/components/slack/notify.py index 985f59a6715..fb7b949e3ed 100644 --- a/homeassistant/components/slack/notify.py +++ b/homeassistant/components/slack/notify.py @@ -4,7 +4,7 @@ from __future__ import annotations import asyncio import logging import os -from typing import Any, List, Optional, TypedDict +from typing import Any, TypedDict from urllib.parse import urlparse from aiohttp import BasicAuth, FormData @@ -106,14 +106,14 @@ class MessageT(TypedDict, total=False): username: str # Optional key icon_url: str # Optional key icon_emoji: str # Optional key - blocks: List[Any] # Optional key + blocks: list[Any] # Optional key async def async_get_service( hass: HomeAssistantType, config: ConfigType, - discovery_info: Optional[DiscoveryInfoType] = None, -) -> Optional[SlackNotificationService]: + discovery_info: DiscoveryInfoType | None = None, +) -> SlackNotificationService | None: """Set up the Slack notification service.""" session = aiohttp_client.async_get_clientsession(hass) client = WebClient(token=config[CONF_API_KEY], run_async=True, session=session) @@ -147,7 +147,7 @@ def _async_get_filename_from_url(url: str) -> str: @callback -def _async_sanitize_channel_names(channel_list: List[str]) -> List[str]: +def _async_sanitize_channel_names(channel_list: list[str]) -> list[str]: """Remove any # symbols from a channel list.""" return [channel.lstrip("#") for channel in channel_list] @@ -174,8 +174,8 @@ class SlackNotificationService(BaseNotificationService): hass: HomeAssistantType, client: WebClient, default_channel: str, - username: Optional[str], - icon: Optional[str], + username: str | None, + icon: str | None, ) -> None: """Initialize.""" self._client = client @@ -187,9 +187,9 @@ class SlackNotificationService(BaseNotificationService): async def _async_send_local_file_message( self, path: str, - targets: List[str], + targets: list[str], message: str, - title: Optional[str], + title: str | None, ) -> None: """Upload a local file (with message) to Slack.""" if not self._hass.config.is_allowed_path(path): @@ -213,12 +213,12 @@ class SlackNotificationService(BaseNotificationService): async def _async_send_remote_file_message( self, url: str, - targets: List[str], + targets: list[str], message: str, - title: Optional[str], + title: str | None, *, - username: Optional[str] = None, - password: Optional[str] = None, + username: str | None = None, + password: str | None = None, ) -> None: """Upload a remote file (with message) to Slack. @@ -263,13 +263,13 @@ class SlackNotificationService(BaseNotificationService): async def _async_send_text_only_message( self, - targets: List[str], + targets: list[str], message: str, - title: Optional[str], + title: str | None, *, - username: Optional[str] = None, - icon: Optional[str] = None, - blocks: Optional[Any] = None, + username: str | None = None, + icon: str | None = None, + blocks: Any | None = None, ) -> None: """Send a text-only message.""" message_dict: MessageT = {"link_names": True, "text": message} diff --git a/homeassistant/components/stream/__init__.py b/homeassistant/components/stream/__init__.py index c2bf63063e5..184ed1f2719 100644 --- a/homeassistant/components/stream/__init__.py +++ b/homeassistant/components/stream/__init__.py @@ -157,7 +157,7 @@ class Stream: def check_idle(self): """Reset access token if all providers are idle.""" - if all([p.idle for p in self._outputs.values()]): + if all(p.idle for p in self._outputs.values()): self.access_token = None def start(self): diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index b6ca7881615..86bf4c24407 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -330,7 +330,7 @@ async def async_setup(hass, config): attribute_templ = data.get(attribute) if attribute_templ: if any( - [isinstance(attribute_templ, vtype) for vtype in [float, int, str]] + isinstance(attribute_templ, vtype) for vtype in [float, int, str] ): data[attribute] = attribute_templ else: diff --git a/homeassistant/components/universal/media_player.py b/homeassistant/components/universal/media_player.py index 1834d22855c..2702f26a3d3 100644 --- a/homeassistant/components/universal/media_player.py +++ b/homeassistant/components/universal/media_player.py @@ -470,7 +470,7 @@ class UniversalMediaPlayer(MediaPlayerEntity): if SERVICE_MEDIA_PREVIOUS_TRACK in self._cmds: flags |= SUPPORT_PREVIOUS_TRACK - if any([cmd in self._cmds for cmd in [SERVICE_VOLUME_UP, SERVICE_VOLUME_DOWN]]): + if any(cmd in self._cmds for cmd in [SERVICE_VOLUME_UP, SERVICE_VOLUME_DOWN]): flags |= SUPPORT_VOLUME_STEP if SERVICE_VOLUME_SET in self._cmds: flags |= SUPPORT_VOLUME_SET diff --git a/homeassistant/components/vicare/__init__.py b/homeassistant/components/vicare/__init__.py index 2b1a367215b..940e076c813 100644 --- a/homeassistant/components/vicare/__init__.py +++ b/homeassistant/components/vicare/__init__.py @@ -33,6 +33,7 @@ DEFAULT_HEATING_TYPE = "generic" class HeatingType(enum.Enum): + # pylint: disable=invalid-name """Possible options for heating type.""" generic = "generic" diff --git a/homeassistant/components/withings/common.py b/homeassistant/components/withings/common.py index c08ddddf4a5..e2e0b06e342 100644 --- a/homeassistant/components/withings/common.py +++ b/homeassistant/components/withings/common.py @@ -1070,11 +1070,9 @@ def get_data_manager_by_webhook_id( def get_all_data_managers(hass: HomeAssistant) -> Tuple[DataManager, ...]: """Get all configured data managers.""" return tuple( - [ - config_entry_data[const.DATA_MANAGER] - for config_entry_data in hass.data[const.DOMAIN].values() - if const.DATA_MANAGER in config_entry_data - ] + config_entry_data[const.DATA_MANAGER] + for config_entry_data in hass.data[const.DOMAIN].values() + if const.DATA_MANAGER in config_entry_data ) @@ -1101,11 +1099,7 @@ async def async_create_entities( def get_platform_attributes(platform: str) -> Tuple[WithingsAttribute, ...]: """Get withings attributes used for a specific platform.""" return tuple( - [ - attribute - for attribute in WITHINGS_ATTRIBUTES - if attribute.platform == platform - ] + attribute for attribute in WITHINGS_ATTRIBUTES if attribute.platform == platform ) diff --git a/homeassistant/components/zha/core/channels/general.py b/homeassistant/components/zha/core/channels/general.py index d105572c182..1c1ab28ba5d 100644 --- a/homeassistant/components/zha/core/channels/general.py +++ b/homeassistant/components/zha/core/channels/general.py @@ -91,7 +91,7 @@ class AnalogOutput(ZigbeeChannel): self.error("Could not set value: %s", ex) return False if isinstance(res, list) and all( - [record.status == Status.SUCCESS for record in res[0]] + record.status == Status.SUCCESS for record in res[0] ): return True return False diff --git a/homeassistant/components/zha/core/channels/hvac.py b/homeassistant/components/zha/core/channels/hvac.py index 1647c5ce52d..e02f6c01836 100644 --- a/homeassistant/components/zha/core/channels/hvac.py +++ b/homeassistant/components/zha/core/channels/hvac.py @@ -434,7 +434,7 @@ class ThermostatChannel(ZigbeeChannel): if not isinstance(res, list): return False - return all([record.status == Status.SUCCESS for record in res[0]]) + return all(record.status == Status.SUCCESS for record in res[0]) @registries.ZIGBEE_CHANNEL_REGISTRY.register(hvac.UserInterface.cluster_id) diff --git a/homeassistant/components/zha/core/const.py b/homeassistant/components/zha/core/const.py index 1d3f767353b..ac4f53d2a8c 100644 --- a/homeassistant/components/zha/core/const.py +++ b/homeassistant/components/zha/core/const.py @@ -176,6 +176,7 @@ POWER_BATTERY_OR_UNKNOWN = "Battery or Unknown" class RadioType(enum.Enum): + # pylint: disable=invalid-name """Possible options for radio type.""" znp = ( diff --git a/homeassistant/components/zha/cover.py b/homeassistant/components/zha/cover.py index 45114c677af..e202def46c5 100644 --- a/homeassistant/components/zha/cover.py +++ b/homeassistant/components/zha/cover.py @@ -301,7 +301,7 @@ class KeenVent(Shade): self._on_off_channel.on(), ] results = await asyncio.gather(*tasks, return_exceptions=True) - if any([isinstance(result, Exception) for result in results]): + if any(isinstance(result, Exception) for result in results): self.debug("couldn't open cover") return diff --git a/homeassistant/components/zhong_hong/climate.py b/homeassistant/components/zhong_hong/climate.py index 68247537847..f20c9f7e328 100644 --- a/homeassistant/components/zhong_hong/climate.py +++ b/homeassistant/components/zhong_hong/climate.py @@ -95,7 +95,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): async def startup(): """Start hub socket after all climate entity is set up.""" nonlocal hub_is_initialized - if not all([device.is_initialized for device in devices]): + if not all(device.is_initialized for device in devices): return if hub_is_initialized: diff --git a/homeassistant/core.py b/homeassistant/core.py index b62dd1ee7d5..3483dc96069 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -153,6 +153,7 @@ def is_callback(func: Callable[..., Any]) -> bool: @enum.unique class HassJobType(enum.Enum): + # pylint: disable=invalid-name """Represent a job type.""" Coroutinefunction = 1 @@ -198,6 +199,7 @@ def _get_callable_job_type(target: Callable) -> HassJobType: class CoreState(enum.Enum): + # pylint: disable=invalid-name """Represent the current state of Home Assistant.""" not_running = "NOT_RUNNING" @@ -589,6 +591,7 @@ class Context: class EventOrigin(enum.Enum): + # pylint: disable=invalid-name """Represent the origin of an event.""" local = "LOCAL" diff --git a/homeassistant/helpers/typing.py b/homeassistant/helpers/typing.py index 279bc0f686f..ffc32efeb2a 100644 --- a/homeassistant/helpers/typing.py +++ b/homeassistant/helpers/typing.py @@ -20,6 +20,7 @@ QueryType = Any class UndefinedType(Enum): + # pylint: disable=invalid-name """Singleton type for use with not set sentinel values.""" _singleton = 0 diff --git a/requirements_test.txt b/requirements_test.txt index 12f215f177a..1f0a3c4dba2 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -10,8 +10,8 @@ jsonpickle==1.4.1 mock-open==1.4.0 mypy==0.812 pre-commit==2.10.1 -pylint==2.6.0 -astroid==2.4.2 +pylint==2.7.2 +astroid==2.5.1 pipdeptree==1.0.0 pylint-strict-informational==0.1 pytest-aiohttp==0.3.0