Upgrade pylint to 2.2.2 (#18750)

* Upgrade to 2.2.0

* simplifiable-if-expression fixes

* duplicate-string-formatting-argument fixes

* unused-import fixes

* Upgrade to 2.2.1

* Remove no longer needed disable

* Upgrade to 2.2.2
This commit is contained in:
Ville Skyttä 2018-12-06 12:54:44 +02:00 committed by Paulus Schoutsen
parent 04c7d5c128
commit 1be440a72b
19 changed files with 35 additions and 40 deletions

View file

@ -92,14 +92,14 @@ class AlarmDecoderBinarySensor(BinarySensorDevice):
"""Return the state attributes.""" """Return the state attributes."""
attr = {} attr = {}
if self._rfid and self._rfstate is not None: if self._rfid and self._rfstate is not None:
attr[ATTR_RF_BIT0] = True if self._rfstate & 0x01 else False attr[ATTR_RF_BIT0] = bool(self._rfstate & 0x01)
attr[ATTR_RF_LOW_BAT] = True if self._rfstate & 0x02 else False attr[ATTR_RF_LOW_BAT] = bool(self._rfstate & 0x02)
attr[ATTR_RF_SUPERVISED] = True if self._rfstate & 0x04 else False attr[ATTR_RF_SUPERVISED] = bool(self._rfstate & 0x04)
attr[ATTR_RF_BIT3] = True if self._rfstate & 0x08 else False attr[ATTR_RF_BIT3] = bool(self._rfstate & 0x08)
attr[ATTR_RF_LOOP3] = True if self._rfstate & 0x10 else False attr[ATTR_RF_LOOP3] = bool(self._rfstate & 0x10)
attr[ATTR_RF_LOOP2] = True if self._rfstate & 0x20 else False attr[ATTR_RF_LOOP2] = bool(self._rfstate & 0x20)
attr[ATTR_RF_LOOP4] = True if self._rfstate & 0x40 else False attr[ATTR_RF_LOOP4] = bool(self._rfstate & 0x40)
attr[ATTR_RF_LOOP1] = True if self._rfstate & 0x80 else False attr[ATTR_RF_LOOP1] = bool(self._rfstate & 0x80)
return attr return attr
@property @property

View file

@ -61,8 +61,7 @@ class MyStromView(HomeAssistantView):
'{}_{}'.format(button_id, button_action)) '{}_{}'.format(button_id, button_action))
self.add_entities([self.buttons[entity_id]]) self.add_entities([self.buttons[entity_id]])
else: else:
new_state = True if self.buttons[entity_id].state == 'off' \ new_state = self.buttons[entity_id].state == 'off'
else False
self.buttons[entity_id].async_on_update(new_state) self.buttons[entity_id].async_on_update(new_state)

View file

