Skip to content

Commit

Permalink
Type str/repr dunders
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Aug 20, 2024
1 parent ebddeb3 commit 256d542
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def get_supported_platform():
class ResolutionError(Exception):
"""Abstract base for dependency resolution errors"""

def __repr__(self):
def __repr__(self) -> str:
return self.__class__.__name__ + repr(self.args)


Expand Down Expand Up @@ -384,7 +384,7 @@ def requirers_str(self):
def report(self):
return self._template.format(**locals())

def __str__(self):
def __str__(self) -> str:
return self.report()


Expand Down Expand Up @@ -2717,15 +2717,15 @@ def __init__(
self.extras = tuple(extras)
self.dist = dist

def __str__(self):
def __str__(self) -> str:
s = "%s = %s" % (self.name, self.module_name)
if self.attrs:
s += ':' + '.'.join(self.attrs)
if self.extras:
s += ' [%s]' % ','.join(self.extras)
return s

def __repr__(self):
def __repr__(self) -> str:
return "EntryPoint.parse(%r)" % str(self)

@overload
Expand Down Expand Up @@ -3149,13 +3149,13 @@ def egg_name(self):
filename += '-' + self.platform
return filename

def __repr__(self):
def __repr__(self) -> str:
if self.location:
return "%s (%s)" % (self, self.location)
else:
return str(self)

def __str__(self):
def __str__(self) -> str:
try:
version = getattr(self, 'version', None)
except ValueError:
Expand Down Expand Up @@ -3500,7 +3500,7 @@ def __contains__(
def __hash__(self):
return self.__hash

def __repr__(self):
def __repr__(self) -> str:
return "Requirement.parse(%r)" % str(self)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion setuptools/package_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ def __iter__(self):
yield self.username
yield self.password

def __str__(self):
def __str__(self) -> str:
return '%(username)s:%(password)s' % vars(self)


Expand Down
2 changes: 1 addition & 1 deletion setuptools/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,6 @@ class SandboxViolation(DistutilsError):
"""
).lstrip()

def __str__(self):
def __str__(self) -> str:
cmd, args, kwargs = self.args
return self.tmpl.format(**locals())
2 changes: 1 addition & 1 deletion setuptools/tests/test_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_unpickleable_exception(self):
class CantPickleThis(Exception):
"This Exception is unpickleable because it's not in globals"

def __repr__(self):
def __repr__(self) -> str:
return 'CantPickleThis%r' % (self.args,)

with setuptools.sandbox.ExceptionSaver() as saved_exc:
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def __init__(self, id, **kwargs):
self._id = id
self._fields = kwargs

def __repr__(self):
def __repr__(self) -> str:
return '%s(**%r)' % (self._id, self._fields)


Expand Down

0 comments on commit 256d542

Please sign in to comment.