From 51f4a1407ef12405e16f643f5f9d2002b4b52ab9 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sun, 2 Oct 2016 11:17:36 -0400 Subject: RF: use @functools.wraps within decorators instead of manual __name__ reassignment @wraps does more and does it right ;) --- git/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'git/util.py') diff --git a/git/util.py b/git/util.py index 814cd7f4..9640a74f 100644 --- a/git/util.py +++ b/git/util.py @@ -14,6 +14,8 @@ import shutil import stat import time +from functools import wraps + from git.compat import is_win from gitdb.util import ( # NOQA make_sha, @@ -50,13 +52,13 @@ def unbare_repo(func): """Methods with this decorator raise InvalidGitRepositoryError if they encounter a bare repository""" + @wraps(func) def wrapper(self, *args, **kwargs): if self.repo.bare: raise InvalidGitRepositoryError("Method '%s' cannot operate on bare repositories" % func.__name__) # END bare method return func(self, *args, **kwargs) # END wrapper - wrapper.__name__ = func.__name__ return wrapper -- cgit v1.2.1