Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade pylint #27279

Merged
merged 15 commits into from
Oct 7, 2019
Merged
4 changes: 2 additions & 2 deletions homeassistant/components/aftership/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ def icon(self):
async def async_added_to_hass(self):
"""Register callbacks."""
self.hass.helpers.dispatcher.async_dispatcher_connect(
UPDATE_TOPIC, self.force_update
UPDATE_TOPIC, self._force_update
)

async def force_update(self):
async def _force_update(self):
"""Force update of data."""
await self.async_update(no_throttle=True)
await self.async_update_ha_state()
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/axis/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async def async_step_zeroconf(self, discovery_info):
if discovery_info[CONF_HOST].startswith("169.254"):
return self.async_abort(reason="link_local_address")

# pylint: disable=unsupported-assignment-operation
# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
self.context["macaddress"] = serialnumber

if any(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bayesian/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def device_class(self):
def device_state_attributes(self):
"""Return the state attributes of the sensor."""
return {
ATTR_OBSERVATIONS: [val for val in self.current_obs.values()],
ATTR_OBSERVATIONS: list(self.current_obs.values()),
ATTR_PROBABILITY: round(self.probability, 2),
ATTR_PROBABILITY_THRESHOLD: self._probability_threshold,
}
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bt_smarthub/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _update_info(self):
_LOGGER.warning("Error scanning devices")
return

clients = [client for client in data.values()]
clients = list(data.values())
self.last_results = clients

def get_bt_smarthub_data(self):
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/cert_expiry/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ def get_cert(host, port):
address = (host, port)
with socket.create_connection(address, timeout=TIMEOUT) as sock:
with ctx.wrap_socket(sock, server_hostname=address[0]) as ssock:
cert = ssock.getpeercert()
# pylint disable: https://github.com/PyCQA/pylint/issues/3166
cert = ssock.getpeercert() # pylint: disable=no-member
return cert
2 changes: 1 addition & 1 deletion homeassistant/components/ddwrt/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,4 @@ def get_ddwrt_data(self, url):

def _parse_ddwrt_response(data_str):
"""Parse the DD-WRT data format."""
return {key: val for key, val in _DDWRT_DATA_REGEX.findall(data_str)}
return dict(_DDWRT_DATA_REGEX.findall(data_str))
2 changes: 1 addition & 1 deletion homeassistant/components/deconz/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async def async_step_ssdp(self, discovery_info):
):
return self.async_abort(reason="already_in_progress")

# pylint: disable=unsupported-assignment-operation
# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
self.context[CONF_BRIDGEID] = bridgeid

