summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Bidoul <stephane.bidoul@gmail.com>2021-08-28 17:29:58 +0200
committerStéphane Bidoul <stephane.bidoul@gmail.com>2021-09-21 22:32:52 +0200
commitddcf558a54e6c2ac4dea49af549529a1d5715e2d (patch)
tree7d323c35811bb9bddeb0c9b02fafe55faa6c13ab
parenta3b1d5657892885fc18b989584c57106748126b4 (diff)
downloadpip-ddcf558a54e6c2ac4dea49af549529a1d5715e2d.tar.gz
_dist_is_editable always returns a location
-rw-r--r--src/pip/_internal/operations/freeze.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/pip/_internal/operations/freeze.py b/src/pip/_internal/operations/freeze.py
index 25395c525..74f5f29bb 100644
--- a/src/pip/_internal/operations/freeze.py
+++ b/src/pip/_internal/operations/freeze.py
@@ -30,7 +30,7 @@ logger = logging.getLogger(__name__)
class _EditableInfo(NamedTuple):
- requirement: Optional[str]
+ requirement: str
editable: bool
comments: List[str]
@@ -167,8 +167,6 @@ def _get_editable_info(dist: BaseDistribution) -> _EditableInfo:
Compute and return values (req, editable, comments) for use in
FrozenRequirement.from_dist().
"""
- if not dist.editable:
- return _EditableInfo(requirement=None, editable=False, comments=[])
editable_project_location = dist.editable_project_location
assert editable_project_location
location = os.path.normcase(os.path.abspath(editable_project_location))
@@ -253,16 +251,17 @@ class FrozenRequirement:
# TODO `get_requirement_info` is taking care of editable requirements.
# TODO This should be refactored when we will add detection of
# editable that provide .dist-info metadata.
- req, editable, comments = _get_editable_info(dist)
- if req is None and not editable:
- # if PEP 610 metadata is present, attempt to use it
+ if dist.editable:
+ req, editable, comments = _get_editable_info(dist)
+ else:
+ comments = []
direct_url = dist.direct_url
if direct_url:
+ # if PEP 610 metadata is present, use it
req = direct_url_as_pep440_direct_reference(direct_url, dist.raw_name)
- comments = []
- if req is None:
- # name==version requirement
- req = _format_as_name_version(dist)
+ else:
+ # name==version requirement
+ req = _format_as_name_version(dist)
return cls(dist.raw_name, req, editable, comments=comments)