From 27c18068971096219b720e0f18ebb68cde34739e Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Thu, 15 Mar 2018 12:10:54 +0100 Subject: [PATCH] Python 3.5 adjustments (#13173) --- homeassistant/bootstrap.py | 8 -------- homeassistant/components/mysensors.py | 5 ++--- homeassistant/core.py | 6 +----- homeassistant/monkey_patch.py | 2 +- homeassistant/scripts/check_config.py | 9 ++++++--- tests/scripts/test_check_config.py | 4 +--- 6 files changed, 11 insertions(+), 23 deletions(-) diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index 34eab679581..00822d93299 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -86,14 +86,6 @@ def async_from_config_dict(config: Dict[str, Any], if enable_log: async_enable_logging(hass, verbose, log_rotate_days, log_file) - if sys.version_info[:2] < (3, 5): - _LOGGER.warning( - 'Python 3.4 support has been deprecated and will be removed in ' - 'the beginning of 2018. Please upgrade Python or your operating ' - 'system. More info: https://home-assistant.io/blog/2017/10/06/' - 'deprecating-python-3.4-support/' - ) - core_config = config.get(core.DOMAIN, {}) try: diff --git a/homeassistant/components/mysensors.py b/homeassistant/components/mysensors.py index 37e257e5eb9..a560b49648f 100644 --- a/homeassistant/components/mysensors.py +++ b/homeassistant/components/mysensors.py @@ -545,9 +545,8 @@ def setup_mysensors_platform( device_class_copy = device_class[s_type] name = get_mysensors_name(gateway, node_id, child_id) - # python 3.4 cannot unpack inside tuple, but combining tuples works - args_copy = device_args + ( - gateway, node_id, child_id, name, value_type) + args_copy = (*device_args, gateway, node_id, child_id, name, + value_type) devices[dev_id] = device_class_copy(*args_copy) new_devices.append(devices[dev_id]) if new_devices: diff --git a/homeassistant/core.py b/homeassistant/core.py index a486ee1adbf..b49b94f853d 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -117,11 +117,7 @@ class HomeAssistant(object): else: self.loop = loop or asyncio.get_event_loop() - executor_opts = {'max_workers': 10} - if sys.version_info[:2] >= (3, 5): - # It will default set to the number of processors on the machine, - # multiplied by 5. That is better for overlap I/O workers. - executor_opts['max_workers'] = None + executor_opts = {'max_workers': None} if sys.version_info[:2] >= (3, 6): executor_opts['thread_name_prefix'] = 'SyncWorker' diff --git a/homeassistant/monkey_patch.py b/homeassistant/monkey_patch.py index 5aa051f2bb5..d5c629c9d34 100644 --- a/homeassistant/monkey_patch.py +++ b/homeassistant/monkey_patch.py @@ -61,7 +61,7 @@ def disable_c_asyncio(): def find_module(self, fullname, path=None): """Find a module.""" if fullname == self.PATH_TRIGGER: - # We lint in Py34, exception is introduced in Py36 + # We lint in Py35, exception is introduced in Py36 # pylint: disable=undefined-variable raise ModuleNotFoundError() # noqa return None diff --git a/homeassistant/scripts/check_config.py b/homeassistant/scripts/check_config.py index 1a58757d17f..ac3ac62e82d 100644 --- a/homeassistant/scripts/check_config.py +++ b/homeassistant/scripts/check_config.py @@ -95,9 +95,12 @@ def run(script_args: List) -> int: if args.files: print(color(C_HEAD, 'yaml files'), '(used /', color('red', 'not used') + ')') - # Python 3.5 gets a recursive, but not in 3.4 - for yfn in sorted(glob(os.path.join(config_dir, '*.yaml')) + - glob(os.path.join(config_dir, '*/*.yaml'))): + deps = os.path.join(config_dir, 'deps') + yaml_files = [f for f in glob(os.path.join(config_dir, '**/*.yaml'), + recursive=True) + if not f.startswith(deps)] + + for yfn in sorted(yaml_files): the_color = '' if yfn in res['yaml_files'] else 'red' print(color(the_color, '-', yfn)) diff --git a/tests/scripts/test_check_config.py b/tests/scripts/test_check_config.py index 677ed8de110..28a3f2ebdc8 100644 --- a/tests/scripts/test_check_config.py +++ b/tests/scripts/test_check_config.py @@ -41,9 +41,7 @@ class TestCheckConfig(unittest.TestCase): # this ensures we have one. try: asyncio.get_event_loop() - except (RuntimeError, AssertionError): - # Py35: RuntimeError - # Py34: AssertionError + except RuntimeError: asyncio.set_event_loop(asyncio.new_event_loop()) # Will allow seeing full diff