You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposal: Add opt-in .python-version discovery with fallback resolution for Python hooks
#2880
prek supports explicit Python version configuration and can infer requires-python from remote hook repositories, but it does not automatically use the .python-version file of the workspace running prek or uv's global Python version pin.
This requires duplicating Python version settings and can cause hooks to use a different interpreter than the workspace.
Proposal
Add an opt-in configuration option, such as default_language_version.python.use_version_file: true, that resolves Python versions for hooks using language: python in the following order:
Workspace: Use .python-version from the workspace running prek.
Global: If the workspace file is missing, use uv's global .python-version (typically ~/.config/uv/.python-version, respecting the platform's user configuration directory).
Hook repository: If neither file exists, select the newest compatible stable Python version satisfying [project].requires-python from each hook's cloned repository pyproject.toml, reusing the existing metadata inference.
Preserve explicit language_version settings and existing PEP 723 precedence. If no version constraint is available, retain the current default behavior.
The feature should remain disabled by default, and changes to the effective Python version should invalidate the relevant cached hook environments.
All Python hooks without an explicit version request would use the workspace's pinned Python 3.13. If the workspace pin is removed, they would fall back to the global uv pin, then to hook-specific Python requirements.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Problem
preksupports explicit Python version configuration and can inferrequires-pythonfrom remote hook repositories, but it does not automatically use the.python-versionfile of the workspace runningprekor uv's global Python version pin.This requires duplicating Python version settings and can cause hooks to use a different interpreter than the workspace.
Proposal
Add an opt-in configuration option, such as
default_language_version.python.use_version_file: true, that resolves Python versions for hooks usinglanguage: pythonin the following order:.python-versionfrom the workspace runningprek..python-version(typically~/.config/uv/.python-version, respecting the platform's user configuration directory).[project].requires-pythonfrom each hook's cloned repositorypyproject.toml, reusing the existing metadata inference.Preserve explicit
language_versionsettings and existing PEP 723 precedence. If no version constraint is available, retain the current default behavior.The feature should remain disabled by default, and changes to the effective Python version should invalidate the relevant cached hook environments.
Usage
.pre-commit-config.yaml:All Python hooks without an explicit version request would use the workspace's pinned Python 3.13. If the workspace pin is removed, they would fall back to the global uv pin, then to hook-specific Python requirements.
References
pyproject.toml#1596All reactions