Skip to content

Document UV environment variable inheritance in prek#1339

Merged
j178 merged 3 commits intomasterfrom
copilot/fix-uv-resolution-in-prek
Jan 12, 2026
Merged

Document UV environment variable inheritance in prek#1339
j178 merged 3 commits intomasterfrom
copilot/fix-uv-resolution-in-prek

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

prek inherits UV environment variables when installing Python hooks, causing unexpected behavior. For example, UV_RESOLUTION=lowest-direct forces hook dependencies to ancient versions that may fail to build on modern Python.

Changes

  • Added warning callout in docs/diff.md under "Dependency Management with uv" section
  • Documents that UV_* environment variables affect prek since it calls uv internally
  • Provides UV_RESOLUTION=lowest-direct as a concrete example of problematic inheritance
  • Uses mkdocs-material warning callout style for visibility

This is documentation-only. Filtering all UV environment variables is impractical given their number and frequency of additions.

Original prompt

This section details on the original issue you should resolve

<issue_title>Difference versus pre-commit: prek inherits UV_RESOLUTION from the environment when installing hooks</issue_title>
<issue_description>When UV_RESOLUTION=lowest-direct is set in the environment (e.g., for testing a project's dependencies with lowest compatible versions), prek passes this through to uv when installing hooks.

This causes hook dependencies to resolve to ancient versions that may not build on modern Python. For example, pre-commit-hooks depends on ruamel-yaml, and with lowest-direct resolution, uv picks ruamel-yaml==0.15.0 (from 2017), which fails to build on Python 3.12+ with:

NameError: name 'Str' is not defined

Reproduction:

UV_RESOLUTION=lowest-direct UV_PYTHON=3.12 prek run --all-files --hook-stage pre-commit

With a .pre-commit-config.yaml that uses https://github.com/pre-commit/pre-commit-hooks


Either this behaviour should be changed in prek, or https://prek.j178.dev/quickstart/#already-using-pre-commit should mention it.</issue_description>

<agent_instructions>Mention uv environments would affect prek (because prek calls uv underhook to create Python venv and install Python deps) in diff.md</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@j178 UV already has a ton of environment‑variable knobs, and there are going to be more. Since everything can affect the UV that’s run by prek, it’s basically impossible to document every single one.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix UV_RESOLUTION handling in prek for hook installations Document UV environment variable inheritance in prek Jan 12, 2026
Copilot AI requested a review from j178 January 12, 2026 12:43
@j178 j178 marked this pull request as ready for review January 12, 2026 12:45
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.05%. Comparing base (b99d05c) to head (83d5969).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1339   +/-   ##
=======================================
  Coverage   90.05%   90.05%           
=======================================
  Files          80       80           
  Lines       15915    15915           
=======================================
  Hits        14333    14333           
  Misses       1582     1582           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@j178 j178 merged commit c48699a into master Jan 12, 2026
23 checks passed
@j178 j178 deleted the copilot/fix-uv-resolution-in-prek branch January 12, 2026 12:47
@j178 j178 added the documentation Improvements or additions to documentation label Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Difference versus pre-commit: prek inherits UV_RESOLUTION from the environment when installing hooks

2 participants