gh-72249: Include the module name in the repr of partial object (GH-101910)

Co-authored-by: Anilyka Barry <vgr255@live.ca>
This commit is contained in:
Furkan Onder 2024-02-25 23:55:19 +03:00 committed by GitHub
parent f082a05c67
commit 8f5be78bce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 18 deletions

View file

@ -303,13 +303,13 @@ class partial:
@recursive_repr()
def __repr__(self):
qualname = type(self).__qualname__
cls = type(self)
qualname = cls.__qualname__
module = cls.__module__
args = [repr(self.func)]
args.extend(repr(x) for x in self.args)
args.extend(f"{k}={v!r}" for (k, v) in self.keywords.items())
if type(self).__module__ == "functools":
return f"functools.{qualname}({', '.join(args)})"
return f"{qualname}({', '.join(args)})"
return f"{module}.{qualname}({', '.join(args)})"
def __reduce__(self):
return type(self), (self.func,), (self.func, self.args,