]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-20684: Remove unused inspect._signature_get_bound_param (GH-21100)
authorAnthony Sottile <asottile@umich.edu>
Sat, 22 May 2021 14:51:43 +0000 (07:51 -0700)
committerGitHub <noreply@github.com>
Sat, 22 May 2021 14:51:43 +0000 (15:51 +0100)
Lib/inspect.py
Lib/test/test_inspect.py
Misc/NEWS.d/next/Library/2020-07-30-14-37-15.bpo-20684.qV35GU.rst [new file with mode: 0644]

index 9f8cc01310f10e323f2ef3b1301816308a5d2f40..89b2e722be8fad304f02307f096591ef79f79680 100644 (file)
@@ -2020,29 +2020,6 @@ def _signature_is_functionlike(obj):
             (isinstance(annotations, (dict)) or annotations is None) )
 
 
-def _signature_get_bound_param(spec):
-    """ Private helper to get first parameter name from a
-    __text_signature__ of a builtin method, which should
-    be in the following format: '($param1, ...)'.
-    Assumptions are that the first argument won't have
-    a default value or an annotation.
-    """
-
-    assert spec.startswith('($')
-
-    pos = spec.find(',')
-    if pos == -1:
-        pos = spec.find(')')
-
-    cpos = spec.find(':')
-    assert cpos == -1 or cpos > pos
-
-    cpos = spec.find('=')
-    assert cpos == -1 or cpos > pos
-
-    return spec[2:pos]
-
-
 def _signature_strip_non_python_syntax(signature):
     """
     Private helper function. Takes a signature in Argument Clinic's
index 0ab65307cdd0954178a69dd35fbe66bbeb4e67b3..69f17f2477a2f2bbe9c758a2cca03eaf06531fb9 100644 (file)
@@ -4014,13 +4014,6 @@ class TestBoundArguments(unittest.TestCase):
         self.assertIs(type(ba.arguments), dict)
 
 class TestSignaturePrivateHelpers(unittest.TestCase):
-    def test_signature_get_bound_param(self):
-        getter = inspect._signature_get_bound_param
-
-        self.assertEqual(getter('($self)'), 'self')
-        self.assertEqual(getter('($self, obj)'), 'self')
-        self.assertEqual(getter('($cls, /, obj)'), 'cls')
-
     def _strip_non_python_syntax(self, input,
         clean_signature, self_parameter, last_positional_only):
         computed_clean_signature, \
diff --git a/Misc/NEWS.d/next/Library/2020-07-30-14-37-15.bpo-20684.qV35GU.rst b/Misc/NEWS.d/next/Library/2020-07-30-14-37-15.bpo-20684.qV35GU.rst
new file mode 100644 (file)
index 0000000..56bc1e4
--- /dev/null
@@ -0,0 +1,2 @@
+Remove unused ``_signature_get_bound_param`` function from :mod:`inspect` -
+by Anthony Sottile.