mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Apply first set of Rustfmt edition 2024 changes (#13478)
Rustfmt introduces a lot of formatting changes in the 2024 edition. To not break everything all at once, we split out the set of formatting changes compatible with both the 2021 and 2024 edition by first formatting with the 2024 style, and then again with the currently used 2021 style. Notable changes are the formatting of derive macro attributes and lines with overly long strings and adding trailing semicolons after statements consistently.
This commit is contained in:
parent
b31d08c683
commit
5d37c7ecc5
77 changed files with 660 additions and 313 deletions
|
@ -262,7 +262,9 @@ impl CandidateSelector {
|
|||
[] => {}
|
||||
[dist] => {
|
||||
if dist.version() == version {
|
||||
debug!("Found installed version of {dist} that satisfies preference in {range}");
|
||||
debug!(
|
||||
"Found installed version of {dist} that satisfies preference in {range}"
|
||||
);
|
||||
|
||||
return Some(Candidate {
|
||||
name: package_name,
|
||||
|
@ -278,7 +280,9 @@ impl CandidateSelector {
|
|||
// We do not consider installed distributions with multiple versions because
|
||||
// during installation these must be reinstalled from the remote
|
||||
_ => {
|
||||
debug!("Ignoring installed versions of {package_name}: multiple distributions found");
|
||||
debug!(
|
||||
"Ignoring installed versions of {package_name}: multiple distributions found"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -526,7 +530,9 @@ impl CandidateSelector {
|
|||
let Some(dist) = maybe_dist.prioritized_dist() else {
|
||||
continue;
|
||||
};
|
||||
trace!("Found candidate for package {package_name} with range {range} after {steps} steps: {version} version");
|
||||
trace!(
|
||||
"Found candidate for package {package_name} with range {range} after {steps} steps: {version} version"
|
||||
);
|
||||
Candidate::new(package_name, version, dist, VersionChoiceKind::Compatible)
|
||||
};
|
||||
|
||||
|
@ -584,7 +590,9 @@ impl CandidateSelector {
|
|||
return incompatible;
|
||||
}
|
||||
|
||||
trace!("Exhausted all candidates for package {package_name} with range {range} after {steps} steps");
|
||||
trace!(
|
||||
"Exhausted all candidates for package {package_name} with range {range} after {steps} steps"
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,9 @@ pub enum ResolveError {
|
|||
#[error("Requirements contain conflicting indexes for package `{0}`: `{1}` vs. `{2}`")]
|
||||
ConflictingIndexes(PackageName, String, String),
|
||||
|
||||
#[error("Package `{0}` attempted to resolve via URL: {1}. URL dependencies must be expressed as direct requirements or constraints. Consider adding `{0} @ {1}` to your dependencies or constraints file.")]
|
||||
#[error(
|
||||
"Package `{0}` attempted to resolve via URL: {1}. URL dependencies must be expressed as direct requirements or constraints. Consider adding `{0} @ {1}` to your dependencies or constraints file."
|
||||
)]
|
||||
DisallowedUrl(PackageName, String),
|
||||
|
||||
#[error(transparent)]
|
||||
|
@ -103,7 +105,9 @@ pub enum ResolveError {
|
|||
#[error("Attempted to construct an invalid version specifier")]
|
||||
InvalidVersion(#[from] uv_pep440::VersionSpecifierBuildError),
|
||||
|
||||
#[error("In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: `{0}`")]
|
||||
#[error(
|
||||
"In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: `{0}`"
|
||||
)]
|
||||
UnhashedPackage(PackageName),
|
||||
|
||||
#[error("found conflicting distribution in resolution: {0}")]
|
||||
|
@ -124,7 +128,9 @@ pub enum ResolveError {
|
|||
#[source]
|
||||
name_error: InvalidNameError,
|
||||
},
|
||||
#[error("The index returned metadata for the wrong package: expected {request} for {expected}, got {request} for {actual}")]
|
||||
#[error(
|
||||
"The index returned metadata for the wrong package: expected {request} for {expected}, got {request} for {actual}"
|
||||
)]
|
||||
MismatchedPackageName {
|
||||
request: &'static str,
|
||||
expected: PackageName,
|
||||
|
|
|
@ -217,7 +217,7 @@ impl FlatDistributions {
|
|||
let priority = match tags {
|
||||
Some(tags) => match filename.compatibility(tags) {
|
||||
TagCompatibility::Incompatible(tag) => {
|
||||
return WheelCompatibility::Incompatible(IncompatibleWheel::Tag(tag))
|
||||
return WheelCompatibility::Incompatible(IncompatibleWheel::Tag(tag));
|
||||
}
|
||||
TagCompatibility::Compatible(priority) => Some(priority),
|
||||
},
|
||||
|
|
|
@ -42,23 +42,41 @@ use crate::{Installable, LockError, RequiresPython, ResolverOutput};
|
|||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum PylockTomlErrorKind {
|
||||
#[error("Package `{0}` includes both a registry (`packages.wheels`) and a directory source (`packages.directory`)")]
|
||||
#[error(
|
||||
"Package `{0}` includes both a registry (`packages.wheels`) and a directory source (`packages.directory`)"
|
||||
)]
|
||||
WheelWithDirectory(PackageName),
|
||||
#[error("Package `{0}` includes both a registry (`packages.wheels`) and a VCS source (`packages.vcs`)")]
|
||||
#[error(
|
||||
"Package `{0}` includes both a registry (`packages.wheels`) and a VCS source (`packages.vcs`)"
|
||||
)]
|
||||
WheelWithVcs(PackageName),
|
||||
#[error("Package `{0}` includes both a registry (`packages.wheels`) and an archive source (`packages.archive`)")]
|
||||
#[error(
|
||||
"Package `{0}` includes both a registry (`packages.wheels`) and an archive source (`packages.archive`)"
|
||||
)]
|
||||
WheelWithArchive(PackageName),
|
||||
#[error("Package `{0}` includes both a registry (`packages.sdist`) and a directory source (`packages.directory`)")]
|
||||
#[error(
|
||||
"Package `{0}` includes both a registry (`packages.sdist`) and a directory source (`packages.directory`)"
|
||||
)]
|
||||
SdistWithDirectory(PackageName),
|
||||
#[error("Package `{0}` includes both a registry (`packages.sdist`) and a VCS source (`packages.vcs`)")]
|
||||
#[error(
|
||||
"Package `{0}` includes both a registry (`packages.sdist`) and a VCS source (`packages.vcs`)"
|
||||
)]
|
||||
SdistWithVcs(PackageName),
|
||||
#[error("Package `{0}` includes both a registry (`packages.sdist`) and an archive source (`packages.archive`)")]
|
||||
#[error(
|
||||
"Package `{0}` includes both a registry (`packages.sdist`) and an archive source (`packages.archive`)"
|
||||
)]
|
||||
SdistWithArchive(PackageName),
|
||||
#[error("Package `{0}` includes both a directory (`packages.directory`) and a VCS source (`packages.vcs`)")]
|
||||
#[error(
|
||||
"Package `{0}` includes both a directory (`packages.directory`) and a VCS source (`packages.vcs`)"
|
||||
)]
|
||||
DirectoryWithVcs(PackageName),
|
||||
#[error("Package `{0}` includes both a directory (`packages.directory`) and an archive source (`packages.archive`)")]
|
||||
#[error(
|
||||
"Package `{0}` includes both a directory (`packages.directory`) and an archive source (`packages.archive`)"
|
||||
)]
|
||||
DirectoryWithArchive(PackageName),
|
||||
#[error("Package `{0}` includes both a VCS (`packages.vcs`) and an archive source (`packages.archive`)")]
|
||||
#[error(
|
||||
"Package `{0}` includes both a VCS (`packages.vcs`) and an archive source (`packages.archive`)"
|
||||
)]
|
||||
VcsWithArchive(PackageName),
|
||||
#[error(
|
||||
"Package `{0}` must include one of: `wheels`, `directory`, `archive`, `sdist`, or `vcs`"
|
||||
|
@ -82,17 +100,29 @@ pub enum PylockTomlErrorKind {
|
|||
PathToUrl,
|
||||
#[error("Failed to convert URL to path")]
|
||||
UrlToPath,
|
||||
#[error("Package `{0}` can't be installed because it doesn't have a source distribution or wheel for the current platform")]
|
||||
#[error(
|
||||
"Package `{0}` can't be installed because it doesn't have a source distribution or wheel for the current platform"
|
||||
)]
|
||||
NeitherSourceDistNorWheel(PackageName),
|
||||
#[error("Package `{0}` can't be installed because it is marked as both `--no-binary` and `--no-build`")]
|
||||
#[error(
|
||||
"Package `{0}` can't be installed because it is marked as both `--no-binary` and `--no-build`"
|
||||
)]
|
||||
NoBinaryNoBuild(PackageName),
|
||||
#[error("Package `{0}` can't be installed because it is marked as `--no-binary` but has no source distribution")]
|
||||
#[error(
|
||||
"Package `{0}` can't be installed because it is marked as `--no-binary` but has no source distribution"
|
||||
)]
|
||||
NoBinary(PackageName),
|
||||
#[error("Package `{0}` can't be installed because it is marked as `--no-build` but has no binary distribution")]
|
||||
#[error(
|
||||
"Package `{0}` can't be installed because it is marked as `--no-build` but has no binary distribution"
|
||||
)]
|
||||
NoBuild(PackageName),
|
||||
#[error("Package `{0}` can't be installed because the binary distribution is incompatible with the current platform")]
|
||||
#[error(
|
||||
"Package `{0}` can't be installed because the binary distribution is incompatible with the current platform"
|
||||
)]
|
||||
IncompatibleWheelOnly(PackageName),
|
||||
#[error("Package `{0}` can't be installed because it is marked as `--no-binary` but is itself a binary distribution")]
|
||||
#[error(
|
||||
"Package `{0}` can't be installed because it is marked as `--no-binary` but is itself a binary distribution"
|
||||
)]
|
||||
NoBinaryWheelOnly(PackageName),
|
||||
#[error(transparent)]
|
||||
WheelFilename(#[from] WheelFilenameError),
|
||||
|
|
|
@ -4111,7 +4111,7 @@ impl Wheel {
|
|||
name: filename.name,
|
||||
version: filename.version,
|
||||
}
|
||||
.into())
|
||||
.into());
|
||||
}
|
||||
};
|
||||
let file = Box::new(uv_distribution_types::File {
|
||||
|
@ -4141,7 +4141,7 @@ impl Wheel {
|
|||
name: filename.name,
|
||||
version: filename.version,
|
||||
}
|
||||
.into())
|
||||
.into());
|
||||
}
|
||||
};
|
||||
let file_url = Url::from_file_path(root.join(index_path).join(file_path))
|
||||
|
|
|
@ -1408,7 +1408,8 @@ impl std::fmt::Display for PubGrubHint {
|
|||
"hint".bold().cyan(),
|
||||
":".bold(),
|
||||
requires_python.cyan(),
|
||||
PackageRange::compatibility(&PubGrubPackage::base(name), package_set, None).cyan(),
|
||||
PackageRange::compatibility(&PubGrubPackage::base(name), package_set, None)
|
||||
.cyan(),
|
||||
package_requires_python.cyan(),
|
||||
package_requires_python.cyan(),
|
||||
)
|
||||
|
@ -1426,7 +1427,8 @@ impl std::fmt::Display for PubGrubHint {
|
|||
"hint".bold().cyan(),
|
||||
":".bold(),
|
||||
requires_python.cyan(),
|
||||
PackageRange::compatibility(&PubGrubPackage::base(name), package_set, None).cyan(),
|
||||
PackageRange::compatibility(&PubGrubPackage::base(name), package_set, None)
|
||||
.cyan(),
|
||||
package_requires_python.cyan(),
|
||||
)
|
||||
}
|
||||
|
@ -1442,7 +1444,8 @@ impl std::fmt::Display for PubGrubHint {
|
|||
"{}{} The Python interpreter uses a Python version that is not supported by your dependencies (e.g., {} only supports {}). Consider passing a `--python-version` value to raise the minimum supported version.",
|
||||
"hint".bold().cyan(),
|
||||
":".bold(),
|
||||
PackageRange::compatibility(&PubGrubPackage::base(name), package_set, None).cyan(),
|
||||
PackageRange::compatibility(&PubGrubPackage::base(name), package_set, None)
|
||||
.cyan(),
|
||||
package_requires_python.cyan(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1857,7 +1857,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
url: None,
|
||||
})
|
||||
.collect(),
|
||||
))
|
||||
));
|
||||
}
|
||||
|
||||
// Add a dependency on both the extra and base package, with and without the marker.
|
||||
|
@ -1885,7 +1885,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
})
|
||||
})
|
||||
.collect(),
|
||||
))
|
||||
));
|
||||
}
|
||||
|
||||
// Add a dependency on the dependency group, with and without the marker.
|
||||
|
@ -1905,7 +1905,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
url: None,
|
||||
})
|
||||
.collect(),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
Ok(Dependencies::Available(dependencies))
|
||||
|
@ -2422,7 +2422,9 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
if !self.selector.use_highest_version(&package_name, &env) {
|
||||
if let Some((lower, _)) = range.iter().next() {
|
||||
if lower == &Bound::Unbounded {
|
||||
debug!("Skipping prefetch for unbounded minimum-version range: {package_name} ({range})");
|
||||
debug!(
|
||||
"Skipping prefetch for unbounded minimum-version range: {package_name} ({range})"
|
||||
);
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -917,7 +917,9 @@ mod tests {
|
|||
let cm = resolve_conflicts(cm, &known_conflicts);
|
||||
assert_eq!(
|
||||
cm.try_to_string().as_deref(),
|
||||
Some("(python_full_version < '3.10' and sys_platform != 'darwin') or (python_full_version >= '3.10' and sys_platform == 'darwin')")
|
||||
Some(
|
||||
"(python_full_version < '3.10' and sys_platform != 'darwin') or (python_full_version >= '3.10' and sys_platform == 'darwin')"
|
||||
)
|
||||
);
|
||||
|
||||
let cm = MarkerTree::from_str("python_version >= '3.10' and extra == 'extra-3-pkg-foo'")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue