mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
[3.12] gh-121025: Improve partialmethod.__repr__ (GH-121033) (GH-121038)
It no longer contains redundant commas and spaces.
(cherry picked from commit d2646e3f45
)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
5290e405c1
commit
41e1ac6a23
4 changed files with 18 additions and 10 deletions
|
@ -372,15 +372,13 @@ class partialmethod(object):
|
|||
self.keywords = keywords
|
||||
|
||||
def __repr__(self):
|
||||
args = ", ".join(map(repr, self.args))
|
||||
keywords = ", ".join("{}={!r}".format(k, v)
|
||||
for k, v in self.keywords.items())
|
||||
format_string = "{module}.{cls}({func}, {args}, {keywords})"
|
||||
return format_string.format(module=self.__class__.__module__,
|
||||
cls=self.__class__.__qualname__,
|
||||
func=self.func,
|
||||
args=args,
|
||||
keywords=keywords)
|
||||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue