Coverage for src/renaissance/integrations/python/ast/kinds.py: 100%
3 statements
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-02 13:12 +0000
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-02 13:12 +0000
1"""AI: Mapping of Python `ast` node kinds and operators to the library's semantic kinds."""
3from renaissance.syntax_tree.semantic_kind import SemanticKind
5PYTHON_OPERATOR_MAP = {
6 "AnnAssign": "=",
7 "Assert": "assert",
8 "Assign": "=",
9 "AsyncFor": "for",
10 "AsyncFunctionDef": "function",
11 "AsyncWith": "with",
12 "AugAssignAdd": "+=",
13 "Break": "break",
14 "Call": "def",
15 "ClassDef": "class",
16 "Continue": "continue",
17 "For": "for",
18 "FunctionDef": "function",
19 "If": "if",
20 "Import": "import",
21 "ImportFrom": "import",
22 "Match": "match",
23 "Pass": "pass",
24 "Try": "try",
25 "TryStar": "try",
26 "While": "while",
27 "With": "with",
28}
30PYTHON_KIND_MAP = {
31 "Module": SemanticKind.TRANSLATION_UNIT,
32 "FunctionDef": SemanticKind.FUNCTION,
33 "AsyncFunctionDef": SemanticKind.FUNCTION,
34 "ClassDef": SemanticKind.CLASS,
35 "Call": SemanticKind.CALL,
36 "Name": SemanticKind.NAME,
37 "Attribute": SemanticKind.ATTRIBUTE,
38 "arg": SemanticKind.PARAMETER,
39 "Param": SemanticKind.PARAMETER,
40 "Constant": SemanticKind.LITERAL,
41 "Integer": SemanticKind.LITERAL,
42 "Float": SemanticKind.LITERAL,
43 "SimpleString": SemanticKind.LITERAL,
44 "FormattedString": SemanticKind.LITERAL,
45 "Assign": SemanticKind.ASSIGNMENT,
46 "AnnAssign": SemanticKind.ASSIGNMENT,
47 "AugAssign": SemanticKind.ASSIGNMENT,
48 "NamedExpr": SemanticKind.ASSIGNMENT,
49 "BinOp": SemanticKind.BINARY_OPERATION,
50 "BinaryOperation": SemanticKind.BINARY_OPERATION,
51 "BoolOp": SemanticKind.BINARY_OPERATION,
52 "Compare": SemanticKind.BINARY_OPERATION,
53 "UnaryOp": SemanticKind.UNARY_OPERATION,
54 "UnaryOperation": SemanticKind.UNARY_OPERATION,
55 "If": SemanticKind.CONDITIONAL,
56 "IfExp": SemanticKind.CONDITIONAL,
57 "For": SemanticKind.LOOP,
58 "AsyncFor": SemanticKind.LOOP,
59 "While": SemanticKind.LOOP,
60 "Return": SemanticKind.RETURN,
61 "Import": SemanticKind.IMPORT,
62 "ImportFrom": SemanticKind.IMPORT,
63 "Assert": SemanticKind.CONDITIONAL,
64 "With": SemanticKind.LOOP,
65 "AsyncWith": SemanticKind.LOOP,
66 "Raise": SemanticKind.RETURN,
67 "Break": SemanticKind.RETURN,
68 "Continue": SemanticKind.RETURN,
69 "Pass": SemanticKind.STATEMENT,
70 "Try": SemanticKind.STATEMENT,
71 "TryStar": SemanticKind.STATEMENT,
72 "Delete": SemanticKind.STATEMENT,
73 "Expr": SemanticKind.EXPRESSION,
74 "Await": SemanticKind.EXPRESSION,
75 "Yield": SemanticKind.EXPRESSION,
76 "YieldFrom": SemanticKind.EXPRESSION,
77 "Global": SemanticKind.GLOBAL,
78 "Nonlocal": SemanticKind.NONLOCAL,
79 "Match": SemanticKind.STATEMENT,
80}