Skip to content

gh-106359: Fix corner case bugs in Argument Clinic converter parser #106361

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 14 commits into from
Jul 3, 2023
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
Next Next commit
Move KwargDict up and name it slightly better
  • Loading branch information
erlend-aasland committed Jul 3, 2023
commit bb879ccebd9fe5ba5fb2bbb8168c550c00d6a5dd
9 changes: 5 additions & 4 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4291,6 +4291,7 @@ def dedent(self, line):


StateKeeper = Callable[[str | None], None]
ConverterArgs = dict[str, Any]

class DSLParser:
function: Function | None
Expand Down Expand Up @@ -5033,10 +5034,10 @@ def bad_node(self, node):
key = f"{parameter_name}_as_{c_name}" if c_name else parameter_name
self.function.parameters[key] = p

KwargDict = dict[str, Any]

@staticmethod
def parse_converter(annotation: ast.expr | None) -> tuple[str, bool, KwargDict]:
def parse_converter(
annotation: ast.expr | None
) -> tuple[str, bool, ConverterArgs]:
msg = "Annotations must be either a name, a function call, or a string."
match annotation:
case ast.Constant(value=str() as value):
Expand All @@ -5045,7 +5046,7 @@ def parse_converter(annotation: ast.expr | None) -> tuple[str, bool, KwargDict]:
return name, False, {}
case ast.Call(func=ast.Name(name)):
symbols = globals()
kwargs: dict[str, Any] = {}
kwargs: ConverterArgs = {}
for node in annotation.keywords:
if not isinstance(node.arg, str):
fail(msg)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy