]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-113317: Argument Clinic: inline required_type_for_self_for_parser() in self conver...
authorErlend E. Aasland <erlend@python.org>
Thu, 15 Feb 2024 16:03:58 +0000 (17:03 +0100)
committerGitHub <noreply@github.com>
Thu, 15 Feb 2024 16:03:58 +0000 (16:03 +0000)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Tools/clinic/clinic.py

index 77d492a386651fd6e40671a80122d0668eeb98f9..7e657351b3f629b9296527ae5e7ede28682df140 100755 (executable)
@@ -4402,14 +4402,6 @@ def correct_name_for_self(
         return "PyTypeObject *", "type"
     raise AssertionError(f"Unhandled type of function f: {f.kind!r}")
 
-def required_type_for_self_for_parser(
-        f: Function
-) -> str | None:
-    type, _ = correct_name_for_self(f)
-    if f.kind in (METHOD_INIT, METHOD_NEW, STATIC_METHOD, CLASS_METHOD):
-        return type
-    return None
-
 
 class self_converter(CConverter):
     """
@@ -4474,7 +4466,10 @@ class self_converter(CConverter):
     @property
     def parser_type(self) -> str:
         assert self.type is not None
-        return required_type_for_self_for_parser(self.function) or self.type
+        if self.function.kind in {METHOD_INIT, METHOD_NEW, STATIC_METHOD, CLASS_METHOD}:
+            tp, _ = correct_name_for_self(self.function)
+            return tp
+        return self.type
 
     def render(self, parameter: Parameter, data: CRenderData) -> None:
         """