Skip to content

Commit

Permalink
pythongh-113317: Argument Clinic: inline required_type_for_self_for_p…
Browse files Browse the repository at this point in the history
…arser() in self converter (python#115522)

Co-authored-by: Alex Waygood <[email protected]>
  • Loading branch information
2 people authored and diegorusso committed Apr 17, 2024
1 parent b2798e2 commit 9226d4c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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:
"""
Expand Down

0 comments on commit 9226d4c

Please sign in to comment.