summaryrefslogtreecommitdiffstats
path: root/Tools/clinic
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2023-07-25 21:08:52 (GMT)
committerGitHub <noreply@github.com>2023-07-25 21:08:52 (GMT)
commitee9010784c7d5a084f6e5465bc706717e1a0a151 (patch)
tree52521c1b904f5ae45d79287ebe457d9951bd3251 /Tools/clinic
parent7c89f1189229c5c67a3766e24ecf00cde658b7fd (diff)
downloadcpython-ee9010784c7d5a084f6e5465bc706717e1a0a151.zip
cpython-ee9010784c7d5a084f6e5465bc706717e1a0a151.tar.gz
cpython-ee9010784c7d5a084f6e5465bc706717e1a0a151.tar.bz2
gh-104050: Argument clinic: more misc typing improvements (#107264)
Diffstat (limited to 'Tools/clinic')
-rwxr-xr-xTools/clinic/clinic.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 8c959ed..c46c686 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -45,6 +45,7 @@ from typing import (
Protocol,
TypeGuard,
TypeVar,
+ cast,
overload,
)
@@ -2694,9 +2695,12 @@ def add_legacy_c_converter(
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):
"""
@@ -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
@@ -4048,7 +4052,7 @@ class self_converter(CConverter):
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.
@@ -4064,6 +4068,7 @@ class self_converter(CConverter):
# 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: