Skip to content

fix: move pre-commit/pytest dev tools out of prod deps (unblock deploy)#705

Merged
jirhiker merged 3 commits into
stagingfrom
fix/move-precommit-to-dev-group
Jun 8, 2026
Merged

fix: move pre-commit/pytest dev tools out of prod deps (unblock deploy)#705
jirhiker merged 3 commits into
stagingfrom
fix/move-precommit-to-dev-group

Conversation

@jirhiker

@jirhiker jirhiker commented Jun 8, 2026

Copy link
Copy Markdown
Member

Why

Deploy buildpack fails again — next unpinned transitive after the joserfc fix (#704):

ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
python-discovery>=1.4 (from virtualenv==21.4.2->-r requirements.txt (line 2393))

Root cause: pre-commit was listed in main [project.dependencies], so it (and its whole toolchain — virtualenv, identify, nodeenv, cfgv, distlib, platformdirs) shipped to production. virtualenv 21.x introduced the unpinned transitive python-discovery>=1.4, which pip --require-hashes rejects.

How

  • Move pre-commit from [project.dependencies][dependency-groups] dev. It's a dev-only tool, never imported by app code.
  • uv lock + uv export --no-dev regenerate the lock and requirements.
  • Result: pre-commit + entire chain (incl. virtualenv → python-discovery) removed from the production requirement set.

Verification

  • Every non-dev package in uv.lock is still pinned + hashed in requirements.txt; only dev-group deps are absent.
  • Confirmed the linux cp313 x86_64 wheels the buildpack installs are present (checked yarl).
  • uv lock --check passes.

Notes

  • Large requirements.txt churn: besides removing the pre-commit chain, local uv 0.9.7 emits only the py3.13-relevant wheel hashes (lock requires-python >=3.13) vs the old broader set. Functionally complete for the deploy target; CD regenerates with the same uv export --no-dev anyway.
  • uv.lock revision bumped 2 → 3 by uv; CD uses setup-uv latest (forward-compatible).
  • Unblocks the release build on #695 once merged to staging.

pre-commit was in the main [project.dependencies] list, so it shipped
to production and dragged in its whole toolchain (virtualenv, identify,
nodeenv, cfgv, distlib, platformdirs). virtualenv 21.x added an
unpinned transitive `python-discovery>=1.4`, which the deploy buildpack
rejected under pip --require-hashes:

  ERROR: In --require-hashes mode, all requirements must have their
  versions pinned with ==. These do not: python-discovery>=1.4
  (from virtualenv==21.4.2)

pre-commit is a dev-only tool and never imported by the app. Move it to
the [dependency-groups] dev list and regenerate uv.lock + requirements
with --no-dev (matching the CD export). This drops pre-commit and its
entire chain from the production requirement set, removing the unpinned
python-discovery transitive.

Verified: every non-dev package in uv.lock is still pinned+hashed in
requirements.txt; the linux cp313 wheels the buildpack installs are
present. Lock revision bumped 2->3 by uv; CD uses setup-uv latest.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 8, 2026 18:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e96323ac2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pyproject.toml
pytest and pytest-cov are test-only tools but were listed in main
[project.dependencies], shipping pytest, pytest-cov, and coverage to
production. Move them to [dependency-groups] dev (pytest was already
duplicated there) and regenerate the lock + --no-dev requirements.
Removes the pytest/coverage chain from the production requirement set.

Verified no non-dev package was dropped from requirements.txt.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jirhiker jirhiker changed the title fix: move pre-commit to dev group to unblock deploy (python-discovery unpinned) fix: move pre-commit/pytest dev tools out of prod deps (unblock deploy) Jun 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Python dependency configuration to ensure pre-commit (and its toolchain) is treated as a development-only dependency, preventing it from being included in the production dependency export used for deployment builds that enforce pip --require-hashes.

Changes:

  • Move pre-commit from [project.dependencies] to [dependency-groups].dev in pyproject.toml.
  • Regenerate uv.lock after the dependency-group change (lock revision bump).
  • Regenerate the production requirements.txt via uv export --no-dev, removing pre-commit and its transitive dependency chain from production requirements.

Reviewed changes

Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.

File Description
pyproject.toml Moves pre-commit into the dev dependency group so it won’t be included in production exports.
uv.lock Updates the lockfile to reflect the dependency-group change (removes pre-commit from main deps, adds it to dev).
requirements.txt Regenerated production requirements without dev-group dependencies, removing the pre-commit toolchain from prod.
Comments suppressed due to low confidence (1)

pyproject.toml:144

  • With pre-commit now moved into the dev dependency group, it would be consistent to also ensure other developer/test tooling is not included in [project.dependencies] (which is what uv export --no-dev uses). As-is, the exported production requirements still include test-only packages like coverage (via pytest-cov), implying those tools may still be declared as runtime deps.

Recommend moving pytest/pytest-cov (and any other test-only packages) from [project.dependencies] into [dependency-groups].dev, then re-lock/re-export so production deploys only runtime deps.

  "behave>=1.3.3",
  "black>=26.5.1",
  "faker>=25.0.0",
  "flake8>=7.3.0",
  "pre-commit>=4.6.0",
  "pyhamcrest>=2.0.3",
  "pytest>=9.0.3",
  "pytest-cov>=6.2.1",
  "python-dotenv>=1.1.1",
  "requests>=2.34.2",
]

Moving pre-commit/pytest to the dev group only affects
`uv export --no-dev` (the buildpack requirements.txt). The deploy
jobs also invoke uv without disabling the dev group, which still
syncs the dev toolchain (pre-commit -> virtualenv -> python-discovery)
into the deploy environment:

- CD_production / CD_staging / CD_testing: `uv run alembic ...` and
  `uv run python -m cli.cli ...`
- docker/app/Dockerfile: production branch `uv sync --locked`

Add --no-dev to all of these so dev dependencies are excluded
consistently across every deploy path. The Dockerfile dev branch keeps
--all-groups intentionally for local/dev images.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 8, 2026 18:43
@jirhiker jirhiker merged commit 3892047 into staging Jun 8, 2026
10 checks passed
@jirhiker jirhiker deleted the fix/move-precommit-to-dev-group branch June 8, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants