Skip to content

Commit

Permalink
gh-104050: Argument clinic: more misc typing improvements (#107264)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Jul 25, 2023
1 parent 7c89f11 commit ee90107
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
Protocol,
TypeGuard,
TypeVar,
cast,
overload,
)

Expand Down Expand Up @@ -2694,9 +2695,12 @@ def closure(f: CConverterClassT) -> CConverterClassT:
return closure

class CConverterAutoRegister(type):
def __init__(cls, name, bases, classdict):
add_c_converter(cls)
add_default_legacy_c_converter(cls)
def __init__(
cls, name: str, bases: tuple[type, ...], classdict: dict[str, Any]
) -> None:
converter_cls = cast(type["CConverter"], cls)
add_c_converter(converter_cls)
add_default_legacy_c_converter(converter_cls)

class CConverter(metaclass=CConverterAutoRegister):
"""
Expand Down Expand Up @@ -3174,10 +3178,10 @@ class defining_class_converter(CConverter):
def converter_init(self, *, type: str | None = None) -> None:
self.specified_type = type

def render(self, parameter, data) -> None:
def render(self, parameter: Parameter, data: CRenderData) -> None:
self._render_self(parameter, data)

def set_template_dict(self, template_dict):
def set_template_dict(self, template_dict: TemplateDict) -> None:
template_dict['defining_class_name'] = self.name


Expand Down Expand Up @@ -4048,7 +4052,7 @@ def parser_type(self) -> str:
assert isinstance(self.function, Function)
return required_type_for_self_for_parser(self.function) or self.type

def render(self, parameter, data):
def render(self, parameter: Parameter, data: CRenderData) -> None:
"""
parameter is a clinic.Parameter instance.
data is a CRenderData instance.
Expand All @@ -4064,6 +4068,7 @@ def render(self, parameter, data):
# because we render parameters in order, and self is always first.
assert len(data.impl_arguments) == 1
assert data.impl_arguments[0] == self.name
assert self.type is not None
data.impl_arguments[0] = '(' + self.type + ")" + data.impl_arguments[0]

def set_template_dict(self, template_dict: TemplateDict) -> None:
Expand Down

0 comments on commit ee90107

Please sign in to comment.