Skip to content

Commit 505e295

Browse files
gh-104050: Add basic typing to CConverter in clinic.py (#104538)
1 parent cca90b6 commit 505e295

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Tools/clinic/clinic.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,15 +2669,15 @@ class CConverter(metaclass=CConverterAutoRegister):
26692669
# keep in sync with self_converter.__init__!
26702670
def __init__(self,
26712671
# Positional args:
2672-
name,
2673-
py_name,
2672+
name: str,
2673+
py_name: str,
26742674
function,
26752675
default=unspecified,
26762676
*, # Keyword only args:
2677-
c_default=None,
2678-
py_default=None,
2679-
annotation=unspecified,
2680-
unused=False,
2677+
c_default: str | None = None,
2678+
py_default: str | None = None,
2679+
annotation: str | Unspecified = unspecified,
2680+
unused: bool = False,
26812681
**kwargs
26822682
):
26832683
self.name = ensure_legal_c_identifier(name)
@@ -2713,10 +2713,10 @@ def __init__(self,
27132713
def converter_init(self):
27142714
pass
27152715

2716-
def is_optional(self):
2716+
def is_optional(self) -> bool:
27172717
return (self.default is not unspecified)
27182718

2719-
def _render_self(self, parameter, data):
2719+
def _render_self(self, parameter: str, data: CRenderData) -> None:
27202720
self.parameter = parameter
27212721
name = self.parser_name
27222722

@@ -2776,7 +2776,7 @@ def _render_non_self(self, parameter, data):
27762776
if cleanup:
27772777
data.cleanup.append('/* Cleanup for ' + name + ' */\n' + cleanup.rstrip() + "\n")
27782778

2779-
def render(self, parameter, data):
2779+
def render(self, parameter: str, data: CRenderData) -> None:
27802780
"""
27812781
parameter is a clinic.Parameter instance.
27822782
data is a CRenderData instance.
@@ -2852,31 +2852,31 @@ def declaration(self, *, in_parser=False):
28522852
declaration.append(';')
28532853
return "".join(declaration)
28542854

2855-
def initialize(self):
2855+
def initialize(self) -> str:
28562856
"""
28572857
The C statements required to set up this variable before parsing.
28582858
Returns a string containing this code indented at column 0.
28592859
If no initialization is necessary, returns an empty string.
28602860
"""
28612861
return ""
28622862

2863-
def modify(self):
2863+
def modify(self) -> str:
28642864
"""
28652865
The C statements required to modify this variable after parsing.
28662866
Returns a string containing this code indented at column 0.
28672867
If no modification is necessary, returns an empty string.
28682868
"""
28692869
return ""
28702870

2871-
def post_parsing(self):
2871+
def post_parsing(self) -> str:
28722872
"""
28732873
The C statements required to do some operations after the end of parsing but before cleaning up.
28742874
Return a string containing this code indented at column 0.
28752875
If no operation is necessary, return an empty string.
28762876
"""
28772877
return ""
28782878

2879-
def cleanup(self):
2879+
def cleanup(self) -> str:
28802880
"""
28812881
The C statements required to clean up after this variable.
28822882
Returns a string containing this code indented at column 0.
@@ -2929,7 +2929,7 @@ def parse_arg(self, argname, displayname):
29292929
""".format(argname=argname, paramname=self.parser_name, cast=cast)
29302930
return None
29312931

2932-
def set_template_dict(self, template_dict):
2932+
def set_template_dict(self, template_dict: dict[str, str]):
29332933
pass
29342934

29352935
@property

0 commit comments

Comments
 (0)