From 6b22dbcd0ba6c5d14964aa012ff5a90d3cb127d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 1 Aug 2019 18:30:49 +0300 Subject: [PATCH] Blacken top level *.py (#25621) * Blacken top level *.py * Tolerate double quotes too in setup.py dependency extraction --- script/check_format | 2 +- script/gen_requirements_all.py | 2 +- setup.py | 85 ++++++++++++++++------------------ 3 files changed, 42 insertions(+), 47 deletions(-) diff --git a/script/check_format b/script/check_format index ec403c723b388..bed35ec63e48c 100755 --- a/script/check_format +++ b/script/check_format @@ -7,4 +7,4 @@ black \ --check \ --fast \ --quiet \ - homeassistant tests script + homeassistant tests script *.py diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index 14cb165e6cfcd..bc3a21336075e 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -215,7 +215,7 @@ def core_requirements(): """Gather core requirements out of setup.py.""" with open("setup.py") as inp: reqs_raw = re.search(r"REQUIRES = \[(.*?)\]", inp.read(), re.S).group(1) - return re.findall(r"'(.*?)'", reqs_raw) + return [x[1] for x in re.findall(r"(['\"])(.*?)\1", reqs_raw)] def gather_recursive_requirements(domain, seen=None): diff --git a/setup.py b/setup.py index 14162a86c1290..5133ce9c16b73 100755 --- a/setup.py +++ b/setup.py @@ -5,55 +5,54 @@ import homeassistant.const as hass_const -PROJECT_NAME = 'Home Assistant' -PROJECT_PACKAGE_NAME = 'homeassistant' -PROJECT_LICENSE = 'Apache License 2.0' -PROJECT_AUTHOR = 'The Home Assistant Authors' -PROJECT_COPYRIGHT = ' 2013-{}, {}'.format(dt.now().year, PROJECT_AUTHOR) -PROJECT_URL = 'https://home-assistant.io/' -PROJECT_EMAIL = 'hello@home-assistant.io' +PROJECT_NAME = "Home Assistant" +PROJECT_PACKAGE_NAME = "homeassistant" +PROJECT_LICENSE = "Apache License 2.0" +PROJECT_AUTHOR = "The Home Assistant Authors" +PROJECT_COPYRIGHT = " 2013-{}, {}".format(dt.now().year, PROJECT_AUTHOR) +PROJECT_URL = "https://home-assistant.io/" +PROJECT_EMAIL = "hello@home-assistant.io" -PROJECT_GITHUB_USERNAME = 'home-assistant' -PROJECT_GITHUB_REPOSITORY = 'home-assistant' +PROJECT_GITHUB_USERNAME = "home-assistant" +PROJECT_GITHUB_REPOSITORY = "home-assistant" -PYPI_URL = 'https://pypi.python.org/pypi/{}'.format(PROJECT_PACKAGE_NAME) -GITHUB_PATH = '{}/{}'.format( - PROJECT_GITHUB_USERNAME, PROJECT_GITHUB_REPOSITORY) -GITHUB_URL = 'https://github.com/{}'.format(GITHUB_PATH) +PYPI_URL = "https://pypi.python.org/pypi/{}".format(PROJECT_PACKAGE_NAME) +GITHUB_PATH = "{}/{}".format(PROJECT_GITHUB_USERNAME, PROJECT_GITHUB_REPOSITORY) +GITHUB_URL = "https://github.com/{}".format(GITHUB_PATH) -DOWNLOAD_URL = '{}/archive/{}.zip'.format(GITHUB_URL, hass_const.__version__) +DOWNLOAD_URL = "{}/archive/{}.zip".format(GITHUB_URL, hass_const.__version__) PROJECT_URLS = { - 'Bug Reports': '{}/issues'.format(GITHUB_URL), - 'Dev Docs': 'https://developers.home-assistant.io/', - 'Discord': 'https://discordapp.com/invite/c5DvZ4e', - 'Forum': 'https://community.home-assistant.io/', + "Bug Reports": "{}/issues".format(GITHUB_URL), + "Dev Docs": "https://developers.home-assistant.io/", + "Discord": "https://discordapp.com/invite/c5DvZ4e", + "Forum": "https://community.home-assistant.io/", } -PACKAGES = find_packages(exclude=['tests', 'tests.*']) +PACKAGES = find_packages(exclude=["tests", "tests.*"]) REQUIRES = [ - 'aiohttp==3.5.4', - 'astral==1.10.1', - 'async_timeout==3.0.1', - 'attrs==19.1.0', - 'bcrypt==3.1.7', - 'certifi>=2019.6.16', - 'importlib-metadata==0.18', - 'jinja2>=2.10.1', - 'PyJWT==1.7.1', + "aiohttp==3.5.4", + "astral==1.10.1", + "async_timeout==3.0.1", + "attrs==19.1.0", + "bcrypt==3.1.7", + "certifi>=2019.6.16", + "importlib-metadata==0.18", + "jinja2>=2.10.1", + "PyJWT==1.7.1", # PyJWT has loose dependency. We want the latest one. - 'cryptography==2.7', - 'pip>=8.0.3', - 'python-slugify==3.0.2', - 'pytz>=2019.01', - 'pyyaml==5.1.1', - 'requests==2.22.0', - 'ruamel.yaml==0.15.99', - 'voluptuous==0.11.5', - 'voluptuous-serialize==2.1.0', + "cryptography==2.7", + "pip>=8.0.3", + "python-slugify==3.0.2", + "pytz>=2019.01", + "pyyaml==5.1.1", + "requests==2.22.0", + "ruamel.yaml==0.15.99", + "voluptuous==0.11.5", + "voluptuous-serialize==2.1.0", ] -MIN_PY_VERSION = '.'.join(map(str, hass_const.REQUIRED_PYTHON_VER)) +MIN_PY_VERSION = ".".join(map(str, hass_const.REQUIRED_PYTHON_VER)) setup( name=PROJECT_PACKAGE_NAME, @@ -67,11 +66,7 @@ include_package_data=True, zip_safe=False, install_requires=REQUIRES, - python_requires='>={}'.format(MIN_PY_VERSION), - test_suite='tests', - entry_points={ - 'console_scripts': [ - 'hass = homeassistant.__main__:main' - ] - }, + python_requires=">={}".format(MIN_PY_VERSION), + test_suite="tests", + entry_points={"console_scripts": ["hass = homeassistant.__main__:main"]}, )