Skip to content

Commit

Permalink
Convert FrozenRequirement
Browse files Browse the repository at this point in the history
  • Loading branch information
ichard26 committed May 5, 2024
1 parent 40a9a20 commit d05323c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/pip/_internal/operations/freeze.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import collections
import logging
import os
from dataclasses import dataclass, field
from typing import Container, Dict, Generator, Iterable, List, NamedTuple, Optional, Set

from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
from pip._vendor.packaging.version import InvalidVersion

from pip._internal.exceptions import BadCommand, InstallationError
Expand Down Expand Up @@ -220,19 +221,16 @@ def _get_editable_info(dist: BaseDistribution) -> _EditableInfo:
)


@dataclass(frozen=True)
class FrozenRequirement:
def __init__(
self,
name: str,
req: str,
editable: bool,
comments: Iterable[str] = (),
) -> None:
self.name = name
self.canonical_name = canonicalize_name(name)
self.req = req
self.editable = editable
self.comments = comments
name: str
req: str
editable: bool
comments: Iterable[str] = field(default_factory=tuple)

@property
def canonical_name(self) -> NormalizedName:
return canonicalize_name(self.name)

@classmethod
def from_dist(cls, dist: BaseDistribution) -> "FrozenRequirement":
Expand Down

0 comments on commit d05323c

Please sign in to comment.