mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Reduce test requirements duplication, sync flake8 and related (#28538)
* Generate pre-commit test dependencies instead of duplicating * Upgrade/sync to flake8 3.7.9, flake8-docstrings 1.5.0, and pydocstyle 4.0.1 https://flake8.readthedocs.io/en/latest/release-notes/3.7.9.html https://gitlab.com/pycqa/flake8-docstrings/blob/1.4.0/HISTORY.rst https://gitlab.com/pycqa/flake8-docstrings/blob/1.5.0/HISTORY.rst http://www.pydocstyle.org/en/4.0.1/release_notes.html * Include requirements_test.txt from *_all.txt instead of copying
This commit is contained in:
parent
ef20f0985a
commit
804b6bbc0e
@ -19,12 +19,12 @@ repos:
|
|||||||
- --quiet
|
- --quiet
|
||||||
files: ^((homeassistant|script|tests)/.+)?[^/]+\.py$
|
files: ^((homeassistant|script|tests)/.+)?[^/]+\.py$
|
||||||
- repo: https://gitlab.com/pycqa/flake8
|
- repo: https://gitlab.com/pycqa/flake8
|
||||||
rev: 3.7.8
|
rev: 3.7.9
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- flake8-docstrings==1.3.1
|
- flake8-docstrings==1.5.0
|
||||||
- pydocstyle==4.0.0
|
- pydocstyle==4.0.1
|
||||||
files: ^(homeassistant|script|tests)/.+\.py$
|
files: ^(homeassistant|script|tests)/.+\.py$
|
||||||
# Using a local "system" mypy instead of the mypy hook, because its
|
# Using a local "system" mypy instead of the mypy hook, because its
|
||||||
# results depend on what is installed. And the mypy hook runs in a
|
# results depend on what is installed. And the mypy hook runs in a
|
||||||
|
@ -15,10 +15,10 @@ repos:
|
|||||||
- --quiet
|
- --quiet
|
||||||
files: ^((homeassistant|script|tests)/.+)?[^/]+\.py$
|
files: ^((homeassistant|script|tests)/.+)?[^/]+\.py$
|
||||||
- repo: https://gitlab.com/pycqa/flake8
|
- repo: https://gitlab.com/pycqa/flake8
|
||||||
rev: 3.7.8
|
rev: 3.7.9
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- flake8-docstrings==1.3.1
|
- flake8-docstrings==1.5.0
|
||||||
- pydocstyle==4.0.0
|
- pydocstyle==4.0.1
|
||||||
files: ^(homeassistant|script|tests)/.+\.py$
|
files: ^(homeassistant|script|tests)/.+\.py$
|
||||||
|
@ -2,16 +2,12 @@
|
|||||||
# 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
|
||||||
|
|
||||||
# When updating this file, update .pre-commit-config*.yaml too
|
-r requirements_test_pre_commit.txt
|
||||||
asynctest==0.13.0
|
asynctest==0.13.0
|
||||||
black==19.10b0
|
|
||||||
codecov==2.0.15
|
codecov==2.0.15
|
||||||
flake8-docstrings==1.5.0
|
|
||||||
flake8==3.7.8
|
|
||||||
mock-open==1.3.1
|
mock-open==1.3.1
|
||||||
mypy==0.740
|
mypy==0.740
|
||||||
pre-commit==1.20.0
|
pre-commit==1.20.0
|
||||||
pydocstyle==4.0.1
|
|
||||||
pylint==2.4.3
|
pylint==2.4.3
|
||||||
astroid==2.3.2
|
astroid==2.3.2
|
||||||
pytest-aiohttp==0.3.0
|
pytest-aiohttp==0.3.0
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
# Home Assistant test
|
# Home Assistant tests, full dependency set
|
||||||
# linters such as flake8 and pylint should be pinned, as new releases
|
# Automatically generated by gen_requirements_all.py, do not edit
|
||||||
# make new things fail. Manually update these pins when pulling in a
|
|
||||||
# new version
|
|
||||||
|
|
||||||
# When updating this file, update .pre-commit-config*.yaml too
|
|
||||||
asynctest==0.13.0
|
|
||||||
black==19.10b0
|
|
||||||
codecov==2.0.15
|
|
||||||
flake8-docstrings==1.5.0
|
|
||||||
flake8==3.7.8
|
|
||||||
mock-open==1.3.1
|
|
||||||
mypy==0.740
|
|
||||||
pre-commit==1.20.0
|
|
||||||
pydocstyle==4.0.1
|
|
||||||
pylint==2.4.3
|
|
||||||
astroid==2.3.2
|
|
||||||
pytest-aiohttp==0.3.0
|
|
||||||
pytest-cov==2.8.1
|
|
||||||
pytest-sugar==0.9.2
|
|
||||||
pytest-timeout==1.3.3
|
|
||||||
pytest==5.2.2
|
|
||||||
requests_mock==1.7.0
|
|
||||||
responses==0.10.6
|
|
||||||
|
|
||||||
|
-r requirements_test.txt
|
||||||
|
|
||||||
# homeassistant.components.homekit
|
# homeassistant.components.homekit
|
||||||
HAP-python==2.6.0
|
HAP-python==2.6.0
|
||||||
|
6
requirements_test_pre_commit.txt
Normal file
6
requirements_test_pre_commit.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Automatically generated from .pre-commit-config-all.yaml by gen_requirements_all.py, do not edit
|
||||||
|
|
||||||
|
black==19.10b0
|
||||||
|
flake8-docstrings==1.5.0
|
||||||
|
flake8==3.7.9
|
||||||
|
pydocstyle==4.0.1
|
@ -8,6 +8,8 @@ import pkgutil
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from homeassistant.util.yaml.loader import load_yaml
|
||||||
|
|
||||||
from script.hassfest.model import Integration
|
from script.hassfest.model import Integration
|
||||||
|
|
||||||
COMMENT_REQUIREMENTS = (
|
COMMENT_REQUIREMENTS = (
|
||||||
@ -225,10 +227,11 @@ def requirements_all_output(reqs):
|
|||||||
def requirements_test_output(reqs):
|
def requirements_test_output(reqs):
|
||||||
"""Generate output for test_requirements."""
|
"""Generate output for test_requirements."""
|
||||||
output = []
|
output = []
|
||||||
output.append("# Home Assistant test")
|
output.append("# Home Assistant tests, full dependency set\n")
|
||||||
output.append("\n")
|
output.append(
|
||||||
output.append(Path("requirements_test.txt").read_text())
|
f"# Automatically generated by {Path(__file__).name}, do not edit\n\n"
|
||||||
output.append("\n")
|
)
|
||||||
|
output.append("-r requirements_test.txt\n")
|
||||||
|
|
||||||
filtered = {
|
filtered = {
|
||||||
requirement: modules
|
requirement: modules
|
||||||
@ -246,6 +249,24 @@ def requirements_test_output(reqs):
|
|||||||
return "".join(output)
|
return "".join(output)
|
||||||
|
|
||||||
|
|
||||||
|
def requirements_pre_commit_output():
|
||||||
|
"""Generate output for pre-commit dependencies."""
|
||||||
|
source = ".pre-commit-config-all.yaml"
|
||||||
|
pre_commit_conf = load_yaml(source)
|
||||||
|
reqs = []
|
||||||
|
for repo in (x for x in pre_commit_conf["repos"] if x.get("rev")):
|
||||||
|
for hook in repo["hooks"]:
|
||||||
|
reqs.append(f"{hook['id']}=={repo['rev']}")
|
||||||
|
reqs.extend(x for x in hook.get("additional_dependencies", ()))
|
||||||
|
output = [
|
||||||
|
f"# Automatically generated "
|
||||||
|
f"from {source} by {Path(__file__).name}, do not edit",
|
||||||
|
"",
|
||||||
|
]
|
||||||
|
output.extend(sorted(reqs))
|
||||||
|
return "\n".join(output) + "\n"
|
||||||
|
|
||||||
|
|
||||||
def gather_constraints():
|
def gather_constraints():
|
||||||
"""Construct output for constraint file."""
|
"""Construct output for constraint file."""
|
||||||
return (
|
return (
|
||||||
@ -285,10 +306,12 @@ def main(validate):
|
|||||||
|
|
||||||
reqs_file = requirements_all_output(data)
|
reqs_file = requirements_all_output(data)
|
||||||
reqs_test_file = requirements_test_output(data)
|
reqs_test_file = requirements_test_output(data)
|
||||||
|
reqs_pre_commit_file = requirements_pre_commit_output()
|
||||||
constraints = gather_constraints()
|
constraints = gather_constraints()
|
||||||
|
|
||||||
files = (
|
files = (
|
||||||
("requirements_all.txt", reqs_file),
|
("requirements_all.txt", reqs_file),
|
||||||
|
("requirements_test_pre_commit.txt", reqs_pre_commit_file),
|
||||||
("requirements_test_all.txt", reqs_test_file),
|
("requirements_test_all.txt", reqs_test_file),
|
||||||
("homeassistant/package_constraints.txt", constraints),
|
("homeassistant/package_constraints.txt", constraints),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user