Skip to content

Do not use EOL python version if no version was requested#1595

Closed
jvllmr wants to merge 1 commit intoj178:masterfrom
jvllmr:python-default-version-range
Closed

Do not use EOL python version if no version was requested#1595
jvllmr wants to merge 1 commit intoj178:masterfrom
jvllmr:python-default-version-range

Conversation

@jvllmr
Copy link

@jvllmr jvllmr commented Feb 6, 2026

This PR makes sure no EOL python versions are used when creating a python venv without a specific requested version.
Otherwise uv chooses i.e. python 3.9 if it was downloaded via uv before.
I think this is only a workaround to uv not resolving a python version from the target pyproject.toml, but this should cover most cases where the target hook does not specify a language_version key since most projects support all versions that are not EOL. This change adds the --python >=3.10 arg to the uv venv command to achieve that.

This is just a suggested work around. I can provide tests if the change is generally accepted.

fixes #1594

Signed-off-by: Jan Vollmer <jan@vllmr.dev>
@jvllmr jvllmr requested a review from j178 as a code owner February 6, 2026 22:15
@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.66%. Comparing base (71790f3) to head (b3806b4).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1595   +/-   ##
=======================================
  Coverage   91.66%   91.66%           
=======================================
  Files          93       93           
  Lines       18312    18315    +3     
=======================================
+ Hits        16785    16788    +3     
  Misses       1527     1527           

☔ 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.

@prek-ci-bot
Copy link

prek-ci-bot bot commented Feb 6, 2026

📦 Cargo Bloat Comparison

Binary size change: +0.00% (23.7 MiB → 23.7 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text    Size             Crate Name
 0.3%   0.8% 82.3KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.7% 71.2KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6% 65.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 51.2KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.5% 50.5KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4% 41.2KiB              prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 38.5KiB              prek prek::run::{{closure}}
 0.1%   0.3% 32.0KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 28.4KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.3% 28.3KiB              prek prek::identify::by_extension::{{closure}}
 0.1%   0.2% 24.8KiB             prek? <prek::config::_::<impl serde_core::de::Deserialize for prek::config::Config>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 22.6KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 22.1KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 22.1KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 21.1KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.0KiB   cargo_metadata? <cargo_metadata::_::<impl serde_core::de::Deserialize for cargo_metadata::Package>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 19.8KiB              prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 19.5KiB              prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 19.3KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2% 19.2KiB              prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
38.4%  91.6%  9.1MiB                   And 20964 smaller methods. Use -n N to show more.
41.9% 100.0%  9.9MiB                   .text section size, the file size is 23.7MiB

Base Branch Results

 File  .text    Size             Crate Name
 0.3%   0.8% 80.9KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.7% 71.1KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6% 65.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 51.2KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.5% 50.5KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4% 41.2KiB              prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 38.4KiB              prek prek::run::{{closure}}
 0.1%   0.3% 31.7KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 28.4KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.3% 28.3KiB              prek prek::identify::by_extension::{{closure}}
 0.1%   0.2% 24.8KiB             prek? <prek::config::_::<impl serde_core::de::Deserialize for prek::config::Config>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 22.6KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 22.1KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 22.1KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 21.1KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.0KiB   cargo_metadata? <cargo_metadata::_::<impl serde_core::de::Deserialize for cargo_metadata::Package>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 19.8KiB              prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 19.5KiB              prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 19.3KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2% 19.2KiB              prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
38.4%  91.6%  9.1MiB                   And 20956 smaller methods. Use -n N to show more.
41.9% 100.0%  9.9MiB                   .text section size, the file size is 23.7MiB

@shaanmajid
Copy link
Collaborator

Thanks for the PR @jvllmr! I appreciate the fix, but I have some concerns about the approach. It'll need periodic bumps as Python versions reach EOL, and it may be both too restrictive (for unmaintained hooks that support/require older Python) and not restrictive enough (for hooks needing >=3.12). I think it would be better to just read pyproject.toml directly, which is analogous to how Go hooks are handled (by reading go.mod). Interested to hear your thoughts @j178

I spun up #1596 if you have any feedback.

@jvllmr
Copy link
Author

jvllmr commented Feb 7, 2026

It's indeed not a catch-all solution, but I think it is feasible because most projects support all versions in >=3.10 and the count of projects with >=3.12 is relatively low. Its definitely better than the current behaviour imo.

@j178
Copy link
Owner

j178 commented Feb 7, 2026

Thanks for the PR! I don’t think we need to put a strict version limit on this. Just because it’s EOL doesn’t mean people can’t still use it. Let’s go with #1596 instead.

@j178 j178 closed this Feb 7, 2026
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.

prek uses incorrect python version for zizmor

3 participants