self.deconz_config = {
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/esphome/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ def supported_features(self) -> int:
features |= SUPPORT_PRESET_MODE
return features

# https://github.com/PyCQA/pylint/issues/3150 for all @esphome_state_property
# pylint: disable=invalid-overridden-method

@esphome_state_property
def hvac_mode(self) -> Optional[str]:
"""Return current operation ie. heat, cool, idle."""
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/esphome/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ async def async_step_user(

@property
def _name(self):
# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
return self.context.get("name")

@_name.setter
def _name(self, value):
# pylint: disable=unsupported-assignment-operation
# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
self.context["name"] = value
self.context["title_placeholders"] = {"name": self._name}

Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/esphome/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def assumed_state(self) -> bool:
def _state(self) -> Optional[CoverState]:
return super()._state

# https://github.com/PyCQA/pylint/issues/3150 for all @esphome_state_property
# pylint: disable=invalid-overridden-method

@esphome_state_property
def is_closed(self) -> Optional[bool]:
"""Return if the cover is closed or not."""
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/esphome/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ async def async_oscillate(self, oscillating: bool) -> None:
key=self._static_info.key, oscillating=oscillating
)

# https://github.com/PyCQA/pylint/issues/3150 for all @esphome_state_property
# pylint: disable=invalid-overridden-method

@esphome_state_property
def is_on(self) -> Optional[bool]:
"""Return true if the entity is on."""
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/esphome/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def _static_info(self) -> LightInfo:
def _state(self) -> Optional[LightState]:
return super()._state

# https://github.com/PyCQA/pylint/issues/3150 for all @esphome_state_property
# pylint: disable=invalid-overridden-method

@esphome_state_property
def is_on(self) -> Optional[bool]:
"""Return true if the switch is on."""
Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/esphome/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ async def async_setup_entry(
)


# https://github.com/PyCQA/pylint/issues/3150 for all @esphome_state_property
# pylint: disable=invalid-overridden-method


class EsphomeSensor(EsphomeEntity):
"""A sensor implementation for esphome."""

Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/esphome/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def assumed_state(self) -> bool:
"""Return true if we do optimistic updates."""
return self._static_info.assumed_state

# https://github.com/PyCQA/pylint/issues/3150 for @esphome_state_property
# pylint: disable=invalid-overridden-method
@esphome_state_property
def is_on(self) -> Optional[bool]:
"""Return true if the switch is on."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async def async_step_zeroconf(self, discovery_info):

_LOGGER.debug("Discovered device %s (%s - %s)", name, model, hkid)

# pylint: disable=unsupported-assignment-operation
# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
self.context["hkid"] = hkid
self.context["title_placeholders"] = {"name": name}

Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/hue/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 1
CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_POLL

# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167

def __init__(self):
"""Initialize the Hue flow."""
self.host = None
Expand Down
10 changes: 8 additions & 2 deletions homeassistant/components/mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,9 @@ def __init__(
self._mqttc.on_message = self._mqtt_on_message

if will_message is not None:
self._mqttc.will_set(*attr.astuple(will_message))
self._mqttc.will_set( # pylint: disable=no-value-for-parameter
*attr.astuple(will_message)
)

async def async_publish(
self, topic: str, payload: PublishPayloadType, qos: int, retain: bool
Expand Down Expand Up @@ -909,7 +911,11 @@ def _mqtt_on_connect(self, _mqttc, _userdata, _flags, result_code: int) -> None:
self.hass.add_job(self._async_perform_subscription, topic, max_qos)

if self.birth_message:
self.hass.add_job(self.async_publish(*attr.astuple(self.birth_message)))
self.hass.add_job(
self.async_publish( # pylint: disable=no-value-for-parameter
*attr.astuple(self.birth_message)
)
)

def _mqtt_on_message(self, _mqttc, _userdata, msg) -> None:
"""Message received callback."""
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/onkyo/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def update(self):
if source in self._source_mapping:
self._current_source = self._source_mapping[source]
break
self._current_source = "_".join([i for i in current_source_tuples[1]])
self._current_source = "_".join(current_source_tuples[1])
if preset_raw and self._current_source.lower() == "radio":
self._attributes[ATTR_PRESET] = preset_raw[1]
elif ATTR_PRESET in self._attributes:
Expand Down Expand Up @@ -413,7 +413,7 @@ def update(self):
if source in self._source_mapping:
self._current_source = self._source_mapping[source]
break
self._current_source = "_".join([i for i in current_source_tuples[1]])
self._current_source = "_".join(current_source_tuples[1])
self._muted = bool(mute_raw[1] == "on")
if preset_raw and self._current_source.lower() == "radio":
self._attributes[ATTR_PRESET] = preset_raw[1]
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/rmvtransport/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def state_attributes(self):
"""Return the state attributes."""
try:
return {
"next_departures": [val for val in self.data.departures[1:]],
"next_departures": self.data.departures[1:],
"direction": self.data.departures[0].get("direction"),
"line": self.data.departures[0].get("line"),
"minutes": self.data.departures[0].get("minutes"),
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/sabnzbd/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def state(self):
"""Return the state of the sensor."""
return self._state

@property
def should_poll(self):
"""Don't poll. Will be updated by dispatcher signal."""
return False
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/synology/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def is_recording(self):
"""Return true if the device is recording."""
return self._camera.is_recording

@property
def should_poll(self):
"""Update the recording state periodically."""
return True
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/tplink/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(self, config):

self.success_init = self._update_info()
except requests.exceptions.RequestException:
_LOGGER.debug("RequestException in %s", __class__.__name__)
_LOGGER.debug("RequestException in %s", self.__class__.__name__)

def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
Expand Down Expand Up @@ -150,7 +150,7 @@ def __init__(self, config):
try:
self.success_init = self._update_info()
except requests.exceptions.RequestException:
_LOGGER.debug("RequestException in %s", __class__.__name__)
_LOGGER.debug("RequestException in %s", self.__class__.__name__)

def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tradfri/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def async_step_zeroconf(self, user_input):
"""Handle zeroconf discovery."""
host = user_input["host"]

# pylint: disable=unsupported-assignment-operation
# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
self.context["host"] = host

if any(host == flow["context"]["host"] for flow in self._async_in_progress()):
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/upnp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def unit(self) -> str:
"""Get unit we are measuring in."""
raise NotImplementedError()

@property
def _async_fetch_value(self):
"""Fetch a value from the IGD."""
raise NotImplementedError()
Expand Down
4 changes: 1 addition & 3 deletions homeassistant/components/vacuum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import voluptuous as vol

from homeassistant.components import group
from homeassistant.const import (
from homeassistant.const import ( # noqa: F401 # STATE_PAUSED/IDLE are API
ATTR_BATTERY_LEVEL,
ATTR_COMMAND,
SERVICE_TOGGLE,
Expand Down Expand Up @@ -68,8 +68,6 @@

STATE_CLEANING = "cleaning"
STATE_DOCKED = "docked"
STATE_IDLE = STATE_IDLE
STATE_PAUSED = STATE_PAUSED
STATE_RETURNING = "returning"
STATE_ERROR = "error"

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/vallox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ async def async_set_profile_fan_speed_boost(
async def async_handle(self, service):
"""Dispatch a service call."""
method = SERVICE_TO_METHOD.get(service.service)
params = {key: value for key, value in service.data.items()}
params = service.data.copy()

if not hasattr(self, method["method"]):
_LOGGER.error("Service not implemented: %s", method["method"])
Expand Down
4 changes: 0 additions & 4 deletions homeassistant/components/wink/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,6 @@ def set_temperature(self, **kwargs):
target_temp_high = target_temp
if self.hvac_mode == HVAC_MODE_HEAT:
target_temp_low = target_temp
if target_temp_low is not None:
target_temp_low = target_temp_low
if target_temp_high is not None:
target_temp_high = target_temp_high
self.wink.set_temperature(target_temp_low, target_temp_high)

def set_hvac_mode(self, hvac_mode):
Expand Down
4 changes: 1 addition & 3 deletions homeassistant/components/zha/core/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ async def _execute_channel_tasks(self, channels, task_name, *args):
zdo_task = None
for channel in channels:
if channel.name == CHANNEL_ZDO:
# pylint: disable=E1111
if zdo_task is None: # We only want to do this once
zdo_task = self._async_create_task(
semaphore, channel, task_name, *args
Expand All @@ -373,8 +372,7 @@ async def _async_create_task(self, semaphore, channel, func_name, *args):
@callback
def async_unsub_dispatcher(self):
"""Unsubscribe the dispatcher."""
if self._unsub:
self._unsub()
self._unsub()

@callback
def async_update_last_seen(self, last_seen):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zha/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
SPEED_SMART,
]

VALUE_TO_SPEED = {i: speed for i, speed in enumerate(SPEED_LIST)}
VALUE_TO_SPEED = dict(enumerate(SPEED_LIST))
SPEED_TO_VALUE = {speed: i for i, speed in enumerate(SPEED_LIST)}


Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zha/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

STATE_LIST = [STATE_UNLOCKED, STATE_LOCKED, STATE_UNLOCKED]

VALUE_TO_STATE = {i: state for i, state in enumerate(STATE_LIST)}
VALUE_TO_STATE = dict(enumerate(STATE_LIST))


async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ def __init__(self, loop: Optional[asyncio.events.AbstractEventLoop] = None) -> N
self.data: dict = {}
self.state = CoreState.not_running
self.exit_code = 0
self.config_entries: Optional[ConfigEntries] = None
self.config_entries: Optional[
ConfigEntries # pylint: disable=used-before-assignment
] = None
# If not None, use to signal end-of-loop
self._stopped: Optional[asyncio.Event] = None

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/helpers/config_entry_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def async_step_confirm(self, user_input=None):
if user_input is None:
return self.async_show_form(step_id="confirm")

if (
if ( # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
self.context
and self.context.get("source") != config_entries.SOURCE_DISCOVERY
):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/util/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@
class XYPoint:
"""Represents a CIE 1931 XY coordinate pair."""

x = attr.ib(type=float)
y = attr.ib(type=float)
x = attr.ib(type=float) # pylint: disable=invalid-name
y = attr.ib(type=float) # pylint: disable=invalid-name


@attr.s()
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/util/dt.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def q_n_r(first: int, second: int) -> Tuple[int, int]:
def parse_time_expression(parameter: Any, min_value: int, max_value: int) -> List[int]:
"""Parse the time expression part and return a list of times to match."""
if parameter is None or parameter == MATCH_ALL:
res = [x for x in range(min_value, max_value + 1)]
res = list(range(min_value, max_value + 1))
elif isinstance(parameter, str) and parameter.startswith("/"):
parameter = int(parameter[1:])
res = [x for x in range(min_value, max_value + 1) if x % parameter == 0]
Expand Down
Loading