From fc4dfdb0a5e40d781cf171c140713538979b875a Mon Sep 17 00:00:00 2001 From: Gabriel Dugny Date: Tue, 27 Jan 2026 21:51:28 +0100 Subject: [PATCH 1/3] chore: support prek --- README.md | 2 ++ tests/test_pre_commit_config_file.py | 52 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/README.md b/README.md index 5dda99e..4396ceb 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ PDM and Poetry plugin to sync your pre-commit versions with your lockfile and au - ⏊ Run every time you run the lockfile is updated, not as a pre-commit hook - 🔄 Install pre-commit hooks automatically, no need to run `pre-commit install` manually - đŸ’Ģ Preserve your pre-commit config file formatting +- ✨ Support [prek](https://prek.j178.dev/) configuration files (preserve `prek` specific keys) - 🍃 Lightweight, only depends on [strictyaml](https://pypi.org/project/strictyaml/) and [packaging](https://pypi.org/project/packaging/) ## Supported versions @@ -87,6 +88,7 @@ disable-sync-from-lock = false # Packages to ignore when syncing from lock ignore = [] # Name of the pre-commit config file to sync with +# Can be set to ".pre-commit-config.yml" to support prek alternate config file pre-commit-config-file = ".pre-commit-config.yaml" # Additional mapping of URLs to python packages # Default is empty, but will merge with the default mapping diff --git a/tests/test_pre_commit_config_file.py b/tests/test_pre_commit_config_file.py index a4d59bf..20b4bd8 100644 --- a/tests/test_pre_commit_config_file.py +++ b/tests/test_pre_commit_config_file.py @@ -190,3 +190,55 @@ def test_update_additional_dependencies_versions(base: str) -> None: def test_precommit_repo_equality(repo1: PreCommitRepo, repo2: PreCommitRepo, equal: bool): assert (repo1 == repo2) is equal assert (hash(repo1) == hash(repo2)) is equal + + +def test_prek_config_support() -> None: + # A config file with prek-specific keys + file_content = """\ +minimum_prek_version: "0.1.0" +orphan: true +repos: + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + priority: 10 + env: + FOO: bar +""" + mock_path = MagicMock(spec=Path) + mock_path.open = mock_open(read_data=file_content) + + config = PreCommitHookConfig.from_yaml_file(mock_path) + + updated_repo = PreCommitRepo( + "https://github.com/psf/black", + "23.4.0", + [PreCommitHook("black")], + ) + + mock_path.open = mock_open() + config.update_pre_commit_repo_versions({config.repos[0]: updated_repo}) + + mock_path.open.assert_called_with("w") + handle = mock_path.open() + + written_lines = [] + for call in handle.writelines.call_args_list: + written_lines.extend(call[0][0]) + + written_content = "".join(written_lines) + + expected_content = """\ +minimum_prek_version: "0.1.0" +orphan: true +repos: + - repo: https://github.com/psf/black + rev: 23.4.0 + hooks: + - id: black + priority: 10 + env: + FOO: bar +""" + assert written_content == expected_content From 32c01cb3dafcec2fd37ff5426d6a14af4755b258 Mon Sep 17 00:00:00 2001 From: Gabriel Dugny Date: Tue, 27 Jan 2026 22:06:13 +0100 Subject: [PATCH 2/3] chore: support Poetry 2.3 --- .mise.toml | 2 +- README.md | 2 +- tox.ini | 32 +++++++++++++++++++------------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.mise.toml b/.mise.toml index f8c70b1..9a2965e 100644 --- a/.mise.toml +++ b/.mise.toml @@ -1,3 +1,3 @@ [tools] -pdm = "2.25" +pdm = "2.26" python = ["3.12", "3.13", "3.14", "3.11", "3.10", "3.9"] diff --git a/README.md b/README.md index 4396ceb..cf4ce84 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ PDM and Poetry plugin to sync your pre-commit versions with your lockfile and au - Python 3.9+ to 3.14+ - PDM 2.7.4 to 2.26+ - Python 3.12.7+ requires PDM 2.20.1+ -- Poetry 1.6 to 2.2+ +- Poetry 1.6 to 2.3+ - uv (lock version 1) > â„šī¸ While we only test these versions, it should work with more recent versions. diff --git a/tox.ini b/tox.ini index 1dba1d6..9e52749 100644 --- a/tox.ini +++ b/tox.ini @@ -8,13 +8,13 @@ env_list = py{313, 312}-pdm{226, 225, 224, 223, 222, 221, 220, HEAD} py{311, 310, 39}-pdm{226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 29, 28, 27, HEAD} py{313, 312, 311, 310, 39}-poetry{22, 21, 20, 18, 17, 16, HEAD} - py{314}-poetry{22, 18, HEAD} + py{314}-poetry{23, 22, 18, HEAD} [testenv] set_env = py{312,313}-pdm{220,221,222,223,226, 225, 224, 226,HEAD}: COVERAGE_FILE = .coverage.{envname} - py{314}-pdm{224,HEAD}: COVERAGE_FILE = .coverage.{envname} - py{39,310,311,312,313,314}-poetry{22, 21, 20, 18, 17, 16, HEAD}: COVERAGE_FILE = .coverage.{envname} + py{314}-pdm{224,225,226,HEAD}: COVERAGE_FILE = .coverage.{envname} + py{39,310,311,312,313,314}-poetry{23,22, 21, 20, 18, 17, 16, HEAD}: COVERAGE_FILE = .coverage.{envname} py{39,310,311}-pdm{27,28,29,210,211,212,213,214,215,216,217,218,219,220,221,222,223,226, 225, 224,HEAD}: COVERAGE_FILE = .coverage.{envname} commands = pytest --cov --cov-append --cov-report=term-missing {posargs:-vv} --cov-config=pyproject.toml @@ -26,7 +26,7 @@ depends = report: py{314, 313, 312, 311, 310, 39}-pdm{226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 29, 28, 27, HEAD} report: py{314, 313, 312, 311, 310, 39}-poetry{22, 21, 20, 18, 17, 16, HEAD} py{314, 313, 312, 311, 310, 39}-pdm{226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 29, 28, 27, HEAD}: clean - py{314, 313, 312, 311, 310, 39}-poetry{22, 21, 20, 18, 17, 16, HEAD}: clean + py{314, 313, 312, 311, 310, 39}-poetry{23, 22, 21, 20, 18, 17, 16, HEAD}: clean [testenv:clean] skip_install = true @@ -52,6 +52,11 @@ deps = -r requirements-tox.txt py310-pdm214: httpx<0.28 py311-pdm214: httpx<0.28 + py312-pdm221: hishel<1.0 + py312-pdm222: hishel<1.0 + py312-pdm223: hishel<1.0 + py312-pdm224: hishel<1.0 + py312-pdm225: hishel<1.0 py39-pdm214: httpx<0.28 py39-pdm27: importlib-metadata<8 pdm210: pdm<2.11,>=2.10 @@ -74,9 +79,9 @@ deps = pdm27: pdm<2.8,>=2.7 pdm28: pdm<2.9,>=2.8 pdm29: pdm<2.10,>=2.9 - pdmHEAD: pdm@ git+https://github.com/pdm-project/pdm.git + pdmHEAD: pdm @ git+https://github.com/pdm-project/pdm.git -[testenv:py{314,313,312, 311, 310, 39}-poetry{16, 17, 18, 20, 21, 22, HEAD}] +[testenv:py{314,313,312, 311, 310, 39}-poetry{16, 17, 18, 20, 21, 22, 23,HEAD}] package = editable deps = -r requirements-tox.txt @@ -86,14 +91,15 @@ deps = poetry20: poetry<2.1,>=2 poetry21: poetry<2.2,>=2.1 poetry22: poetry<2.3,>=2.2 - poetryHEAD: poetry@ git+https://github.com/python-poetry/poetry.git + poetry23: poetry<2.4,>=2.3 + poetryHEAD: poetry @ git+https://github.com/python-poetry/poetry.git [gh] python = - 3.9= py39-pdm{27,28,29,210,211,212,213,214,215,216,217,218,219,220,221,222,223,225,224,HEAD},py39-poetry{22, 21, 20, 18, 17, 16, HEAD}, report, clean - 3.10= py310-pdm{27,28,29,210,211,212,213,214,215,216,217,218,219,220,221,222,223,225,224,HEAD}, py310-poetry{22, 21, 20, 18, 17, 16, HEAD}, report, clean - 3.11= py311-pdm{27,28,29,210,211,212,213,214,215,216,217,218,219,220,221,222,223,225,224,HEAD}, py311-poetry{22, 21, 20, 18, 17, 16, HEAD}, report, clean - 3.12= py312-pdm{220,221,222,223,225,224,226,HEAD}, py312-poetry{22, 21, 20, 18, 17, 16, HEAD}, report, clean - 3.13= py313-pdm{220,221,222,223,225,224,226,HEAD}, py313-poetry{22, 21, 20, 18, 17, 16, HEAD}, report, clean - 3.14= py314-pdm{226,HEAD}, py314-poetry{22, 21, 20, 18, 17, 16, HEAD}, report, clean + 3.9= py39-pdm{27,28,29,210,211,212,213,214,215,216,217,218,219,220,221,222,223,225,224,HEAD},py39-poetry{23, 22, 21, 20, 18, 17, 16, HEAD}, report, clean + 3.10= py310-pdm{27,28,29,210,211,212,213,214,215,216,217,218,219,220,221,222,223,225,224,HEAD}, py310-poetry{23, 22, 21, 20, 18, 17, 16, HEAD}, report, clean + 3.11= py311-pdm{27,28,29,210,211,212,213,214,215,216,217,218,219,220,221,222,223,225,224,HEAD}, py311-poetry{23, 22, 21, 20, 18, 17, 16, HEAD}, report, clean + 3.12= py312-pdm{220,221,222,223,225,224,226,HEAD}, py312-poetry{23, 22, 21, 20, 18, 17, 16, HEAD}, report, clean + 3.13= py313-pdm{220,221,222,223,225,224,226,HEAD}, py313-poetry{23, 22, 21, 20, 18, 17, 16, HEAD}, report, clean + 3.14= py314-pdm{226,HEAD}, py314-poetry{23, 22, 21, 20, 18, 17, 16, HEAD}, report, clean fail_on_no_env = True From d56bd1a9069ca5a6d8cf457aa37fddbe03a56b38 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 21:06:29 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 9e52749..5899dc2 100644 --- a/tox.ini +++ b/tox.ini @@ -79,7 +79,7 @@ deps = pdm27: pdm<2.8,>=2.7 pdm28: pdm<2.9,>=2.8 pdm29: pdm<2.10,>=2.9 - pdmHEAD: pdm @ git+https://github.com/pdm-project/pdm.git + pdmHEAD: pdm@ git+https://github.com/pdm-project/pdm.git [testenv:py{314,313,312, 311, 310, 39}-poetry{16, 17, 18, 20, 21, 22, 23,HEAD}] package = editable @@ -92,7 +92,7 @@ deps = poetry21: poetry<2.2,>=2.1 poetry22: poetry<2.3,>=2.2 poetry23: poetry<2.4,>=2.3 - poetryHEAD: poetry @ git+https://github.com/python-poetry/poetry.git + poetryHEAD: poetry@ git+https://github.com/python-poetry/poetry.git [gh] python =