mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Flake8 35 (#11972)
* Upgrade flake8 to 3.5 * Fix flake8 bare except errors * Make flake8 and pylint cooperate
This commit is contained in:
parent
5426e5c875
commit
78a3c01f27
@ -153,8 +153,7 @@ class StoredData(object):
|
|||||||
with self._lock, open(self._data_file, 'rb') as myfile:
|
with self._lock, open(self._data_file, 'rb') as myfile:
|
||||||
self._data = pickle.load(myfile) or {}
|
self._data = pickle.load(myfile) or {}
|
||||||
self._cache_outdated = False
|
self._cache_outdated = False
|
||||||
# pylint: disable=bare-except
|
except: # noqa: E722 # pylint: disable=bare-except
|
||||||
except:
|
|
||||||
_LOGGER.error("Error loading data from pickled file %s",
|
_LOGGER.error("Error loading data from pickled file %s",
|
||||||
self._data_file)
|
self._data_file)
|
||||||
|
|
||||||
@ -172,8 +171,7 @@ class StoredData(object):
|
|||||||
url, self._data_file)
|
url, self._data_file)
|
||||||
try:
|
try:
|
||||||
pickle.dump(self._data, myfile)
|
pickle.dump(self._data, myfile)
|
||||||
# pylint: disable=bare-except
|
except: # noqa: E722 # pylint: disable=bare-except
|
||||||
except:
|
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Error saving pickled data to %s", self._data_file)
|
"Error saving pickled data to %s", self._data_file)
|
||||||
self._cache_outdated = True
|
self._cache_outdated = True
|
||||||
|
@ -165,7 +165,7 @@ class BluesoundPlayer(MediaPlayerDevice):
|
|||||||
try:
|
try:
|
||||||
resp = yield from self.send_bluesound_command(
|
resp = yield from self.send_bluesound_command(
|
||||||
'SyncStatus', raise_timeout, raise_timeout)
|
'SyncStatus', raise_timeout, raise_timeout)
|
||||||
except:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if not resp:
|
if not resp:
|
||||||
@ -202,7 +202,7 @@ class BluesoundPlayer(MediaPlayerDevice):
|
|||||||
|
|
||||||
except CancelledError:
|
except CancelledError:
|
||||||
_LOGGER.debug("Stopping the polling of node %s", self._name)
|
_LOGGER.debug("Stopping the polling of node %s", self._name)
|
||||||
except:
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected error in %s", self._name)
|
_LOGGER.exception("Unexpected error in %s", self._name)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ class BluesoundPlayer(MediaPlayerDevice):
|
|||||||
_LOGGER.info("Node %s is offline, retrying later", self.host)
|
_LOGGER.info("Node %s is offline, retrying later", self.host)
|
||||||
self._retry_remove = async_track_time_interval(
|
self._retry_remove = async_track_time_interval(
|
||||||
self._hass, self.async_init, NODE_RETRY_INITIATION)
|
self._hass, self.async_init, NODE_RETRY_INITIATION)
|
||||||
except:
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected when initiating error in %s",
|
_LOGGER.exception("Unexpected when initiating error in %s",
|
||||||
self.host)
|
self.host)
|
||||||
raise
|
raise
|
||||||
|
@ -97,7 +97,7 @@ class ClementineDevice(MediaPlayerDevice):
|
|||||||
self._track_artist = client.current_track['track_artist']
|
self._track_artist = client.current_track['track_artist']
|
||||||
self._track_album_name = client.current_track['track_album']
|
self._track_album_name = client.current_track['track_album']
|
||||||
|
|
||||||
except:
|
except Exception:
|
||||||
self._state = STATE_OFF
|
self._state = STATE_OFF
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -70,8 +70,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
phonebook = FritzBoxPhonebook(
|
phonebook = FritzBoxPhonebook(
|
||||||
host=host, port=port, username=username, password=password,
|
host=host, port=port, username=username, password=password,
|
||||||
phonebook_id=phonebook_id, prefixes=prefixes)
|
phonebook_id=phonebook_id, prefixes=prefixes)
|
||||||
# pylint: disable=bare-except
|
except: # noqa: E722 # pylint: disable=bare-except
|
||||||
except:
|
|
||||||
phonebook = None
|
phonebook = None
|
||||||
_LOGGER.warning("Phonebook with ID %s not found on Fritz!Box",
|
_LOGGER.warning("Phonebook with ID %s not found on Fritz!Box",
|
||||||
phonebook_id)
|
phonebook_id)
|
||||||
|
@ -197,7 +197,6 @@ class QNAPStatsAPI(object):
|
|||||||
|
|
||||||
self.data = {}
|
self.data = {}
|
||||||
|
|
||||||
# pylint: disable=bare-except
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update API information and store locally."""
|
"""Update API information and store locally."""
|
||||||
@ -207,7 +206,7 @@ class QNAPStatsAPI(object):
|
|||||||
self.data["smart_drive_health"] = self._api.get_smart_disk_health()
|
self.data["smart_drive_health"] = self._api.get_smart_disk_health()
|
||||||
self.data["volumes"] = self._api.get_volumes()
|
self.data["volumes"] = self._api.get_volumes()
|
||||||
self.data["bandwidth"] = self._api.get_bandwidth()
|
self.data["bandwidth"] = self._api.get_bandwidth()
|
||||||
except:
|
except: # noqa: E722 # pylint: disable=bare-except
|
||||||
_LOGGER.exception("Failed to fetch QNAP stats from the NAS")
|
_LOGGER.exception("Failed to fetch QNAP stats from the NAS")
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +136,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
class SynoApi(object):
|
class SynoApi(object):
|
||||||
"""Class to interface with Synology DSM API."""
|
"""Class to interface with Synology DSM API."""
|
||||||
|
|
||||||
# pylint: disable=bare-except
|
|
||||||
def __init__(self, host, port, username, password, temp_unit):
|
def __init__(self, host, port, username, password, temp_unit):
|
||||||
"""Initialize the API wrapper class."""
|
"""Initialize the API wrapper class."""
|
||||||
from SynologyDSM import SynologyDSM
|
from SynologyDSM import SynologyDSM
|
||||||
@ -144,7 +143,7 @@ class SynoApi(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._api = SynologyDSM(host, port, username, password)
|
self._api = SynologyDSM(host, port, username, password)
|
||||||
except:
|
except: # noqa: E722 # pylint: disable=bare-except
|
||||||
_LOGGER.error("Error setting up Synology DSM")
|
_LOGGER.error("Error setting up Synology DSM")
|
||||||
|
|
||||||
# Will be updated when update() gets called.
|
# Will be updated when update() gets called.
|
||||||
|
@ -151,7 +151,7 @@ def _ws_process_message(message, async_callback, *args):
|
|||||||
"Unsuccessful websocket message delivered, ignoring: %s", message)
|
"Unsuccessful websocket message delivered, ignoring: %s", message)
|
||||||
try:
|
try:
|
||||||
yield from async_callback(message['data']['sia'], *args)
|
yield from async_callback(message['data']['sia'], *args)
|
||||||
except: # pylint: disable=bare-except
|
except: # noqa: E722 # pylint: disable=bare-except
|
||||||
_LOGGER.exception("Exception in callback, ignoring")
|
_LOGGER.exception("Exception in callback, ignoring")
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ def patch_weakref_tasks():
|
|||||||
asyncio.tasks.Task._all_tasks = IgnoreCalls()
|
asyncio.tasks.Task._all_tasks = IgnoreCalls()
|
||||||
try:
|
try:
|
||||||
del asyncio.tasks.Task.__del__
|
del asyncio.tasks.Task.__del__
|
||||||
except:
|
except: # noqa: E722
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# linters such as flake8 and pylint should be pinned, as new releases
|
# linters such as flake8 and pylint should be pinned, as new releases
|
||||||
# make new things fail. Manually update these pins when pulling in a
|
# make new things fail. Manually update these pins when pulling in a
|
||||||
# new version
|
# new version
|
||||||
flake8==3.3
|
flake8==3.5
|
||||||
pylint==1.6.5
|
pylint==1.6.5
|
||||||
mypy==0.560
|
mypy==0.560
|
||||||
pydocstyle==1.1.1
|
pydocstyle==1.1.1
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# linters such as flake8 and pylint should be pinned, as new releases
|
# linters such as flake8 and pylint should be pinned, as new releases
|
||||||
# make new things fail. Manually update these pins when pulling in a
|
# make new things fail. Manually update these pins when pulling in a
|
||||||
# new version
|
# new version
|
||||||
flake8==3.3
|
flake8==3.5
|
||||||
pylint==1.6.5
|
pylint==1.6.5
|
||||||
mypy==0.560
|
mypy==0.560
|
||||||
pydocstyle==1.1.1
|
pydocstyle==1.1.1
|
||||||
|
@ -87,10 +87,9 @@ class TestEmulatedHue(unittest.TestCase):
|
|||||||
self.assertTrue('text/xml' in result.headers['content-type'])
|
self.assertTrue('text/xml' in result.headers['content-type'])
|
||||||
|
|
||||||
# Make sure the XML is parsable
|
# Make sure the XML is parsable
|
||||||
# pylint: disable=bare-except
|
|
||||||
try:
|
try:
|
||||||
ET.fromstring(result.text)
|
ET.fromstring(result.text)
|
||||||
except:
|
except: # noqa: E722 # pylint: disable=bare-except
|
||||||
self.fail('description.xml is not valid XML!')
|
self.fail('description.xml is not valid XML!')
|
||||||
|
|
||||||
def test_create_username(self):
|
def test_create_username(self):
|
||||||
|
@ -34,7 +34,7 @@ def get_error_log(hass, test_client, expected_count):
|
|||||||
def _generate_and_log_exception(exception, log):
|
def _generate_and_log_exception(exception, log):
|
||||||
try:
|
try:
|
||||||
raise Exception(exception)
|
raise Exception(exception)
|
||||||
except: # pylint: disable=bare-except
|
except: # noqa: E722 # pylint: disable=bare-except
|
||||||
_LOGGER.exception(log)
|
_LOGGER.exception(log)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user