Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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