mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-26 12:09:12 +00:00
pep440: some minor refactoring, mostly around error types (#780)
This PR does a bit of refactoring to the pep440 crate, and in particular around the erorr types. This PR is meant to be a precursor to another PR that does some surgery (both in parsing and in `Version` representation) that benefits somewhat from this refactoring. As usual, please review commit-by-commit.
This commit is contained in:
parent
1cc3250e76
commit
d7c9b151fb
8 changed files with 710 additions and 262 deletions
|
@ -4,7 +4,7 @@ use once_cell::sync::Lazy;
|
|||
use regex::Regex;
|
||||
use serde::{de, Deserialize, Deserializer, Serialize};
|
||||
|
||||
use pep440_rs::{Pep440Error, VersionSpecifiers};
|
||||
use pep440_rs::{VersionSpecifiers, VersionSpecifiersParseError};
|
||||
use pep508_rs::{Pep508Error, Requirement};
|
||||
use puffin_warnings::warn_user_once;
|
||||
|
||||
|
@ -99,7 +99,7 @@ impl From<LenientRequirement> for Requirement {
|
|||
pub struct LenientVersionSpecifiers(VersionSpecifiers);
|
||||
|
||||
impl FromStr for LenientVersionSpecifiers {
|
||||
type Err = Pep440Error;
|
||||
type Err = VersionSpecifiersParseError;
|
||||
|
||||
fn from_str(input: &str) -> Result<Self, Self::Err> {
|
||||
Ok(Self(parse_with_fixups(input, "version specifier")?))
|
||||
|
|
|
@ -7,7 +7,7 @@ use mailparse::{MailHeaderMap, MailParseError};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
|
||||
use pep440_rs::{Pep440Error, Version, VersionSpecifiers};
|
||||
use pep440_rs::{Version, VersionSpecifiers, VersionSpecifiersParseError};
|
||||
use pep508_rs::{Pep508Error, Requirement};
|
||||
use puffin_normalize::{ExtraName, InvalidNameError, PackageName};
|
||||
|
||||
|
@ -63,7 +63,7 @@ pub enum Error {
|
|||
Pep440VersionError(String),
|
||||
/// Invalid VersionSpecifier
|
||||
#[error(transparent)]
|
||||
Pep440Error(#[from] Pep440Error),
|
||||
Pep440Error(#[from] VersionSpecifiersParseError),
|
||||
/// Invalid Requirement
|
||||
#[error(transparent)]
|
||||
Pep508Error(#[from] Pep508Error),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue