From 9953ea83ff36921dfef2ee052e8a5c01c48e8f96 Mon Sep 17 00:00:00 2001 From: andrey-git Date: Fri, 18 May 2018 13:17:33 +0300 Subject: [PATCH 01/13] Add python 3.7 to travis and tox --- .travis.yml | 4 ++-- tox.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b089d3f89be327..37ca04fc300e3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,8 @@ matrix: env: TOXENV=py35 - python: "3.6" env: TOXENV=py36 - # - python: "3.6-dev" - # env: TOXENV=py36 + - python: "3.7-dev" + env: TOXENV=py37 # allow_failures: # - python: "3.5" # env: TOXENV=typing diff --git a/tox.ini b/tox.ini index 8b034346475f54..cb22562a98db28 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py35, py36, lint, pylint, typing +envlist = py35, py36, py37, lint, pylint, typing skip_missing_interpreters = True [testenv] From e71b3895603af783b7fb57dd935aa2bb0e043f94 Mon Sep 17 00:00:00 2001 From: andrey-git Date: Fri, 18 May 2018 13:50:08 +0300 Subject: [PATCH 02/13] Use pyyaml from github --- tox.ini | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tox.ini b/tox.ini index cb22562a98db28..f079438179c09b 100644 --- a/tox.ini +++ b/tox.ini @@ -27,6 +27,14 @@ deps = commands = pylint homeassistant +[testenv:py37] +deps = + # Workaround for yaml/pyyaml#126 + git+https://github.com/yaml/pyyaml@master#egg=pyyaml + -r{toxinidir}/requirements_all.txt + -r{toxinidir}/requirements_test.txt + -c{toxinidir}/homeassistant/package_constraints.txt + [testenv:lint] basepython = {env:PYTHON3_PATH:python3} deps = From f6e1fcfbe8da4d81f5d944d32b12b806a4e07131 Mon Sep 17 00:00:00 2001 From: andrey-git Date: Fri, 18 May 2018 14:42:25 +0300 Subject: [PATCH 03/13] Don't version constraints --- homeassistant/package_constraints.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index f6666c829e0d22..d75c24ea379b02 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -1,5 +1,5 @@ requests==2.18.4 -pyyaml>=3.11,<4 +pyyaml>=3.11,<4 ; python_version < '3.7' pytz>=2017.02 pip>=8.0.3 jinja2>=2.10 From 3794c2cc645aded7e2f7386c98874bf3835c9b5c Mon Sep 17 00:00:00 2001 From: andrey-git Date: Fri, 18 May 2018 14:50:49 +0300 Subject: [PATCH 04/13] Fix version tag --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index f079438179c09b..4a9f939b1885f9 100644 --- a/tox.ini +++ b/tox.ini @@ -30,7 +30,7 @@ commands = [testenv:py37] deps = # Workaround for yaml/pyyaml#126 - git+https://github.com/yaml/pyyaml@master#egg=pyyaml + git+https://github.com/yaml/pyyaml@master#pyyaml==3.12 -r{toxinidir}/requirements_all.txt -r{toxinidir}/requirements_test.txt -c{toxinidir}/homeassistant/package_constraints.txt From 44949109121e14a50be0d7bb7d1cb8c1a836d877 Mon Sep 17 00:00:00 2001 From: andrey-git Date: Sat, 7 Jul 2018 10:27:51 +0300 Subject: [PATCH 05/13] Change to new pyyaml release --- .travis.yml | 2 +- homeassistant/package_constraints.txt | 2 +- requirements_all.txt | 2 +- setup.py | 2 +- tox.ini | 8 -------- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 37ca04fc300e3c..adbe8fa52a4b63 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: env: TOXENV=py35 - python: "3.6" env: TOXENV=py36 - - python: "3.7-dev" + - python: "3.7" env: TOXENV=py37 # allow_failures: # - python: "3.5" diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 32374b90135b89..66b17cf9bd99d5 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -6,7 +6,7 @@ certifi>=2018.04.16 jinja2>=2.10 pip>=8.0.3 pytz>=2018.04 -pyyaml>=3.11,<4 +pyyaml>=3.13,<4 requests==2.19.1 voluptuous==0.11.1 diff --git a/requirements_all.txt b/requirements_all.txt index c72e56821d6f11..71380b40a10559 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -7,7 +7,7 @@ certifi>=2018.04.16 jinja2>=2.10 pip>=8.0.3 pytz>=2018.04 -pyyaml>=3.11,<4 +pyyaml>=3.13,<4 requests==2.19.1 voluptuous==0.11.1 diff --git a/setup.py b/setup.py index 928d894c9d1a9f..bbf10dd309dc40 100755 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ 'jinja2>=2.10', 'pip>=8.0.3', 'pytz>=2018.04', - 'pyyaml>=3.11,<4', + 'pyyaml>=3.13,<4', 'requests==2.19.1', 'voluptuous==0.11.1', ] diff --git a/tox.ini b/tox.ini index 6face422a74015..578a431febf9cd 100644 --- a/tox.ini +++ b/tox.ini @@ -27,14 +27,6 @@ deps = commands = pylint {posargs} homeassistant -[testenv:py37] -deps = - # Workaround for yaml/pyyaml#126 - git+https://github.com/yaml/pyyaml@master#pyyaml==3.12 - -r{toxinidir}/requirements_all.txt - -r{toxinidir}/requirements_test.txt - -c{toxinidir}/homeassistant/package_constraints.txt - [testenv:lint] basepython = {env:PYTHON3_PATH:python3} deps = From b603297389425b24a6c143593317f50568f11162 Mon Sep 17 00:00:00 2001 From: andrey-git Date: Sat, 7 Jul 2018 10:42:38 +0300 Subject: [PATCH 06/13] Python 3.7 requires xenial --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index adbe8fa52a4b63..5b3c43ec8c8bae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ matrix: env: TOXENV=py36 - python: "3.7" env: TOXENV=py37 + dist: xenial # allow_failures: # - python: "3.5" # env: TOXENV=typing From 152056e63490715f1d4ca31390543359c83125b6 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 7 Jul 2018 12:05:59 +0200 Subject: [PATCH 07/13] Fix namespace detection --- homeassistant/loader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/loader.py b/homeassistant/loader.py index 9e5efffdccbab1..9053adcd123002 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -87,7 +87,8 @@ def get_component(hass, comp_or_platform) -> Optional[ModuleType]: # This prevents that when only # custom_components/switch/some_platform.py exists, # the import custom_components.switch would succeed. - if module.__spec__ and module.__spec__.origin == 'namespace': + # __file__ was unset for namespaces before Python 3.7 + if getattr(module, '__file__') is None: continue _LOGGER.info("Loaded %s from %s", comp_or_platform, path) From f1a979ae399debae127ee1ebe2a5509e43dc7388 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 7 Jul 2018 12:06:08 +0200 Subject: [PATCH 08/13] Use correct RegEx type --- tests/test_util/aiohttp.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_util/aiohttp.py b/tests/test_util/aiohttp.py index e67d5de50d1bcc..0296b8c2fbab54 100644 --- a/tests/test_util/aiohttp.py +++ b/tests/test_util/aiohttp.py @@ -11,6 +11,8 @@ from aiohttp.client_exceptions import ClientResponseError +retype = type(re.compile('')) + class AiohttpClientMocker: """Mock Aiohttp client requests.""" @@ -40,7 +42,7 @@ def request(self, method, url, *, if content is None: content = b'' - if not isinstance(url, re._pattern_type): + if not isinstance(url, retype): url = URL(url) if params: url = url.with_query(params) @@ -146,7 +148,7 @@ def match_request(self, method, url, params=None): return False # regular expression matching - if isinstance(self._url, re._pattern_type): + if isinstance(self._url, retype): return self._url.search(str(url)) is not None if (self._url.scheme != url.scheme or self._url.host != url.host or From e8b3c038252e4c915f414a3121f195d6bcd67f4f Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 7 Jul 2018 12:09:20 +0200 Subject: [PATCH 09/13] Update pexpect to 4.6 --- homeassistant/components/device_tracker/unifi_direct.py | 2 +- requirements_all.txt | 4 +++- requirements_test_all.txt | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/device_tracker/unifi_direct.py b/homeassistant/components/device_tracker/unifi_direct.py index c3c4a48bb826ff..228443fe22ba66 100644 --- a/homeassistant/components/device_tracker/unifi_direct.py +++ b/homeassistant/components/device_tracker/unifi_direct.py @@ -16,7 +16,7 @@ CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_PORT) -REQUIREMENTS = ['pexpect==4.0.1'] +REQUIREMENTS = ['pexpect==4.6.0'] _LOGGER = logging.getLogger(__name__) diff --git a/requirements_all.txt b/requirements_all.txt index 71380b40a10559..22855caef323c0 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -628,10 +628,12 @@ pdunehd==1.3 # homeassistant.components.device_tracker.aruba # homeassistant.components.device_tracker.asuswrt # homeassistant.components.device_tracker.cisco_ios -# homeassistant.components.device_tracker.unifi_direct # homeassistant.components.media_player.pandora pexpect==4.0.1 +# homeassistant.components.device_tracker.unifi_direct +pexpect==4.6.0 + # homeassistant.components.rpi_pfio pifacecommon==4.1.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index aabbdc44bea154..770942236c4bb8 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -111,10 +111,12 @@ paho-mqtt==1.3.1 # homeassistant.components.device_tracker.aruba # homeassistant.components.device_tracker.asuswrt # homeassistant.components.device_tracker.cisco_ios -# homeassistant.components.device_tracker.unifi_direct # homeassistant.components.media_player.pandora pexpect==4.0.1 +# homeassistant.components.device_tracker.unifi_direct +pexpect==4.6.0 + # homeassistant.components.pilight pilight==0.1.1 From 03cc1949fb1aa3b575cd02371ff54d8cdd8dff92 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 7 Jul 2018 12:13:53 +0200 Subject: [PATCH 10/13] Use correct validation for dictionaries --- homeassistant/components/vacuum/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/vacuum/__init__.py b/homeassistant/components/vacuum/__init__.py index 1b7d5685231602..880b3604a86a49 100644 --- a/homeassistant/components/vacuum/__init__.py +++ b/homeassistant/components/vacuum/__init__.py @@ -57,7 +57,7 @@ VACUUM_SEND_COMMAND_SERVICE_SCHEMA = VACUUM_SERVICE_SCHEMA.extend({ vol.Required(ATTR_COMMAND): cv.string, - vol.Optional(ATTR_PARAMS): vol.Any(cv.Dict, cv.ensure_list), + vol.Optional(ATTR_PARAMS): vol.Any(dict, cv.ensure_list), }) SERVICE_TO_METHOD = { From eb626ad7a0af1563bf82032de25e66631ade1aed Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 7 Jul 2018 12:27:17 +0200 Subject: [PATCH 11/13] Disable Py37 incompatible packages --- tests/components/mqtt/test_server.py | 6 ++++++ tests/components/sensor/test_geo_rss_events.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/tests/components/mqtt/test_server.py b/tests/components/mqtt/test_server.py index 9b4c0c69ac63f2..1c37c9049f3188 100644 --- a/tests/components/mqtt/test_server.py +++ b/tests/components/mqtt/test_server.py @@ -1,5 +1,8 @@ """The tests for the MQTT component embedded server.""" from unittest.mock import Mock, MagicMock, patch +import sys + +import pytest from homeassistant.setup import setup_component import homeassistant.components.mqtt as mqtt @@ -7,6 +10,9 @@ from tests.common import get_test_home_assistant, mock_coro +# Until https://github.com/beerfactory/hbmqtt/pull/139 is released +@pytest.mark.skipif(sys.version_info[:2] >= (3, 7), + reason='Package incompatible with Python 3.7') class TestMQTT: """Test the MQTT component.""" diff --git a/tests/components/sensor/test_geo_rss_events.py b/tests/components/sensor/test_geo_rss_events.py index f9ec83cc8be0e8..cc57c80143005a 100644 --- a/tests/components/sensor/test_geo_rss_events.py +++ b/tests/components/sensor/test_geo_rss_events.py @@ -1,7 +1,10 @@ """The test for the geo rss events sensor platform.""" import unittest from unittest import mock +import sys + import feedparser +import pytest from homeassistant.setup import setup_component from tests.common import load_fixture, get_test_home_assistant @@ -22,6 +25,9 @@ } +# Until https://github.com/kurtmckee/feedparser/pull/131 is released. +@pytest.mark.skipif(sys.version_info[:2] >= (3, 7), + reason='Package incompatible with Python 3.7') class TestGeoRssServiceUpdater(unittest.TestCase): """Test the GeoRss service updater.""" From d4f80523907addd1fc939c4d6e3e44d27f3076ae Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 7 Jul 2018 12:35:51 +0200 Subject: [PATCH 12/13] Upgrade all pexpect to 4.6 --- homeassistant/components/device_tracker/aruba.py | 2 +- homeassistant/components/device_tracker/asuswrt.py | 2 +- homeassistant/components/device_tracker/cisco_ios.py | 2 +- homeassistant/components/media_player/pandora.py | 2 +- requirements_all.txt | 4 +--- requirements_test_all.txt | 4 +--- 6 files changed, 6 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/device_tracker/aruba.py b/homeassistant/components/device_tracker/aruba.py index 92ef78f60f3b0b..61eee99e721607 100644 --- a/homeassistant/components/device_tracker/aruba.py +++ b/homeassistant/components/device_tracker/aruba.py @@ -16,7 +16,7 @@ _LOGGER = logging.getLogger(__name__) -REQUIREMENTS = ['pexpect==4.0.1'] +REQUIREMENTS = ['pexpect==4.6.0'] _DEVICES_REGEX = re.compile( r'(?P([^\s]+)?)\s+' + diff --git a/homeassistant/components/device_tracker/asuswrt.py b/homeassistant/components/device_tracker/asuswrt.py index 5cb7e283c99721..bea02143d72a6b 100644 --- a/homeassistant/components/device_tracker/asuswrt.py +++ b/homeassistant/components/device_tracker/asuswrt.py @@ -19,7 +19,7 @@ CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_PORT, CONF_MODE, CONF_PROTOCOL) -REQUIREMENTS = ['pexpect==4.0.1'] +REQUIREMENTS = ['pexpect==4.6.0'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/device_tracker/cisco_ios.py b/homeassistant/components/device_tracker/cisco_ios.py index c13f622c5bf101..1afea2c1607f73 100644 --- a/homeassistant/components/device_tracker/cisco_ios.py +++ b/homeassistant/components/device_tracker/cisco_ios.py @@ -16,7 +16,7 @@ _LOGGER = logging.getLogger(__name__) -REQUIREMENTS = ['pexpect==4.0.1'] +REQUIREMENTS = ['pexpect==4.6.0'] PLATFORM_SCHEMA = vol.All( PLATFORM_SCHEMA.extend({ diff --git a/homeassistant/components/media_player/pandora.py b/homeassistant/components/media_player/pandora.py index a47db7f633c4a6..90638cd9dfce36 100644 --- a/homeassistant/components/media_player/pandora.py +++ b/homeassistant/components/media_player/pandora.py @@ -22,7 +22,7 @@ STATE_IDLE) from homeassistant import util -REQUIREMENTS = ['pexpect==4.0.1'] +REQUIREMENTS = ['pexpect==4.6.0'] _LOGGER = logging.getLogger(__name__) # SUPPORT_VOLUME_SET is close to available but we need volume up/down diff --git a/requirements_all.txt b/requirements_all.txt index 22855caef323c0..23236ddc5f44c0 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -628,10 +628,8 @@ pdunehd==1.3 # homeassistant.components.device_tracker.aruba # homeassistant.components.device_tracker.asuswrt # homeassistant.components.device_tracker.cisco_ios -# homeassistant.components.media_player.pandora -pexpect==4.0.1 - # homeassistant.components.device_tracker.unifi_direct +# homeassistant.components.media_player.pandora pexpect==4.6.0 # homeassistant.components.rpi_pfio diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 770942236c4bb8..06ad1a76f2c0d7 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -111,10 +111,8 @@ paho-mqtt==1.3.1 # homeassistant.components.device_tracker.aruba # homeassistant.components.device_tracker.asuswrt # homeassistant.components.device_tracker.cisco_ios -# homeassistant.components.media_player.pandora -pexpect==4.0.1 - # homeassistant.components.device_tracker.unifi_direct +# homeassistant.components.media_player.pandora pexpect==4.6.0 # homeassistant.components.pilight From eed23ba0aa79e11032f2d18ded2625fb599bcf7b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 7 Jul 2018 16:32:49 +0200 Subject: [PATCH 13/13] Add explicit None as default param --- homeassistant/loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/loader.py b/homeassistant/loader.py index 9053adcd123002..153d00f92fce56 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -88,7 +88,7 @@ def get_component(hass, comp_or_platform) -> Optional[ModuleType]: # custom_components/switch/some_platform.py exists, # the import custom_components.switch would succeed. # __file__ was unset for namespaces before Python 3.7 - if getattr(module, '__file__') is None: + if getattr(module, '__file__', None) is None: continue _LOGGER.info("Loaded %s from %s", comp_or_platform, path)