forked from pool/python-fire
- Add fix-issue-164.patch patch to fix gh#google/python-fire#164 and we can run whole test suite. OBS-URL: https://build.opensuse.org/request/show/682932 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-fire?expand=0&rev=7
58 lines
2.2 KiB
Diff
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, {})
|