Add --no-sources to avoid reading from tool.uv.sources (#5801)

## Summary

Closes https://github.com/astral-sh/uv/issues/5791.
This commit is contained in:
Charlie Marsh 2024-08-06 10:14:19 -04:00 committed by GitHub
parent 478d32c655
commit 089f50a845
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 455 additions and 40 deletions

View file

@ -9,6 +9,7 @@ pub use name_specifiers::*;
pub use overrides::*;
pub use package_options::*;
pub use preview::*;
pub use sources::*;
pub use target_triple::*;
mod authentication;
@ -22,4 +23,5 @@ mod name_specifiers;
mod overrides;
mod package_options;
mod preview;
mod sources;
mod target_triple;

View file

@ -0,0 +1,19 @@
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum SourceStrategy {
/// Use `tool.uv.sources` when resolving dependencies.
#[default]
Enabled,
/// Ignore `tool.uv.sources` when resolving dependencies.
Disabled,
}
impl SourceStrategy {
/// Return the [`SourceStrategy`] from the command-line arguments, if any.
pub fn from_args(no_sources: bool) -> Self {
if no_sources {
Self::Disabled
} else {
Self::Enabled
}
}
}