Skip to content

Commit e74fa29

Browse files
gh-113317: Argument Clinic: inline required_type_for_self_for_parser() in self converter (#115522)
Co-authored-by: Alex Waygood <[email protected]>
1 parent cfb2640 commit e74fa29

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

Tools/clinic/clinic.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -4402,14 +4402,6 @@ def correct_name_for_self(
44024402
return "PyTypeObject *", "type"
44034403
raise AssertionError(f"Unhandled type of function f: {f.kind!r}")
44044404

4405-
def required_type_for_self_for_parser(
4406-
f: Function
4407-
) -> str | None:
4408-
type, _ = correct_name_for_self(f)
4409-
if f.kind in (METHOD_INIT, METHOD_NEW, STATIC_METHOD, CLASS_METHOD):
4410-
return type
4411-
return None
4412-
44134405

44144406
class self_converter(CConverter):
44154407
"""
@@ -4474,7 +4466,10 @@ def pre_render(self) -> None:
44744466
@property
44754467
def parser_type(self) -> str:
44764468
assert self.type is not None
4477-
return required_type_for_self_for_parser(self.function) or self.type
4469+
if self.function.kind in {METHOD_INIT, METHOD_NEW, STATIC_METHOD, CLASS_METHOD}:
4470+
tp, _ = correct_name_for_self(self.function)
4471+
return tp
4472+
return self.type
44784473

44794474
def render(self, parameter: Parameter, data: CRenderData) -> None:
44804475
"""

0 commit comments

Comments
 (0)