pylint 2.3.0 (#21485)

* pylint 2.3.0

* remove const

*  disable=syntax-error
This commit is contained in:
Daniel Høyer Iversen 2019-02-27 22:10:40 +01:00 committed by David F. Mulcahey
parent 2482816a11
commit 519315f9c8
26 changed files with 47 additions and 57 deletions

View File

@ -170,7 +170,6 @@ class AuthManager:
user = await self.async_get_user_by_credentials(credentials) user = await self.async_get_user_by_credentials(credentials)
if user is None: if user is None:
raise ValueError('Unable to find the user.') raise ValueError('Unable to find the user.')
else:
return user return user
auth_provider = self._async_get_auth_provider(credentials) auth_provider = self._async_get_auth_provider(credentials)

View File

@ -66,7 +66,7 @@ class BloomSky:
self.API_URL, headers={AUTHORIZATION: self._api_key}, timeout=10) self.API_URL, headers={AUTHORIZATION: self._api_key}, timeout=10)
if response.status_code == 401: if response.status_code == 401:
raise RuntimeError("Invalid API_KEY") raise RuntimeError("Invalid API_KEY")
elif response.status_code != 200: if response.status_code != 200:
_LOGGER.error("Invalid HTTP response: %s", response.status_code) _LOGGER.error("Invalid HTTP response: %s", response.status_code)
return return
# Create dictionary keyed off of the device unique id # Create dictionary keyed off of the device unique id

View File

@ -291,7 +291,7 @@ class DeviceTracker:
""" """
if mac is None and dev_id is None: if mac is None and dev_id is None:
raise HomeAssistantError('Neither mac or device id passed in') raise HomeAssistantError('Neither mac or device id passed in')
elif mac is not None: if mac is not None:
mac = str(mac).upper() mac = str(mac).upper()
device = self.mac_to_dev.get(mac) device = self.mac_to_dev.get(mac)
if not device: if not device:

View File

@ -216,7 +216,6 @@ def _req_json_rpc(url, session_id, rpcmethod, subsystem, method, **params):
if 'message' in response['error'] and \ if 'message' in response['error'] and \
response['error']['message'] == "Access denied": response['error']['message'] == "Access denied":
raise PermissionError(response['error']['message']) raise PermissionError(response['error']['message'])
else:
raise HomeAssistantError(response['error']['message']) raise HomeAssistantError(response['error']['message'])
if rpcmethod == "call": if rpcmethod == "call":

View File

@ -366,7 +366,6 @@ def _get_related_entity_ids(session, entity_filter):
if tryno == RETRIES - 1: if tryno == RETRIES - 1:
raise raise
else:
time.sleep(QUERY_RETRY_WAIT) time.sleep(QUERY_RETRY_WAIT)

View File

@ -345,7 +345,6 @@ class BluesoundPlayer(MediaPlayerDevice):
if raise_timeout: if raise_timeout:
_LOGGER.info("Timeout: %s", self.host) _LOGGER.info("Timeout: %s", self.host)
raise raise
else:
_LOGGER.debug("Failed communicating: %s", self.host) _LOGGER.debug("Failed communicating: %s", self.host)
return None return None

View File

@ -41,6 +41,5 @@ async def resolve_auth_code(hass, client_id, client_secret, code):
except AuthorizationError as err: except AuthorizationError as err:
if err.response.status_code == 401: if err.response.status_code == 401:
raise config_flow.CodeInvalid() raise config_flow.CodeInvalid()
else:
raise config_flow.NestAuthError('Unknown error: {} ({})'.format( raise config_flow.NestAuthError('Unknown error: {} ({})'.format(
err, err.response.status_code)) err, err.response.status_code))

View File

@ -248,7 +248,7 @@ class NFAndroidTVNotificationService(BaseNotificationService):
req = requests.get(url, timeout=DEFAULT_TIMEOUT) req = requests.get(url, timeout=DEFAULT_TIMEOUT)
return req.content return req.content
elif local_path is not None: if local_path is not None:
# Check whether path is whitelisted in configuration.yaml # Check whether path is whitelisted in configuration.yaml
if self.is_allowed_path(local_path): if self.is_allowed_path(local_path):
return open(local_path, "rb") return open(local_path, "rb")

View File

@ -149,7 +149,6 @@ class PushsaferNotificationService(BaseNotificationService):
response = requests.get(url, timeout=CONF_TIMEOUT) response = requests.get(url, timeout=CONF_TIMEOUT)
return self.get_base64(response.content, return self.get_base64(response.content,
response.headers['content-type']) response.headers['content-type'])
else:
_LOGGER.warning("url not found in param") _LOGGER.warning("url not found in param")
return None return None

View File

@ -152,7 +152,7 @@ class SlackNotificationService(BaseNotificationService):
req = requests.get(url, timeout=CONF_TIMEOUT) req = requests.get(url, timeout=CONF_TIMEOUT)
return req.content return req.content
elif local_path: if local_path:
# Check whether path is whitelisted in configuration.yaml # Check whether path is whitelisted in configuration.yaml
if self.is_allowed_path(local_path): if self.is_allowed_path(local_path):
return open(local_path, 'rb') return open(local_path, 'rb')

View File

@ -81,7 +81,7 @@ async def async_register_panel(
"""Register a new custom panel.""" """Register a new custom panel."""
if js_url is None and html_url is None and module_url is None: if js_url is None and html_url is None and module_url is None:
raise ValueError('Either js_url, module_url or html_url is required.') raise ValueError('Either js_url, module_url or html_url is required.')
elif (js_url and html_url) or (module_url and html_url): if (js_url and html_url) or (module_url and html_url):
raise ValueError('Pass in only one of JS url, Module url or HTML url.') raise ValueError('Pass in only one of JS url, Module url or HTML url.')
if config is not None and not isinstance(config, dict): if config is not None and not isinstance(config, dict):

View File

@ -125,7 +125,7 @@ def execute(hass, filename, source, data=None):
# pylint: disable=too-many-boolean-expressions # pylint: disable=too-many-boolean-expressions
if name.startswith('async_'): if name.startswith('async_'):
raise ScriptError("Not allowed to access async methods") raise ScriptError("Not allowed to access async methods")
elif (obj is hass and name not in ALLOWED_HASS or if (obj is hass and name not in ALLOWED_HASS or
obj is hass.bus and name not in ALLOWED_EVENTBUS or obj is hass.bus and name not in ALLOWED_EVENTBUS or
obj is hass.states and name not in ALLOWED_STATEMACHINE or obj is hass.states and name not in ALLOWED_STATEMACHINE or
obj is hass.services and name not in ALLOWED_SERVICEREGISTRY or obj is hass.services and name not in ALLOWED_SERVICEREGISTRY or

View File

@ -76,5 +76,4 @@ def execute(qry):
if tryno == RETRIES - 1: if tryno == RETRIES - 1:
raise raise
else:
time.sleep(QUERY_RETRY_WAIT) time.sleep(QUERY_RETRY_WAIT)

View File

@ -119,7 +119,6 @@ class CurrencylayerData:
self._resource, params=self._parameters, timeout=10) self._resource, params=self._parameters, timeout=10)
if 'error' in result.json(): if 'error' in result.json():
raise ValueError(result.json()['error']['info']) raise ValueError(result.json()['error']['info'])
else:
self.data = result.json()['quotes'] self.data = result.json()['quotes']
_LOGGER.debug("Currencylayer data updated: %s", _LOGGER.debug("Currencylayer data updated: %s",
result.json()['timestamp']) result.json()['timestamp'])

View File

@ -44,7 +44,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Sterling Bank sensor platform.""" """Set up the Sterling Bank sensor platform."""
from starlingbank import StarlingAccount from starlingbank import StarlingAccount # pylint: disable=syntax-error
sensors = [] sensors = []
for account in config[CONF_ACCOUNTS]: for account in config[CONF_ACCOUNTS]:

View File

@ -34,10 +34,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None) -> None:
name = config.get(CONF_NAME) name = config.get(CONF_NAME)
mac_addr = config[CONF_MAC] mac_addr = config[CONF_MAC]
flip_on_off = config[CONF_FLIP_ON_OFF] flip_on_off = config[CONF_FLIP_ON_OFF]
add_entities([Switchmate(mac_addr, name, flip_on_off)], True) add_entities([SwitchmateEntity(mac_addr, name, flip_on_off)], True)
class Switchmate(SwitchDevice): class SwitchmateEntity(SwitchDevice):
"""Representation of a Switchmate.""" """Representation of a Switchmate."""
def __init__(self, mac, name, flip_on_off) -> None: def __init__(self, mac, name, flip_on_off) -> None:

View File

@ -628,7 +628,7 @@ class BaseTelegramBotEntity:
self.hass.bus.async_fire(event, event_data) self.hass.bus.async_fire(event, event_data)
return True return True
elif ATTR_CALLBACK_QUERY in data: if ATTR_CALLBACK_QUERY in data:
event = EVENT_TELEGRAM_CALLBACK event = EVENT_TELEGRAM_CALLBACK
data = data.get(ATTR_CALLBACK_QUERY) data = data.get(ATTR_CALLBACK_QUERY)
message_ok, event_data = self._get_message_data(data) message_ok, event_data = self._get_message_data(data)
@ -642,6 +642,6 @@ class BaseTelegramBotEntity:
self.hass.bus.async_fire(event, event_data) self.hass.bus.async_fire(event, event_data)
return True return True
else:
_LOGGER.warning("Message with unknown data received: %s", data) _LOGGER.warning("Message with unknown data received: %s", data)
return True return True

View File

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

View File

@ -84,7 +84,6 @@ class FlowHandler(config_entries.ConfigFlow):
KEY_SCAN_INTERVAL: self._scan_interval.seconds, KEY_SCAN_INTERVAL: self._scan_interval.seconds,
KEY_SESSION: session, KEY_SESSION: session,
}) })
else:
errors['base'] = 'auth_error' errors['base'] = 'auth_error'
try: try:

View File

@ -130,7 +130,7 @@ class WebSocketHandler:
if msg.type in (WSMsgType.CLOSE, WSMsgType.CLOSING): if msg.type in (WSMsgType.CLOSE, WSMsgType.CLOSING):
raise Disconnect raise Disconnect
elif msg.type != WSMsgType.TEXT: if msg.type != WSMsgType.TEXT:
disconnect_warn = 'Received non-Text message.' disconnect_warn = 'Received non-Text message.'
raise Disconnect raise Disconnect

View File

@ -75,7 +75,7 @@ class AreaRegistry:
if self._async_is_registered(name): if self._async_is_registered(name):
raise ValueError('Name is already in use') raise ValueError('Name is already in use')
else:
changes['name'] = name changes['name'] = name
new = self.areas[area_id] = attr.evolve(old, **changes) new = self.areas[area_id] = attr.evolve(old, **changes)

View File

@ -293,7 +293,7 @@ def time_period_str(value: str) -> timedelta:
"""Validate and transform time offset.""" """Validate and transform time offset."""
if isinstance(value, int): if isinstance(value, int):
raise vol.Invalid('Make sure you wrap time values in quotes') raise vol.Invalid('Make sure you wrap time values in quotes')
elif not isinstance(value, str): if not isinstance(value, str):
raise vol.Invalid(TIME_PERIOD_ERROR.format(value)) raise vol.Invalid(TIME_PERIOD_ERROR.format(value))
negative_offset = False negative_offset = False
@ -440,7 +440,7 @@ def template(value):
"""Validate a jinja2 template.""" """Validate a jinja2 template."""
if value is None: if value is None:
raise vol.Invalid('template value is None') raise vol.Invalid('template value is None')
elif isinstance(value, (list, dict, template_helper.Template)): if isinstance(value, (list, dict, template_helper.Template)):
raise vol.Invalid('template value should be a string') raise vol.Invalid('template value should be a string')
value = template_helper.Template(str(value)) value = template_helper.Template(str(value))

View File

@ -28,7 +28,6 @@ def generate_entity_id(entity_id_format: str, name: Optional[str],
if current_ids is None: if current_ids is None:
if hass is None: if hass is None:
raise ValueError("Missing required parameter currentids or hass") raise ValueError("Missing required parameter currentids or hass")
else:
return run_callback_threadsafe( return run_callback_threadsafe(
hass.loop, async_generate_entity_id, entity_id_format, name, hass.loop, async_generate_entity_id, entity_id_format, name,
current_ids, hass current_ids, hass

View File

@ -334,7 +334,7 @@ class EntityPlatform:
if not valid_entity_id(entity.entity_id): if not valid_entity_id(entity.entity_id):
raise HomeAssistantError( raise HomeAssistantError(
'Invalid entity id: {}'.format(entity.entity_id)) 'Invalid entity id: {}'.format(entity.entity_id))
elif (entity.entity_id in self.entities or if (entity.entity_id in self.entities or
entity.entity_id in self.hass.states.async_entity_ids( entity.entity_id in self.hass.states.async_entity_ids(
self.domain)): self.domain)):
msg = 'Entity id already exists: {}'.format(entity.entity_id) msg = 'Entity id already exists: {}'.format(entity.entity_id)

View File

@ -8,7 +8,7 @@ flake8==3.7.7
mock-open==1.3.1 mock-open==1.3.1
mypy==0.670 mypy==0.670
pydocstyle==3.0.0 pydocstyle==3.0.0
pylint==2.2.2 pylint==2.3.0
pytest-aiohttp==0.3.0 pytest-aiohttp==0.3.0
pytest-cov==2.6.1 pytest-cov==2.6.1
pytest-sugar==0.9.2 pytest-sugar==0.9.2

View File

@ -9,7 +9,7 @@ flake8==3.7.7
mock-open==1.3.1 mock-open==1.3.1
mypy==0.670 mypy==0.670
pydocstyle==3.0.0 pydocstyle==3.0.0
pylint==2.2.2 pylint==2.3.0
pytest-aiohttp==0.3.0 pytest-aiohttp==0.3.0
pytest-cov==2.6.1 pytest-cov==2.6.1
pytest-sugar==0.9.2 pytest-sugar==0.9.2