From b3ac98eff450b35b8831600437ed92664a4f6d0e Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 30 Sep 2018 03:10:40 -0700 Subject: [PATCH] Only define comments when needed. --- src/pip/_internal/operations/freeze.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/pip/_internal/operations/freeze.py b/src/pip/_internal/operations/freeze.py index 371b507540d..79ec88bf110 100644 --- a/src/pip/_internal/operations/freeze.py +++ b/src/pip/_internal/operations/freeze.py @@ -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: @@ -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) @@ -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( @@ -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: