Merge pull request #6663 from pradyunsg/better-InstallRequirement-repr

Add InstallRequirement.format_debug() as a debugging helper
This commit is contained in:
Pradyun Gedam 2019-07-20 12:10:08 +05:30 committed by GitHub
commit e0e343e035
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -180,6 +180,21 @@ class InstallRequirement(object):
return '<%s object: %s editable=%r>' % (
self.__class__.__name__, str(self), self.editable)
def format_debug(self):
# type: () -> str
"""An un-tested helper for getting state, for debugging.
"""
attributes = vars(self)
names = sorted(attributes)
state = (
"{}={!r}".format(attr, attributes[attr]) for attr in sorted(names)
)
return '<{name} object: {{{state}}}>'.format(
name=self.__class__.__name__,
state=", ".join(state),
)
def populate_link(self, finder, upgrade, require_hashes):
# type: (PackageFinder, bool, bool) -> None
"""Ensure that if a link can be found for this, that it is found.