@ -55,8 +55,8 @@ MANIFEST_JSON = {
for size in (192, 384, 512, 1024): for size in (192, 384, 512, 1024):
MANIFEST_JSON['icons'].append({ MANIFEST_JSON['icons'].append({
'src': '/static/icons/favicon-{}x{}.png'.format(size, size), 'src': '/static/icons/favicon-{size}x{size}.png'.format(size=size),
'sizes': '{}x{}'.format(size, size), 'sizes': '{size}x{size}'.format(size=size),
'type': 'image/png' 'type': 'image/png'
}) })

View file

@ -245,7 +245,7 @@ class HomeKit():
return return
self.status = STATUS_WAIT self.status = STATUS_WAIT
# pylint: disable=unused-variable # pylint: disable=unused-import
from . import ( # noqa F401 from . import ( # noqa F401
type_covers, type_fans, type_lights, type_locks, type_covers, type_fans, type_lights, type_locks,
type_media_players, type_security_systems, type_sensors, type_media_players, type_security_systems, type_sensors,

View file

@ -78,7 +78,7 @@ class Fan(HomeAccessory):
"""Set state if call came from HomeKit.""" """Set state if call came from HomeKit."""
_LOGGER.debug('%s: Set oscillating to %d', self.entity_id, value) _LOGGER.debug('%s: Set oscillating to %d', self.entity_id, value)
self._flag[CHAR_SWING_MODE] = True self._flag[CHAR_SWING_MODE] = True
oscillating = True if value == 1 else False oscillating = value == 1
params = {ATTR_ENTITY_ID: self.entity_id, params = {ATTR_ENTITY_ID: self.entity_id,
ATTR_OSCILLATING: oscillating} ATTR_OSCILLATING: oscillating}
self.call_service(DOMAIN, SERVICE_OSCILLATE, params, oscillating) self.call_service(DOMAIN, SERVICE_OSCILLATE, params, oscillating)

View file

@ -779,7 +779,7 @@ class BluesoundPlayer(MediaPlayerDevice):
@property @property
def shuffle(self): def shuffle(self):
"""Return true if shuffle is active.""" """Return true if shuffle is active."""
return True if self._status.get('shuffle', '0') == '1' else False return self._status.get('shuffle', '0') == '1'
async def async_join(self, master): async def async_join(self, master):
"""Join the player to a group.""" """Join the player to a group."""

View file

@ -136,7 +136,7 @@ class UERadioDevice(MediaPlayerDevice):
@property @property
def is_volume_muted(self): def is_volume_muted(self):
"""Boolean if volume is currently muted.""" """Boolean if volume is currently muted."""
return True if self._volume <= 0 else False return self._volume <= 0
@property @property
def volume_level(self): def volume_level(self):

View file

@ -9,8 +9,7 @@ CONF_SECRET = 'secret'
def supports_encryption(): def supports_encryption():
"""Test if we support encryption.""" """Test if we support encryption."""
try: try:
# pylint: disable=unused-variable import libnacl # noqa pylint: disable=unused-import
import libnacl # noqa
return True return True
except OSError: except OSError:
return False return False

View file

@ -179,10 +179,8 @@ def _setup_bme680(config):
sensor_handler = BME680Handler( sensor_handler = BME680Handler(
sensor, sensor,
True if ( (SENSOR_GAS in config[CONF_MONITORED_CONDITIONS] or
SENSOR_GAS in config[CONF_MONITORED_CONDITIONS] or SENSOR_AQ in config[CONF_MONITORED_CONDITIONS]),
SENSOR_AQ in config[CONF_MONITORED_CONDITIONS]
) else False,
config[CONF_AQ_BURN_IN_TIME], config[CONF_AQ_BURN_IN_TIME],
config[CONF_AQ_HUM_BASELINE], config[CONF_AQ_HUM_BASELINE],
config[CONF_AQ_HUM_WEIGHTING] config[CONF_AQ_HUM_WEIGHTING]

View file

@ -55,7 +55,7 @@ async def async_setup_platform(hass, config, async_add_entities,
"""Set up the MiFlora sensor.""" """Set up the MiFlora sensor."""
from miflora import miflora_poller from miflora import miflora_poller
try: try:
import bluepy.btle # noqa: F401 pylint: disable=unused-variable import bluepy.btle # noqa: F401 pylint: disable=unused-import
from btlewrap import BluepyBackend from btlewrap import BluepyBackend
backend = BluepyBackend backend = BluepyBackend
except ImportError: except ImportError:

View file

@ -60,7 +60,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the MiTempBt sensor.""" """Set up the MiTempBt sensor."""
from mitemp_bt import mitemp_bt_poller from mitemp_bt import mitemp_bt_poller
try: try:
import bluepy.btle # noqa: F401 pylint: disable=unused-variable import bluepy.btle # noqa: F401 pylint: disable=unused-import
from btlewrap import BluepyBackend from btlewrap import BluepyBackend
backend = BluepyBackend backend = BluepyBackend
except ImportError: except ImportError:

View file

@ -147,10 +147,10 @@ class MVGLiveData:
self._products = products self._products = products
self._timeoffset = timeoffset self._timeoffset = timeoffset
self._number = number self._number = number
self._include_ubahn = True if 'U-Bahn' in self._products else False self._include_ubahn = 'U-Bahn' in self._products
self._include_tram = True if 'Tram' in self._products else False self._include_tram = 'Tram' in self._products
self._include_bus = True if 'Bus' in self._products else False self._include_bus = 'Bus' in self._products
self._include_sbahn = True if 'S-Bahn' in self._products else False self._include_sbahn = 'S-Bahn' in self._products
self.mvg = MVGLive.MVGLive() self.mvg = MVGLive.MVGLive()
self.departures = [] self.departures = []

View file

@ -80,8 +80,7 @@ class StatisticsSensor(Entity):
precision): precision):
"""Initialize the Statistics sensor.""" """Initialize the Statistics sensor."""
self._entity_id = entity_id self._entity_id = entity_id
self.is_binary = True if self._entity_id.split('.')[0] == \ self.is_binary = self._entity_id.split('.')[0] == 'binary_sensor'
'binary_sensor' else False
if not self.is_binary: if not self.is_binary:
self._name = '{} {}'.format(name, ATTR_MEAN) self._name = '{} {}'.format(name, ATTR_MEAN)
else: else:

View file

@ -129,7 +129,7 @@ class APISpaceApiView(HomeAssistantView):
if space_state is not None: if space_state is not None:
state = { state = {
ATTR_OPEN: False if space_state.state == 'off' else True, ATTR_OPEN: space_state.state != 'off',
ATTR_LASTCHANGE: ATTR_LASTCHANGE:
dt_util.as_timestamp(space_state.last_updated), dt_util.as_timestamp(space_state.last_updated),
} }

View file

@ -123,7 +123,7 @@ class I2CHatSwitch(ToggleEntity):
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
"""Turn the device on.""" """Turn the device on."""
try: try:
state = True if self._invert_logic is False else False state = self._invert_logic is False
self.I2C_HATS_MANAGER.write_dq(self._address, self._channel, state) self.I2C_HATS_MANAGER.write_dq(self._address, self._channel, state)
self.schedule_update_ha_state() self.schedule_update_ha_state()
except I2CHatsException as ex: except I2CHatsException as ex:
@ -132,7 +132,7 @@ class I2CHatSwitch(ToggleEntity):
def turn_off(self, **kwargs): def turn_off(self, **kwargs):
"""Turn the device off.""" """Turn the device off."""
try: try:
state = False if self._invert_logic is False else True state = self._invert_logic is not False
self.I2C_HATS_MANAGER.write_dq(self._address, self._channel, state) self.I2C_HATS_MANAGER.write_dq(self._address, self._channel, state)
self.schedule_update_ha_state() self.schedule_update_ha_state()
except I2CHatsException as ex: except I2CHatsException as ex:

View file

@ -437,9 +437,10 @@ def _format_config_error(ex: vol.Invalid, domain: str, config: Dict) -> str:
""" """
message = "Invalid config for [{}]: ".format(domain) message = "Invalid config for [{}]: ".format(domain)
if 'extra keys not allowed' in ex.error_message: if 'extra keys not allowed' in ex.error_message:
message += '[{}] is an invalid option for [{}]. Check: {}->{}.'\ message += '[{option}] is an invalid option for [{domain}]. ' \
.format(ex.path[-1], domain, domain, 'Check: {domain}->{path}.'.format(
'->'.join(str(m) for m in ex.path)) option=ex.path[-1], domain=domain,
path='->'.join(str(m) for m in ex.path))
else: else:
message += '{}.'.format(humanize_error(config, ex)) message += '{}.'.format(humanize_error(config, ex))

View file

@ -68,8 +68,7 @@ async def async_handle(hass: HomeAssistantType, platform: str,
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
# https://github.com/PyCQA/pylint/issues/2284 except IntentHandleError:
except IntentHandleError: # pylint: disable=try-except-raise
raise raise
except Exception as err: except Exception as err:
raise IntentUnexpectedError( raise IntentUnexpectedError(

View file

@ -8,7 +8,7 @@ flake8==3.6.0
mock-open==1.3.1 mock-open==1.3.1
mypy==0.641 mypy==0.641
pydocstyle==2.1.1 pydocstyle==2.1.1
pylint==2.1.1 pylint==2.2.2
pytest-aiohttp==0.3.0 pytest-aiohttp==0.3.0
pytest-cov==2.6.0 pytest-cov==2.6.0
pytest-sugar==0.9.2 pytest-sugar==0.9.2

View file

@ -9,7 +9,7 @@ flake8==3.6.0
mock-open==1.3.1 mock-open==1.3.1
mypy==0.641 mypy==0.641
pydocstyle==2.1.1 pydocstyle==2.1.1
pylint==2.1.1 pylint==2.2.2
pytest-aiohttp==0.3.0 pytest-aiohttp==0.3.0
pytest-cov==2.6.0 pytest-cov==2.6.0
pytest-sugar==0.9.2 pytest-sugar==0.9.2