Update pylint (#47205)

This commit is contained in:
Marc Mueller 2021-03-01 09:09:01 +01:00 committed by GitHub
parent cb94e7949b
commit 16dcbf1467
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 50 additions and 52 deletions

View File

@ -111,7 +111,7 @@ class TrustedNetworksAuthProvider(AuthProvider):
if ( if (
user.id in user_list user.id in user_list
or any( or any(
[group.id in flattened_group_list for group in user.groups] group.id in flattened_group_list for group in user.groups
) )
) )
] ]

View File

@ -18,6 +18,7 @@ INTENTS_API_ENDPOINT = "/api/alexa"
class SpeechType(enum.Enum): class SpeechType(enum.Enum):
# pylint: disable=invalid-name
"""The Alexa speech types.""" """The Alexa speech types."""
plaintext = "PlainText" plaintext = "PlainText"
@ -28,6 +29,7 @@ SPEECH_MAPPINGS = {"plain": SpeechType.plaintext, "ssml": SpeechType.ssml}
class CardType(enum.Enum): class CardType(enum.Enum):
# pylint: disable=invalid-name
"""The Alexa card types.""" """The Alexa card types."""
simple = "Simple" simple = "Simple"

View File

@ -44,7 +44,7 @@ async def device_scan(identifier, loop, cache=None):
return True return True
if identifier == dev.name: if identifier == dev.name:
return True 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(): def _host_filter():
try: try:

View File

@ -127,7 +127,7 @@ async def async_setup_entry(
if ( if (
device_class == DEVICE_CLASS_MOTION device_class == DEVICE_CLASS_MOTION
and device_type is not None 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: # Special cases for Insteon Motion Sensors I & II:
# Some subnodes never report status until activated, so # 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.) # Other devices (incl Insteon.)
for device_class in [*BINARY_SENSOR_DEVICE_TYPES_ISY]: for device_class in [*BINARY_SENSOR_DEVICE_TYPES_ISY]:
if any( if any(
[
device_type.startswith(t) device_type.startswith(t)
for t in set(BINARY_SENSOR_DEVICE_TYPES_ISY[device_class]) for t in set(BINARY_SENSOR_DEVICE_TYPES_ISY[device_class])
]
): ):
return device_class, device_type return device_class, device_type
return (None, device_type) return (None, device_type)

View File

@ -97,10 +97,8 @@ def _check_for_insteon_type(
platforms = SUPPORTED_PLATFORMS if not single_platform else [single_platform] platforms = SUPPORTED_PLATFORMS if not single_platform else [single_platform]
for platform in platforms: for platform in platforms:
if any( if any(
[
device_type.startswith(t) device_type.startswith(t)
for t in set(NODE_FILTERS[platform][FILTER_INSTEON_TYPE]) for t in set(NODE_FILTERS[platform][FILTER_INSTEON_TYPE])
]
): ):
# Hacky special-cases for certain devices with different platforms # 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] platforms = SUPPORTED_PLATFORMS if not single_platform else [single_platform]
for platform in platforms: for platform in platforms:
if any( if any(
[
device_type.startswith(t) device_type.startswith(t)
for t in set(NODE_FILTERS[platform][FILTER_ZWAVE_CAT]) for t in set(NODE_FILTERS[platform][FILTER_ZWAVE_CAT])
]
): ):
hass_isy_data[ISY994_NODES][platform].append(node) hass_isy_data[ISY994_NODES][platform].append(node)

View File

@ -24,6 +24,7 @@ CONF_RESET_AFTER = "reset_after"
class ColorTempModes(Enum): class ColorTempModes(Enum):
# pylint: disable=invalid-name
"""Color temperature modes for config validation.""" """Color temperature modes for config validation."""
ABSOLUTE = "DPT-7.600" ABSOLUTE = "DPT-7.600"
@ -31,6 +32,7 @@ class ColorTempModes(Enum):
class SupportedPlatforms(Enum): class SupportedPlatforms(Enum):
# pylint: disable=invalid-name
"""Supported platforms.""" """Supported platforms."""
BINARY_SENSOR = "binary_sensor" BINARY_SENSOR = "binary_sensor"

View File

@ -4,7 +4,7 @@ from __future__ import annotations
import asyncio import asyncio
import logging import logging
import os import os
from typing import Any, List, Optional, TypedDict from typing import Any, TypedDict
from urllib.parse import urlparse from urllib.parse import urlparse
from aiohttp import BasicAuth, FormData from aiohttp import BasicAuth, FormData
@ -106,14 +106,14 @@ class MessageT(TypedDict, total=False):
username: str # Optional key username: str # Optional key
icon_url: str # Optional key icon_url: str # Optional key
icon_emoji: str # Optional key icon_emoji: str # Optional key
blocks: List[Any] # Optional key blocks: list[Any] # Optional key
async def async_get_service( async def async_get_service(
hass: HomeAssistantType, hass: HomeAssistantType,
config: ConfigType, config: ConfigType,
discovery_info: Optional[DiscoveryInfoType] = None, discovery_info: DiscoveryInfoType | None = None,
) -> Optional[SlackNotificationService]: ) -> SlackNotificationService | None:
"""Set up the Slack notification service.""" """Set up the Slack notification service."""
session = aiohttp_client.async_get_clientsession(hass) session = aiohttp_client.async_get_clientsession(hass)
client = WebClient(token=config[CONF_API_KEY], run_async=True, session=session) 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 @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.""" """Remove any # symbols from a channel list."""
return [channel.lstrip("#") for channel in channel_list] return [channel.lstrip("#") for channel in channel_list]
@ -174,8 +174,8 @@ class SlackNotificationService(BaseNotificationService):
hass: HomeAssistantType, hass: HomeAssistantType,
client: WebClient, client: WebClient,
default_channel: str, default_channel: str,
username: Optional[str], username: str | None,
icon: Optional[str], icon: str | None,
) -> None: ) -> None:
"""Initialize.""" """Initialize."""
self._client = client self._client = client
@ -187,9 +187,9 @@ class SlackNotificationService(BaseNotificationService):
async def _async_send_local_file_message( async def _async_send_local_file_message(
self, self,
path: str, path: str,
targets: List[str], targets: list[str],
message: str, message: str,
title: Optional[str], title: str | None,
) -> None: ) -> None:
"""Upload a local file (with message) to Slack.""" """Upload a local file (with message) to Slack."""
if not self._hass.config.is_allowed_path(path): if not self._hass.config.is_allowed_path(path):
@ -213,12 +213,12 @@ class SlackNotificationService(BaseNotificationService):
async def _async_send_remote_file_message( async def _async_send_remote_file_message(
self, self,
url: str, url: str,
targets: List[str], targets: list[str],
message: str, message: str,
title: Optional[str], title: str | None,
*, *,
username: Optional[str] = None, username: str | None = None,
password: Optional[str] = None, password: str | None = None,
) -> None: ) -> None:
"""Upload a remote file (with message) to Slack. """Upload a remote file (with message) to Slack.
@ -263,13 +263,13 @@ class SlackNotificationService(BaseNotificationService):
async def _async_send_text_only_message( async def _async_send_text_only_message(
self, self,
targets: List[str], targets: list[str],
message: str, message: str,
title: Optional[str], title: str | None,
*, *,
username: Optional[str] = None, username: str | None = None,
icon: Optional[str] = None, icon: str | None = None,
blocks: Optional[Any] = None, blocks: Any | None = None,
) -> None: ) -> None:
"""Send a text-only message.""" """Send a text-only message."""
message_dict: MessageT = {"link_names": True, "text": message} message_dict: MessageT = {"link_names": True, "text": message}

View File

@ -157,7 +157,7 @@ class Stream:
def check_idle(self): def check_idle(self):
"""Reset access token if all providers are idle.""" """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 self.access_token = None
def start(self): def start(self):

View File

@ -330,7 +330,7 @@ async def async_setup(hass, config):
attribute_templ = data.get(attribute) attribute_templ = data.get(attribute)
if attribute_templ: if attribute_templ:
if any( 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 data[attribute] = attribute_templ
else: else:

View File

@ -470,7 +470,7 @@ class UniversalMediaPlayer(MediaPlayerEntity):
if SERVICE_MEDIA_PREVIOUS_TRACK in self._cmds: if SERVICE_MEDIA_PREVIOUS_TRACK in self._cmds:
flags |= SUPPORT_PREVIOUS_TRACK 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 flags |= SUPPORT_VOLUME_STEP
if SERVICE_VOLUME_SET in self._cmds: if SERVICE_VOLUME_SET in self._cmds:
flags |= SUPPORT_VOLUME_SET flags |= SUPPORT_VOLUME_SET

View File

@ -33,6 +33,7 @@ DEFAULT_HEATING_TYPE = "generic"
class HeatingType(enum.Enum): class HeatingType(enum.Enum):
# pylint: disable=invalid-name
"""Possible options for heating type.""" """Possible options for heating type."""
generic = "generic" generic = "generic"

View File

@ -1070,11 +1070,9 @@ def get_data_manager_by_webhook_id(
def get_all_data_managers(hass: HomeAssistant) -> Tuple[DataManager, ...]: def get_all_data_managers(hass: HomeAssistant) -> Tuple[DataManager, ...]:
"""Get all configured data managers.""" """Get all configured data managers."""
return tuple( return tuple(
[
config_entry_data[const.DATA_MANAGER] config_entry_data[const.DATA_MANAGER]
for config_entry_data in hass.data[const.DOMAIN].values() for config_entry_data in hass.data[const.DOMAIN].values()
if const.DATA_MANAGER in config_entry_data 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, ...]: def get_platform_attributes(platform: str) -> Tuple[WithingsAttribute, ...]:
"""Get withings attributes used for a specific platform.""" """Get withings attributes used for a specific platform."""
return tuple( return tuple(
[ attribute for attribute in WITHINGS_ATTRIBUTES if attribute.platform == platform
attribute
for attribute in WITHINGS_ATTRIBUTES
if attribute.platform == platform
]
) )

View File

@ -91,7 +91,7 @@ class AnalogOutput(ZigbeeChannel):
self.error("Could not set value: %s", ex) self.error("Could not set value: %s", ex)
return False return False
if isinstance(res, list) and all( 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 True
return False return False

View File

@ -434,7 +434,7 @@ class ThermostatChannel(ZigbeeChannel):
if not isinstance(res, list): if not isinstance(res, list):
return False 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) @registries.ZIGBEE_CHANNEL_REGISTRY.register(hvac.UserInterface.cluster_id)

View File

@ -176,6 +176,7 @@ POWER_BATTERY_OR_UNKNOWN = "Battery or Unknown"
class RadioType(enum.Enum): class RadioType(enum.Enum):
# pylint: disable=invalid-name
"""Possible options for radio type.""" """Possible options for radio type."""
znp = ( znp = (

View File

@ -301,7 +301,7 @@ class KeenVent(Shade):
self._on_off_channel.on(), self._on_off_channel.on(),
] ]
results = await asyncio.gather(*tasks, return_exceptions=True) 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") self.debug("couldn't open cover")
return return

View File

@ -95,7 +95,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
async def startup(): async def startup():
"""Start hub socket after all climate entity is set up.""" """Start hub socket after all climate entity is set up."""
nonlocal hub_is_initialized 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 return
if hub_is_initialized: if hub_is_initialized:

View File

@ -153,6 +153,7 @@ def is_callback(func: Callable[..., Any]) -> bool:
@enum.unique @enum.unique
class HassJobType(enum.Enum): class HassJobType(enum.Enum):
# pylint: disable=invalid-name
"""Represent a job type.""" """Represent a job type."""
Coroutinefunction = 1 Coroutinefunction = 1
@ -198,6 +199,7 @@ def _get_callable_job_type(target: Callable) -> HassJobType:
class CoreState(enum.Enum): class CoreState(enum.Enum):
# pylint: disable=invalid-name
"""Represent the current state of Home Assistant.""" """Represent the current state of Home Assistant."""
not_running = "NOT_RUNNING" not_running = "NOT_RUNNING"
@ -589,6 +591,7 @@ class Context:
class EventOrigin(enum.Enum): class EventOrigin(enum.Enum):
# pylint: disable=invalid-name
"""Represent the origin of an event.""" """Represent the origin of an event."""
local = "LOCAL" local = "LOCAL"

View File

@ -20,6 +20,7 @@ QueryType = Any
class UndefinedType(Enum): class UndefinedType(Enum):
# pylint: disable=invalid-name
"""Singleton type for use with not set sentinel values.""" """Singleton type for use with not set sentinel values."""
_singleton = 0 _singleton = 0

View File

@ -10,8 +10,8 @@ jsonpickle==1.4.1
mock-open==1.4.0 mock-open==1.4.0
mypy==0.812 mypy==0.812
pre-commit==2.10.1 pre-commit==2.10.1
pylint==2.6.0 pylint==2.7.2
astroid==2.4.2 astroid==2.5.1
pipdeptree==1.0.0 pipdeptree==1.0.0
pylint-strict-informational==0.1 pylint-strict-informational==0.1
pytest-aiohttp==0.3.0 pytest-aiohttp==0.3.0