Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove warnings for missing lower bounds #11195

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions crates/uv-bench/benches/uv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ mod resolver {
use uv_cache::Cache;
use uv_client::RegistryClient;
use uv_configuration::{
BuildOptions, Concurrency, ConfigSettings, Constraints, IndexStrategy, LowerBound,
PreviewMode, SourceStrategy,
BuildOptions, Concurrency, ConfigSettings, Constraints, IndexStrategy, PreviewMode,
SourceStrategy,
};
use uv_dispatch::{BuildDispatch, SharedState};
use uv_distribution::DistributionDatabase;
Expand Down Expand Up @@ -187,7 +187,6 @@ mod resolver {
&build_options,
&hashes,
exclude_newer,
LowerBound::default(),
sources,
concurrency,
PreviewMode::Enabled,
Expand Down
4 changes: 1 addition & 3 deletions crates/uv-build-frontend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use tokio::process::Command;
use tokio::sync::{Mutex, Semaphore};
use tracing::{debug, info_span, instrument, Instrument};

use uv_configuration::{BuildKind, BuildOutput, ConfigSettings, LowerBound, SourceStrategy};
use uv_configuration::{BuildKind, BuildOutput, ConfigSettings, SourceStrategy};
use uv_distribution::BuildRequires;
use uv_distribution_types::{IndexLocations, Resolution};
use uv_fs::{PythonExt, Simplified};
Expand Down Expand Up @@ -480,7 +480,6 @@ impl SourceBuild {
install_path,
locations,
source_strategy,
LowerBound::Allow,
)
.await
.map_err(Error::Lowering)?;
Expand Down Expand Up @@ -910,7 +909,6 @@ async fn create_pep517_build_environment(
install_path,
locations,
source_strategy,
LowerBound::Allow,
)
.await
.map_err(Error::Lowering)?;
Expand Down
8 changes: 0 additions & 8 deletions crates/uv-configuration/src/bounds.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/uv-configuration/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub use authentication::*;
pub use bounds::*;
pub use build_options::*;
pub use concurrency::*;
pub use config_settings::*;
Expand All @@ -24,7 +23,6 @@ pub use trusted_publishing::*;
pub use vcs::*;

mod authentication;
mod bounds;
mod build_options;
mod concurrency;
mod config_settings;
Expand Down
13 changes: 4 additions & 9 deletions crates/uv-dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use uv_build_frontend::{SourceBuild, SourceBuildContext};
use uv_cache::Cache;
use uv_client::RegistryClient;
use uv_configuration::{
BuildKind, BuildOptions, ConfigSettings, Constraints, IndexStrategy, LowerBound, PreviewMode,
Reinstall, SourceStrategy,
BuildKind, BuildOptions, ConfigSettings, Constraints, IndexStrategy, PreviewMode, Reinstall,
SourceStrategy,
};
use uv_configuration::{BuildOutput, Concurrency};
use uv_distribution::DistributionDatabase;
Expand Down Expand Up @@ -93,7 +93,7 @@ pub struct BuildDispatch<'a> {
exclude_newer: Option<ExcludeNewer>,
source_build_context: SourceBuildContext,
build_extra_env_vars: FxHashMap<OsString, OsString>,
bounds: LowerBound,

sources: SourceStrategy,
concurrency: Concurrency,
preview: PreviewMode,
Expand All @@ -116,7 +116,6 @@ impl<'a> BuildDispatch<'a> {
build_options: &'a BuildOptions,
hasher: &'a HashStrategy,
exclude_newer: Option<ExcludeNewer>,
bounds: LowerBound,
sources: SourceStrategy,
concurrency: Concurrency,
preview: PreviewMode,
Expand All @@ -139,7 +138,7 @@ impl<'a> BuildDispatch<'a> {
exclude_newer,
source_build_context: SourceBuildContext::default(),
build_extra_env_vars: FxHashMap::default(),
bounds,

sources,
concurrency,
preview,
Expand Down Expand Up @@ -194,10 +193,6 @@ impl BuildContext for BuildDispatch<'_> {
self.config_settings
}

fn bounds(&self) -> LowerBound {
self.bounds
}

fn sources(&self) -> SourceStrategy {
self.sources
}
Expand Down
1 change: 0 additions & 1 deletion crates/uv-distribution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ uv-pep508 = { workspace = true }
uv-platform-tags = { workspace = true }
uv-pypi-types = { workspace = true }
uv-types = { workspace = true }
uv-warnings = { workspace = true }
uv-workspace = { workspace = true }

anyhow = { workspace = true }
Expand Down
15 changes: 2 additions & 13 deletions crates/uv-distribution/src/metadata/build_requires.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;
use std::path::Path;

use uv_configuration::{LowerBound, SourceStrategy};
use uv_configuration::SourceStrategy;
use uv_distribution_types::IndexLocations;
use uv_normalize::PackageName;
use uv_workspace::pyproject::ToolUvSources;
Expand Down Expand Up @@ -37,7 +37,6 @@ impl BuildRequires {
install_path: &Path,
locations: &IndexLocations,
sources: SourceStrategy,
lower_bound: LowerBound,
) -> Result<Self, MetadataError> {
let discovery = match sources {
SourceStrategy::Enabled => DiscoveryOptions::default(),
Expand All @@ -54,13 +53,7 @@ impl BuildRequires {
return Ok(Self::from_metadata23(metadata));
};

Self::from_project_workspace(
metadata,
&project_workspace,
locations,
sources,
lower_bound,
)
Self::from_project_workspace(metadata, &project_workspace, locations, sources)
}

/// Lower the `build-system.requires` field from a `pyproject.toml` file.
Expand All @@ -69,7 +62,6 @@ impl BuildRequires {
project_workspace: &ProjectWorkspace,
locations: &IndexLocations,
source_strategy: SourceStrategy,
lower_bound: LowerBound,
) -> Result<Self, MetadataError> {
// Collect any `tool.uv.index` entries.
let empty = vec![];
Expand Down Expand Up @@ -118,7 +110,6 @@ impl BuildRequires {
group,
locations,
project_workspace.workspace(),
lower_bound,
None,
)
.map(move |requirement| match requirement {
Expand Down Expand Up @@ -148,7 +139,6 @@ impl BuildRequires {
workspace: &Workspace,
locations: &IndexLocations,
source_strategy: SourceStrategy,
lower_bound: LowerBound,
) -> Result<Self, MetadataError> {
// Collect any `tool.uv.index` entries.
let empty = vec![];
Expand Down Expand Up @@ -195,7 +185,6 @@ impl BuildRequires {
group,
locations,
workspace,
lower_bound,
None,
)
.map(move |requirement| match requirement {
Expand Down
69 changes: 13 additions & 56 deletions crates/uv-distribution/src/metadata/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use either::Either;
use thiserror::Error;
use url::Url;

use uv_configuration::LowerBound;
use uv_distribution_filename::DistExtension;
use uv_distribution_types::{Index, IndexLocations, IndexName, Origin};
use uv_git::GitReference;
Expand All @@ -16,7 +15,6 @@ use uv_pep508::{looks_like_git_repository, MarkerTree, VerbatimUrl, VersionOrUrl
use uv_pypi_types::{
ConflictItem, ParsedUrlError, Requirement, RequirementSource, VerbatimParsedUrl,
};
use uv_warnings::warn_user_once;
use uv_workspace::pyproject::{PyProjectToml, Source, Sources};
use uv_workspace::Workspace;

Expand Down Expand Up @@ -45,7 +43,7 @@ impl LoweredRequirement {
group: Option<&GroupName>,
locations: &'data IndexLocations,
workspace: &'data Workspace,
lower_bound: LowerBound,

git_member: Option<&'data GitWorkspaceMember<'data>>,
) -> impl Iterator<Item = Result<Self, LoweringError>> + 'data {
// Identify the source from the `tool.uv.sources` table.
Expand Down Expand Up @@ -136,19 +134,6 @@ impl LoweredRequirement {
}

let Some(sources) = sources else {
let has_sources = !project_sources.is_empty() || !workspace.sources().is_empty();
if matches!(lower_bound, LowerBound::Warn) {
// Support recursive editable inclusions.
if has_sources
&& requirement.version_or_url.is_none()
&& project_name.is_none_or(|project_name| *project_name != requirement.name)
{
warn_user_once!(
"Missing version constraint (e.g., a lower bound) for `{}`",
requirement.name
);
}
}
return Either::Left(std::iter::once(Ok(Self(Requirement::from(requirement)))));
};

Expand Down Expand Up @@ -252,12 +237,7 @@ impl LoweredRequirement {
})
}
});
let source = registry_source(
&requirement,
index.into_url(),
conflict,
lower_bound,
);
let source = registry_source(&requirement, index.into_url(), conflict);
(source, marker)
}
Source::Workspace {
Expand Down Expand Up @@ -367,7 +347,6 @@ impl LoweredRequirement {
sources: &'data BTreeMap<PackageName, Sources>,
indexes: &'data [Index],
locations: &'data IndexLocations,
lower_bound: LowerBound,
) -> impl Iterator<Item = Result<Self, LoweringError>> + 'data {
let source = sources.get(&requirement.name).cloned();

Expand Down Expand Up @@ -473,12 +452,7 @@ impl LoweredRequirement {
));
};
let conflict = None;
let source = registry_source(
&requirement,
index.into_url(),
conflict,
lower_bound,
);
let source = registry_source(&requirement, index.into_url(), conflict);
(source, marker)
}
Source::Workspace { .. } => {
Expand Down Expand Up @@ -652,40 +626,23 @@ fn registry_source(
requirement: &uv_pep508::Requirement<VerbatimParsedUrl>,
index: Url,
conflict: Option<ConflictItem>,
bounds: LowerBound,
) -> RequirementSource {
match &requirement.version_or_url {
None => {
if matches!(bounds, LowerBound::Warn) {
warn_user_once!(
"Missing version constraint (e.g., a lower bound) for `{}`",
requirement.name
);
}
RequirementSource::Registry {
specifier: VersionSpecifiers::empty(),
index: Some(index),
conflict,
}
}
None => RequirementSource::Registry {
specifier: VersionSpecifiers::empty(),
index: Some(index),
conflict,
},
Some(VersionOrUrl::VersionSpecifier(version)) => RequirementSource::Registry {
specifier: version.clone(),
index: Some(index),
conflict,
},
Some(VersionOrUrl::Url(_)) => {
if matches!(bounds, LowerBound::Warn) {
warn_user_once!(
"Missing version constraint (e.g., a lower bound) for `{}` due to use of a URL specifier",
requirement.name
);
}
RequirementSource::Registry {
specifier: VersionSpecifiers::empty(),
index: Some(index),
conflict,
}
}
Some(VersionOrUrl::Url(_)) => RequirementSource::Registry {
specifier: VersionSpecifiers::empty(),
index: Some(index),
conflict,
},
}
}

Expand Down
4 changes: 1 addition & 3 deletions crates/uv-distribution/src/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::Path;

use thiserror::Error;

use uv_configuration::{LowerBound, SourceStrategy};
use uv_configuration::SourceStrategy;
use uv_distribution_types::{GitSourceUrl, IndexLocations};
use uv_normalize::{ExtraName, GroupName, PackageName};
use uv_pep440::{Version, VersionSpecifiers};
Expand Down Expand Up @@ -80,7 +80,6 @@ impl Metadata {
git_source: Option<&GitWorkspaceMember<'_>>,
locations: &IndexLocations,
sources: SourceStrategy,
bounds: LowerBound,
) -> Result<Self, MetadataError> {
// Lower the requirements.
let requires_dist = uv_pypi_types::RequiresDist {
Expand All @@ -101,7 +100,6 @@ impl Metadata {
git_source,
locations,
sources,
bounds,
)
.await?;

Expand Down
Loading
Loading