mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-27 02:17:08 +00:00
Improve logging of interpreter implementation (#3791)
``` Found Python interpreter CPython 3.12.3 at... ``` instead of ``` Found Python interpreter cpython 3.12.3 at ```
This commit is contained in:
parent
81eff0ecc8
commit
306a4d7ce3
2 changed files with 26 additions and 2 deletions
|
|
@ -17,6 +17,12 @@ pub enum ImplementationName {
|
|||
PyPy,
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
pub(crate) enum LenientImplementationName {
|
||||
Known(ImplementationName),
|
||||
Unknown(String),
|
||||
}
|
||||
|
||||
impl ImplementationName {
|
||||
pub(crate) fn iter() -> impl Iterator<Item = &'static ImplementationName> {
|
||||
static NAMES: &[ImplementationName] =
|
||||
|
|
@ -52,3 +58,21 @@ impl Display for ImplementationName {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for LenientImplementationName {
|
||||
fn from(s: &str) -> Self {
|
||||
match ImplementationName::from_str(s) {
|
||||
Ok(implementation) => Self::Known(implementation),
|
||||
Err(_) => Self::Unknown(s.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for LenientImplementationName {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Known(implementation) => implementation.fmt(f),
|
||||
Self::Unknown(name) => f.write_str(name),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue