15
0
forked from pool/python-fire
Files
python-fire/fix-issue-164.patch
2019-03-08 23:35:04 +00:00

58 lines
2.2 KiB
Diff

From 2cc070bb50577ec45fae640b56e02c69feb6f82c Mon Sep 17 00:00:00 2001
From: Andrew Au <cshung@gmail.com>
Date: Fri, 22 Feb 2019 16:23:03 -0800
Subject: [PATCH] Fix issue 164
---
fire/helputils_test.py | 1 -
fire/inspectutils.py | 10 ++++++----
fire/inspectutils_test.py | 2 --
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/fire/helputils_test.py b/fire/helputils_test.py
index 0557122..c3d5055 100644
--- a/fire/helputils_test.py
+++ b/fire/helputils_test.py
@@ -88,7 +88,6 @@ def testHelpStringBuiltin(self):
helpstring = helputils.HelpString('test'.upper)
self.assertIn('Type: builtin_function_or_method', helpstring)
self.assertIn('String form: <built-in method upper of', helpstring)
- self.assertIn('Usage: [VARS ...] [--KWARGS ...]', helpstring)
def testHelpStringIntType(self):
helpstring = helputils.HelpString(int)
diff --git a/fire/inspectutils.py b/fire/inspectutils.py
index 45f7ce6..244a84f 100644
--- a/fire/inspectutils.py
+++ b/fire/inspectutils.py
@@ -74,10 +74,12 @@ class with an __init__ method.
if six.PY2 and hasattr(fn, '__init__'):
fn = fn.__init__
else:
- # If the function is a bound method, we skip the `self` argument.
- is_method = inspect.ismethod(fn)
- skip_arg = is_method and fn.__self__ is not None
-
+ if inspect.ismethod(fn):
+ # If the function is a bound method, we skip the `self` argument.
+ skip_arg = fn.__self__ is not None
+ elif inspect.isbuiltin(fn):
+ # If the function is a bound builtin, we skip the `self` argument.
+ skip_arg = fn.__self__ is not None
return fn, skip_arg
diff --git a/fire/inspectutils_test.py b/fire/inspectutils_test.py
index 8c6dd9a..ba42865 100644
--- a/fire/inspectutils_test.py
+++ b/fire/inspectutils_test.py
@@ -56,8 +56,6 @@ def testGetFullArgSpecFromBuiltin(self):
spec = inspectutils.GetFullArgSpec('test'.upper)
self.assertEqual(spec.args, [])
self.assertEqual(spec.defaults, ())
- self.assertEqual(spec.varargs, 'vars')
- self.assertEqual(spec.varkw, 'kwargs')
self.assertEqual(spec.kwonlyargs, [])
self.assertEqual(spec.kwonlydefaults, {})
self.assertEqual(spec.annotations, {})