mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-104050: Argument clinic: misc improvements to type annotation coverage (#107206)
This commit is contained in:
parent
7608fa8fd5
commit
d93fe5afe2
1 changed files with 15 additions and 9 deletions
|
|
@ -2640,7 +2640,7 @@ class LandMine:
|
|||
# try to access any
|
||||
__message__: str
|
||||
|
||||
def __getattribute__(self, name: str):
|
||||
def __getattribute__(self, name: str) -> Any:
|
||||
if name in ('__repr__', '__message__'):
|
||||
return super().__getattribute__(name)
|
||||
# raise RuntimeError(repr(name))
|
||||
|
|
@ -3896,7 +3896,7 @@ class Py_buffer_converter(CConverter):
|
|||
|
||||
self.format_unit = format_unit
|
||||
|
||||
def cleanup(self):
|
||||
def cleanup(self) -> str:
|
||||
name = self.name
|
||||
return "".join(["if (", name, ".obj) {\n PyBuffer_Release(&", name, ");\n}\n"])
|
||||
|
||||
|
|
@ -4115,7 +4115,7 @@ class CReturnConverter(metaclass=CReturnConverterAutoRegister):
|
|||
self,
|
||||
*,
|
||||
py_default: str | None = None,
|
||||
**kwargs
|
||||
**kwargs: Any
|
||||
) -> None:
|
||||
self.py_default = py_default
|
||||
try:
|
||||
|
|
@ -4493,7 +4493,7 @@ class DSLParser:
|
|||
self,
|
||||
name: str,
|
||||
command: str,
|
||||
*args
|
||||
*args: str
|
||||
) -> None:
|
||||
match command:
|
||||
case "new":
|
||||
|
|
@ -4847,12 +4847,13 @@ class DSLParser:
|
|||
return self.next(self.state_parameter, line)
|
||||
|
||||
|
||||
def to_required(self):
|
||||
def to_required(self) -> None:
|
||||
"""
|
||||
Transition to the "required" parameter state.
|
||||
"""
|
||||
if self.parameter_state is not ParamState.REQUIRED:
|
||||
self.parameter_state = ParamState.REQUIRED
|
||||
assert self.function is not None
|
||||
for p in self.function.parameters.values():
|
||||
p.group = -p.group
|
||||
|
||||
|
|
@ -5000,7 +5001,7 @@ class DSLParser:
|
|||
# of disallowed ast nodes.
|
||||
class DetectBadNodes(ast.NodeVisitor):
|
||||
bad = False
|
||||
def bad_node(self, node):
|
||||
def bad_node(self, node: ast.AST) -> None:
|
||||
self.bad = True
|
||||
|
||||
# inline function call
|
||||
|
|
@ -5248,7 +5249,9 @@ class DSLParser:
|
|||
# every line of the docstring must start with at least F spaces,
|
||||
# where F > P.
|
||||
# these F spaces will be stripped.
|
||||
def state_parameter_docstring(self, line):
|
||||
def state_parameter_docstring(self, line: str | None) -> None:
|
||||
assert line is not None
|
||||
|
||||
stripped = line.strip()
|
||||
if stripped.startswith('#'):
|
||||
return
|
||||
|
|
@ -5263,7 +5266,7 @@ class DSLParser:
|
|||
assert self.indent.depth == 1
|
||||
return self.next(self.state_function_docstring, line)
|
||||
|
||||
assert self.function.parameters
|
||||
assert self.function and self.function.parameters
|
||||
last_parameter = next(reversed(list(self.function.parameters.values())))
|
||||
|
||||
new_docstring = last_parameter.docstring
|
||||
|
|
@ -5276,7 +5279,10 @@ class DSLParser:
|
|||
last_parameter.docstring = new_docstring
|
||||
|
||||
# the final stanza of the DSL is the docstring.
|
||||
def state_function_docstring(self, line):
|
||||
def state_function_docstring(self, line: str | None) -> None:
|
||||
assert self.function is not None
|
||||
assert line is not None
|
||||
|
||||
if self.group:
|
||||
fail("Function " + self.function.name + " has a ] without a matching [.")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue