File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919from __future__ import print_function
2020
2121import inspect
22+ import types
2223from fire import docstrings
2324
2425import six
@@ -70,16 +71,19 @@ class with an __init__ method.
7071 """
7172 skip_arg = False
7273 if inspect .isclass (fn ):
73- # If the function is a class, we try to use it's init method.
74+ # If the function is a class, we try to use its init method.
7475 skip_arg = True
7576 if six .PY2 and hasattr (fn , '__init__' ):
7677 fn = fn .__init__
7778 elif inspect .ismethod (fn ):
7879 # If the function is a bound method, we skip the `self` argument.
7980 skip_arg = fn .__self__ is not None
8081 elif inspect .isbuiltin (fn ):
81- # If the function is a bound builtin, we skip the `self` argument.
82- skip_arg = fn .__self__ is not None
82+ # If the function is a bound builtin, we skip the `self` argument, unless
83+ # the function is from a standard library module in which case its __self__
84+ # attribute is that module.
85+ if not isinstance (fn .__self__ , types .ModuleType ):
86+ skip_arg = True
8387 elif not inspect .isfunction (fn ):
8488 # The purpose of this else clause is to set skip_arg for callable objects.
8589 skip_arg = True
You can’t perform that action at this time.
0 commit comments