From ca0517621d61ebcb557f3daf7fab85fb9c7bdfc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Mon, 30 Aug 2021 08:46:53 +0200 Subject: [PATCH] Refactor direct url editable test --- src/pip/_internal/metadata/base.py | 3 +-- src/pip/_internal/models/direct_url.py | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pip/_internal/metadata/base.py b/src/pip/_internal/metadata/base.py index ba173fffa79..7eacd00e287 100644 --- a/src/pip/_internal/metadata/base.py +++ b/src/pip/_internal/metadata/base.py @@ -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 @@ -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 diff --git a/src/pip/_internal/models/direct_url.py b/src/pip/_internal/models/direct_url.py index d652ce15356..92060d45db8 100644 --- a/src/pip/_internal/models/direct_url.py +++ b/src/pip/_internal/models/direct_url.py @@ -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