Skip to content

Commit 2d63f5c

Browse files
Avasamabravalheri
andauthored
Type str/repr dunders (#4582)
Co-authored-by: Anderson Bravalheri <[email protected]>
1 parent d12330d commit 2d63f5c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

pkg_resources/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def get_supported_platform():
301301
class ResolutionError(Exception):
302302
"""Abstract base for dependency resolution errors"""
303303

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

307307

@@ -377,7 +377,7 @@ def requirers_str(self):
377377
def report(self):
378378
return self._template.format(**locals())
379379

380-
def __str__(self):
380+
def __str__(self) -> str:
381381
return self.report()
382382

383383

@@ -2725,15 +2725,15 @@ def __init__(
27252725
self.extras = tuple(extras)
27262726
self.dist = dist
27272727

2728-
def __str__(self):
2728+
def __str__(self) -> str:
27292729
s = "%s = %s" % (self.name, self.module_name)
27302730
if self.attrs:
27312731
s += ':' + '.'.join(self.attrs)
27322732
if self.extras:
27332733
s += ' [%s]' % ','.join(self.extras)
27342734
return s
27352735

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

27392739
@overload
@@ -3157,13 +3157,13 @@ def egg_name(self):
31573157
filename += '-' + self.platform
31583158
return filename
31593159

3160-
def __repr__(self):
3160+
def __repr__(self) -> str:
31613161
if self.location:
31623162
return "%s (%s)" % (self, self.location)
31633163
else:
31643164
return str(self)
31653165

3166-
def __str__(self):
3166+
def __str__(self) -> str:
31673167
try:
31683168
version = getattr(self, 'version', None)
31693169
except ValueError:
@@ -3508,7 +3508,7 @@ def __contains__(
35083508
def __hash__(self):
35093509
return self.__hash
35103510

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

35143514
@staticmethod

setuptools/sandbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,6 @@ class SandboxViolation(DistutilsError):
509509
"""
510510
).lstrip()
511511

512-
def __str__(self):
512+
def __str__(self) -> str:
513513
cmd, args, kwargs = self.args
514514
return self.tmpl.format(**locals())

setuptools/tests/test_sandbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_unpickleable_exception(self):
7575
class CantPickleThis(Exception):
7676
"This Exception is unpickleable because it's not in globals"
7777

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

8181
with setuptools.sandbox.ExceptionSaver() as saved_exc:

setuptools/tests/test_wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def __init__(self, id, **kwargs):
175175
self._id = id
176176
self._fields = kwargs
177177

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

181181

0 commit comments

Comments
 (0)