Skip to content

Commit

Permalink
Fix lint (#21520)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Feb 28, 2019
1 parent 548d7bb commit 229d19b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
21 changes: 12 additions & 9 deletions homeassistant/components/person/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import OrderedDict
from itertools import chain
import logging
from typing import Optional
import uuid

import voluptuous as vol
Expand All @@ -13,7 +14,7 @@
ATTR_ID, ATTR_LATITUDE, ATTR_LONGITUDE, ATTR_GPS_ACCURACY,
CONF_ID, CONF_NAME, EVENT_HOMEASSISTANT_START,
STATE_UNKNOWN, STATE_UNAVAILABLE, STATE_HOME, STATE_NOT_HOME)
from homeassistant.core import callback, Event
from homeassistant.core import callback, Event, State
from homeassistant.auth import EVENT_USER_REMOVED
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent
Expand Down Expand Up @@ -377,11 +378,6 @@ def _async_handle_tracker_update(self, entity, old_state, new_state):
"""Handle the device tracker state changes."""
self._update_state()

def _get_latest(self, prev, curr):
return curr \
if prev is None or curr.last_updated > prev.last_updated \
else prev

@callback
def _update_state(self):
"""Update the state."""
Expand All @@ -393,11 +389,11 @@ def _update_state(self):
continue

if state.attributes.get(ATTR_SOURCE_TYPE) == SOURCE_TYPE_GPS:
latest_gps = self._get_latest(latest_gps, state)
latest_gps = _get_latest(latest_gps, state)
elif state.state == STATE_HOME:
latest_home = self._get_latest(latest_home, state)
latest_home = _get_latest(latest_home, state)
elif state.state == STATE_NOT_HOME:
latest_not_home = self._get_latest(latest_not_home, state)
latest_not_home = _get_latest(latest_not_home, state)

if latest_home:
latest = latest_home
Expand Down Expand Up @@ -508,3 +504,10 @@ async def ws_delete_person(hass: HomeAssistantType,
manager = hass.data[DOMAIN] # type: PersonManager
await manager.async_delete_person(msg['person_id'])
connection.send_result(msg['id'])


def _get_latest(prev: Optional[State], curr: State):
"""Get latest state."""
if prev is None or curr.last_updated > prev.last_updated:
return curr
return prev
4 changes: 2 additions & 2 deletions homeassistant/components/sensor/airvisual.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async def async_setup_platform(
"Using city, state, and country: %s, %s, %s", city, state, country)
location_id = ','.join((city, state, country))
data = AirVisualData(
Client(config[CONF_API_KEY], websession),
Client(websession, api_key=config[CONF_API_KEY]),
city=city,
state=state,
country=country,
Expand All @@ -152,7 +152,7 @@ async def async_setup_platform(
"Using latitude and longitude: %s, %s", latitude, longitude)
location_id = ','.join((str(latitude), str(longitude)))
data = AirVisualData(
Client(config[CONF_API_KEY], websession),
Client(websession, api_key=config[CONF_API_KEY]),
latitude=latitude,
longitude=longitude,
show_on_map=config[CONF_SHOW_ON_MAP],
Expand Down

0 comments on commit 229d19b

Please sign in to comment.