Lint config cleanups (#28864)

* Remove bunch of unneeded lint exclusions

* Use symbolic names instead of identifiers in pylint disables

* Tighten scope of some pylint disables
This commit is contained in:
Ville Skyttä 2019-11-26 08:40:08 +02:00 committed by Paulus Schoutsen
parent afaa464142
commit 99c7608fb4
77 changed files with 92 additions and 126 deletions

View file

@ -272,7 +272,6 @@ def cmdline() -> List[str]:
async def setup_and_run_hass(config_dir: str, args: argparse.Namespace) -> int:
"""Set up HASS and run."""
# pylint: disable=redefined-outer-name
from homeassistant import bootstrap, core
hass = core.HomeAssistant()

View file

@ -42,7 +42,7 @@ class MultiFactorAuthModule:
self.config = config
@property
def id(self) -> str: # pylint: disable=invalid-name
def id(self) -> str:
"""Return id of the auth module.
Default is same as type

View file

@ -58,15 +58,12 @@ class PolicyPermissions(AbstractPermissions):
def __eq__(self, other: Any) -> bool:
"""Equals check."""
# pylint: disable=protected-access
return isinstance(other, PolicyPermissions) and other._policy == self._policy
class _OwnerPermissions(AbstractPermissions):
"""Owner permissions."""
# pylint: disable=no-self-use
def access_all_entities(self, key: str) -> bool:
"""Check if we have a certain access to all entities."""
return True

View file

@ -48,7 +48,7 @@ class AuthProvider:
self.config = config
@property
def id(self) -> Optional[str]: # pylint: disable=invalid-name
def id(self) -> Optional[str]:
"""Return id of the auth provider.
Optional, can be None.

View file

@ -10,7 +10,7 @@ from homeassistant import config_entries
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback
from .const import DOMAIN, DEFAULT_CACHEDB # pylint: disable=W0611
from .const import DOMAIN, DEFAULT_CACHEDB # pylint: disable=unused-import
CONF_POLLING = "polling"

View file

@ -101,7 +101,6 @@ async def async_unload_entry(hass, entry):
return await hass.data[DOMAIN].async_unload_entry(entry)
# pylint: disable=no-self-use
class AlarmControlPanel(Entity):
"""An abstract class for alarm control devices."""

View file

@ -64,7 +64,7 @@ class DateTimeJSONEncoder(json.JSONEncoder):
Additionally add encoding for datetime objects as isoformat.
"""
def default(self, o): # pylint: disable=E0202
def default(self, o): # pylint: disable=method-hidden
"""Implement encoding logic."""
if isinstance(o, datetime):
return o.isoformat()

View file

@ -36,7 +36,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the brunt platform."""
# pylint: disable=no-name-in-module
username = config[CONF_USERNAME]
password = config[CONF_PASSWORD]

View file

@ -150,7 +150,6 @@ class CastStatusListener:
chromecast.register_status_listener(self)
chromecast.socket_client.media_controller.register_status_listener(self)
chromecast.register_connection_listener(self)
# pylint: disable=protected-access
if cast_device._cast_info.is_audio_group:
self._mz_mgr.add_multizone(chromecast)
else:

View file

@ -306,7 +306,6 @@ class MarkerSensor(Entity):
self._attributes = self.data.attributes
# pylint: disable=no-name-in-module
class CupsData:
"""Get the latest data from CUPS and update the state."""

View file

@ -28,7 +28,7 @@ NOTIFICATION_TITLE = "myLeviton Decora Setup"
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Decora WiFi platform."""
# pylint: disable=import-error, no-name-in-module
# pylint: disable=import-error
from decora_wifi import DecoraWiFiSession
from decora_wifi.models.person import Person
from decora_wifi.models.residential_account import ResidentialAccount

View file

@ -264,7 +264,6 @@ class DoorBirdRequestView(HomeAssistantView):
name = API_URL[1:].replace("/", ":")
extra_urls = [API_URL + "/{event}"]
# pylint: disable=no-self-use
async def get(self, request, event):
"""Respond to requests from the device."""
from aiohttp import web

View file

@ -84,7 +84,6 @@ class EnOceanDevice(Entity):
def value_changed(self, packet):
"""Update the internal state of the device when a packet arrives."""
# pylint: disable=no-self-use
def send_command(self, data, optional, packet_type):
"""Send a command via the EnOcean dongle."""
from enocean.protocol.packet import Packet

View file

@ -190,7 +190,7 @@ class EQ3BTSmartThermostat(ClimateDevice):
def update(self):
"""Update the data from the thermostat."""
# pylint: disable=import-error,no-name-in-module
# pylint: disable=import-error
from bluepy.btle import BTLEException
try:

View file

@ -81,7 +81,6 @@ class EsphomeFan(EsphomeEntity, FanEntity):
data["speed"] = _fan_speeds.from_hass(speed)
await self._client.fan_command(**data)
# pylint: disable=arguments-differ
async def async_turn_off(self, **kwargs) -> None:
"""Turn off the fan."""
await self._client.fan_command(key=self._static_info.key, state=False)

View file

@ -237,11 +237,7 @@ class EvoBroker:
loc_idx = params[CONF_LOCATION_IDX]
self.config = client.installation_info[loc_idx][GWS][0][TCS][0]
self.tcs = (
client.locations[loc_idx] # pylint: disable=protected-access
._gateways[0]
._control_systems[0]
)
self.tcs = client.locations[loc_idx]._gateways[0]._control_systems[0]
self.temps = None
async def save_auth_tokens(self) -> None:

View file

@ -77,7 +77,6 @@ class AbstractConfig:
@property
def should_report_state(self):
"""Return if states should be proactively reported."""
# pylint: disable=no-self-use
return False
@property

View file

@ -102,7 +102,6 @@ class GoogleConfig(AbstractConfig):
@property
def should_report_state(self):
"""Return if states should be proactively reported."""
# pylint: disable=no-self-use
return self._config.get(CONF_REPORT_STATE)
def should_expose(self, state) -> bool:

View file

@ -57,7 +57,9 @@ def setup(hass: HomeAssistant, yaml_config: Dict[str, Any]):
service_principal_path
)
topic_path = publisher.topic_path(project_id, topic_name) # pylint: disable=E1101
topic_path = publisher.topic_path( # pylint: disable=no-member
project_id, topic_name
)
encoder = DateTimeJSONEncoder()
@ -87,7 +89,7 @@ class DateTimeJSONEncoder(json.JSONEncoder):
Additionally add encoding for datetime objects as isoformat.
"""
def default(self, o): # pylint: disable=E0202
def default(self, o): # pylint: disable=method-hidden
"""Implement encoding logic."""
if isinstance(o, datetime.datetime):
return o.isoformat()

View file

@ -656,7 +656,6 @@ class Group(Entity):
if gr_on is None:
return
# pylint: disable=too-many-boolean-expressions
if tr_state is None or (
(gr_state == gr_on and tr_state.state == gr_off)
or (gr_state == gr_off and tr_state.state == gr_on)

View file

@ -316,7 +316,6 @@ class HarmonyRemote(remote.RemoteDevice):
except aioexc.TimeOut:
_LOGGER.error("%s: Powering off timed-out", self.name)
# pylint: disable=arguments-differ
async def async_send_command(self, command, **kwargs):
"""Send a list of commands to one device."""
_LOGGER.debug("%s: Send Command", self.name)

View file

@ -362,8 +362,7 @@ class HomeKit:
return
self.status = STATUS_WAIT
# pylint: disable=unused-import
from . import ( # noqa: F401
from . import ( # noqa: F401 pylint: disable=unused-import
type_covers,
type_fans,
type_lights,

View file

@ -109,7 +109,6 @@ class HomeKitEntity(Entity):
setup_fn = getattr(self, f"_setup_{setup_fn_name}", None)
if not setup_fn:
return
# pylint: disable=not-callable
setup_fn(char)
@callback
@ -132,7 +131,6 @@ class HomeKitEntity(Entity):
if not update_fn:
continue
# pylint: disable=not-callable
update_fn(result["value"])
self.async_write_ha_state()

View file

@ -160,9 +160,7 @@ class HoneywellUSThermostat(ClimateDevice):
self._username = username
self._password = password
_LOGGER.debug(
"latestData = %s ", device._data # pylint: disable=protected-access
)
_LOGGER.debug("latestData = %s ", device._data)
# not all honeywell HVACs support all modes
mappings = [v for k, v in HVAC_MODE_TO_HW_MODE.items() if device.raw_ui_data[k]]
@ -174,13 +172,13 @@ class HoneywellUSThermostat(ClimateDevice):
| SUPPORT_TARGET_TEMPERATURE_RANGE
)
if device._data["canControlHumidification"]: # pylint: disable=protected-access
if device._data["canControlHumidification"]:
self._supported_features |= SUPPORT_TARGET_HUMIDITY
if device.raw_ui_data["SwitchEmergencyHeatAllowed"]:
self._supported_features |= SUPPORT_AUX_HEAT
if not device._data["hasFan"]: # pylint: disable=protected-access
if not device._data["hasFan"]:
return
# not all honeywell fans support all modes

View file

@ -13,8 +13,6 @@ CACHE_TIME = 31 * 86400 # = 1 month
CACHE_HEADERS = {hdrs.CACHE_CONTROL: f"public, max-age={CACHE_TIME}"}
# https://github.com/PyCQA/astroid/issues/633
# pylint: disable=duplicate-bases
class CachingStaticResource(StaticResource):
"""Static Resource handler that will add cache headers."""

View file

@ -87,7 +87,6 @@ async def async_setup(hass, config):
time = call.data.get(ATTR_TIME)
date = call.data.get(ATTR_DATE)
dttm = call.data.get(ATTR_DATETIME)
# pylint: disable=too-many-boolean-expressions
if (
dttm
and (date or time)

View file

@ -110,7 +110,6 @@ class ISYBinarySensorDevice(ISYDevice, BinarySensorDevice):
self._negative_node = None
self._heartbeat_device = None
self._device_class_from_type = _detect_device_type(self._node)
# pylint: disable=protected-access
if _is_val_unknown(self._node.status._val):
self._computed_state = None
self._status_was_unknown = True

View file

@ -148,7 +148,6 @@ async def handle_webhook(
blocking=True,
context=context,
)
# noqa: E722 pylint: disable=broad-except
except (vol.Invalid, ServiceNotFound, Exception) as ex:
_LOGGER.error(
"Error when calling service during mobile_app "
@ -174,7 +173,6 @@ async def handle_webhook(
tpl = item[ATTR_TEMPLATE]
attach(hass, tpl)
resp[key] = tpl.async_render(item.get(ATTR_TEMPLATE_VARIABLES))
# noqa: E722 pylint: disable=broad-except
except TemplateError as ex:
resp[key] = {"error": str(ex)}

View file

@ -335,7 +335,6 @@ MQTT_PUBLISH_SCHEMA = vol.Schema(
)
# pylint: disable=invalid-name
SubscribePayloadType = Union[str, bytes] # Only bytes if encoding is None

View file

@ -3,7 +3,6 @@ from typing import Union, Callable
import attr
# pylint: disable=invalid-name
PublishPayloadType = Union[str, bytes, int, float, None]

View file

@ -192,7 +192,7 @@ class PlexServer:
@property
def url_in_use(self):
"""Return URL used for connected Plex server."""
return self._plex_server._baseurl # pylint: disable=W0212
return self._plex_server._baseurl # pylint: disable=protected-access
@property
def use_episode_art(self):

View file

@ -147,7 +147,6 @@ def execute(hass, filename, source, data=None):
def protected_getattr(obj, name, default=None):
"""Restricted method to get attributes."""
# pylint: disable=too-many-boolean-expressions
if name.startswith("async_"):
raise ScriptError("Not allowed to access async methods")
if (

View file

@ -284,7 +284,6 @@ class RachioWebhookView(HomeAssistantView):
url = WEBHOOK_PATH
name = url[1:].replace("/", ":")
# pylint: disable=no-self-use
@asyncio.coroutine
async def post(self, request) -> web.Response:
"""Handle webhook calls from the server."""

View file

@ -75,7 +75,7 @@ def _setup_controller(hass, controller_config, config):
position = len(hass.data[DATA_RAINBIRD])
try:
controller.get_serial_number()
except Exception as exc: # pylint: disable=W0703
except Exception as exc: # pylint: disable=broad-except
_LOGGER.error("Unable to setup controller: %s", exc)
return False
hass.data[DATA_RAINBIRD].append(controller)

View file

@ -28,7 +28,7 @@ def session_scope(*, hass=None, session=None):
if session.transaction:
need_rollback = True
session.commit()
except Exception as err: # pylint: disable=broad-except
except Exception as err:
_LOGGER.error("Error executing query: %s", err)
if need_rollback:
session.rollback()

View file

@ -207,7 +207,7 @@ class ScriptEntity(ToggleEntity):
)
try:
await self.script.async_run(kwargs.get(ATTR_VARIABLES), context)
except Exception as err: # pylint: disable=broad-except
except Exception as err:
self.script.async_log_exception(
_LOGGER, f"Error executing script {self.entity_id}", err
)

View file

@ -43,7 +43,6 @@ SUPPORTED_FEATURES = (
)
# pylint: disable=unused-argument
async def async_setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up a media player entity for a Sisyphus table."""
host = discovery_info[CONF_HOST]

View file

@ -1056,7 +1056,6 @@ class SonosEntity(MediaPlayerDevice):
def restore(self):
"""Restore a snapshotted state to a player."""
try:
# pylint: disable=protected-access
self._soco_snapshot.restore()
except (TypeError, AttributeError, SoCoException) as ex:
# Can happen if restoring a coordinator onto a current slave

View file

@ -2,7 +2,7 @@
from datetime import timedelta
import logging
# pylint: disable=import-error, no-member, no-value-for-parameter
# pylint: disable=import-error, no-member
import switchmate
import voluptuous as vol

View file

@ -44,7 +44,7 @@ async def _info_wrapper(hass, info_callback):
return await info_callback(hass)
except asyncio.TimeoutError:
return {"error": "Fetching info timed out"}
except Exception as err: # pylint: disable=W0703
except Exception as err: # pylint: disable=broad-except
_LOGGER.exception("Error fetching info")
return {"error": str(err)}

View file

@ -55,7 +55,7 @@ def message_handler(handler):
"""Initialize the messages handler instance."""
super().__init__(handler)
def check_update(self, update): # pylint: disable=no-self-use
def check_update(self, update):
"""Check is update valid."""
return isinstance(update, Update)

View file

@ -104,8 +104,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
try:
# Display warning that PIL will be used if no OpenCV is found.
# pylint: disable=unused-import,unused-variable
import cv2 # noqa: F401
import cv2 # noqa: F401 pylint: disable=unused-import
except ImportError:
_LOGGER.warning(
"No OpenCV library found. TensorFlow will process image with "

View file

@ -162,7 +162,6 @@ class Timer(RestoreEntity):
event = EVENT_TIMER_RESTARTED
self._state = STATUS_ACTIVE
# pylint: disable=redefined-outer-name
start = dt_util.utcnow()
if self._remaining and newduration is None:
self._end = start + self._remaining

View file

@ -139,7 +139,7 @@ class ToonData:
"""Update all Toon data and notify entities."""
# Ignore the TTL meganism from client library
# It causes a lots of issues, hence we take control over caching
self._toon._clear_cache() # pylint: disable=W0212
self._toon._clear_cache() # pylint: disable=protected-access
# Gather data from client library (single API call)
self.gas = self._toon.gas

View file

@ -2,7 +2,7 @@
import asyncio
from datetime import timedelta
# pylint: disable=import-error,no-name-in-module
# pylint: disable=import-error
from distutils.version import StrictVersion
import json
import logging

View file

@ -150,7 +150,6 @@ class Device:
async def async_get_total_packets_received(self):
"""Get total packets received."""
# pylint: disable=invalid-name
return await self._igd_device.async_get_total_packets_received()
async def async_get_total_packets_sent(self):

View file

@ -37,7 +37,6 @@ def set_arm_state(state, code=None):
while "result" not in transaction:
sleep(0.5)
transaction = hub.session.get_arm_state_transaction(transaction_id)
# pylint: disable=unexpected-keyword-arg
hub.update_overview(no_throttle=True)

View file

@ -226,7 +226,7 @@ class WithingsDataManager:
WithingsDataManager.print_service_available()
return result
except Exception as ex: # pylint: disable=broad-except
except Exception as ex:
# Withings api encountered error.
if isinstance(ex, (UnauthorizedException, AuthFailedException)):
raise NotAuthenticatedError(ex)

View file

@ -14,7 +14,7 @@ from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
from homeassistant.helpers import ConfigType
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN # pylint: disable=W0611
from .const import DOMAIN # pylint: disable=unused-import
_LOGGER = logging.getLogger(__name__)

View file

@ -190,7 +190,6 @@ async def async_send_message(
message = self.Message(sto=recipient, stype="chat")
message["body"] = url
# pylint: disable=invalid-sequence-index
message["oob"]["url"] = url
try:
message.send()

View file

@ -1,7 +1,5 @@
"""Support for exposing Home Assistant via Zeroconf."""
# PyLint bug confuses absolute/relative imports
# https://github.com/PyCQA/pylint/issues/1931
# pylint: disable=no-name-in-module
import logging
import socket

View file

@ -100,8 +100,7 @@ async def async_setup_entry(hass, config_entry):
if config.get(CONF_ENABLE_QUIRKS, True):
# needs to be done here so that the ZHA module is finished loading
# before zhaquirks is imported
# pylint: disable=W0611, W0612
import zhaquirks # noqa: F401
import zhaquirks # noqa: F401 pylint: disable=unused-import
zha_gateway = ZHAGateway(hass, config, config_entry)
await zha_gateway.async_initialize()

View file

@ -27,7 +27,7 @@ from homeassistant.components.sensor import DOMAIN as SENSOR
from homeassistant.components.switch import DOMAIN as SWITCH
# importing channels updates registries
from . import channels # noqa: F401 pylint: disable=wrong-import-position,unused-import
from . import channels # noqa: F401 pylint: disable=unused-import
from .const import (
CONTROLLER,
SENSOR_ACCELERATION,

View file

@ -1,5 +1,5 @@
"""Data storage helper for ZHA."""
# pylint: disable=W0611
# pylint: disable=unused-import
from collections import OrderedDict
import logging
from typing import MutableMapping

View file

@ -48,8 +48,7 @@ class ZwaveFlowHandler(config_entries.ConfigFlow):
try:
from functools import partial
# pylint: disable=unused-variable
option = await self.hass.async_add_executor_job( # noqa: F841
option = await self.hass.async_add_executor_job( # noqa: F841 pylint: disable=unused-variable
partial(
ZWaveOption,
user_input[CONF_USB_STICK_PATH],

View file

@ -627,7 +627,6 @@ async def merge_packages_config(
_log_pkg_error: Callable = _log_pkg_error,
) -> Dict:
"""Merge packages into the top-level configuration. Mutate config."""
# pylint: disable=too-many-nested-blocks
PACKAGES_CONFIG_SCHEMA(packages)
for pack_name, pack_conf in packages.items():
for comp_name, comp_conf in pack_conf.items():
@ -766,7 +765,6 @@ async def async_process_component_config(
# Validate platform specific schema
if hasattr(platform, "PLATFORM_SCHEMA"):
# pylint: disable=no-member
try:
p_validated = platform.PLATFORM_SCHEMA( # type: ignore
p_config

View file

@ -75,7 +75,6 @@ from homeassistant.util.unit_system import (
)
# Typing imports that create a circular dependency
# pylint: disable=using-constant-test
if TYPE_CHECKING:
from homeassistant.config_entries import ConfigEntries
from homeassistant.components.http import HomeAssistantHTTP

View file

@ -2,10 +2,8 @@
from typing import Optional, Tuple, TYPE_CHECKING
import jinja2
# pylint: disable=using-constant-test
if TYPE_CHECKING:
# pylint: disable=unused-import
from .core import Context # noqa: F401
from .core import Context # noqa: F401 pylint: disable=unused-import
class HomeAssistantError(Exception):

View file

@ -4,7 +4,6 @@ from typing import Any, Iterable, Tuple, Sequence, Dict
from homeassistant.const import CONF_PLATFORM
# pylint: disable=invalid-name
ConfigType = Dict[str, Any]

View file

@ -24,7 +24,7 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow):
self._domain = domain
self._title = title
self._discovery_function = discovery_function
self.CONNECTION_CLASS = connection_class # pylint: disable=C0103
self.CONNECTION_CLASS = connection_class # pylint: disable=invalid-name
async def async_step_user(self, user_input=None):
"""Handle a flow initialized by the user."""

View file

@ -231,7 +231,6 @@ class Script:
Should only be called on exceptions raised by this scripts async_run.
"""
# pylint: disable=protected-access
step = self._exception_step
action = self.sequence[step]
action_type = _determine_action(action)
@ -281,7 +280,6 @@ class Script:
@callback
def async_script_delay(now):
"""Handle delay."""
# pylint: disable=cell-var-from-loop
with suppress(ValueError):
self._async_listener.remove(unsub)

View file

@ -142,7 +142,7 @@ class RenderInfo:
def result(self) -> str:
"""Results of the template computation."""
if self._exception is not None:
raise self._exception # pylint: disable=raising-bad-type
raise self._exception
return self._result
def _freeze(self) -> None:

View file

@ -26,7 +26,7 @@ from typing import (
)
# Typing imports that create a circular dependency
# pylint: disable=using-constant-test,unused-import
# pylint: disable=unused-import
if TYPE_CHECKING:
from homeassistant.core import HomeAssistant

View file

@ -68,7 +68,6 @@ def load_yaml(fname: str) -> JSON_TYPE:
raise HomeAssistantError(exc)
# pylint: disable=pointless-statement
@overload
def _add_reference(
obj: Union[list, NodeListClass], loader: yaml.SafeLoader, node: yaml.nodes.Node

View file

@ -50,6 +50,8 @@ disable=
too-many-boolean-expressions,
unnecessary-pass,
unused-argument
enable=
use-symbolic-message-instead
[REPORTS]
score=no

View file

@ -1,4 +1,4 @@
# pylint: disable=W0621
# pylint: disable=redefined-outer-name
"""Tests for the Daikin config flow."""
import asyncio

View file

@ -27,7 +27,9 @@ def mock_connection_fixture() -> AsyncConnection:
def _rest_call_side_effect(path, body=None):
return path, body
connection._restCall.side_effect = _rest_call_side_effect # pylint: disable=W0212
connection._restCall.side_effect = ( # pylint: disable=protected-access
_rest_call_side_effect
)
connection.api_call.return_value = mock_coro(True)
connection.init.side_effect = mock_coro(True)

View file

@ -58,7 +58,9 @@ async def async_manipulate_test_data(
fire_target = hmip_device if fire_device is None else fire_device
if isinstance(fire_target, AsyncHome):
fire_target.fire_update_event(fire_target._rawJSONData) # pylint: disable=W0212
fire_target.fire_update_event(
fire_target._rawJSONData # pylint: disable=protected-access
)
else:
fire_target.fire_update_event()
@ -136,7 +138,9 @@ class HomeTemplate(Home):
def _get_mock(instance):
"""Create a mock and copy instance attributes over mock."""
if isinstance(instance, Mock):
instance.__dict__.update(instance._mock_wraps.__dict__) # pylint: disable=W0212
instance.__dict__.update(
instance._mock_wraps.__dict__ # pylint: disable=protected-access
)
return instance
mock = Mock(spec=instance, wraps=instance)

View file

@ -18,7 +18,7 @@ async def _async_manipulate_security_zones(
hass, home, internal_active=False, external_active=False, alarm_triggered=False
):
"""Set new values on hmip security zones."""
json = home._rawJSONData # pylint: disable=W0212
json = home._rawJSONData # pylint: disable=protected-access
json["functionalHomes"]["SECURITY_AND_ALARM"]["alarmActive"] = alarm_triggered
external_zone_id = json["functionalHomes"]["SECURITY_AND_ALARM"]["securityZones"][
"EXTERNAL"

View file

@ -367,7 +367,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_absence_with_duration"
assert home.mock_calls[-1][1] == (60,)
assert len(home._connection.mock_calls) == 1 # pylint: disable=W0212
assert len(home._connection.mock_calls) == 1 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@ -377,7 +377,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_absence_with_duration"
assert home.mock_calls[-1][1] == (60,)
assert len(home._connection.mock_calls) == 2 # pylint: disable=W0212
assert len(home._connection.mock_calls) == 2 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@ -387,7 +387,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_absence_with_period"
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0),)
assert len(home._connection.mock_calls) == 3 # pylint: disable=W0212
assert len(home._connection.mock_calls) == 3 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@ -397,7 +397,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_absence_with_period"
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0),)
assert len(home._connection.mock_calls) == 4 # pylint: disable=W0212
assert len(home._connection.mock_calls) == 4 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@ -407,7 +407,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_vacation"
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0), 18.5)
assert len(home._connection.mock_calls) == 5 # pylint: disable=W0212
assert len(home._connection.mock_calls) == 5 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@ -417,7 +417,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_vacation"
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0), 18.5)
assert len(home._connection.mock_calls) == 6 # pylint: disable=W0212
assert len(home._connection.mock_calls) == 6 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@ -427,14 +427,14 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "deactivate_absence"
assert home.mock_calls[-1][1] == ()
assert len(home._connection.mock_calls) == 7 # pylint: disable=W0212
assert len(home._connection.mock_calls) == 7 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud", "deactivate_eco_mode", blocking=True
)
assert home.mock_calls[-1][0] == "deactivate_absence"
assert home.mock_calls[-1][1] == ()
assert len(home._connection.mock_calls) == 8 # pylint: disable=W0212
assert len(home._connection.mock_calls) == 8 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@ -444,14 +444,14 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "deactivate_vacation"
assert home.mock_calls[-1][1] == ()
assert len(home._connection.mock_calls) == 9 # pylint: disable=W0212
assert len(home._connection.mock_calls) == 9 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud", "deactivate_vacation", blocking=True
)
assert home.mock_calls[-1][0] == "deactivate_vacation"
assert home.mock_calls[-1][1] == ()
assert len(home._connection.mock_calls) == 10 # pylint: disable=W0212
assert len(home._connection.mock_calls) == 10 # pylint: disable=protected-access
not_existing_hap_id = "5555F7110000000000000001"
await hass.services.async_call(
@ -463,7 +463,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
assert home.mock_calls[-1][0] == "deactivate_vacation"
assert home.mock_calls[-1][1] == ()
# There is no further call on connection.
assert len(home._connection.mock_calls) == 10 # pylint: disable=W0212
assert len(home._connection.mock_calls) == 10 # pylint: disable=protected-access
async def test_hmip_heating_group_services(hass, mock_hap_with_service):
@ -485,7 +485,9 @@ async def test_hmip_heating_group_services(hass, mock_hap_with_service):
)
assert hmip_device.mock_calls[-1][0] == "set_active_profile"
assert hmip_device.mock_calls[-1][1] == (1,)
assert len(hmip_device._connection.mock_calls) == 2 # pylint: disable=W0212
assert (
len(hmip_device._connection.mock_calls) == 2 # pylint: disable=protected-access
)
await hass.services.async_call(
"homematicip_cloud",
@ -495,4 +497,7 @@ async def test_hmip_heating_group_services(hass, mock_hap_with_service):
)
assert hmip_device.mock_calls[-1][0] == "set_active_profile"
assert hmip_device.mock_calls[-1][1] == (1,)
assert len(hmip_device._connection.mock_calls) == 12 # pylint: disable=W0212
assert (
len(hmip_device._connection.mock_calls) # pylint: disable=protected-access
== 12
)

View file

@ -105,7 +105,7 @@ async def test_hap_reconnected(hass, default_mock_hap):
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_UNAVAILABLE
default_mock_hap._accesspoint_connected = False # pylint: disable=W0212
default_mock_hap._accesspoint_connected = False # pylint: disable=protected-access
await async_manipulate_test_data(hass, default_mock_hap.home, "connected", True)
await hass.async_block_till_done()
ha_state = hass.states.get(entity_id)

View file

@ -40,7 +40,7 @@ def init_config_flow(hass):
sensors=None,
)
flow = config_flow.LogiCircleFlowHandler()
flow._get_authorization_url = Mock( # pylint: disable=W0212
flow._get_authorization_url = Mock( # pylint: disable=protected-access
return_value="http://example.com"
)
flow.hass = hass
@ -65,7 +65,9 @@ def mock_logi_circle():
yield mock_logi_circle_
async def test_step_import(hass, mock_logi_circle): # pylint: disable=W0621
async def test_step_import(
hass, mock_logi_circle # pylint: disable=redefined-outer-name
):
"""Test that we trigger import when configuring with client."""
flow = init_config_flow(hass)
@ -75,8 +77,8 @@ async def test_step_import(hass, mock_logi_circle): # pylint: disable=W0621
async def test_full_flow_implementation(
hass, mock_logi_circle
): # pylint: disable=W0621
hass, mock_logi_circle # pylint: disable=redefined-outer-name
):
"""Test registering an implementation and finishing flow works."""
config_flow.register_flow_implementation(
hass,
@ -154,7 +156,7 @@ async def test_abort_if_already_setup(hass):
)
async def test_abort_if_authorize_fails(
hass, mock_logi_circle, side_effect, error
): # pylint: disable=W0621
): # pylint: disable=redefined-outer-name
"""Test we abort if authorizing fails."""
flow = init_config_flow(hass)
mock_logi_circle.LogiCircle().authorize.side_effect = side_effect
@ -176,7 +178,9 @@ async def test_not_pick_implementation_if_only_one(hass):
assert result["step_id"] == "auth"
async def test_gen_auth_url(hass, mock_logi_circle): # pylint: disable=W0621
async def test_gen_auth_url(
hass, mock_logi_circle
): # pylint: disable=redefined-outer-name
"""Test generating authorize URL from Logi Circle API."""
config_flow.register_flow_implementation(
hass,
@ -192,7 +196,7 @@ async def test_gen_auth_url(hass, mock_logi_circle): # pylint: disable=W0621
flow.flow_impl = "test-auth-url"
await async_setup_component(hass, "http", {})
result = flow._get_authorization_url() # pylint: disable=W0212
result = flow._get_authorization_url() # pylint: disable=protected-access
assert result == "http://authorize.url"
@ -206,7 +210,7 @@ async def test_callback_view_rejects_missing_code(hass):
async def test_callback_view_accepts_code(
hass, mock_logi_circle
): # pylint: disable=W0621
): # pylint: disable=redefined-outer-name
"""Test the auth callback view handles requests with auth code."""
init_config_flow(hass)
view = LogiCircleAuthCallbackView()

View file

@ -1495,8 +1495,7 @@ async def test_encrypted_payload_no_topic_key(hass, setup_comp):
async def test_encrypted_payload_libsodium(hass, setup_comp):
"""Test sending encrypted message payload."""
try:
# pylint: disable=unused-import
import nacl # noqa: F401
import nacl # noqa: F401 pylint: disable=unused-import
except (ImportError, OSError):
pytest.skip("PyNaCl/libsodium is not installed")
return

View file

@ -14,7 +14,7 @@ def init_config_flow(hass, side_effect=None):
"""Init a configuration flow."""
config_flow.register_flow_implementation(hass, DOMAIN, "id", "secret")
flow = config_flow.PointFlowHandler()
flow._get_authorization_url = Mock( # pylint: disable=W0212
flow._get_authorization_url = Mock( # pylint: disable=protected-access
return_value=mock_coro("https://example.com"), side_effect=side_effect
)
flow.hass = hass
@ -28,7 +28,7 @@ def is_authorized():
@pytest.fixture
def mock_pypoint(is_authorized): # pylint: disable=W0621
def mock_pypoint(is_authorized): # pylint: disable=redefined-outer-name
"""Mock pypoint."""
with MockDependency("pypoint") as mock_pypoint_:
mock_pypoint_.PointSession().get_access_token.return_value = {
@ -66,7 +66,9 @@ async def test_abort_if_already_setup(hass):
assert result["reason"] == "already_setup"
async def test_full_flow_implementation(hass, mock_pypoint): # pylint: disable=W0621
async def test_full_flow_implementation(
hass, mock_pypoint # pylint: disable=redefined-outer-name
):
"""Test registering an implementation and finishing flow works."""
config_flow.register_flow_implementation(hass, "test-other", None, None)
flow = init_config_flow(hass)
@ -92,7 +94,7 @@ async def test_full_flow_implementation(hass, mock_pypoint): # pylint: disable=
assert result["data"]["token"] == {"access_token": "boo"}
async def test_step_import(hass, mock_pypoint): # pylint: disable=W0621
async def test_step_import(hass, mock_pypoint): # pylint: disable=redefined-outer-name
"""Test that we trigger import when configuring with client."""
flow = init_config_flow(hass)
@ -104,7 +106,7 @@ async def test_step_import(hass, mock_pypoint): # pylint: disable=W0621
@pytest.mark.parametrize("is_authorized", [False])
async def test_wrong_code_flow_implementation(
hass, mock_pypoint
): # pylint: disable=W0621
): # pylint: disable=redefined-outer-name
"""Test wrong code."""
flow = init_config_flow(hass)

View file

@ -5,7 +5,7 @@ from unittest.mock import Mock
class AsyncMock(Mock):
"""Implements Mock async."""
# pylint: disable=W0235
# pylint: disable=useless-super-delegation
async def __call__(self, *args, **kwargs):
"""Hack for async support for Mock."""
return super().__call__(*args, **kwargs)

View file

@ -9,7 +9,7 @@ from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.components.smhi import config_flow
# pylint: disable=W0212
# pylint: disable=protected-access
async def test_homeassistant_location_exists() -> None:
"""Test if homeassistant location exists it should return True."""
hass = Mock()

View file

@ -99,7 +99,7 @@ def test_properties_no_data(hass: HomeAssistant) -> None:
assert weather.temperature_unit == TEMP_CELSIUS
# pylint: disable=W0212
# pylint: disable=protected-access
def test_properties_unknown_symbol() -> None:
"""Test behaviour when unknown symbol from API."""
hass = Mock()
@ -152,7 +152,7 @@ def test_properties_unknown_symbol() -> None:
assert forecast[ATTR_FORECAST_CONDITION] is None
# pylint: disable=W0212
# pylint: disable=protected-access
async def test_refresh_weather_forecast_exceeds_retries(hass) -> None:
"""Test the refresh weather forecast function."""
from smhi.smhi_lib import SmhiForecastException