diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 000000000..c655c0373 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,46 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "dependencyDashboard": true, + "suppressNotifications": ["prEditedNotification"], + "extends": ["config:base"], + "labels": ["dependencies"], + "pre-commit": { + "enabled": true + }, + "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 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": "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 dependency update", + "matchManagers": ["pip_requirements", "regex"], + "matchPackageNames": ["pytype", "pyright"], + "description": "Daily update of pyright and pytype", + "separateMajorMinor": "false", + "schedule": ["daily"] + } + ] +} diff --git a/requirements-tests.txt b/requirements-tests.txt index 8115345d9..2dc611b3c 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 e5673be2c..416735035 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -8,13 +8,7 @@ from __future__ import annotations 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 @@ if __name__ == "__main__": check_no_symlinks() check_test_cases() check_requirement_pins() - check_precommit_requirements()