Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
re-use partial.__repr__ implementation
  • Loading branch information
picnixz committed Jun 26, 2024
commit fca145842c70b7d29165a0f0d28df1da3b35513a
15 changes: 7 additions & 8 deletions Lib/functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,13 @@ def __init__(self, func, /, *args, **keywords):
self.keywords = keywords

def __repr__(self):
module = self.__class__.__module__
typename = self.__class__.__qualname__
args = ", ".join(map(repr, self.args))
keywords = ", ".join(f"{k}={v!r}" for k, v in self.keywords.items())
arguments = ", ".join(filter(None, (args, keywords)))
if arguments:
return f"{module}.{typename}({self.func}, {arguments})"
return f"{module}.{typename}({self.func})"
cls = type(self)
module = cls.__module__
qualname = cls.__qualname__
args = [repr(self.func)]
args.extend(map(repr, self.args))
args.extend(f"{k}={v!r}" for k, v in self.keywords.items())
return f"{module}.{qualname}({', '.join(args)})"

def _make_unbound_method(self):
def _method(cls_or_self, /, *args, **keywords):
Expand Down