Skip to content

Commit

Permalink
Remove trailing period from user-facing messages (#5218)
Browse files Browse the repository at this point in the history
## Summary

Per #5209, we only show periods in messages when the message itself
spans more than a single sentence.
  • Loading branch information
charliermarsh authored Jul 19, 2024
1 parent f2e2825 commit ed9b820
Show file tree
Hide file tree
Showing 55 changed files with 377 additions and 379 deletions.
8 changes: 4 additions & 4 deletions crates/distribution-types/src/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ impl Diagnostic for ResolutionDiagnostic {
fn message(&self) -> String {
match self {
Self::MissingExtra { dist, extra } => {
format!("The package `{dist}` does not have an extra named `{extra}`.")
format!("The package `{dist}` does not have an extra named `{extra}`")
}
Self::MissingDev { dist, dev } => {
format!("The package `{dist}` does not have a development dependency group named `{dev}`.")
format!("The package `{dist}` does not have a development dependency group named `{dev}`")
}
Self::YankedVersion { dist, reason } => {
if let Some(reason) = reason {
format!("`{dist}` is yanked (reason: \"{reason}\").")
format!("`{dist}` is yanked (reason: \"{reason}\")")
} else {
format!("`{dist}` is yanked.")
format!("`{dist}` is yanked")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-auth/src/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ impl Credentials {
let mut buf = String::new();
decoder
.read_to_string(&mut buf)
.expect("HTTP Basic Authentication should be base64 encoded.");
.expect("HTTP Basic Authentication should be base64 encoded");
let (username, password) = buf
.split_once(':')
.expect("HTTP Basic Authentication should include a `:` separator.");
.expect("HTTP Basic Authentication should include a `:` separator");
let username = if username.is_empty() {
None
} else {
Expand Down
70 changes: 34 additions & 36 deletions crates/uv-cli/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,96 +73,94 @@ impl CompatArgs for PipCompileCompatArgs {
fn validate(&self) -> Result<()> {
if self.allow_unsafe {
warn_user!(
"pip-compile's `--allow-unsafe` has no effect (uv can safely pin `pip` and other packages)."
"pip-compile's `--allow-unsafe` has no effect (uv can safely pin `pip` and other packages)"
);
}

if self.no_allow_unsafe {
warn_user!("pip-compile's `--no-allow-unsafe` has no effect (uv can safely pin `pip` and other packages).");
warn_user!("pip-compile's `--no-allow-unsafe` has no effect (uv can safely pin `pip` and other packages)");
}

if self.reuse_hashes {
return Err(anyhow!(
"pip-compile's `--reuse-hashes` is unsupported (uv doesn't reuse hashes)."
"pip-compile's `--reuse-hashes` is unsupported (uv doesn't reuse hashes)"
));
}

if self.no_reuse_hashes {
warn_user!(
"pip-compile's `--no-reuse-hashes` has no effect (uv doesn't reuse hashes)."
);
warn_user!("pip-compile's `--no-reuse-hashes` has no effect (uv doesn't reuse hashes)");
}

if let Some(resolver) = self.resolver {
match resolver {
Resolver::Backtracking => {
warn_user!(
"pip-compile's `--resolver=backtracking` has no effect (uv always backtracks)."
"pip-compile's `--resolver=backtracking` has no effect (uv always backtracks)"
);
}
Resolver::Legacy => {
return Err(anyhow!(
"pip-compile's `--resolver=legacy` is unsupported (uv always backtracks)."
"pip-compile's `--resolver=legacy` is unsupported (uv always backtracks)"
));
}
}
}

if self.max_rounds.is_some() {
return Err(anyhow!(
"pip-compile's `--max-rounds` is unsupported (uv always resolves until convergence)."
"pip-compile's `--max-rounds` is unsupported (uv always resolves until convergence)"
));
}

if self.client_cert.is_some() {
return Err(anyhow!(
"pip-compile's `--client-cert` is unsupported (uv doesn't support dedicated client certificates)."
"pip-compile's `--client-cert` is unsupported (uv doesn't support dedicated client certificates)"
));
}

if self.trusted_host.is_some() {
return Err(anyhow!(
"pip-compile's `--trusted-host` is unsupported (uv always requires HTTPS)."
"pip-compile's `--trusted-host` is unsupported (uv always requires HTTPS)"
));
}

if self.emit_trusted_host {
return Err(anyhow!(
"pip-compile's `--emit-trusted-host` is unsupported (uv always requires HTTPS)."
"pip-compile's `--emit-trusted-host` is unsupported (uv always requires HTTPS)"
));
}

if self.no_emit_trusted_host {
warn_user!(
"pip-compile's `--no-emit-trusted-host` has no effect (uv never emits trusted hosts)."
"pip-compile's `--no-emit-trusted-host` has no effect (uv never emits trusted hosts)"
);
}

if self.config.is_some() {
return Err(anyhow!(
"pip-compile's `--config` is unsupported (uv does not use a configuration file)."
"pip-compile's `--config` is unsupported (uv does not use a configuration file)"
));
}

if self.no_config {
warn_user!(
"pip-compile's `--no-config` has no effect (uv does not use a configuration file)."
"pip-compile's `--no-config` has no effect (uv does not use a configuration file)"
);
}

if self.emit_options {
return Err(anyhow!(
"pip-compile's `--emit-options` is unsupported (uv never emits options)."
"pip-compile's `--emit-options` is unsupported (uv never emits options)"
));
}

if self.no_emit_options {
warn_user!("pip-compile's `--no-emit-options` has no effect (uv never emits options).");
warn_user!("pip-compile's `--no-emit-options` has no effect (uv never emits options)");
}

if self.pip_args.is_some() {
return Err(anyhow!(
"pip-compile's `--pip-args` is unsupported (try passing arguments to uv directly)."
"pip-compile's `--pip-args` is unsupported (try passing arguments to uv directly)"
));
}

Expand Down Expand Up @@ -191,11 +189,11 @@ impl CompatArgs for PipListCompatArgs {
/// `--outdated`), this method will return an error.
fn validate(&self) -> Result<()> {
if self.disable_pip_version_check {
warn_user!("pip's `--disable-pip-version-check` has no effect.");
warn_user!("pip's `--disable-pip-version-check` has no effect");
}

if self.outdated {
return Err(anyhow!("pip's `--outdated` is unsupported."));
return Err(anyhow!("pip's `--outdated` is unsupported"));
}

Ok(())
Expand Down Expand Up @@ -245,49 +243,49 @@ impl CompatArgs for PipSyncCompatArgs {
fn validate(&self) -> Result<()> {
if self.ask {
return Err(anyhow!(
"pip-sync's `--ask` is unsupported (uv never asks for confirmation)."
"pip-sync's `--ask` is unsupported (uv never asks for confirmation)"
));
}

if self.python_executable.is_some() {
return Err(anyhow!(
"pip-sync's `--python-executable` is unsupported (to install into a separate Python environment, try setting `VIRTUAL_ENV` instead)."
"pip-sync's `--python-executable` is unsupported (to install into a separate Python environment, try setting `VIRTUAL_ENV` instead)"
));
}

if self.user {
return Err(anyhow!(
"pip-sync's `--user` is unsupported (use a virtual environment instead)."
"pip-sync's `--user` is unsupported (use a virtual environment instead)"
));
}

if self.client_cert.is_some() {
return Err(anyhow!(
"pip-sync's `--client-cert` is unsupported (uv doesn't support dedicated client certificates)."
"pip-sync's `--client-cert` is unsupported (uv doesn't support dedicated client certificates)"
));
}

if self.trusted_host.is_some() {
return Err(anyhow!(
"pip-sync's `--trusted-host` is unsupported (uv always requires HTTPS)."
"pip-sync's `--trusted-host` is unsupported (uv always requires HTTPS)"
));
}

if self.config.is_some() {
return Err(anyhow!(
"pip-sync's `--config` is unsupported (uv does not use a configuration file)."
"pip-sync's `--config` is unsupported (uv does not use a configuration file)"
));
}

if self.no_config {
warn_user!(
"pip-sync's `--no-config` has no effect (uv does not use a configuration file)."
"pip-sync's `--no-config` has no effect (uv does not use a configuration file)"
);
}

if self.pip_args.is_some() {
return Err(anyhow!(
"pip-sync's `--pip-args` is unsupported (try passing arguments to uv directly)."
"pip-sync's `--pip-args` is unsupported (try passing arguments to uv directly)"
));
}

Expand Down Expand Up @@ -332,28 +330,28 @@ impl CompatArgs for VenvCompatArgs {
fn validate(&self) -> Result<()> {
if self.clear {
warn_user!(
"virtualenv's `--clear` has no effect (uv always clears the virtual environment)."
"virtualenv's `--clear` has no effect (uv always clears the virtual environment)"
);
}

if self.no_seed {
warn_user!(
"virtualenv's `--no-seed` has no effect (uv omits seed packages by default)."
"virtualenv's `--no-seed` has no effect (uv omits seed packages by default)"
);
}

if self.no_pip {
warn_user!("virtualenv's `--no-pip` has no effect (uv omits `pip` by default).");
warn_user!("virtualenv's `--no-pip` has no effect (uv omits `pip` by default)");
}

if self.no_setuptools {
warn_user!(
"virtualenv's `--no-setuptools` has no effect (uv omits `setuptools` by default)."
"virtualenv's `--no-setuptools` has no effect (uv omits `setuptools` by default)"
);
}

if self.no_wheel {
warn_user!("virtualenv's `--no-wheel` has no effect (uv omits `wheel` by default).");
warn_user!("virtualenv's `--no-wheel` has no effect (uv omits `wheel` by default)");
}

Ok(())
Expand Down Expand Up @@ -381,12 +379,12 @@ impl CompatArgs for PipInstallCompatArgs {
/// return an error.
fn validate(&self) -> Result<()> {
if self.disable_pip_version_check {
warn_user!("pip's `--disable-pip-version-check` has no effect.");
warn_user!("pip's `--disable-pip-version-check` has no effect");
}

if self.user {
return Err(anyhow!(
"pip's `--user` is unsupported (use a virtual environment instead)."
"pip's `--user` is unsupported (use a virtual environment instead)"
));
}

Expand All @@ -412,7 +410,7 @@ impl CompatArgs for PipGlobalCompatArgs {
/// return an error.
fn validate(&self) -> Result<()> {
if self.disable_pip_version_check {
warn_user!("pip's `--disable-pip-version-check` has no effect.");
warn_user!("pip's `--disable-pip-version-check` has no effect");
}

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-client/src/base_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl<'a> BaseClientBuilder<'a> {
value.parse::<u64>()
.or_else(|_| {
// On parse error, warn and use the default timeout
warn_user_once!("Ignoring invalid value from environment for UV_HTTP_TIMEOUT. Expected integer number of seconds, got \"{value}\".");
warn_user_once!("Ignoring invalid value from environment for `UV_HTTP_TIMEOUT`. Expected an integer number of seconds, got \"{value}\".");
Ok(default_timeout)
})
})
Expand Down Expand Up @@ -175,7 +175,7 @@ impl<'a> BaseClientBuilder<'a> {
client_core
};

client_core.build().expect("Failed to build HTTP client.")
client_core.build().expect("Failed to build HTTP client")
});

// Wrap in any relevant middleware.
Expand Down
6 changes: 3 additions & 3 deletions crates/uv-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,18 @@ pub enum ErrorKind {
#[error(transparent)]
DistInfo(#[from] install_wheel_rs::Error),

#[error("{0} isn't available locally, but making network requests to registries was banned.")]
#[error("{0} isn't available locally, but making network requests to registries was banned")]
NoIndex(String),

/// The package was not found in the registry.
///
/// Make sure the package name is spelled correctly and that you've
/// configured the right registry to fetch it from.
#[error("Package `{0}` was not found in the registry.")]
#[error("Package `{0}` was not found in the registry")]
PackageNotFound(String),

/// The package was not found in the local (file-based) index.
#[error("Package `{0}` was not found in the local index.")]
#[error("Package `{0}` was not found in the local index")]
FileNotFound(String),

/// The metadata file could not be parsed.
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-client/tests/user_agent_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ async fn test_user_agent_has_linehaul() -> Result<()> {
// Unpack User-Agent with linehaul
let (uv_version, uv_linehaul) = body
.split_once(' ')
.expect("Failed to split User-Agent header.");
.expect("Failed to split User-Agent header");

// Deserializing Linehaul
let linehaul: LineHaul = serde_json::from_str(uv_linehaul)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-distribution/src/metadata/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub(crate) fn lower_requirement(
};

if preview.is_disabled() {
warn_user_once!("`uv.sources` is experimental and may change without warning.");
warn_user_once!("`uv.sources` is experimental and may change without warning");
}

let source = match source {
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-distribution/src/pyproject_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum Error {
MalformedDependencies,
#[error("Sources in `pyproject.toml` are malformed")]
MalformedSources,
#[error("Cannot perform ambiguous update; multiple entries with matching package names.")]
#[error("Cannot perform ambiguous update; found multiple entries with matching package names")]
Ambiguous,
}

Expand Down
8 changes: 4 additions & 4 deletions crates/uv-installer/src/site_packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,26 +428,26 @@ impl Diagnostic for SitePackagesDiagnostic {
version,
requires_python,
} => format!(
"The package `{package}` requires Python {requires_python}, but `{version}` is installed."
"The package `{package}` requires Python {requires_python}, but `{version}` is installed"
),
Self::MissingDependency {
package,
requirement,
} => {
format!("The package `{package}` requires `{requirement}`, but it's not installed.")
format!("The package `{package}` requires `{requirement}`, but it's not installed")
}
Self::IncompatibleDependency {
package,
version,
requirement,
} => format!(
"The package `{package}` requires `{requirement}`, but `{version}` is installed."
"The package `{package}` requires `{requirement}`, but `{version}` is installed"
),
Self::DuplicatePackage { package, paths } => {
let mut paths = paths.clone();
paths.sort();
format!(
"The package `{package}` has multiple installed distributions:{}",
"The package `{package}` has multiple installed distributions: {}",
paths.iter().fold(String::new(), |acc, path| acc + &format!("\n - {}", path.display()))
)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-python/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ fn warn_on_unsupported_python(interpreter: &Interpreter) {
// Warn on usage with an unsupported Python version
if interpreter.python_tuple() < (3, 8) {
warn_user_once!(
"uv is only compatible with Python 3.8+, found Python {}.",
"uv is only compatible with Python >=3.8, found Python {}",
interpreter.python_version()
);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-python/src/py_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ pub enum Error {
stdout: String,
stderr: String,
},
#[error("Failed to run `py --list-paths` to find Python installations.")]
#[error("Failed to run `py --list-paths` to find Python installations")]
Io(#[source] io::Error),
#[error("The `py` launcher could not be found.")]
#[error("The `py` launcher could not be found")]
NotFound,
}

Expand Down
Loading

0 comments on commit ed9b820

Please sign in to comment.