Skip to content

Commit

Permalink
Refactor direct url editable test
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Aug 30, 2021
1 parent 4c82baf commit 7bf6b89
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/pip/_internal/metadata/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
DIRECT_URL_METADATA_NAME,
DirectUrl,
DirectUrlValidationError,
DirInfo,
)
from pip._internal.utils.compat import stdlib_pkgs # TODO: Move definition here.
from pip._internal.utils.egg_link import egg_link_path_from_sys_path
Expand Down Expand Up @@ -86,7 +85,7 @@ def editable_project_location(self) -> Optional[str]:
# TODO: this property is relatively costly to compute, memoize it ?
direct_url = self.direct_url
if direct_url:
if isinstance(direct_url.info, DirInfo) and direct_url.info.editable:
if direct_url.is_local_editable():
return url_to_path(direct_url.url)
else:
# Search for an .egg-link file by walking sys.path, as it was
Expand Down
3 changes: 3 additions & 0 deletions src/pip/_internal/models/direct_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,6 @@ def from_json(cls, s: str) -> "DirectUrl":

def to_json(self) -> str:
return json.dumps(self.to_dict(), sort_keys=True)

def is_local_editable(self) -> bool:
return isinstance(self.info, DirInfo) and self.info.editable

0 comments on commit 7bf6b89

Please sign in to comment.