summaryrefslogtreecommitdiff
path: root/src/pip
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2018-10-08 22:21:45 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2018-10-08 22:57:32 -0700
commitfaff436100d8ffa83c94a30ed1271ce49b7ba1ae (patch)
treebc305b1c53f2276720f3acad28155f61909e4a3d /src/pip
parent500598287d4be3a2e181148ed3139cf415e08a4f (diff)
downloadpip-faff436100d8ffa83c94a30ed1271ce49b7ba1ae.tar.gz
Add guard clause.
Diffstat (limited to 'src/pip')
-rw-r--r--src/pip/_internal/operations/freeze.py33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/pip/_internal/operations/freeze.py b/src/pip/_internal/operations/freeze.py
index 31d6b46c0..b173875bf 100644
--- a/src/pip/_internal/operations/freeze.py
+++ b/src/pip/_internal/operations/freeze.py
@@ -173,29 +173,28 @@ class FrozenRequirement(object):
"""
location = os.path.normcase(os.path.abspath(dist.location))
from pip._internal.vcs import vcs, get_src_requirement
- if dist_is_editable(dist) and vcs.get_backend_name(location):
- try:
- req = get_src_requirement(dist, location)
- except InstallationError as exc:
- logger.warning(
- "Error when trying to get requirement for VCS system %s, "
- "falling back to uneditable format", exc
- )
- else:
- if req is not None:
- return (req, True, [])
+ if not dist_is_editable(dist) or not vcs.get_backend_name(location):
+ req = dist.as_requirement()
+ return (req, False, [])
+ try:
+ req = get_src_requirement(dist, location)
+ except InstallationError as exc:
logger.warning(
- 'Could not determine repository location of %s', location
+ "Error when trying to get requirement for VCS system %s, "
+ "falling back to uneditable format", exc
)
- comments = ['## !! Could not determine repository location']
- req = dist.as_requirement()
-
- return (req, False, comments)
+ else:
+ if req is not None:
+ return (req, True, [])
+ logger.warning(
+ 'Could not determine repository location of %s', location
+ )
+ comments = ['## !! Could not determine repository location']
req = dist.as_requirement()
- return (req, False, [])
+ return (req, False, comments)
@classmethod
def from_dist(cls, dist, dependency_links):