Rename Error::IO to Error::Io (#5174)

## Summary

I believe this is by convention (see, e.g., in Rust itself:
https://github.com/search?q=repo%3Arust-lang%2Frust+%2F%28%3F-i%29Io%2F&type=code).
This commit is contained in:
Charlie Marsh 2024-07-18 00:13:45 -04:00 committed by GitHub
parent 61a81da760
commit 8484611753
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 23 additions and 23 deletions

View file

@ -169,7 +169,7 @@ impl RequirementsTxt {
{
return Err(RequirementsTxtFileError {
file: requirements_txt.to_path_buf(),
error: RequirementsTxtParserError::IO(io::Error::new(
error: RequirementsTxtParserError::Io(io::Error::new(
io::ErrorKind::InvalidInput,
"Remote file not supported without `http` feature",
)),
@ -182,7 +182,7 @@ impl RequirementsTxt {
if client_builder.is_offline() {
return Err(RequirementsTxtFileError {
file: requirements_txt.to_path_buf(),
error: RequirementsTxtParserError::IO(io::Error::new(
error: RequirementsTxtParserError::Io(io::Error::new(
io::ErrorKind::InvalidInput,
format!("Network connectivity is disabled, but a remote requirements file was requested: {}", requirements_txt.display()),
)),
@ -196,7 +196,7 @@ impl RequirementsTxt {
// Ex) `file:///home/ferris/project/requirements.txt`
uv_fs::read_to_string_transcode(&requirements_txt)
.await
.map_err(RequirementsTxtParserError::IO)
.map_err(RequirementsTxtParserError::Io)
}
.map_err(|err| RequirementsTxtFileError {
file: requirements_txt.to_path_buf(),
@ -800,7 +800,7 @@ pub struct RequirementsTxtFileError {
/// Error parsing requirements.txt, error disambiguation
#[derive(Debug)]
pub enum RequirementsTxtParserError {
IO(io::Error),
Io(io::Error),
Url {
source: url::ParseError,
url: String,
@ -877,7 +877,7 @@ pub enum RequirementsTxtParserError {
impl Display for RequirementsTxtParserError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::IO(err) => err.fmt(f),
Self::Io(err) => err.fmt(f),
Self::Url { url, start, .. } => {
write!(f, "Invalid URL at position {start}: `{url}`")
}
@ -945,7 +945,7 @@ impl Display for RequirementsTxtParserError {
impl std::error::Error for RequirementsTxtParserError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match &self {
Self::IO(err) => err.source(),
Self::Io(err) => err.source(),
Self::Url { source, .. } => Some(source),
Self::FileUrl { .. } => None,
Self::VerbatimUrl { source, .. } => Some(source),
@ -971,7 +971,7 @@ impl std::error::Error for RequirementsTxtParserError {
impl Display for RequirementsTxtFileError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match &self.error {
RequirementsTxtParserError::IO(err) => err.fmt(f),
RequirementsTxtParserError::Io(err) => err.fmt(f),
RequirementsTxtParserError::Url { url, start, .. } => {
write!(
f,
@ -1108,7 +1108,7 @@ impl std::error::Error for RequirementsTxtFileError {
impl From<io::Error> for RequirementsTxtParserError {
fn from(err: io::Error) -> Self {
Self::IO(err)
Self::Io(err)
}
}

View file

@ -87,7 +87,7 @@ static SETUP_PY_REQUIREMENTS: Lazy<[Requirement; 2]> = Lazy::new(|| {
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
IO(#[from] io::Error),
Io(#[from] io::Error),
#[error("Invalid source distribution: {0}")]
InvalidSourceDist(String),
#[error("Invalid `pyproject.toml`")]

View file

@ -149,7 +149,7 @@ pub enum PythonSource {
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
IO(#[from] io::Error),
Io(#[from] io::Error),
/// An error was encountering when retrieving interpreter information.
#[error(transparent)]

View file

@ -28,7 +28,7 @@ use crate::{Interpreter, PythonRequest, PythonVersion, VersionRequest};
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
IO(#[from] io::Error),
Io(#[from] io::Error),
#[error(transparent)]
ImplementationError(#[from] ImplementationError),
#[error("Invalid Python version: {0}")]

View file

@ -24,7 +24,7 @@ use uv_fs::{LockedFile, Simplified};
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
IO(#[from] io::Error),
Io(#[from] io::Error),
#[error(transparent)]
Download(#[from] DownloadError),
#[error(transparent)]

View file

@ -32,12 +32,12 @@ pub struct PyVenvConfiguration {
#[derive(Debug, Error)]
pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),
#[error("Broken virtualenv `{0}`: `pyvenv.cfg` is missing")]
MissingPyVenvCfg(PathBuf),
#[error("Broken virtualenv `{0}`: `pyvenv.cfg` could not be parsed")]
ParsePyVenvCfg(PathBuf, #[source] io::Error),
#[error(transparent)]
IO(#[from] io::Error),
}
/// Locate an active virtual environment by inspecting environment variables.

View file

@ -30,7 +30,7 @@ mod tool;
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
IO(#[from] io::Error),
Io(#[from] io::Error),
#[error("Failed to update `uv-receipt.toml` at {0}")]
ReceiptWrite(PathBuf, #[source] Box<toml::ser::Error>),
#[error("Failed to read `uv-receipt.toml` at {0}")]
@ -121,7 +121,7 @@ impl InstalledTools {
let path = self.tool_dir(name).join("uv-receipt.toml");
match ToolReceipt::from_path(&path) {
Ok(tool_receipt) => Ok(Some(tool_receipt.tool)),
Err(Error::IO(err)) if err.kind() == io::ErrorKind::NotFound => Ok(None),
Err(Error::Io(err)) if err.kind() == io::ErrorKind::NotFound => Ok(None),
Err(err) => Err(err),
}
}

View file

@ -11,7 +11,7 @@ mod virtualenv;
#[derive(Debug, Error)]
pub enum Error {
#[error(transparent)]
IO(#[from] io::Error),
Io(#[from] io::Error),
#[error("Failed to determine Python interpreter to use")]
Discovery(#[from] uv_python::DiscoveryError),
#[error("Failed to determine Python interpreter to use")]

View file

@ -86,7 +86,7 @@ pub(crate) fn create(
match location.metadata() {
Ok(metadata) => {
if metadata.is_file() {
return Err(Error::IO(io::Error::new(
return Err(Error::Io(io::Error::new(
io::ErrorKind::AlreadyExists,
format!("File exists at `{}`", location.user_display()),
)));
@ -103,7 +103,7 @@ pub(crate) fn create(
{
info!("Ignoring empty directory");
} else {
return Err(Error::IO(io::Error::new(
return Err(Error::Io(io::Error::new(
io::ErrorKind::AlreadyExists,
format!(
"The directory `{}` exists, but it's not a virtualenv",
@ -116,7 +116,7 @@ pub(crate) fn create(
Err(err) if err.kind() == io::ErrorKind::NotFound => {
fs::create_dir_all(location)?;
}
Err(err) => return Err(Error::IO(err)),
Err(err) => return Err(Error::Io(err)),
}
let location = location.canonicalize()?;

View file

@ -26,7 +26,7 @@ pub(crate) async fn list(
let installed_tools = InstalledTools::from_settings()?;
let _lock = match installed_tools.acquire_lock() {
Ok(lock) => lock,
Err(uv_tool::Error::IO(err)) if err.kind() == std::io::ErrorKind::NotFound => {
Err(uv_tool::Error::Io(err)) if err.kind() == std::io::ErrorKind::NotFound => {
writeln!(printer.stderr(), "No tools installed")?;
return Ok(ExitStatus::Success);
}

View file

@ -27,7 +27,7 @@ pub(crate) async fn uninstall(
let installed_tools = InstalledTools::from_settings()?.init()?;
let _lock = match installed_tools.acquire_lock() {
Ok(lock) => lock,
Err(uv_tool::Error::IO(err)) if err.kind() == std::io::ErrorKind::NotFound => {
Err(uv_tool::Error::Io(err)) if err.kind() == std::io::ErrorKind::NotFound => {
if let Some(name) = name {
bail!("`{name}` is not installed");
}
@ -48,7 +48,7 @@ pub(crate) async fn uninstall(
)?;
return Ok(ExitStatus::Success);
}
Err(uv_tool::Error::IO(err)) if err.kind() == std::io::ErrorKind::NotFound => {
Err(uv_tool::Error::Io(err)) if err.kind() == std::io::ErrorKind::NotFound => {
bail!("`{name}` is not installed");
}
Err(err) => {