mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 02:07:54 +00:00
Update pylint (#47205)
This commit is contained in:
parent
cb94e7949b
commit
16dcbf1467
@ -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
|
||||
)
|
||||
)
|
||||
]
|
||||
|
@ -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"
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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}
|
||||
|
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -33,6 +33,7 @@ DEFAULT_HEATING_TYPE = "generic"
|
||||
|
||||
|
||||
class HeatingType(enum.Enum):
|
||||
# pylint: disable=invalid-name
|
||||
"""Possible options for heating type."""
|
||||
|
||||
generic = "generic"
|
||||
|
@ -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
|
||||
)
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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 = (
|
||||
|
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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"
|
||||
|
@ -20,6 +20,7 @@ QueryType = Any
|
||||
|
||||
|
||||
class UndefinedType(Enum):
|
||||
# pylint: disable=invalid-name
|
||||
"""Singleton type for use with not set sentinel values."""
|
||||
|
||||
_singleton = 0
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user