Upgrade linter (#4461)
This commit is contained in:
parent
37e28428c1
commit
d2bbc6ef70
21 changed files with 28 additions and 7 deletions
|
@ -66,6 +66,7 @@ def _platform_validator(config):
|
||||||
|
|
||||||
return getattr(platform, 'TRIGGER_SCHEMA')(config)
|
return getattr(platform, 'TRIGGER_SCHEMA')(config)
|
||||||
|
|
||||||
|
|
||||||
_TRIGGER_SCHEMA = vol.All(
|
_TRIGGER_SCHEMA = vol.All(
|
||||||
cv.ensure_list,
|
cv.ensure_list,
|
||||||
[
|
[
|
||||||
|
|
|
@ -42,6 +42,7 @@ def get_scanner(hass, config):
|
||||||
scanner = ActiontecDeviceScanner(config[DOMAIN])
|
scanner = ActiontecDeviceScanner(config[DOMAIN])
|
||||||
return scanner if scanner.success_init else None
|
return scanner if scanner.success_init else None
|
||||||
|
|
||||||
|
|
||||||
Device = namedtuple("Device", ["mac", "ip", "last_update"])
|
Device = namedtuple("Device", ["mac", "ip", "last_update"])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ def get_scanner(hass, config):
|
||||||
|
|
||||||
return scanner if scanner.success_init else None
|
return scanner if scanner.success_init else None
|
||||||
|
|
||||||
|
|
||||||
AsusWrtResult = namedtuple('AsusWrtResult', 'neighbors leases arp nvram')
|
AsusWrtResult = namedtuple('AsusWrtResult', 'neighbors leases arp nvram')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ def get_scanner(hass, config):
|
||||||
|
|
||||||
return scanner if scanner.success_init else None
|
return scanner if scanner.success_init else None
|
||||||
|
|
||||||
|
|
||||||
Device = namedtuple('Device', ['mac', 'name', 'ip', 'last_update'])
|
Device = namedtuple('Device', ['mac', 'name', 'ip', 'last_update'])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -222,6 +222,7 @@ class GzipFileSender(FileSender):
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
_GZIP_FILE_SENDER = GzipFileSender()
|
_GZIP_FILE_SENDER = GzipFileSender()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ def _cv_input_slider(cfg):
|
||||||
cfg[CONF_INITIAL] = state
|
cfg[CONF_INITIAL] = state
|
||||||
return cfg
|
return cfg
|
||||||
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
DOMAIN: vol.Schema({
|
DOMAIN: vol.Schema({
|
||||||
cv.slug: vol.All({
|
cv.slug: vol.All({
|
||||||
|
|
|
@ -78,6 +78,7 @@ def valid_publish_topic(value):
|
||||||
"""Validate that we can publish using this MQTT topic."""
|
"""Validate that we can publish using this MQTT topic."""
|
||||||
return valid_subscribe_topic(value, invalid_chars='#+\0')
|
return valid_subscribe_topic(value, invalid_chars='#+\0')
|
||||||
|
|
||||||
|
|
||||||
_VALID_QOS_SCHEMA = vol.All(vol.Coerce(int), vol.In([0, 1, 2]))
|
_VALID_QOS_SCHEMA = vol.All(vol.Coerce(int), vol.In([0, 1, 2]))
|
||||||
_HBMQTT_CONFIG_SCHEMA = vol.Schema(dict)
|
_HBMQTT_CONFIG_SCHEMA = vol.Schema(dict)
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ def valid_sensor(value):
|
||||||
def _valid_light_switch(value):
|
def _valid_light_switch(value):
|
||||||
return _valid_device(value, "light_switch")
|
return _valid_device(value, "light_switch")
|
||||||
|
|
||||||
|
|
||||||
DEVICE_SCHEMA = vol.Schema({
|
DEVICE_SCHEMA = vol.Schema({
|
||||||
vol.Required(ATTR_NAME): cv.string,
|
vol.Required(ATTR_NAME): cv.string,
|
||||||
vol.Optional(ATTR_FIREEVENT, default=False): cv.boolean,
|
vol.Optional(ATTR_FIREEVENT, default=False): cv.boolean,
|
||||||
|
|
|
@ -93,6 +93,7 @@ def _valid_customize(value):
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
CORE_CONFIG_SCHEMA = vol.Schema({
|
CORE_CONFIG_SCHEMA = vol.Schema({
|
||||||
CONF_NAME: vol.Coerce(str),
|
CONF_NAME: vol.Coerce(str),
|
||||||
CONF_LATITUDE: cv.latitude,
|
CONF_LATITUDE: cv.latitude,
|
||||||
|
|
|
@ -305,6 +305,7 @@ def time_zone(value):
|
||||||
'Invalid time zone passed in. Valid options can be found here: '
|
'Invalid time zone passed in. Valid options can be found here: '
|
||||||
'http://en.wikipedia.org/wiki/List_of_tz_database_time_zones')
|
'http://en.wikipedia.org/wiki/List_of_tz_database_time_zones')
|
||||||
|
|
||||||
|
|
||||||
weekdays = vol.All(ensure_list, [vol.In(WEEKDAYS)])
|
weekdays = vol.All(ensure_list, [vol.In(WEEKDAYS)])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -417,6 +417,7 @@ class TemplateEnvironment(ImmutableSandboxedEnvironment):
|
||||||
"""Test if callback is safe."""
|
"""Test if callback is safe."""
|
||||||
return isinstance(obj, AllStates) or super().is_safe_callable(obj)
|
return isinstance(obj, AllStates) or super().is_safe_callable(obj)
|
||||||
|
|
||||||
|
|
||||||
ENV = TemplateEnvironment()
|
ENV = TemplateEnvironment()
|
||||||
ENV.filters['round'] = forgiving_round
|
ENV.filters['round'] = forgiving_round
|
||||||
ENV.filters['multiply'] = multiply
|
ENV.filters['multiply'] = multiply
|
||||||
|
|
|
@ -249,6 +249,7 @@ def _secret_yaml(loader: SafeLineLoader,
|
||||||
_LOGGER.error('Secret %s not defined.', node.value)
|
_LOGGER.error('Secret %s not defined.', node.value)
|
||||||
raise HomeAssistantError(node.value)
|
raise HomeAssistantError(node.value)
|
||||||
|
|
||||||
|
|
||||||
yaml.SafeLoader.add_constructor('!include', _include_yaml)
|
yaml.SafeLoader.add_constructor('!include', _include_yaml)
|
||||||
yaml.SafeLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
|
yaml.SafeLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
|
||||||
_ordered_dict)
|
_ordered_dict)
|
||||||
|
|
|
@ -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.0.4
|
flake8==3.2.0
|
||||||
pylint==1.6.4
|
pylint==1.6.4
|
||||||
mypy-lang==0.4.5
|
mypy-lang==0.4.5
|
||||||
pydocstyle==1.1.1
|
pydocstyle==1.1.1
|
||||||
|
|
|
@ -34,5 +34,6 @@ FINGERPRINTS = {}
|
||||||
with open(fingerprint_file, 'w') as fp:
|
with open(fingerprint_file, 'w') as fp:
|
||||||
fp.write(result)
|
fp.write(result)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
fingerprint()
|
fingerprint()
|
||||||
|
|
|
@ -138,5 +138,6 @@ def main():
|
||||||
|
|
||||||
write_file(data)
|
write_file(data)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -63,5 +63,6 @@ def main():
|
||||||
|
|
||||||
print('Updated to latest version')
|
print('Updated to latest version')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -184,8 +184,10 @@ class TestApns(unittest.TestCase):
|
||||||
|
|
||||||
devices_path = hass.config.path('test_app_apns.yaml')
|
devices_path = hass.config.path('test_app_apns.yaml')
|
||||||
with open(devices_path, 'w+') as out:
|
with open(devices_path, 'w+') as out:
|
||||||
out.write('1234: {name: test device 1, tracking_device_id: tracking123}\n') # nopep8
|
out.write('1234: {name: test device 1, '
|
||||||
out.write('5678: {name: test device 2, tracking_device_id: tracking456}\n') # nopep8
|
'tracking_device_id: tracking123}\n')
|
||||||
|
out.write('5678: {name: test device 2, '
|
||||||
|
'tracking_device_id: tracking456}\n')
|
||||||
|
|
||||||
notify.setup(hass, config)
|
notify.setup(hass, config)
|
||||||
self.assertTrue(hass.services.call('apns',
|
self.assertTrue(hass.services.call('apns',
|
||||||
|
@ -293,8 +295,10 @@ class TestApns(unittest.TestCase):
|
||||||
|
|
||||||
devices_path = hass.config.path('test_app_apns.yaml')
|
devices_path = hass.config.path('test_app_apns.yaml')
|
||||||
with open(devices_path, 'w+') as out:
|
with open(devices_path, 'w+') as out:
|
||||||
out.write('1234: {name: test device 1, tracking_device_id: tracking123}\n') # nopep8
|
out.write('1234: {name: test device 1, '
|
||||||
out.write('5678: {name: test device 2, tracking_device_id: tracking456}\n') # nopep8
|
'tracking_device_id: tracking123}\n')
|
||||||
|
out.write('5678: {name: test device 2, '
|
||||||
|
'tracking_device_id: tracking456}\n')
|
||||||
|
|
||||||
notify_service = ApnsNotificationService(
|
notify_service = ApnsNotificationService(
|
||||||
hass,
|
hass,
|
||||||
|
|
|
@ -29,6 +29,7 @@ def test_real(func):
|
||||||
|
|
||||||
return guard_func
|
return guard_func
|
||||||
|
|
||||||
|
|
||||||
# Guard a few functions that would make network connections
|
# Guard a few functions that would make network connections
|
||||||
location.detect_location_info = test_real(location.detect_location_info)
|
location.detect_location_info = test_real(location.detect_location_info)
|
||||||
location.elevation = test_real(location.elevation)
|
location.elevation = test_real(location.elevation)
|
||||||
|
|
|
@ -341,7 +341,7 @@ def test_template_complex():
|
||||||
1, 'Hello',
|
1, 'Hello',
|
||||||
'{{ beer }}',
|
'{{ beer }}',
|
||||||
'{% if 1 == 1 %}Hello{% else %}World{% endif %}',
|
'{% if 1 == 1 %}Hello{% else %}World{% endif %}',
|
||||||
{'test': 1, 'test': '{{ beer }}'},
|
{'test': 1, 'test2': '{{ beer }}'},
|
||||||
['{{ beer }}', 1]
|
['{{ beer }}', 1]
|
||||||
):
|
):
|
||||||
schema(value)
|
schema(value)
|
||||||
|
|
|
@ -36,4 +36,5 @@ class MockScanner(object):
|
||||||
"""
|
"""
|
||||||
return None if device == 'DEV1' else device.lower()
|
return None if device == 'DEV1' else device.lower()
|
||||||
|
|
||||||
|
|
||||||
SCANNER = MockScanner()
|
SCANNER = MockScanner()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue