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
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)
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
Expand Down