mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-26 20:19:08 +00:00
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:
parent
61a81da760
commit
8484611753
11 changed files with 23 additions and 23 deletions
|
@ -169,7 +169,7 @@ impl RequirementsTxt {
|
||||||
{
|
{
|
||||||
return Err(RequirementsTxtFileError {
|
return Err(RequirementsTxtFileError {
|
||||||
file: requirements_txt.to_path_buf(),
|
file: requirements_txt.to_path_buf(),
|
||||||
error: RequirementsTxtParserError::IO(io::Error::new(
|
error: RequirementsTxtParserError::Io(io::Error::new(
|
||||||
io::ErrorKind::InvalidInput,
|
io::ErrorKind::InvalidInput,
|
||||||
"Remote file not supported without `http` feature",
|
"Remote file not supported without `http` feature",
|
||||||
)),
|
)),
|
||||||
|
@ -182,7 +182,7 @@ impl RequirementsTxt {
|
||||||
if client_builder.is_offline() {
|
if client_builder.is_offline() {
|
||||||
return Err(RequirementsTxtFileError {
|
return Err(RequirementsTxtFileError {
|
||||||
file: requirements_txt.to_path_buf(),
|
file: requirements_txt.to_path_buf(),
|
||||||
error: RequirementsTxtParserError::IO(io::Error::new(
|
error: RequirementsTxtParserError::Io(io::Error::new(
|
||||||
io::ErrorKind::InvalidInput,
|
io::ErrorKind::InvalidInput,
|
||||||
format!("Network connectivity is disabled, but a remote requirements file was requested: {}", requirements_txt.display()),
|
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`
|
// Ex) `file:///home/ferris/project/requirements.txt`
|
||||||
uv_fs::read_to_string_transcode(&requirements_txt)
|
uv_fs::read_to_string_transcode(&requirements_txt)
|
||||||
.await
|
.await
|
||||||
.map_err(RequirementsTxtParserError::IO)
|
.map_err(RequirementsTxtParserError::Io)
|
||||||
}
|
}
|
||||||
.map_err(|err| RequirementsTxtFileError {
|
.map_err(|err| RequirementsTxtFileError {
|
||||||
file: requirements_txt.to_path_buf(),
|
file: requirements_txt.to_path_buf(),
|
||||||
|
@ -800,7 +800,7 @@ pub struct RequirementsTxtFileError {
|
||||||
/// Error parsing requirements.txt, error disambiguation
|
/// Error parsing requirements.txt, error disambiguation
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum RequirementsTxtParserError {
|
pub enum RequirementsTxtParserError {
|
||||||
IO(io::Error),
|
Io(io::Error),
|
||||||
Url {
|
Url {
|
||||||
source: url::ParseError,
|
source: url::ParseError,
|
||||||
url: String,
|
url: String,
|
||||||
|
@ -877,7 +877,7 @@ pub enum RequirementsTxtParserError {
|
||||||
impl Display for RequirementsTxtParserError {
|
impl Display for RequirementsTxtParserError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::IO(err) => err.fmt(f),
|
Self::Io(err) => err.fmt(f),
|
||||||
Self::Url { url, start, .. } => {
|
Self::Url { url, start, .. } => {
|
||||||
write!(f, "Invalid URL at position {start}: `{url}`")
|
write!(f, "Invalid URL at position {start}: `{url}`")
|
||||||
}
|
}
|
||||||
|
@ -945,7 +945,7 @@ impl Display for RequirementsTxtParserError {
|
||||||
impl std::error::Error for RequirementsTxtParserError {
|
impl std::error::Error for RequirementsTxtParserError {
|
||||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||||
match &self {
|
match &self {
|
||||||
Self::IO(err) => err.source(),
|
Self::Io(err) => err.source(),
|
||||||
Self::Url { source, .. } => Some(source),
|
Self::Url { source, .. } => Some(source),
|
||||||
Self::FileUrl { .. } => None,
|
Self::FileUrl { .. } => None,
|
||||||
Self::VerbatimUrl { source, .. } => Some(source),
|
Self::VerbatimUrl { source, .. } => Some(source),
|
||||||
|
@ -971,7 +971,7 @@ impl std::error::Error for RequirementsTxtParserError {
|
||||||
impl Display for RequirementsTxtFileError {
|
impl Display for RequirementsTxtFileError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match &self.error {
|
match &self.error {
|
||||||
RequirementsTxtParserError::IO(err) => err.fmt(f),
|
RequirementsTxtParserError::Io(err) => err.fmt(f),
|
||||||
RequirementsTxtParserError::Url { url, start, .. } => {
|
RequirementsTxtParserError::Url { url, start, .. } => {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
|
@ -1108,7 +1108,7 @@ impl std::error::Error for RequirementsTxtFileError {
|
||||||
|
|
||||||
impl From<io::Error> for RequirementsTxtParserError {
|
impl From<io::Error> for RequirementsTxtParserError {
|
||||||
fn from(err: io::Error) -> Self {
|
fn from(err: io::Error) -> Self {
|
||||||
Self::IO(err)
|
Self::Io(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ static SETUP_PY_REQUIREMENTS: Lazy<[Requirement; 2]> = Lazy::new(|| {
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
IO(#[from] io::Error),
|
Io(#[from] io::Error),
|
||||||
#[error("Invalid source distribution: {0}")]
|
#[error("Invalid source distribution: {0}")]
|
||||||
InvalidSourceDist(String),
|
InvalidSourceDist(String),
|
||||||
#[error("Invalid `pyproject.toml`")]
|
#[error("Invalid `pyproject.toml`")]
|
||||||
|
|
|
@ -149,7 +149,7 @@ pub enum PythonSource {
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
IO(#[from] io::Error),
|
Io(#[from] io::Error),
|
||||||
|
|
||||||
/// An error was encountering when retrieving interpreter information.
|
/// An error was encountering when retrieving interpreter information.
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
|
|
|
@ -28,7 +28,7 @@ use crate::{Interpreter, PythonRequest, PythonVersion, VersionRequest};
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
IO(#[from] io::Error),
|
Io(#[from] io::Error),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
ImplementationError(#[from] ImplementationError),
|
ImplementationError(#[from] ImplementationError),
|
||||||
#[error("Invalid Python version: {0}")]
|
#[error("Invalid Python version: {0}")]
|
||||||
|
|
|
@ -24,7 +24,7 @@ use uv_fs::{LockedFile, Simplified};
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
IO(#[from] io::Error),
|
Io(#[from] io::Error),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Download(#[from] DownloadError),
|
Download(#[from] DownloadError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
|
|
|
@ -32,12 +32,12 @@ pub struct PyVenvConfiguration {
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
#[error(transparent)]
|
||||||
|
Io(#[from] io::Error),
|
||||||
#[error("Broken virtualenv `{0}`: `pyvenv.cfg` is missing")]
|
#[error("Broken virtualenv `{0}`: `pyvenv.cfg` is missing")]
|
||||||
MissingPyVenvCfg(PathBuf),
|
MissingPyVenvCfg(PathBuf),
|
||||||
#[error("Broken virtualenv `{0}`: `pyvenv.cfg` could not be parsed")]
|
#[error("Broken virtualenv `{0}`: `pyvenv.cfg` could not be parsed")]
|
||||||
ParsePyVenvCfg(PathBuf, #[source] io::Error),
|
ParsePyVenvCfg(PathBuf, #[source] io::Error),
|
||||||
#[error(transparent)]
|
|
||||||
IO(#[from] io::Error),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Locate an active virtual environment by inspecting environment variables.
|
/// Locate an active virtual environment by inspecting environment variables.
|
||||||
|
|
|
@ -30,7 +30,7 @@ mod tool;
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
IO(#[from] io::Error),
|
Io(#[from] io::Error),
|
||||||
#[error("Failed to update `uv-receipt.toml` at {0}")]
|
#[error("Failed to update `uv-receipt.toml` at {0}")]
|
||||||
ReceiptWrite(PathBuf, #[source] Box<toml::ser::Error>),
|
ReceiptWrite(PathBuf, #[source] Box<toml::ser::Error>),
|
||||||
#[error("Failed to read `uv-receipt.toml` at {0}")]
|
#[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");
|
let path = self.tool_dir(name).join("uv-receipt.toml");
|
||||||
match ToolReceipt::from_path(&path) {
|
match ToolReceipt::from_path(&path) {
|
||||||
Ok(tool_receipt) => Ok(Some(tool_receipt.tool)),
|
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),
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ mod virtualenv;
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
IO(#[from] io::Error),
|
Io(#[from] io::Error),
|
||||||
#[error("Failed to determine Python interpreter to use")]
|
#[error("Failed to determine Python interpreter to use")]
|
||||||
Discovery(#[from] uv_python::DiscoveryError),
|
Discovery(#[from] uv_python::DiscoveryError),
|
||||||
#[error("Failed to determine Python interpreter to use")]
|
#[error("Failed to determine Python interpreter to use")]
|
||||||
|
|
|
@ -86,7 +86,7 @@ pub(crate) fn create(
|
||||||
match location.metadata() {
|
match location.metadata() {
|
||||||
Ok(metadata) => {
|
Ok(metadata) => {
|
||||||
if metadata.is_file() {
|
if metadata.is_file() {
|
||||||
return Err(Error::IO(io::Error::new(
|
return Err(Error::Io(io::Error::new(
|
||||||
io::ErrorKind::AlreadyExists,
|
io::ErrorKind::AlreadyExists,
|
||||||
format!("File exists at `{}`", location.user_display()),
|
format!("File exists at `{}`", location.user_display()),
|
||||||
)));
|
)));
|
||||||
|
@ -103,7 +103,7 @@ pub(crate) fn create(
|
||||||
{
|
{
|
||||||
info!("Ignoring empty directory");
|
info!("Ignoring empty directory");
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::IO(io::Error::new(
|
return Err(Error::Io(io::Error::new(
|
||||||
io::ErrorKind::AlreadyExists,
|
io::ErrorKind::AlreadyExists,
|
||||||
format!(
|
format!(
|
||||||
"The directory `{}` exists, but it's not a virtualenv",
|
"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 => {
|
Err(err) if err.kind() == io::ErrorKind::NotFound => {
|
||||||
fs::create_dir_all(location)?;
|
fs::create_dir_all(location)?;
|
||||||
}
|
}
|
||||||
Err(err) => return Err(Error::IO(err)),
|
Err(err) => return Err(Error::Io(err)),
|
||||||
}
|
}
|
||||||
|
|
||||||
let location = location.canonicalize()?;
|
let location = location.canonicalize()?;
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub(crate) async fn list(
|
||||||
let installed_tools = InstalledTools::from_settings()?;
|
let installed_tools = InstalledTools::from_settings()?;
|
||||||
let _lock = match installed_tools.acquire_lock() {
|
let _lock = match installed_tools.acquire_lock() {
|
||||||
Ok(lock) => 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")?;
|
writeln!(printer.stderr(), "No tools installed")?;
|
||||||
return Ok(ExitStatus::Success);
|
return Ok(ExitStatus::Success);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub(crate) async fn uninstall(
|
||||||
let installed_tools = InstalledTools::from_settings()?.init()?;
|
let installed_tools = InstalledTools::from_settings()?.init()?;
|
||||||
let _lock = match installed_tools.acquire_lock() {
|
let _lock = match installed_tools.acquire_lock() {
|
||||||
Ok(lock) => 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 {
|
if let Some(name) = name {
|
||||||
bail!("`{name}` is not installed");
|
bail!("`{name}` is not installed");
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ pub(crate) async fn uninstall(
|
||||||
)?;
|
)?;
|
||||||
return Ok(ExitStatus::Success);
|
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");
|
bail!("`{name}` is not installed");
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue