https://github.com/python/cpython/commit/e74fa294c9b0c67bfcbefdda5a069f0a7648f524
commit: e74fa294c9b0c67bfcbefdda5a069f0a7648f524
branch: main
author: Erlend E. Aasland <[email protected]>
committer: erlend-aasland <[email protected]>
date: 2024-02-15T16:03:58Z
summary:

gh-113317: Argument Clinic: inline required_type_for_self_for_parser() in self 
converter (#115522)

Co-authored-by: Alex Waygood <[email protected]>

files:
M Tools/clinic/clinic.py

diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 77d492a386651f..7e657351b3f629 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -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 @@ def pre_render(self) -> None:
     @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:
         """

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to