Skip to content

Commit

Permalink
Only define comments when needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjerdonek committed Oct 8, 2018
1 parent e80a90e commit b3ac98e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/pip/_internal/operations/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ def _init_args_from_dist(cls, dist, dependency_links):
This method is for use in FrozenRequirement.from_dist().
"""
location = os.path.normcase(os.path.abspath(dist.location))
comments = []
from pip._internal.vcs import vcs, get_src_requirement
if dist_is_editable(dist) and vcs.get_backend_name(location):
try:
Expand All @@ -188,12 +187,12 @@ def _init_args_from_dist(cls, dist, dependency_links):
)
else:
if req is not None:
return (req, True, comments)
return (req, True, [])

logger.warning(
'Could not determine repository location of %s', location
)
comments.append('## !! Could not determine repository location')
comments = ['## !! Could not determine repository location']
req = dist.as_requirement()

return (req, False, comments)
Expand All @@ -207,17 +206,17 @@ def _init_args_from_dist(cls, dist, dependency_links):
ver_match = cls._rev_re.search(version)
date_match = cls._date_re.search(version)
if not (ver_match or date_match):
return (req, False, comments)
return (req, False, [])

svn_backend = vcs.get_backend('svn')
if svn_backend:
svn_location = svn_backend().get_location(dist, dependency_links)
if not svn_location:
logger.warning('Warning: cannot find svn location for %s', req)
comments.append(
comments = [
'## FIXME: could not find svn URL in dependency_links '
'for this package:'
)
]
return (req, False, comments)

deprecated(
Expand All @@ -227,9 +226,9 @@ def _init_args_from_dist(cls, dist, dependency_links):
gone_in="19.0",
issue=4187,
)
comments.append(
comments = [
'# Installing as editable to satisfy requirement %s:' % req
)
]
if ver_match:
rev = ver_match.group(1)
else:
Expand Down

0 comments on commit b3ac98e

Please sign in to comment.