diff --git a/homeassistant/components/apple_tv.py b/homeassistant/components/apple_tv.py index 958e4a197775fc..97fb2363024fb2 100644 --- a/homeassistant/components/apple_tv.py +++ b/homeassistant/components/apple_tv.py @@ -45,7 +45,7 @@ NOTIFICATION_SCAN_ID = 'apple_tv_scan_notification' NOTIFICATION_SCAN_TITLE = 'Apple TV Scan' -T = TypeVar('T') +T = TypeVar('T') # pylint: disable=invalid-name # This version of ensure_list interprets an empty dict as no value diff --git a/homeassistant/components/calendar/todoist.py b/homeassistant/components/calendar/todoist.py index ba1f60027ba3cb..30c5a6177b4aef 100644 --- a/homeassistant/components/calendar/todoist.py +++ b/homeassistant/components/calendar/todoist.py @@ -26,6 +26,9 @@ CONF_PROJECT_LABEL_WHITELIST = 'labels' CONF_PROJECT_WHITELIST = 'include_projects' +# https://github.com/PyCQA/pylint/pull/2320 +# pylint: disable=fixme + # Calendar Platform: Does this calendar event last all day? ALL_DAY = 'all_day' # Attribute: All tasks in this project diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 472be92583aebb..58991a8e50597b 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -439,6 +439,7 @@ def get(cls, name): @classmethod def get_default(cls, entity_id): """Return the default turn-on profile for the given light.""" + # pylint: disable=unsupported-membership-test name = entity_id + ".default" if name in cls._all: return name diff --git a/homeassistant/components/media_player/bluesound.py b/homeassistant/components/media_player/bluesound.py index a6b345b1d3bc76..5631ec06cf1ab4 100644 --- a/homeassistant/components/media_player/bluesound.py +++ b/homeassistant/components/media_player/bluesound.py @@ -216,12 +216,8 @@ def _try_get_index(string, search_string): async def force_update_sync_status( self, on_updated_cb=None, raise_timeout=False): """Update the internal status.""" - resp = None - try: - resp = await self.send_bluesound_command( - 'SyncStatus', raise_timeout, raise_timeout) - except Exception: - raise + resp = await self.send_bluesound_command( + 'SyncStatus', raise_timeout, raise_timeout) if not resp: return None diff --git a/homeassistant/components/media_player/pandora.py b/homeassistant/components/media_player/pandora.py index 30e307fd1172c1..c4d8b77809552b 100644 --- a/homeassistant/components/media_player/pandora.py +++ b/homeassistant/components/media_player/pandora.py @@ -253,9 +253,11 @@ def _query_for_playing_status(self): _LOGGER.warning("On unexpected station list page") self._pianobar.sendcontrol('m') # press enter self._pianobar.sendcontrol('m') # do it again b/c an 'i' got in + # pylint: disable=assignment-from-none response = self.update_playing_status() elif match_idx == 3: _LOGGER.debug("Received new playlist list") + # pylint: disable=assignment-from-none response = self.update_playing_status() else: response = self._pianobar.before.decode('utf-8') diff --git a/homeassistant/components/sensor/citybikes.py b/homeassistant/components/sensor/citybikes.py index 24f8ea7e6a94f6..c9a69923135ccc 100644 --- a/homeassistant/components/sensor/citybikes.py +++ b/homeassistant/components/sensor/citybikes.py @@ -186,19 +186,14 @@ def get_closest_network_id(cls, hass, latitude, longitude): networks = yield from async_citybikes_request( hass, NETWORKS_URI, NETWORKS_RESPONSE_SCHEMA) cls.NETWORKS_LIST = networks[ATTR_NETWORKS_LIST] - networks_list = cls.NETWORKS_LIST - network = networks_list[0] - result = network[ATTR_ID] - minimum_dist = location.distance( - latitude, longitude, - network[ATTR_LOCATION][ATTR_LATITUDE], - network[ATTR_LOCATION][ATTR_LONGITUDE]) - for network in networks_list[1:]: + result = None + minimum_dist = None + for network in cls.NETWORKS_LIST: network_latitude = network[ATTR_LOCATION][ATTR_LATITUDE] network_longitude = network[ATTR_LOCATION][ATTR_LONGITUDE] dist = location.distance( latitude, longitude, network_latitude, network_longitude) - if dist < minimum_dist: + if minimum_dist is None or dist < minimum_dist: minimum_dist = dist result = network[ATTR_ID] diff --git a/homeassistant/components/sensor/nzbget.py b/homeassistant/components/sensor/nzbget.py index a8dda416a547af..a6fee5a69e8f38 100644 --- a/homeassistant/components/sensor/nzbget.py +++ b/homeassistant/components/sensor/nzbget.py @@ -173,8 +173,4 @@ def post(self, method, params=None): @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): """Update cached response.""" - try: - self.status = self.post('status')['result'] - except requests.exceptions.ConnectionError: - # failed to update status - exception already logged in self.post - raise + self.status = self.post('status')['result'] diff --git a/homeassistant/components/sensor/pyload.py b/homeassistant/components/sensor/pyload.py index a5593c259a5505..4aa121e0895c76 100644 --- a/homeassistant/components/sensor/pyload.py +++ b/homeassistant/components/sensor/pyload.py @@ -162,8 +162,4 @@ def post(self, method, params=None): @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): """Update cached response.""" - try: - self.status = self.post('speed') - except requests.exceptions.ConnectionError: - # Failed to update status - exception already logged in self.post - raise + self.status = self.post('speed') diff --git a/homeassistant/core.py b/homeassistant/core.py index a7684d130ae496..828dfc24d6ca6c 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -49,9 +49,11 @@ if TYPE_CHECKING: from homeassistant.config_entries import ConfigEntries # noqa +# pylint: disable=invalid-name T = TypeVar('T') CALLABLE_T = TypeVar('CALLABLE_T', bound=Callable) CALLBACK_TYPE = Callable[[], None] +# pylint: enable=invalid-name DOMAIN = 'homeassistant' diff --git a/homeassistant/helpers/intent.py b/homeassistant/helpers/intent.py index 4357c4109ebbf1..8f26d4fe0eeeab 100644 --- a/homeassistant/helpers/intent.py +++ b/homeassistant/helpers/intent.py @@ -63,7 +63,8 @@ async def async_handle(hass, platform, intent_type, slots=None, intent_type, err) raise InvalidSlotInfo( 'Received invalid slot info for {}'.format(intent_type)) from err - except IntentHandleError: + # https://github.com/PyCQA/pylint/issues/2284 + except IntentHandleError: # pylint: disable=try-except-raise raise except Exception as err: raise IntentUnexpectedError( diff --git a/homeassistant/loader.py b/homeassistant/loader.py index c5cf99de234954..3ac49e354b5d50 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -27,7 +27,7 @@ if TYPE_CHECKING: from homeassistant.core import HomeAssistant # NOQA -CALLABLE_T = TypeVar('CALLABLE_T', bound=Callable) +CALLABLE_T = TypeVar('CALLABLE_T', bound=Callable) # noqa pylint: disable=invalid-name PREPARED = False diff --git a/homeassistant/scripts/check_config.py b/homeassistant/scripts/check_config.py index 1924de88aafd7b..d7be5b1a91c7d0 100644 --- a/homeassistant/scripts/check_config.py +++ b/homeassistant/scripts/check_config.py @@ -163,13 +163,13 @@ def check(config_dir, secrets=False): 'secret_cache': None, } - # pylint: disable=unused-variable + # pylint: disable=possibly-unused-variable def mock_load(filename): """Mock hass.util.load_yaml to save config file names.""" res['yaml_files'][filename] = True return MOCKS['load'][1](filename) - # pylint: disable=unused-variable + # pylint: disable=possibly-unused-variable def mock_secrets(ldr, node): """Mock _get_secrets.""" try: diff --git a/homeassistant/scripts/influxdb_import.py b/homeassistant/scripts/influxdb_import.py index 421e84d503a7ca..031df1d3a72a38 100644 --- a/homeassistant/scripts/influxdb_import.py +++ b/homeassistant/scripts/influxdb_import.py @@ -137,6 +137,7 @@ def run(script_args: List) -> int: override_measurement = args.override_measurement default_measurement = args.default_measurement + # pylint: disable=assignment-from-no-return query = session.query(func.count(models.Events.event_type)).filter( models.Events.event_type == 'state_changed') diff --git a/homeassistant/util/__init__.py b/homeassistant/util/__init__.py index 37f669944d97c9..ff098b24fb8874 100644 --- a/homeassistant/util/__init__.py +++ b/homeassistant/util/__init__.py @@ -17,9 +17,11 @@ from .dt import as_local, utcnow +# pylint: disable=invalid-name T = TypeVar('T') U = TypeVar('U') ENUM_T = TypeVar('ENUM_T', bound=enum.Enum) +# pylint: enable=invalid-name RE_SANITIZE_FILENAME = re.compile(r'(~|\.\.|/|\\)') RE_SANITIZE_PATH = re.compile(r'(~|\.(\.)+)') @@ -121,6 +123,9 @@ def get_random_string(length: int = 10) -> str: class OrderedEnum(enum.Enum): """Taken from Python 3.4.0 docs.""" + # https://github.com/PyCQA/pylint/issues/2306 + # pylint: disable=comparison-with-callable + def __ge__(self: ENUM_T, other: ENUM_T) -> bool: """Return the greater than element.""" if self.__class__ is other.__class__: diff --git a/homeassistant/util/decorator.py b/homeassistant/util/decorator.py index 9d2a4600a64ce4..22ed1a4dae66de 100644 --- a/homeassistant/util/decorator.py +++ b/homeassistant/util/decorator.py @@ -1,6 +1,7 @@ """Decorator utility functions.""" from typing import Callable, TypeVar -CALLABLE_T = TypeVar('CALLABLE_T', bound=Callable) + +CALLABLE_T = TypeVar('CALLABLE_T', bound=Callable) # noqa pylint: disable=invalid-name class Registry(dict): diff --git a/homeassistant/util/dt.py b/homeassistant/util/dt.py index 06159a944a26b4..ce6775b9ea7e3d 100644 --- a/homeassistant/util/dt.py +++ b/homeassistant/util/dt.py @@ -98,7 +98,7 @@ def utc_from_timestamp(timestamp: float) -> dt.datetime: def start_of_local_day(dt_or_d: - Union[dt.date, dt.datetime]=None) -> dt.datetime: + Union[dt.date, dt.datetime] = None) -> dt.datetime: """Return local datetime object of start of day from date or datetime.""" if dt_or_d is None: date = now().date() # type: dt.date diff --git a/homeassistant/util/yaml.py b/homeassistant/util/yaml.py index 40ddfdf7b966a5..69f83aefad7989 100644 --- a/homeassistant/util/yaml.py +++ b/homeassistant/util/yaml.py @@ -24,8 +24,8 @@ SECRET_YAML = 'secrets.yaml' __SECRET_CACHE = {} # type: Dict[str, JSON_TYPE] -JSON_TYPE = Union[List, Dict, str] -DICT_T = TypeVar('DICT_T', bound=Dict) +JSON_TYPE = Union[List, Dict, str] # pylint: disable=invalid-name +DICT_T = TypeVar('DICT_T', bound=Dict) # pylint: disable=invalid-name class NodeListClass(list): diff --git a/pylintrc b/pylintrc index 1e9e490adfedbf..00bc6582f3a038 100644 --- a/pylintrc +++ b/pylintrc @@ -11,6 +11,8 @@ # too-few-* - same as too-many-* # abstract-method - with intro of async there are always methods missing # inconsistent-return-statements - doesn't handle raise +# useless-return - https://github.com/PyCQA/pylint/issues/2300 +# not-an-iterable - https://github.com/PyCQA/pylint/issues/2311 disable= abstract-class-little-used, abstract-method, @@ -19,6 +21,7 @@ disable= global-statement, inconsistent-return-statements, locally-disabled, + not-an-iterable, not-context-manager, redefined-variable-type, too-few-public-methods, @@ -30,7 +33,8 @@ disable= too-many-public-methods, too-many-return-statements, too-many-statements, - unused-argument + unused-argument, + useless-return [REPORTS] reports=no diff --git a/requirements_test.txt b/requirements_test.txt index 4d1f86059fcd4f..225958a722cd07 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -8,7 +8,7 @@ flake8==3.5 mock-open==1.3.1 mypy==0.620 pydocstyle==1.1.1 -pylint==1.9.2 +pylint==2.0.1 pytest-aiohttp==0.3.0 pytest-cov==2.5.1 pytest-sugar==0.9.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index be979aa5374d0b..a38ac24dd7bce4 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -9,7 +9,7 @@ flake8==3.5 mock-open==1.3.1 mypy==0.620 pydocstyle==1.1.1 -pylint==1.9.2 +pylint==2.0.1 pytest-aiohttp==0.3.0 pytest-cov==2.5.1 pytest-sugar==0.9.1