Skip to content

Commit 7e2906e

Browse files
AlexWaygoodjtcave
authored andcommitted
pythongh-104050: Argument clinic: more misc typing coverage improvements (python#107210)
1 parent 2675e87 commit 7e2906e

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

Tools/clinic/clinic.py

+18-11
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,9 @@ class FormatCounterFormatter(string.Formatter):
437437
def __init__(self) -> None:
438438
self.counts = collections.Counter[str]()
439439

440-
def get_value(self, key: str, args, kwargs) -> str: # type: ignore[override]
440+
def get_value(
441+
self, key: str, args: object, kwargs: object # type: ignore[override]
442+
) -> Literal['']:
441443
self.counts[key] += 1
442444
return ''
443445

@@ -2797,7 +2799,7 @@ class CConverter(metaclass=CConverterAutoRegister):
27972799
# This lets the self_converter overrule the user-settable
27982800
# name, *just* for the text signature.
27992801
# Only set by self_converter.
2800-
signature_name = None
2802+
signature_name: str | None = None
28012803

28022804
# keep in sync with self_converter.__init__!
28032805
def __init__(self,
@@ -2811,8 +2813,8 @@ def __init__(self,
28112813
py_default: str | None = None,
28122814
annotation: str | Literal[Sentinels.unspecified] = unspecified,
28132815
unused: bool = False,
2814-
**kwargs
2815-
):
2816+
**kwargs: Any
2817+
) -> None:
28162818
self.name = ensure_legal_c_identifier(name)
28172819
self.py_name = py_name
28182820
self.unused = unused
@@ -2849,7 +2851,7 @@ def __init__(self,
28492851
self.converter_init(**kwargs)
28502852
self.function = function
28512853

2852-
def converter_init(self):
2854+
def converter_init(self) -> None:
28532855
pass
28542856

28552857
def is_optional(self) -> bool:
@@ -3032,7 +3034,7 @@ def cleanup(self) -> str:
30323034
"""
30333035
return ""
30343036

3035-
def pre_render(self):
3037+
def pre_render(self) -> None:
30363038
"""
30373039
A second initialization function, like converter_init,
30383040
called just before rendering.
@@ -3169,7 +3171,7 @@ class defining_class_converter(CConverter):
31693171
format_unit = ''
31703172
show_in_signature = False
31713173

3172-
def converter_init(self, *, type=None) -> None:
3174+
def converter_init(self, *, type: str | None = None) -> None:
31733175
self.specified_type = type
31743176

31753177
def render(self, parameter, data) -> None:
@@ -3321,7 +3323,9 @@ class int_converter(CConverter):
33213323
format_unit = 'i'
33223324
c_ignored_default = "0"
33233325

3324-
def converter_init(self, *, accept: TypeSet = {int}, type=None) -> None:
3326+
def converter_init(
3327+
self, *, accept: TypeSet = {int}, type: str | None = None
3328+
) -> None:
33253329
if accept == {str}:
33263330
self.format_unit = 'C'
33273331
elif accept != {int}:
@@ -3982,14 +3986,15 @@ class self_converter(CConverter):
39823986
A special-case converter:
39833987
this is the default converter used for "self".
39843988
"""
3985-
type = None
3989+
type: str | None = None
39863990
format_unit = ''
39873991

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

3991-
def pre_render(self):
3995+
def pre_render(self) -> None:
39923996
f = self.function
3997+
assert isinstance(f, Function)
39933998
default_type, default_name = correct_name_for_self(f)
39943999
self.signature_name = default_name
39954000
self.type = self.specified_type or self.type or default_type
@@ -4038,7 +4043,9 @@ def pre_render(self):
40384043
# in the impl call.
40394044

40404045
@property
4041-
def parser_type(self):
4046+
def parser_type(self) -> str:
4047+
assert self.type is not None
4048+
assert isinstance(self.function, Function)
40424049
return required_type_for_self_for_parser(self.function) or self.type
40434050

40444051
def render(self, parameter, data):

0 commit comments

Comments
 (0)