10000 gh-104050: Annotate more Argument Clinic DSLParser state methods by erlend-aasland · Pull Request #106376 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-104050: Annotate more Argument Clinic DSLParser state methods #106376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Prev Previous commit
Fix the remaining stuff
  • Loading branch information
AlexWaygood authored and erlend-aasland committed Jul 3, 2023
commit 73c1dc2ba9c8e01078b5c2361fc24e59f83816f2
10 changes: 7 additions & 3 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4864,7 +4864,9 @@ def state_parameter(self, line: str | None) -> None:
if not module:
fail("Function " + self.function.name + " has an invalid parameter declaration:\n\t" + line)

function_args = module.body[0].args
function = module.body[0]
assert isinstance(function, ast.FunctionDef)
function_args = function.args

if len(function_args.args) > 1:
fail("Function " + self.function.name + " has an invalid parameter declaration (comma?):\n\t" + line)
Expand Down Expand Up @@ -4950,7 +4952,9 @@ def bad_node(self, node):
if bad:
fail("Unsupported expression as default value: " + repr(default))

expr = module.body[0].value
assignment = module.body[0]
assert isinstance(assignment, ast.Assign)
expr = assignment.value
# mild hack: explicitly support NULL as a default value
c_default: str | None
if isinstance(expr, ast.Name) and expr.id == 'NULL':
Expand Down Expand Up @@ -4989,7 +4993,7 @@ def bad_node(self, node):
else:
value = ast.literal_eval(expr)
py_default = repr(value)
if isinstance(value, (bool, None.__class__)):
if isinstance(value, (bool, NoneType)):
c_default = "Py_" + py_default
elif isinstance(value, str):
c_default = c_repr(value)
Expand Down
0