Skip to content

Conversation

@lmmx
Copy link
Contributor

@lmmx lmmx commented Dec 2, 2025

Providing config from pyproject.toml as well as env vars and CLI flags

Allows configuration of what were previously env var only settings via pyproject.toml [tool.prek] (closes #1175)

  • Note this does not let you put hook definitions in pyproject.toml, only the env var settings

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 80.87432% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.61%. Comparing base (bd4da34) to head (0e1361b).

Files with missing lines Patch % Lines
src/settings.rs 79.16% 35 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1179      +/-   ##
==========================================
- Coverage   89.69%   89.61%   -0.09%     
==========================================
  Files          78       79       +1     
  Lines       14631    14804     +173     
==========================================
+ Hits        13124    13266     +142     
- Misses       1507     1538      +31     

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

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

📦 Cargo Bloat Comparison

Binary size change: +0.61% (16.4 MiB → 16.5 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text     Size          Crate Name
 0.6%   1.4% 104.8KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.6%   1.3%  99.7KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  54.6KiB           prek prek::archive::unpack::{{closure}}
 0.3%   0.7%  53.0KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.3%   0.6%  43.9KiB           prek prek::run::{{closure}}
 0.2%   0.5%  40.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  39.2KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  37.3KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.5%  35.2KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  30.1KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  28.8KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  28.1KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.4%  27.6KiB           prek prek::identify::by_extension::{{closure}}
 0.2%   0.3%  26.1KiB           prek <prek::languages::rust::rust::Rust as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.3%  25.1KiB           prek prek::main
 0.1%   0.3%  24.4KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.3%  24.4KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.1%   0.3%  24.3KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.1%   0.3%  23.9KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
 0.1%   0.3%  23.9KiB        globset globset::GlobSetBuilder::build
40.8%  88.8%   6.7MiB                And 10451 smaller methods. Use -n N to show more.
45.9% 100.0%   7.6MiB                .text section size, the file size is 16.5MiB

Base Branch Results

 File  .text     Size          Crate Name
 0.6%   1.4% 104.8KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.6%   1.3%  99.7KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  54.6KiB           prek prek::archive::unpack::{{closure}}
 0.3%   0.7%  53.0KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.3%   0.6%  48.6KiB           prek prek::run::{{closure}}
 0.2%   0.5%  40.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  39.2KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  37.3KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.5%  35.2KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  30.1KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  28.8KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  28.1KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.4%  27.6KiB           prek prek::identify::by_extension::{{closure}}
 0.2%   0.3%  26.1KiB           prek <prek::languages::rust::rust::Rust as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.3%  25.1KiB           prek prek::main
 0.1%   0.3%  24.4KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.3%  24.4KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.1%   0.3%  24.3KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.1%   0.3%  24.2KiB           prek prek::hook::HookBuilder::build::{{closure}}
 0.1%   0.3%  23.9KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
40.7%  88.6%   6.7MiB                And 10403 smaller methods. Use -n N to show more.
45.9% 100.0%   7.5MiB                .text section size, the file size is 16.4MiB

@lmmx lmmx changed the title build: add figment for multi-provider configuration feat: figment for multi-provider configuration Dec 2, 2025
@lmmx lmmx changed the title feat: figment for multi-provider configuration [WIP] feat: figment for multi-provider configuration Dec 2, 2025
@lmmx lmmx force-pushed the figment-providers branch from 0880ac7 to b9bd64c Compare December 2, 2025 21:23
@lmmx
Copy link
Contributor Author

lmmx commented Dec 2, 2025

What do you make of this approach using figment @j178?

Figment is a settings provider handling tool - docs

I put an initial draft of what this would look like in the PR to see the effect on the size (+1.83% or +0.3MB)

edit I switched to a fork of figment I published myself because the maintainer has left it for a year plus now and it was causing a copy of TOML to be pulled in due to dependency mismatch.

@lmmx lmmx force-pushed the figment-providers branch from c655a64 to d87dcc8 Compare December 3, 2025 10:46
@lmmx lmmx force-pushed the figment-providers branch from d87dcc8 to beb4e4e Compare December 3, 2025 11:36
@lmmx lmmx force-pushed the figment-providers branch from beb4e4e to cf99192 Compare December 3, 2025 11:37
@j178
Copy link
Owner

j178 commented Dec 3, 2025

Haven’t looked too closely yet (work’s been crazy busy), but I’m not really a fan of using such a complicated config framework for the pretty simple configs we use in prek. I might take a closer look later, but it’s probably not going to be a high priority for me.

@lmmx
Copy link
Contributor Author

lmmx commented Dec 3, 2025

Ahh ok. I see its benefit as simpler handling of configs from multiple places.

If there's an alternative that you'd prefer to land support for #1175 with let me know.

@lmmx lmmx changed the title [WIP] feat: figment for multi-provider configuration [WIP] feat: add pyproject.toml config provider Dec 3, 2025
@lmmx
Copy link
Contributor Author

lmmx commented Dec 3, 2025

I've rewritten without figment in that case, I guess we can add it back if we end up with many providers to handle.

Renamed the PR/description accordingly.

@lmmx lmmx changed the title [WIP] feat: add pyproject.toml config provider feat: add pyproject.toml config provider Dec 3, 2025
@lmmx lmmx marked this pull request as ready for review December 3, 2025 15:13
@j178
Copy link
Owner

j178 commented Dec 3, 2025

Thank you, @lmmx, as always for your great contribution! Since support of pyproject.toml isn't a highly urgent priority right now, I won't be able to get to this immediately, but I really appreciate the work.

@lmmx
Copy link
Contributor Author

lmmx commented Dec 3, 2025

Most welcome and not a problem :)

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.

Make env var options configurable via pyproject.toml

2 participants