From a5bf0b0e931ea5042177dae77d11fe8286240d37 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 10 Mar 2024 18:31:23 +0000 Subject: [PATCH 1/6] Setup renovate for updating dependencies --- .github/removate.json | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/removate.json diff --git a/.github/removate.json b/.github/removate.json new file mode 100644 index 000000000000..078871888f1e --- /dev/null +++ b/.github/removate.json @@ -0,0 +1,47 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:base"], + "customManagers": [ + { + "customType": "regex", + "fileMatch": ["^pyproject.toml$"], + "matchStrings": [ + "\n\\[tool\\.typeshed\\]\npyright_version\\s*=\\s*\"(?[\\d.]*?)\"\\s*?\\n" + ], + "depNameTemplate": "pyright", + "datasourceTemplate": "npm" + } + ], + "packageRules": [ + { + "groupName": "github-actions", + "matchManagers": ["github-actions"], + "description": "Group all GitHub Action dependencies", + "separateMajorMinor": "false", + "schedule": ["every 3 months on the first day of the month"] + }, + { + "groupName": "Monthly pip dependencies", + "matchManagers": ["pip_requirements"], + "excludePackageNames": ["mypy", "pytype", "flake8-pyi"], + "description": "Monthly update of most pip dependencies", + "separateMajorMinor": "false", + "schedule": ["every 3 months on the first day of the month"] + }, + { + "groupName": "Daily pip dependencies", + "matchManagers": ["pip_requirements"], + "matchPackageNames": ["pytype", "flake8-pyi"], + "description": "Daily update of certain pip dependencies", + "separateMajorMinor": "false", + "schedule": ["daily"] + }, + { + "groupName": "Daily pyright update", + "matchManagers": ["regex"], + "description": "Daily update of pyright version", + "schedule": ["daily"] + } + ], + "suppressNotifications": ["prEditedNotification"] + } From 9e77f28c7f12a725dc4cb2b9633d5a34de985223 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 10 Mar 2024 18:56:42 +0000 Subject: [PATCH 2/6] no one saw that --- .github/{removate.json => renovate.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{removate.json => renovate.json} (100%) diff --git a/.github/removate.json b/.github/renovate.json similarity index 100% rename from .github/removate.json rename to .github/renovate.json From d2d3b9089c8d3fa0704619a02c66f575df9f5549 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 10 Mar 2024 20:56:37 +0000 Subject: [PATCH 3/6] Update renovate.json --- .github/renovate.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index 078871888f1e..c2f8943a576d 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -16,7 +16,7 @@ { "groupName": "github-actions", "matchManagers": ["github-actions"], - "description": "Group all GitHub Action dependencies", + "description": "Quarterly update of GitHub Action dependencies", "separateMajorMinor": "false", "schedule": ["every 3 months on the first day of the month"] }, @@ -24,7 +24,7 @@ "groupName": "Monthly pip dependencies", "matchManagers": ["pip_requirements"], "excludePackageNames": ["mypy", "pytype", "flake8-pyi"], - "description": "Monthly update of most pip dependencies", + "description": "Quarterly update of most pip dependencies", "separateMajorMinor": "false", "schedule": ["every 3 months on the first day of the month"] }, From d873b226ff310e5794d984ae22f7e1a5c0fc38b3 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 10 Mar 2024 21:22:18 +0000 Subject: [PATCH 4/6] backslash hell because no rawstrings in JSON --- .github/renovate.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/renovate.json b/.github/renovate.json index c2f8943a576d..7dab4276cbf8 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -6,7 +6,7 @@ "customType": "regex", "fileMatch": ["^pyproject.toml$"], "matchStrings": [ - "\n\\[tool\\.typeshed\\]\npyright_version\\s*=\\s*\"(?[\\d.]*?)\"\\s*?\\n" + "\\n\\[tool\\.typeshed\\]\\npyright_version\\s*=\\s*(\"|')(?[\\d.]*?)(\"|')\\s*?\\n" ], "depNameTemplate": "pyright", "datasourceTemplate": "npm" From 735f933b07f8fb9ade4a5db4d7c8778a8e478dd2 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 10 Mar 2024 21:33:46 +0000 Subject: [PATCH 5/6] Try to make formatting a little more consistent --- .github/renovate.json | 92 +++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index 7dab4276cbf8..7d1ea34d14d6 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,47 +1,47 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["config:base"], - "customManagers": [ - { - "customType": "regex", - "fileMatch": ["^pyproject.toml$"], - "matchStrings": [ - "\\n\\[tool\\.typeshed\\]\\npyright_version\\s*=\\s*(\"|')(?[\\d.]*?)(\"|')\\s*?\\n" - ], - "depNameTemplate": "pyright", - "datasourceTemplate": "npm" - } - ], - "packageRules": [ - { - "groupName": "github-actions", - "matchManagers": ["github-actions"], - "description": "Quarterly update of GitHub Action dependencies", - "separateMajorMinor": "false", - "schedule": ["every 3 months on the first day of the month"] - }, - { - "groupName": "Monthly pip dependencies", - "matchManagers": ["pip_requirements"], - "excludePackageNames": ["mypy", "pytype", "flake8-pyi"], - "description": "Quarterly update of most pip dependencies", - "separateMajorMinor": "false", - "schedule": ["every 3 months on the first day of the month"] - }, - { - "groupName": "Daily pip dependencies", - "matchManagers": ["pip_requirements"], - "matchPackageNames": ["pytype", "flake8-pyi"], - "description": "Daily update of certain pip dependencies", - "separateMajorMinor": "false", - "schedule": ["daily"] - }, - { - "groupName": "Daily pyright update", - "matchManagers": ["regex"], - "description": "Daily update of pyright version", - "schedule": ["daily"] - } - ], - "suppressNotifications": ["prEditedNotification"] - } + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:base"], + "customManagers": [ + { + "customType": "regex", + "fileMatch": ["^pyproject.toml$"], + "matchStrings": [ + "\\n\\[tool\\.typeshed\\]\\npyright_version\\s*=\\s*(\"|')(?[\\d.]*?)(\"|')\\s*?\\n" + ], + "depNameTemplate": "pyright", + "datasourceTemplate": "npm" + } + ], + "packageRules": [ + { + "groupName": "github-actions", + "matchManagers": ["github-actions"], + "description": "Quarterly update of GitHub Action dependencies", + "separateMajorMinor": "false", + "schedule": ["every 3 months on the first day of the month"] + }, + { + "groupName": "Monthly pip dependencies", + "matchManagers": ["pip_requirements"], + "excludePackageNames": ["mypy", "pytype", "flake8-pyi"], + "description": "Quarterly update of most pip dependencies", + "separateMajorMinor": "false", + "schedule": ["every 3 months on the first day of the month"] + }, + { + "groupName": "Daily pip dependencies", + "matchManagers": ["pip_requirements"], + "matchPackageNames": ["pytype", "flake8-pyi"], + "description": "Daily update of certain pip dependencies", + "separateMajorMinor": "false", + "schedule": ["daily"] + }, + { + "groupName": "Daily pyright update", + "matchManagers": ["regex"], + "description": "Daily update of pyright version", + "schedule": ["daily"] + } + ], + "suppressNotifications": ["prEditedNotification"] +} From d8a32f653eaf5b32b0924759438bd996cc3a7765 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 12 Mar 2024 20:29:25 +0000 Subject: [PATCH 6/6] Also update pre-commit --- .github/renovate.json | 33 ++++++++++++------------- requirements-tests.txt | 4 --- tests/check_consistent.py | 52 --------------------------------------- 3 files changed, 16 insertions(+), 73 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index 7d1ea34d14d6..c655c0373120 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,6 +1,12 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "dependencyDashboard": true, + "suppressNotifications": ["prEditedNotification"], "extends": ["config:base"], + "labels": ["dependencies"], + "pre-commit": { + "enabled": true + }, "customManagers": [ { "customType": "regex", @@ -14,34 +20,27 @@ ], "packageRules": [ { - "groupName": "github-actions", + "groupName": "GitHub Actions update", "matchManagers": ["github-actions"], "description": "Quarterly update of GitHub Action dependencies", "separateMajorMinor": "false", "schedule": ["every 3 months on the first day of the month"] }, { - "groupName": "Monthly pip dependencies", - "matchManagers": ["pip_requirements"], - "excludePackageNames": ["mypy", "pytype", "flake8-pyi"], - "description": "Quarterly update of most pip dependencies", + "groupName": "Quarterly dependency update", + "matchManagers": ["pip_requirements", "pre-commit"], + "excludePackageNames": ["pytype", "pyright"], + "description": "Quarterly update of most test dependencies", "separateMajorMinor": "false", "schedule": ["every 3 months on the first day of the month"] }, { - "groupName": "Daily pip dependencies", - "matchManagers": ["pip_requirements"], - "matchPackageNames": ["pytype", "flake8-pyi"], - "description": "Daily update of certain pip dependencies", + "groupName": "Daily dependency update", + "matchManagers": ["pip_requirements", "regex"], + "matchPackageNames": ["pytype", "pyright"], + "description": "Daily update of pyright and pytype", "separateMajorMinor": "false", "schedule": ["daily"] - }, - { - "groupName": "Daily pyright update", - "matchManagers": ["regex"], - "description": "Daily update of pyright version", - "schedule": ["daily"] } - ], - "suppressNotifications": ["prEditedNotification"] + ] } diff --git a/requirements-tests.txt b/requirements-tests.txt index 8115345d99a6..2dc611b3c379 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -15,13 +15,9 @@ aiohttp==3.9.3 packaging==23.2 pathspec>=0.11.1 pre-commit -pyyaml==6.0.1 stubdefaulter==0.1.0 termcolor>=2.3 tomli==2.0.1 tomlkit==0.12.3 typing_extensions>=4.9.0rc1 uv - -# Type stubs used to type check our scripts. -types-pyyaml>=6.0.12.7 diff --git a/tests/check_consistent.py b/tests/check_consistent.py index e5673be2cd61..416735035c55 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -8,13 +8,7 @@ import os import re import sys -import urllib.parse from pathlib import Path -from typing import TypedDict - -import yaml -from packaging.requirements import Requirement -from packaging.specifiers import SpecifierSet from parse_metadata import read_metadata from utils import ( @@ -143,34 +137,6 @@ def check_metadata() -> None: read_metadata(distribution) -class PreCommitConfigRepos(TypedDict): - hooks: list[dict[str, str]] - repo: str - - -class PreCommitConfig(TypedDict): - repos: list[PreCommitConfigRepos] - - -def get_precommit_requirements() -> dict[str, SpecifierSet]: - with open(".pre-commit-config.yaml", encoding="UTF-8") as precommit_file: - precommit = precommit_file.read() - yam: PreCommitConfig = yaml.load(precommit, Loader=yaml.Loader) - precommit_requirements: dict[str, SpecifierSet] = {} - for repo in yam["repos"]: - package_rev = repo.get("rev") - if not isinstance(package_rev, str): - continue - package_name = Path(urllib.parse.urlparse(repo["repo"]).path).name - package_specifier = SpecifierSet(f"=={package_rev.removeprefix('v')}") - precommit_requirements[package_name] = package_specifier - for hook in repo["hooks"]: - for additional_req in hook.get("additional_dependencies", ()): - req = Requirement(additional_req) - precommit_requirements[req.name] = req.specifier - return precommit_requirements - - def check_requirement_pins() -> None: """Check that type checkers and linters are pinned to an exact version.""" requirements = parse_requirements() @@ -182,23 +148,6 @@ def check_requirement_pins() -> None: assert str(spec).startswith("=="), msg -def check_precommit_requirements() -> None: - """Check that the requirements in the requirements file and .pre-commit-config.yaml match.""" - requirements_txt_requirements = parse_requirements() - precommit_requirements = get_precommit_requirements() - no_txt_entry_msg = f"All pre-commit requirements must also be listed in `{REQS_FILE}` (missing {{requirement!r}})" - for requirement, specifier in precommit_requirements.items(): - # annoying: the Ruff and Black repos for pre-commit are different to the names in the requirements file - if requirement in {"ruff-pre-commit", "black-pre-commit-mirror"}: - requirement = requirement.split("-")[0] - assert requirement in requirements_txt_requirements, no_txt_entry_msg.format(requirement=requirement) - specifier_mismatch = ( - f'Specifier "{specifier}" for {requirement!r} in `.pre-commit-config.yaml` ' - f'does not match specifier "{requirements_txt_requirements[requirement].specifier}" in `{REQS_FILE}`' - ) - assert specifier == requirements_txt_requirements[requirement].specifier, specifier_mismatch - - if __name__ == "__main__": assert sys.version_info >= (3, 9), "Python 3.9+ is required to run this test" check_stdlib() @@ -208,4 +157,3 @@ def check_precommit_requirements() -> None: check_no_symlinks() check_test_cases() check_requirement_pins() - check_precommit_requirements()