Skip to content
Merged
Changes from 1 commit
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
32 changes: 19 additions & 13 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2950,12 +2950,18 @@ def parse_argument(self, args: list[str]) -> None:
# All the functions after here are intended as extension points.
#

def simple_declaration(self, by_reference=False, *, in_parser=False):
def simple_declaration(
self,
by_reference: bool = False,
*,
in_parser: bool = False
) -> str:
"""
Computes the basic declaration of the variable.
Used in computing the prototype declaration and the
variable declaration.
"""
assert isinstance(self.type, str)
prototype = [self.type]
if by_reference or not self.type.endswith('*'):
prototype.append(" ")
Expand All @@ -2970,7 +2976,7 @@ def simple_declaration(self, by_reference=False, *, in_parser=False):
prototype.append(name)
return "".join(prototype)

def declaration(self, *, in_parser=False) -> str:
def declaration(self, *, in_parser: bool = False) -> str:
"""
The C statement to declare this variable.
"""
Expand Down Expand Up @@ -3579,9 +3585,9 @@ class object_converter(CConverter):

def converter_init(
self, *,
converter=None,
type=None,
subclass_of=None
converter: str | None = None,
type: str | None = None,
subclass_of: str | None = None
) -> None:
if converter:
if subclass_of:
Expand Down Expand Up @@ -3973,7 +3979,7 @@ class self_converter(CConverter):
type = None
format_unit = ''

def converter_init(self, *, type=None) -> None:
def converter_init(self, *, type: str | None = None) -> None:
self.specified_type = type

def pre_render(self):
Expand Down Expand Up @@ -4047,7 +4053,7 @@ def render(self, parameter, data):
assert data.impl_arguments[0] == self.name
data.impl_arguments[0] = '(' + self.type + ")" + data.impl_arguments[0]

def set_template_dict(self, template_dict):
def set_template_dict(self, template_dict: TemplateDict) -> None:
template_dict['self_name'] = self.name
template_dict['self_type'] = self.parser_type
kind = self.function.kind
Expand All @@ -4066,7 +4072,7 @@ def set_template_dict(self, template_dict):
line = f'{type_check} &&\n '
template_dict['self_type_check'] = line

type_object = self.function.cls.type_object
type_object = cls.type_object
type_ptr = f'PyTypeObject *base_tp = {type_object};'
template_dict['base_type_ptr'] = type_ptr

Expand Down Expand Up @@ -4276,11 +4282,11 @@ def eval_ast_expr(


class IndentStack:
def __init__(self):
self.indents = []
self.margin = None
def __init__(self) -> None:
self.indents: list[int] = []
self.margin = ""

def _ensure(self):
def _ensure(self) -> None:
if not self.indents:
fail('IndentStack expected indents, but none are defined.')

Expand Down Expand Up @@ -5534,7 +5540,7 @@ def add_parameter(text):

return docstring

def state_terminal(self, line):
def state_terminal(self, line: str | None) -> None:
"""
Called when processing the block is done.
"""
Expand Down