fluent-codegen 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,93 @@
1
+ """Compatibility module for generating Python AST.
2
+
3
+ Provides a curated subset of the stdlib `ast` module used by the codegen module.
4
+ """
5
+
6
+ import ast
7
+ from typing import TypedDict
8
+
9
+ # This is a very limited subset of Python AST:
10
+ # - only the things needed by codegen.py
11
+
12
+ Add = ast.Add
13
+ And = ast.And
14
+ Assign = ast.Assign
15
+ AnnAssign = ast.AnnAssign
16
+ BoolOp = ast.BoolOp
17
+ BinOp = ast.BinOp
18
+ Compare = ast.Compare
19
+ Dict = ast.Dict
20
+ Div = ast.Div
21
+ Eq = ast.Eq
22
+ ExceptHandler = ast.ExceptHandler
23
+ Expr = ast.Expr
24
+ FloorDiv = ast.FloorDiv
25
+ Gt = ast.Gt
26
+ GtE = ast.GtE
27
+ If = ast.If
28
+ In = ast.In
29
+ List = ast.List
30
+ Load = ast.Load
31
+ Lt = ast.Lt
32
+ LtE = ast.LtE
33
+ Mod = ast.Mod
34
+ Module = ast.Module
35
+ Mult = ast.Mult
36
+ MatMult = ast.MatMult
37
+ NotEq = ast.NotEq
38
+ NotIn = ast.NotIn
39
+ Or = ast.Or
40
+ Pow = ast.Pow
41
+ Sub = ast.Sub
42
+ boolop = ast.boolop
43
+ cmpop = ast.cmpop
44
+ operator = ast.operator
45
+ Pass = ast.Pass
46
+ Return = ast.Return
47
+ Set = ast.Set
48
+ Starred = ast.Starred
49
+ Store = ast.Store
50
+ Subscript = ast.Subscript
51
+ Tuple = ast.Tuple
52
+ arguments = ast.arguments
53
+ JoinedStr = ast.JoinedStr
54
+ FormattedValue = ast.FormattedValue
55
+ Attribute = ast.Attribute
56
+ Call = ast.Call
57
+ FunctionDef = ast.FunctionDef
58
+ Name = ast.Name
59
+ Try = ast.Try
60
+ With = ast.With
61
+ withitem = ast.withitem
62
+ arg = ast.arg
63
+ keyword = ast.keyword
64
+ ClassDef = ast.ClassDef
65
+ walk = ast.walk
66
+ fix_missing_locations = ast.fix_missing_locations
67
+ unparse = ast.unparse
68
+ Constant = ast.Constant
69
+ AST = ast.AST
70
+ stmt = ast.stmt
71
+ expr = ast.expr
72
+ Import = ast.Import
73
+ ImportFrom = ast.ImportFrom
74
+ alias = ast.alias
75
+
76
+ # `compile` builtin needs these attributes on AST nodes.
77
+ # It's hard to get something sensible we can put for line/col numbers so we put arbitrary values.
78
+
79
+
80
+ class DefaultAstArgs(TypedDict):
81
+ lineno: int
82
+ col_offset: int
83
+
84
+
85
+ DEFAULT_AST_ARGS: DefaultAstArgs = {"lineno": 1, "col_offset": 1}
86
+ # Some AST types have different requirements:
87
+ DEFAULT_AST_ARGS_MODULE: dict[str, object] = dict()
88
+ DEFAULT_AST_ARGS_ADD: dict[str, object] = dict()
89
+ DEFAULT_AST_ARGS_ARGUMENTS: dict[str, object] = dict()
90
+
91
+
92
+ def subscript_slice_object[T](value: T) -> T:
93
+ return value