We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Optional
default
1 parent 09c00ed commit 9213184Copy full SHA for 9213184
schema.py
@@ -2,7 +2,6 @@
2
obtained from config-files, forms, external services or command-line
3
parsing, converted from JSON/YAML (or something else) to Python data-types."""
4
5
-import inspect
6
import re
7
8
try:
@@ -274,10 +273,17 @@ def _priority(s):
274
273
275
276
def _invoke_with_optional_kwargs(f, **kwargs):
277
- s = inspect.signature(f)
278
- if len(s.parameters) == 0:
279
- return f()
280
- return f(**kwargs)
+ try:
+ return f(**kwargs)
+ except TypeError as e:
+ if (
+ e.args[0].startswith("{}() got an unexpected keyword argument".format(f.__name__)) # Python 2/3.
281
+ or e.args[0].startswith("{}() takes no arguments".format(f.__name__)) # Python 2 only.
282
+ ):
283
+ return f()
284
+ else:
285
+ raise
286
+
287
288
289
class Schema(object):
0 commit comments