summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Simionato <michele.simionato@gmail.com>2018-01-14 09:24:44 +0100
committerMichele Simionato <michele.simionato@gmail.com>2018-01-14 09:24:44 +0100
commit743cdd2c6b1cee23a04ed8595d4319e350023a85 (patch)
tree49ae75fa1bbf6746a255936c640fba8cce6b278b
parente2827ec9f780bd1f98d20e54c364d6d45d5f2249 (diff)
downloadpython-decorator-git-743cdd2c6b1cee23a04ed8595d4319e350023a85.tar.gz
Small simplification
-rw-r--r--src/decorator.py37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/decorator.py b/src/decorator.py
index 3aa7313..9f4eb2b 100644
--- a/src/decorator.py
+++ b/src/decorator.py
@@ -1,6 +1,6 @@
# ######################### LICENSE ############################ #
-# Copyright (c) 2005-2017, Michele Simionato
+# Copyright (c) 2005-2018, Michele Simionato
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
@@ -112,26 +112,21 @@ class FunctionMaker(object):
setattr(self, a, getattr(argspec, a))
for i, arg in enumerate(self.args):
setattr(self, 'arg%d' % i, arg)
- if sys.version < '3': # easy way
- self.shortsignature = self.signature = (
- inspect.formatargspec(
- formatvalue=lambda val: "", *argspec[:-2])[1:-1])
- else: # Python 3 way
- allargs = list(self.args)
- allshortargs = list(self.args)
- if self.varargs:
- allargs.append('*' + self.varargs)
- allshortargs.append('*' + self.varargs)
- elif self.kwonlyargs:
- allargs.append('*') # single star syntax
- for a in self.kwonlyargs:
- allargs.append('%s=None' % a)
- allshortargs.append('%s=%s' % (a, a))
- if self.varkw:
- allargs.append('**' + self.varkw)
- allshortargs.append('**' + self.varkw)
- self.signature = ', '.join(allargs)
- self.shortsignature = ', '.join(allshortargs)
+ allargs = list(self.args)
+ allshortargs = list(self.args)
+ if self.varargs:
+ allargs.append('*' + self.varargs)
+ allshortargs.append('*' + self.varargs)
+ elif self.kwonlyargs:
+ allargs.append('*') # single star syntax
+ for a in self.kwonlyargs:
+ allargs.append('%s=None' % a)
+ allshortargs.append('%s=%s' % (a, a))
+ if self.varkw:
+ allargs.append('**' + self.varkw)
+ allshortargs.append('**' + self.varkw)
+ self.signature = ', '.join(allargs)
+ self.shortsignature = ', '.join(allshortargs)
self.dict = func.__dict__.copy()
# func=None happens when decorating a caller
if name: