Update pylint to 2.10.1 (#54963)

* Update pylint to 2.10.0

* useless-suppression

* Consider-using-tuple

* Apply suggestions from code review

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Use dict.items()

* Add pylint disable

* Use pylint 2.10.1

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
Marc Mueller 2021-08-21 10:41:23 +02:00 committed by GitHub
parent 5142ebfcc2
commit 69e413ac1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 11 additions and 33 deletions

View file

@ -157,7 +157,7 @@ class BraviaTVOptionsFlowHandler(config_entries.OptionsFlow):
content_mapping = await self.hass.async_add_executor_job( content_mapping = await self.hass.async_add_executor_job(
braviarc.load_source_list braviarc.load_source_list
) )
self.source_list = {item: item for item in [*content_mapping]} self.source_list = {item: item for item in content_mapping}
return await self.async_step_user() return await self.async_step_user()
async def async_step_user( async def async_step_user(

View file

@ -69,8 +69,6 @@ class TurboJPEGSingleton:
def __init__(self) -> None: def __init__(self) -> None:
"""Try to create TurboJPEG only once.""" """Try to create TurboJPEG only once."""
# pylint: disable=unused-private-member
# https://github.com/PyCQA/pylint/issues/4681
try: try:
# TurboJPEG checks for libturbojpeg # TurboJPEG checks for libturbojpeg
# when its created, but it imports # when its created, but it imports

View file

@ -504,7 +504,6 @@ class ClimateEntity(Entity):
async def async_turn_on(self) -> None: async def async_turn_on(self) -> None:
"""Turn the entity on.""" """Turn the entity on."""
if hasattr(self, "turn_on"): if hasattr(self, "turn_on"):
# pylint: disable=no-member
await self.hass.async_add_executor_job(self.turn_on) # type: ignore[attr-defined] await self.hass.async_add_executor_job(self.turn_on) # type: ignore[attr-defined]
return return
@ -518,7 +517,6 @@ class ClimateEntity(Entity):
async def async_turn_off(self) -> None: async def async_turn_off(self) -> None:
"""Turn the entity off.""" """Turn the entity off."""
if hasattr(self, "turn_off"): if hasattr(self, "turn_off"):
# pylint: disable=no-member
await self.hass.async_add_executor_job(self.turn_off) # type: ignore[attr-defined] await self.hass.async_add_executor_job(self.turn_off) # type: ignore[attr-defined]
return return

View file

@ -184,20 +184,14 @@ def _detect_device_type_and_class(node: Group | Node) -> (str, str):
# Z-Wave Devices: # Z-Wave Devices:
if node.protocol == PROTO_ZWAVE: if node.protocol == PROTO_ZWAVE:
device_type = f"Z{node.zwave_props.category}" device_type = f"Z{node.zwave_props.category}"
for device_class in [*BINARY_SENSOR_DEVICE_TYPES_ZWAVE]: for device_class, values in BINARY_SENSOR_DEVICE_TYPES_ZWAVE.items():
if ( if node.zwave_props.category in values:
node.zwave_props.category
in BINARY_SENSOR_DEVICE_TYPES_ZWAVE[device_class]
):
return device_class, device_type return device_class, device_type
return (None, device_type) return (None, device_type)
# Other devices (incl Insteon.) # Other devices (incl Insteon.)
for device_class in [*BINARY_SENSOR_DEVICE_TYPES_ISY]: for device_class, values in BINARY_SENSOR_DEVICE_TYPES_ISY.items():
if any( if any(device_type.startswith(t) for t in values):
device_type.startswith(t)
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

@ -529,7 +529,7 @@ class Profile:
transition: int | None = None transition: int | None = None
hs_color: tuple[float, float] | None = dataclasses.field(init=False) hs_color: tuple[float, float] | None = dataclasses.field(init=False)
SCHEMA = vol.Schema( # pylint: disable=invalid-name SCHEMA = vol.Schema(
vol.Any( vol.Any(
vol.ExactSequence( vol.ExactSequence(
( (

View file

@ -813,7 +813,6 @@ class MediaPlayerEntity(Entity):
async def async_toggle(self): async def async_toggle(self):
"""Toggle the power on the media player.""" """Toggle the power on the media player."""
if hasattr(self, "toggle"): if hasattr(self, "toggle"):
# pylint: disable=no-member
await self.hass.async_add_executor_job(self.toggle) await self.hass.async_add_executor_job(self.toggle)
return return
@ -828,7 +827,6 @@ class MediaPlayerEntity(Entity):
This method is a coroutine. This method is a coroutine.
""" """
if hasattr(self, "volume_up"): if hasattr(self, "volume_up"):
# pylint: disable=no-member
await self.hass.async_add_executor_job(self.volume_up) await self.hass.async_add_executor_job(self.volume_up)
return return
@ -841,7 +839,6 @@ class MediaPlayerEntity(Entity):
This method is a coroutine. This method is a coroutine.
""" """
if hasattr(self, "volume_down"): if hasattr(self, "volume_down"):
# pylint: disable=no-member
await self.hass.async_add_executor_job(self.volume_down) await self.hass.async_add_executor_job(self.volume_down)
return return
@ -851,7 +848,6 @@ class MediaPlayerEntity(Entity):
async def async_media_play_pause(self): async def async_media_play_pause(self):
"""Play or pause the media player.""" """Play or pause the media player."""
if hasattr(self, "media_play_pause"): if hasattr(self, "media_play_pause"):
# pylint: disable=no-member
await self.hass.async_add_executor_job(self.media_play_pause) await self.hass.async_add_executor_job(self.media_play_pause)
return return

View file

@ -201,7 +201,7 @@ class NFAndroidTVNotificationService(BaseNotificationService):
if local_path is not None: if local_path is not None:
# Check whether path is whitelisted in configuration.yaml # Check whether path is whitelisted in configuration.yaml
if self.is_allowed_path(local_path): if self.is_allowed_path(local_path):
return open(local_path, "rb") # pylint: disable=consider-using-with return open(local_path, "rb")
_LOGGER.warning("'%s' is not secure to load data from!", local_path) _LOGGER.warning("'%s' is not secure to load data from!", local_path)
else: else:
_LOGGER.warning("Neither URL nor local path found in params!") _LOGGER.warning("Neither URL nor local path found in params!")

View file

@ -183,7 +183,6 @@ class BaseNotificationService:
if hasattr(self, "targets"): if hasattr(self, "targets"):
stale_targets = set(self.registered_targets) stale_targets = set(self.registered_targets)
# pylint: disable=no-member
for name, target in self.targets.items(): # type: ignore for name, target in self.targets.items(): # type: ignore
target_name = slugify(f"{self._target_service_name_prefix}_{name}") target_name = slugify(f"{self._target_service_name_prefix}_{name}")
if target_name in stale_targets: if target_name in stale_targets:

View file

@ -68,7 +68,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
@callback @callback
def _async_setup_shared_data(hass: HomeAssistant): def _async_setup_shared_data(hass: HomeAssistant):
"""Create shared data for platform config and rest coordinators.""" """Create shared data for platform config and rest coordinators."""
hass.data[DOMAIN] = {key: [] for key in [REST_DATA, *COORDINATOR_AWARE_PLATFORMS]} hass.data[DOMAIN] = {key: [] for key in (REST_DATA, *COORDINATOR_AWARE_PLATFORMS)}
async def _async_process_config(hass, config) -> bool: async def _async_process_config(hass, config) -> bool:

View file

@ -104,7 +104,7 @@ async def discover_devices(hass, hass_config):
async with async_timeout.timeout(SCAN_INTERVAL.total_seconds()): async with async_timeout.timeout(SCAN_INTERVAL.total_seconds()):
channels = { channels = {
channel["id"]: channel channel["id"]: channel
for channel in await server.get_channels( for channel in await server.get_channels( # pylint: disable=cell-var-from-loop
include=["iodevice", "state", "connected"] include=["iodevice", "state", "connected"]
) )
} }

View file

@ -111,8 +111,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
vol.Lower, vol.Lower,
vol.In( vol.In(
[ [
# https://github.com/PyCQA/pylint/issues/2062
# pylint: disable=no-member
LockState.UNLOCKED.name.lower(), LockState.UNLOCKED.name.lower(),
LockState.LOCKED_IN.name.lower(), LockState.LOCKED_IN.name.lower(),
LockState.LOCKED_OUT.name.lower(), LockState.LOCKED_OUT.name.lower(),
@ -156,8 +154,6 @@ class SurePetcareAPI:
async def set_lock_state(self, flap_id: int, state: str) -> None: async def set_lock_state(self, flap_id: int, state: str) -> None:
"""Update the lock state of a flap.""" """Update the lock state of a flap."""
# https://github.com/PyCQA/pylint/issues/2062
# pylint: disable=no-member
if state == LockState.UNLOCKED.name.lower(): if state == LockState.UNLOCKED.name.lower():
await self.surepy.sac.unlock(flap_id) await self.surepy.sac.unlock(flap_id)
elif state == LockState.LOCKED_IN.name.lower(): elif state == LockState.LOCKED_IN.name.lower():

View file

@ -286,7 +286,7 @@ def load_data(
_LOGGER.warning("Can't load data in %s after %s retries", url, retry_num) _LOGGER.warning("Can't load data in %s after %s retries", url, retry_num)
elif filepath is not None: elif filepath is not None:
if hass.config.is_allowed_path(filepath): if hass.config.is_allowed_path(filepath):
return open(filepath, "rb") # pylint: disable=consider-using-with return open(filepath, "rb")
_LOGGER.warning("'%s' are not secure to load data from!", filepath) _LOGGER.warning("'%s' are not secure to load data from!", filepath)
else: else:

View file

@ -40,7 +40,6 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA, extra=vol.ALLOW_EXTRA,
) )
# pylint: disable=no-member
PROFILE_TO_STR_SETTABLE = { PROFILE_TO_STR_SETTABLE = {
VALLOX_PROFILE.HOME: "Home", VALLOX_PROFILE.HOME: "Home",
VALLOX_PROFILE.AWAY: "Away", VALLOX_PROFILE.AWAY: "Away",
@ -50,7 +49,6 @@ PROFILE_TO_STR_SETTABLE = {
STR_TO_PROFILE = {v: k for (k, v) in PROFILE_TO_STR_SETTABLE.items()} STR_TO_PROFILE = {v: k for (k, v) in PROFILE_TO_STR_SETTABLE.items()}
# pylint: disable=no-member
PROFILE_TO_STR_REPORTABLE = { PROFILE_TO_STR_REPORTABLE = {
**{VALLOX_PROFILE.NONE: "None", VALLOX_PROFILE.EXTRA: "Extra"}, **{VALLOX_PROFILE.NONE: "None", VALLOX_PROFILE.EXTRA: "Extra"},
**PROFILE_TO_STR_SETTABLE, **PROFILE_TO_STR_SETTABLE,

View file

@ -622,7 +622,6 @@ class Entity(ABC):
await self.parallel_updates.acquire() await self.parallel_updates.acquire()
try: try:
# pylint: disable=no-member
if hasattr(self, "async_update"): if hasattr(self, "async_update"):
task = self.hass.async_create_task(self.async_update()) # type: ignore task = self.hass.async_create_task(self.async_update()) # type: ignore
elif hasattr(self, "update"): elif hasattr(self, "update"):

View file

@ -13,7 +13,7 @@ jsonpickle==1.4.1
mock-open==1.4.0 mock-open==1.4.0
mypy==0.910 mypy==0.910
pre-commit==2.14.0 pre-commit==2.14.0
pylint==2.9.5 pylint==2.10.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