mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add pyupgrade (in pre-commit and CI) (#33688)
* Add pyupgrade (in pre-commit and CI) * Fix leftover results of pyupgrade * Ensure we run for Python 3.7 on pyupgrade
This commit is contained in:
parent
5bf7e0fcc0
commit
f38011560f
@ -1,4 +1,9 @@
|
|||||||
repos:
|
repos:
|
||||||
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
|
rev: v2.1.0
|
||||||
|
hooks:
|
||||||
|
- id: pyupgrade
|
||||||
|
args: [--py37-plus]
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 19.10b0
|
rev: 19.10b0
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -68,6 +68,10 @@ stages:
|
|||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
pre-commit run yamllint --all-files
|
pre-commit run yamllint --all-files
|
||||||
displayName: 'Run yamllint'
|
displayName: 'Run yamllint'
|
||||||
|
- script: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pre-commit run pyupgrade --all-files
|
||||||
|
displayName: 'Run pyupgrade'
|
||||||
- job: 'Validate'
|
- job: 'Validate'
|
||||||
pool:
|
pool:
|
||||||
vmImage: 'ubuntu-latest'
|
vmImage: 'ubuntu-latest'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Home-Assistant documentation build configuration file, created by
|
# Home-Assistant documentation build configuration file, created by
|
||||||
# sphinx-quickstart on Sun Aug 28 13:13:10 2016.
|
# sphinx-quickstart on Sun Aug 28 13:13:10 2016.
|
||||||
@ -26,7 +25,7 @@ from homeassistant.const import __short_version__, __version__
|
|||||||
PROJECT_NAME = 'Home Assistant'
|
PROJECT_NAME = 'Home Assistant'
|
||||||
PROJECT_PACKAGE_NAME = 'homeassistant'
|
PROJECT_PACKAGE_NAME = 'homeassistant'
|
||||||
PROJECT_AUTHOR = 'The Home Assistant Authors'
|
PROJECT_AUTHOR = 'The Home Assistant Authors'
|
||||||
PROJECT_COPYRIGHT = ' 2013-2020, {}'.format(PROJECT_AUTHOR)
|
PROJECT_COPYRIGHT = f' 2013-2020, {PROJECT_AUTHOR}'
|
||||||
PROJECT_LONG_DESCRIPTION = ('Home Assistant is an open-source '
|
PROJECT_LONG_DESCRIPTION = ('Home Assistant is an open-source '
|
||||||
'home automation platform running on Python 3. '
|
'home automation platform running on Python 3. '
|
||||||
'Track and control all devices at home and '
|
'Track and control all devices at home and '
|
||||||
@ -37,7 +36,7 @@ PROJECT_GITHUB_REPOSITORY = 'home-assistant'
|
|||||||
|
|
||||||
GITHUB_PATH = '{}/{}'.format(
|
GITHUB_PATH = '{}/{}'.format(
|
||||||
PROJECT_GITHUB_USERNAME, PROJECT_GITHUB_REPOSITORY)
|
PROJECT_GITHUB_USERNAME, PROJECT_GITHUB_REPOSITORY)
|
||||||
GITHUB_URL = 'https://github.com/{}'.format(GITHUB_PATH)
|
GITHUB_URL = f'https://github.com/{GITHUB_PATH}'
|
||||||
|
|
||||||
|
|
||||||
sys.path.insert(0, os.path.abspath('_ext'))
|
sys.path.insert(0, os.path.abspath('_ext'))
|
||||||
@ -132,7 +131,7 @@ def linkcode_resolve(domain, info):
|
|||||||
|
|
||||||
fn = fn[index:]
|
fn = fn[index:]
|
||||||
|
|
||||||
return '{}/blob/{}/{}{}'.format(GITHUB_URL, code_branch, fn, linespec)
|
return f'{GITHUB_URL}/blob/{code_branch}/{fn}{linespec}'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
@ -7,4 +7,5 @@ flake8-docstrings==1.5.0
|
|||||||
flake8==3.7.9
|
flake8==3.7.9
|
||||||
isort==4.3.21
|
isort==4.3.21
|
||||||
pydocstyle==5.0.2
|
pydocstyle==5.0.2
|
||||||
|
pyupgrade==2.1.0
|
||||||
yamllint==1.21.0
|
yamllint==1.21.0
|
||||||
|
@ -62,7 +62,7 @@ def validate(integrations: Dict[str, Integration], config: Config):
|
|||||||
codeowners_path = config.root / "CODEOWNERS"
|
codeowners_path = config.root / "CODEOWNERS"
|
||||||
config.cache["codeowners"] = content = generate_and_validate(integrations)
|
config.cache["codeowners"] = content = generate_and_validate(integrations)
|
||||||
|
|
||||||
with open(str(codeowners_path), "r") as fp:
|
with open(str(codeowners_path)) as fp:
|
||||||
if fp.read().strip() != content:
|
if fp.read().strip() != content:
|
||||||
config.add_error(
|
config.add_error(
|
||||||
"codeowners",
|
"codeowners",
|
||||||
|
@ -68,7 +68,7 @@ def validate(integrations: Dict[str, Integration], config: Config):
|
|||||||
config_flow_path = config.root / "homeassistant/generated/config_flows.py"
|
config_flow_path = config.root / "homeassistant/generated/config_flows.py"
|
||||||
config.cache["config_flow"] = content = generate_and_validate(integrations)
|
config.cache["config_flow"] = content = generate_and_validate(integrations)
|
||||||
|
|
||||||
with open(str(config_flow_path), "r") as fp:
|
with open(str(config_flow_path)) as fp:
|
||||||
if fp.read().strip() != content:
|
if fp.read().strip() != content:
|
||||||
config.add_error(
|
config.add_error(
|
||||||
"config_flow",
|
"config_flow",
|
||||||
|
@ -17,7 +17,7 @@ class Error:
|
|||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
"""Represent error as string."""
|
"""Represent error as string."""
|
||||||
return "[{}] {}".format(self.plugin.upper(), self.error)
|
return f"[{self.plugin.upper()}] {self.error}"
|
||||||
|
|
||||||
|
|
||||||
@attr.s
|
@attr.s
|
||||||
|
@ -65,7 +65,7 @@ def validate(integrations: Dict[str, Integration], config: Config):
|
|||||||
ssdp_path = config.root / "homeassistant/generated/ssdp.py"
|
ssdp_path = config.root / "homeassistant/generated/ssdp.py"
|
||||||
config.cache["ssdp"] = content = generate_and_validate(integrations)
|
config.cache["ssdp"] = content = generate_and_validate(integrations)
|
||||||
|
|
||||||
with open(str(ssdp_path), "r") as fp:
|
with open(str(ssdp_path)) as fp:
|
||||||
if fp.read().strip() != content:
|
if fp.read().strip() != content:
|
||||||
config.add_error(
|
config.add_error(
|
||||||
"ssdp",
|
"ssdp",
|
||||||
|
@ -120,7 +120,7 @@ def validate(integrations: Dict[str, Integration], config: Config):
|
|||||||
zeroconf_path = config.root / "homeassistant/generated/zeroconf.py"
|
zeroconf_path = config.root / "homeassistant/generated/zeroconf.py"
|
||||||
config.cache["zeroconf"] = content = generate_and_validate(integrations)
|
config.cache["zeroconf"] = content = generate_and_validate(integrations)
|
||||||
|
|
||||||
with open(str(zeroconf_path), "r") as fp:
|
with open(str(zeroconf_path)) as fp:
|
||||||
current = fp.read().strip()
|
current = fp.read().strip()
|
||||||
if current != content:
|
if current != content:
|
||||||
config.add_error(
|
config.add_error(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user