Upgrade pylint to 2.0.1 (#15683)

* Upgrade pylint to 2.0.1

* Pylint 2 bad-whitespace fix

* Pylint 2 possibly-unused-variable fixes

* Pylint 2 try-except-raise fixes

* Disable pylint fixme for todoist for now

https://github.com/PyCQA/pylint/pull/2320

* Disable pylint 2 useless-return for now

https://github.com/PyCQA/pylint/issues/2300

* Disable pylint 2 invalid-name for type variables for now

https://github.com/PyCQA/pylint/issues/1290

* Disable pylint 2 not-an-iterable for now

https://github.com/PyCQA/pylint/issues/2311

* Pylint 2 unsubscriptable-object workarounds

* Disable intentional pylint 2 assignment-from-nones

* Disable pylint 2 unsupported-membership-test apparent false positives

* Disable pylint 2 assignment-from-no-return apparent false positives

* Disable pylint 2 comparison-with-callable false positives

https://github.com/PyCQA/pylint/issues/2306
This commit is contained in:
Ville Skyttä 2018-07-26 09:55:42 +03:00 committed by Paulus Schoutsen
parent 9fb8bc8991
commit eee9b50b70
20 changed files with 40 additions and 37 deletions

View file

@ -45,7 +45,7 @@ NOTIFICATION_AUTH_TITLE = 'Apple TV Authentication'
NOTIFICATION_SCAN_ID = 'apple_tv_scan_notification' NOTIFICATION_SCAN_ID = 'apple_tv_scan_notification'
NOTIFICATION_SCAN_TITLE = 'Apple TV Scan' 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 # This version of ensure_list interprets an empty dict as no value

View file

@ -26,6 +26,9 @@ CONF_PROJECT_DUE_DATE = 'due_date_days'
CONF_PROJECT_LABEL_WHITELIST = 'labels' CONF_PROJECT_LABEL_WHITELIST = 'labels'
CONF_PROJECT_WHITELIST = 'include_projects' CONF_PROJECT_WHITELIST = 'include_projects'
# https://github.com/PyCQA/pylint/pull/2320
# pylint: disable=fixme
# Calendar Platform: Does this calendar event last all day? # Calendar Platform: Does this calendar event last all day?
ALL_DAY = 'all_day' ALL_DAY = 'all_day'
# Attribute: All tasks in this project # Attribute: All tasks in this project

View file

@ -439,6 +439,7 @@ class Profiles:
@classmethod @classmethod
def get_default(cls, entity_id): def get_default(cls, entity_id):
"""Return the default turn-on profile for the given light.""" """Return the default turn-on profile for the given light."""
# pylint: disable=unsupported-membership-test
name = entity_id + ".default" name = entity_id + ".default"
if name in cls._all: if name in cls._all:
return name return name

View file

@ -216,12 +216,8 @@ class BluesoundPlayer(MediaPlayerDevice):
async def force_update_sync_status( async def force_update_sync_status(
self, on_updated_cb=None, raise_timeout=False): self, on_updated_cb=None, raise_timeout=False):
"""Update the internal status.""" """Update the internal status."""
resp = None resp = await self.send_bluesound_command(
try: 'SyncStatus', raise_timeout, raise_timeout)
resp = await self.send_bluesound_command(
'SyncStatus', raise_timeout, raise_timeout)
except Exception:
raise
if not resp: if not resp:
return None return None

View file

@ -253,9 +253,11 @@ class PandoraMediaPlayer(MediaPlayerDevice):
_LOGGER.warning("On unexpected station list page") _LOGGER.warning("On unexpected station list page")
self._pianobar.sendcontrol('m') # press enter self._pianobar.sendcontrol('m') # press enter
self._pianobar.sendcontrol('m') # do it again b/c an 'i' got in self._pianobar.sendcontrol('m') # do it again b/c an 'i' got in
# pylint: disable=assignment-from-none
response = self.update_playing_status() response = self.update_playing_status()
elif match_idx == 3: elif match_idx == 3:
_LOGGER.debug("Received new playlist list") _LOGGER.debug("Received new playlist list")
# pylint: disable=assignment-from-none
response = self.update_playing_status() response = self.update_playing_status()
else: else:
response = self._pianobar.before.decode('utf-8') response = self._pianobar.before.decode('utf-8')

View file

@ -186,19 +186,14 @@ class CityBikesNetwork:
networks = yield from async_citybikes_request( networks = yield from async_citybikes_request(
hass, NETWORKS_URI, NETWORKS_RESPONSE_SCHEMA) hass, NETWORKS_URI, NETWORKS_RESPONSE_SCHEMA)
cls.NETWORKS_LIST = networks[ATTR_NETWORKS_LIST] cls.NETWORKS_LIST = networks[ATTR_NETWORKS_LIST]
networks_list = cls.NETWORKS_LIST result = None
network = networks_list[0] minimum_dist = None
result = network[ATTR_ID] for network in cls.NETWORKS_LIST:
minimum_dist = location.distance(
latitude, longitude,
network[ATTR_LOCATION][ATTR_LATITUDE],
network[ATTR_LOCATION][ATTR_LONGITUDE])
for network in networks_list[1:]:
network_latitude = network[ATTR_LOCATION][ATTR_LATITUDE] network_latitude = network[ATTR_LOCATION][ATTR_LATITUDE]
network_longitude = network[ATTR_LOCATION][ATTR_LONGITUDE] network_longitude = network[ATTR_LOCATION][ATTR_LONGITUDE]
dist = location.distance( dist = location.distance(
latitude, longitude, network_latitude, network_longitude) latitude, longitude, network_latitude, network_longitude)
if dist < minimum_dist: if minimum_dist is None or dist < minimum_dist:
minimum_dist = dist minimum_dist = dist
result = network[ATTR_ID] result = network[ATTR_ID]

View file

@ -173,8 +173,4 @@ class NZBGetAPI:
@Throttle(MIN_TIME_BETWEEN_UPDATES) @Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self): def update(self):
"""Update cached response.""" """Update cached response."""
try: self.status = self.post('status')['result']
self.status = self.post('status')['result']
except requests.exceptions.ConnectionError:
# failed to update status - exception already logged in self.post
raise

View file

@ -162,8 +162,4 @@ class PyLoadAPI:
@Throttle(MIN_TIME_BETWEEN_UPDATES) @Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self): def update(self):
"""Update cached response.""" """Update cached response."""
try: self.status = self.post('speed')
self.status = self.post('speed')
except requests.exceptions.ConnectionError:
# Failed to update status - exception already logged in self.post
raise

View file

@ -49,9 +49,11 @@ from homeassistant.util.unit_system import UnitSystem, METRIC_SYSTEM # NOQA
if TYPE_CHECKING: if TYPE_CHECKING:
from homeassistant.config_entries import ConfigEntries # noqa from homeassistant.config_entries import ConfigEntries # noqa
# pylint: disable=invalid-name
T = TypeVar('T') T = TypeVar('T')
CALLABLE_T = TypeVar('CALLABLE_T', bound=Callable) CALLABLE_T = TypeVar('CALLABLE_T', bound=Callable)
CALLBACK_TYPE = Callable[[], None] CALLBACK_TYPE = Callable[[], None]
# pylint: enable=invalid-name
DOMAIN = 'homeassistant' DOMAIN = 'homeassistant'

View file

@ -63,7 +63,8 @@ async def async_handle(hass, platform, intent_type, slots=None,
intent_type, err) intent_type, err)
raise InvalidSlotInfo( raise InvalidSlotInfo(
'Received invalid slot info for {}'.format(intent_type)) from err '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 raise
except Exception as err: except Exception as err:
raise IntentUnexpectedError( raise IntentUnexpectedError(

View file

@ -27,7 +27,7 @@ from homeassistant.util import OrderedSet
if TYPE_CHECKING: if TYPE_CHECKING:
from homeassistant.core import HomeAssistant # NOQA 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 PREPARED = False

View file

@ -163,13 +163,13 @@ def check(config_dir, secrets=False):
'secret_cache': None, 'secret_cache': None,
} }
# pylint: disable=unused-variable # pylint: disable=possibly-unused-variable
def mock_load(filename): def mock_load(filename):
"""Mock hass.util.load_yaml to save config file names.""" """Mock hass.util.load_yaml to save config file names."""
res['yaml_files'][filename] = True res['yaml_files'][filename] = True
return MOCKS['load'][1](filename) return MOCKS['load'][1](filename)
# pylint: disable=unused-variable # pylint: disable=possibly-unused-variable
def mock_secrets(ldr, node): def mock_secrets(ldr, node):
"""Mock _get_secrets.""" """Mock _get_secrets."""
try: try:

View file

@ -137,6 +137,7 @@ def run(script_args: List) -> int:
override_measurement = args.override_measurement override_measurement = args.override_measurement
default_measurement = args.default_measurement default_measurement = args.default_measurement
# pylint: disable=assignment-from-no-return
query = session.query(func.count(models.Events.event_type)).filter( query = session.query(func.count(models.Events.event_type)).filter(
models.Events.event_type == 'state_changed') models.Events.event_type == 'state_changed')

View file

@ -17,9 +17,11 @@ from typing import (Any, Optional, TypeVar, Callable, KeysView, Union, # noqa
from .dt import as_local, utcnow from .dt import as_local, utcnow
# pylint: disable=invalid-name
T = TypeVar('T') T = TypeVar('T')
U = TypeVar('U') U = TypeVar('U')
ENUM_T = TypeVar('ENUM_T', bound=enum.Enum) ENUM_T = TypeVar('ENUM_T', bound=enum.Enum)
# pylint: enable=invalid-name
RE_SANITIZE_FILENAME = re.compile(r'(~|\.\.|/|\\)') RE_SANITIZE_FILENAME = re.compile(r'(~|\.\.|/|\\)')
RE_SANITIZE_PATH = 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): class OrderedEnum(enum.Enum):
"""Taken from Python 3.4.0 docs.""" """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: def __ge__(self: ENUM_T, other: ENUM_T) -> bool:
"""Return the greater than element.""" """Return the greater than element."""
if self.__class__ is other.__class__: if self.__class__ is other.__class__:

View file

@ -1,6 +1,7 @@
"""Decorator utility functions.""" """Decorator utility functions."""
from typing import Callable, TypeVar 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): class Registry(dict):

View file

@ -98,7 +98,7 @@ def utc_from_timestamp(timestamp: float) -> dt.datetime:
def start_of_local_day(dt_or_d: 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.""" """Return local datetime object of start of day from date or datetime."""
if dt_or_d is None: if dt_or_d is None:
date = now().date() # type: dt.date date = now().date() # type: dt.date

View file

@ -24,8 +24,8 @@ _SECRET_NAMESPACE = 'homeassistant'
SECRET_YAML = 'secrets.yaml' SECRET_YAML = 'secrets.yaml'
__SECRET_CACHE = {} # type: Dict[str, JSON_TYPE] __SECRET_CACHE = {} # type: Dict[str, JSON_TYPE]
JSON_TYPE = Union[List, Dict, str] JSON_TYPE = Union[List, Dict, str] # pylint: disable=invalid-name
DICT_T = TypeVar('DICT_T', bound=Dict) DICT_T = TypeVar('DICT_T', bound=Dict) # pylint: disable=invalid-name
class NodeListClass(list): class NodeListClass(list):

View file

@ -11,6 +11,8 @@
# too-few-* - same as too-many-* # too-few-* - same as too-many-*
# abstract-method - with intro of async there are always methods missing # abstract-method - with intro of async there are always methods missing
# inconsistent-return-statements - doesn't handle raise # 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= disable=
abstract-class-little-used, abstract-class-little-used,
abstract-method, abstract-method,
@ -19,6 +21,7 @@ disable=
global-statement, global-statement,
inconsistent-return-statements, inconsistent-return-statements,
locally-disabled, locally-disabled,
not-an-iterable,
not-context-manager, not-context-manager,
redefined-variable-type, redefined-variable-type,
too-few-public-methods, too-few-public-methods,
@ -30,7 +33,8 @@ disable=
too-many-public-methods, too-many-public-methods,
too-many-return-statements, too-many-return-statements,
too-many-statements, too-many-statements,
unused-argument unused-argument,
useless-return
[REPORTS] [REPORTS]
reports=no reports=no

View file

@ -8,7 +8,7 @@ flake8==3.5
mock-open==1.3.1 mock-open==1.3.1
mypy==0.620 mypy==0.620
pydocstyle==1.1.1 pydocstyle==1.1.1
pylint==1.9.2 pylint==2.0.1
pytest-aiohttp==0.3.0 pytest-aiohttp==0.3.0
pytest-cov==2.5.1 pytest-cov==2.5.1
pytest-sugar==0.9.1 pytest-sugar==0.9.1

View file

@ -9,7 +9,7 @@ flake8==3.5
mock-open==1.3.1 mock-open==1.3.1
mypy==0.620 mypy==0.620
pydocstyle==1.1.1 pydocstyle==1.1.1
pylint==1.9.2 pylint==2.0.1
pytest-aiohttp==0.3.0 pytest-aiohttp==0.3.0
pytest-cov==2.5.1 pytest-cov==2.5.1
pytest-sugar==0.9.1 pytest-sugar==0.9.1