mapFolding 0.10.0__py3-none-any.whl → 0.11.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.
Files changed (26) hide show
  1. mapFolding/__init__.py +29 -27
  2. mapFolding/someAssemblyRequired/Z0Z_makeSomeModules.py +4 -6
  3. mapFolding/someAssemblyRequired/__init__.py +15 -24
  4. mapFolding/someAssemblyRequired/_toolIfThis.py +4 -144
  5. mapFolding/someAssemblyRequired/_toolboxContainers.py +12 -284
  6. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +6 -6
  7. mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +5 -5
  8. mapFolding/someAssemblyRequired/transformationTools.py +5 -178
  9. {mapfolding-0.10.0.dist-info → mapfolding-0.11.0.dist-info}/METADATA +2 -1
  10. {mapfolding-0.10.0.dist-info → mapfolding-0.11.0.dist-info}/RECORD +14 -26
  11. {mapfolding-0.10.0.dist-info → mapfolding-0.11.0.dist-info}/WHEEL +1 -1
  12. mapFolding/someAssemblyRequired/_astTypes.py +0 -117
  13. mapFolding/someAssemblyRequired/_theTypes.py +0 -34
  14. mapFolding/someAssemblyRequired/_toolBe.py +0 -524
  15. mapFolding/someAssemblyRequired/_toolDOT.py +0 -493
  16. mapFolding/someAssemblyRequired/_toolGrab.py +0 -653
  17. mapFolding/someAssemblyRequired/_toolMake.py +0 -339
  18. mapFolding/someAssemblyRequired/_toolThen.py +0 -63
  19. mapFolding/someAssemblyRequired/_toolboxAST.py +0 -57
  20. mapFolding/someAssemblyRequired/_toolboxPython.py +0 -188
  21. mapFolding/toolFactory/astFactory.py +0 -493
  22. mapFolding/toolFactory/astFactory_annex.py +0 -63
  23. mapFolding/toolFactory/astFactory_docstrings.py +0 -63
  24. {mapfolding-0.10.0.dist-info → mapfolding-0.11.0.dist-info}/entry_points.txt +0 -0
  25. {mapfolding-0.10.0.dist-info → mapfolding-0.11.0.dist-info}/licenses/LICENSE +0 -0
  26. {mapfolding-0.10.0.dist-info → mapfolding-0.11.0.dist-info}/top_level.txt +0 -0
@@ -1,493 +0,0 @@
1
- from mapFolding import The, writeStringToHere
2
- from mapFolding.toolFactory.astFactory_annex import handmadeMethodsGrab, handmadeTypeAlias_astTypes, MakeAttributeFunctionDef, MakeImportFunctionDef
3
- from mapFolding.toolFactory.astFactory_docstrings import docstringWarning, ClassDefDocstringBe, ClassDefDocstringDOT, ClassDefDocstringGrab, ClassDefDocstringMake
4
- from pathlib import PurePosixPath
5
- from string import ascii_letters
6
- from typing import cast, NamedTuple, TypeAlias as typing_TypeAlias, TypedDict
7
- import ast
8
-
9
- # TODO this is not DRY, but you can't import from some assembly required
10
- ast_Identifier: typing_TypeAlias = str
11
- str_nameDOTname: typing_TypeAlias = str
12
- ast_expr_Slice: typing_TypeAlias = ast.expr
13
-
14
- class StuPydTypeSystemFromHell(TypedDict):
15
- astAnnotation: ast.expr
16
- listClassDefIdentifier: list[ast_Identifier | str_nameDOTname]
17
-
18
- sys_version_infoTarget: tuple[int, int] = (3, 13)
19
-
20
- list_astDOTStuPydHARDCODED: list[ast_Identifier] = ['astDOTParamSpec', 'astDOTTryStar', 'astDOTTypeAlias', 'astDOTTypeVar', 'astDOTTypeVarTuple', 'astDOTtype_param']
21
-
22
- list_astDOTStuPyd = list_astDOTStuPydHARDCODED
23
- astImportFromClassNewInPythonVersion = ast.ImportFrom('mapFolding', [ast.alias(pleasedonotcrashwhileimportingtypes) for pleasedonotcrashwhileimportingtypes in list_astDOTStuPyd], 0)
24
-
25
- keywordArgumentsIdentifier: ast_Identifier = 'keywordArguments'
26
- moduleIdentifierPrefix: str = '_tool'
27
- overloadName = ast.Name('overload', ast.Load())
28
- staticmethodName = ast.Name('staticmethod', ast.Load())
29
- typing_TypeAliasName: ast.expr = cast(ast.expr, ast.Name('typing_TypeAlias', ast.Load()))
30
-
31
- class MakeDictionaryOf_astClassAnnotations(ast.NodeVisitor):
32
- def __init__(self, astAST: ast.AST) -> None:
33
- super().__init__()
34
- self.astAST = astAST
35
- self.dictionarySubstitutions: dict[ast_Identifier, ast.Attribute | ast.Name] = {
36
- '_Identifier': ast.Name('ast_Identifier'),
37
- '_Pattern': ast.Attribute(value=ast.Name('ast'), attr='pattern', ctx=ast.Load()),
38
- '_Slice': ast.Name('ast_expr_Slice'),
39
- 'str': ast.Name('ast_Identifier'),
40
- }
41
-
42
- def visit_ClassDef(self, node: ast.ClassDef) -> None:
43
- if 'astDOT' + node.name in list_astDOTStuPyd:
44
- NameOrAttribute = ast.Name('astDOT' + node.name, ctx=ast.Load())
45
- else:
46
- NameOrAttribute = ast.Attribute(value=ast.Name('ast'), attr=node.name, ctx=ast.Load())
47
- self.dictionarySubstitutions[node.name] = NameOrAttribute
48
-
49
- def getDictionary(self) -> dict[ast_Identifier, ast.Attribute | ast.Name]:
50
- self.visit(self.astAST)
51
- return self.dictionarySubstitutions
52
-
53
- class Prepend_ast2astClasses(ast.NodeTransformer):
54
- """The _effect_ of this `NodeTransformer` is to replace a naked `Jabberwocky` identifier with the specific
55
- `ast.Jabberwocky` identifier.
56
-
57
- The explanation, however, sounds like "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo."
58
-
59
- Initialize `ast.NodeTransformer` with mapping from subclass `ast._Identifier` of class `AST`, which is implemented
60
- in C, imported from module `_ast`, and defined in stub `ast.pyi`, to subclass `ast.Attribute`, rendered as
61
- "ast._Identifier" or subclass `ast.Name` for `AST` subclasses implemented later than Python version 3.10, rendered
62
- as "astDOT_Identifier" and defined as `typing.TypeAlias` or `typing.Any` depending on the runtime Python version in
63
- "__init__".
64
-
65
- Call method `visit` of `ast.NodeTransformer` with class `AST` or `AST` subclass parameter. `ast.NodeTransformer`
66
- will call `visit_Name` to visit each node descendant class `AST` or `AST` subclass parameter of class `ast.Name`.
67
- The class `ast.Name` descendant node identifier is `node`. If method `visit_Name` matches subclass `ast._Identifier`
68
- `node.id` to a mapping key, it returns the subclass `ast.Attribute` or subclass `ast.Name` mapping value. Otherwise,
69
- `visit_Name` returns subclass `ast.Name` `node`.
70
- """
71
- def __init__(self, dictionarySubstitutions: dict[ast_Identifier, ast.Attribute | ast.Name]) -> None:
72
- super().__init__()
73
- self.dictionarySubstitutions = dictionarySubstitutions
74
-
75
- def visit_Name(self, node: ast.Name) -> ast.Attribute | ast.Name:
76
- if node.id in self.dictionarySubstitutions:
77
- return self.dictionarySubstitutions[node.id]
78
- return node
79
-
80
- def makeTools(astStubFile: ast.AST, logicalPathInfix: str_nameDOTname) -> None:
81
- def writeModule(astModule: ast.Module, moduleIdentifier: ast_Identifier) -> None:
82
- ast.fix_missing_locations(astModule)
83
- pythonSource: str = ast.unparse(astModule)
84
- pathFilenameModule = PurePosixPath(The.pathPackage, logicalPathInfix, moduleIdentifier + The.fileExtension)
85
- writeStringToHere(pythonSource, pathFilenameModule)
86
-
87
- # Create each ClassDef and add directly to it instead of creating unnecessary intermediate structures.
88
- # fewer identifiers == fewer bugs
89
- ClassDefBe = ast.ClassDef(name='Be', bases=[], keywords=[], body=[], decorator_list=[])
90
- ClassDefDOT = ast.ClassDef(name='DOT', bases=[], keywords=[], body=[], decorator_list=[])
91
- ClassDefMake = ast.ClassDef(name='Make', bases=[], keywords=[], body=[], decorator_list=[])
92
- ClassDefGrab = ast.ClassDef(name='Grab', bases=[], keywords=[], body=[], decorator_list=[])
93
-
94
- dictionaryOf_astDOTclass: dict[ast_Identifier, ast.Attribute | ast.Name] = MakeDictionaryOf_astClassAnnotations(astStubFile).getDictionary()
95
-
96
- attributeIdentifier2Str4TypeAlias2astAnnotationAndListClassDefIdentifier: dict[ast_Identifier, dict[str, StuPydTypeSystemFromHell]] = {}
97
-
98
- # NOTE Convert each ast.ClassDef into `TypeAlias` and methods in `Be`, `DOT`, `Grab`, and `Make`.
99
- for node in ast.walk(astStubFile):
100
- # Filter out undesired nodes.
101
- if not isinstance(node, ast.ClassDef):
102
- continue
103
- if any(isinstance(decorator, ast.Call) and isinstance(decorator.func, ast.Name) and decorator.func.id == 'deprecated' for decorator in node.decorator_list):
104
- continue
105
- if node.name.startswith('_'):
106
- continue
107
-
108
- # Change the identifier solely for the benefit of clarity as you read this code.
109
- astDOTClassDef = node
110
- del node # NOTE this is necessary because AI assistants don't always follow instructions.
111
-
112
- # Create ast "fragments" before you need them.
113
- ClassDefIdentifier: ast_Identifier = astDOTClassDef.name
114
- ClassDef_astNameOrAttribute: ast.Attribute | ast.Name = dictionaryOf_astDOTclass[ClassDefIdentifier]
115
- # Reset these identifiers in case they were changed
116
- keywordArguments_ast_arg: ast.arg | None = ast.arg(keywordArgumentsIdentifier, ast.Name('int', ctx=ast.Load()))
117
- keywordArguments_ast_keyword: ast.keyword | None = ast.keyword(None, ast.Name(keywordArgumentsIdentifier, ctx=ast.Load()))
118
-
119
- ClassDefBe.body.append(ast.FunctionDef(name=ClassDefIdentifier
120
- , args=ast.arguments(posonlyargs=[], args=[ast.arg(arg='node', annotation=ast.Name('ast.AST'))], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[])
121
- , body=[ast.Return(value=ast.Call(func=ast.Name('isinstance'), args=[ast.Name('node'), ClassDef_astNameOrAttribute], keywords=[]))]
122
- , decorator_list=[staticmethodName]
123
- , returns=ast.Subscript(value=ast.Name('TypeGuard'), slice=ClassDef_astNameOrAttribute, ctx=ast.Load())))
124
-
125
- # Start: cope with different arguments for Python versions. ==============================================================
126
- # NOTE: I would love suggestions to improve this section.
127
- list_astDOTClassDefAttributeIdentifier: list[ast_Identifier] = []
128
- list__match_args__: list[list[ast_Identifier]] = []
129
- dictAttributes: dict[tuple[int, int], list[ast_Identifier]] = {}
130
- for subnode in ast.walk(astDOTClassDef):
131
- list_astDOTClassDefAttributeIdentifier = []
132
- if (isinstance(subnode, ast.If) and isinstance(subnode.test, ast.Compare)
133
- and isinstance(subnode.test.left, ast.Attribute)
134
- and subnode.test.left.attr == 'version_info' and isinstance(subnode.test.comparators[0], ast.Tuple)
135
- and isinstance(subnode.body[0], ast.Assign) and isinstance(subnode.body[0].targets[0], ast.Name) and subnode.body[0].targets[0].id == '__match_args__'
136
- and isinstance(subnode.body[0].value, ast.Tuple) and subnode.body[0].value.elts):
137
- sys_version_info: tuple[int, int] = ast.literal_eval(subnode.test.comparators[0])
138
- if sys_version_info > sys_version_infoTarget:
139
- continue
140
- if any(sys_version_info < key for key in dictAttributes.keys()): # pyright: ignore[reportOperatorIssue]
141
- continue
142
- dictAttributes[sys_version_info] = []
143
- for astAST in subnode.body[0].value.elts:
144
- if isinstance(astAST, ast.Constant):
145
- dictAttributes[sys_version_info].append(astAST.value)
146
- if sys_version_info == sys_version_infoTarget:
147
- break
148
-
149
- if (isinstance(subnode, ast.Assign) and isinstance(subnode.targets[0], ast.Name) and subnode.targets[0].id == '__match_args__'
150
- and isinstance(subnode.value, ast.Tuple) and subnode.value.elts):
151
- for astAST in subnode.value.elts:
152
- if isinstance(astAST, ast.Constant):
153
- list_astDOTClassDefAttributeIdentifier.append(astAST.value)
154
- list__match_args__.append(list_astDOTClassDefAttributeIdentifier)
155
-
156
- if not list__match_args__ and not dictAttributes and not list_astDOTClassDefAttributeIdentifier:
157
- continue
158
- elif sys_version_infoTarget in dictAttributes:
159
- list_astDOTClassDefAttributeIdentifier = dictAttributes[sys_version_infoTarget]
160
- elif dictAttributes:
161
- list_astDOTClassDefAttributeIdentifier = dictAttributes[max(dictAttributes.keys())]
162
- elif len(list__match_args__) == 1:
163
- list_astDOTClassDefAttributeIdentifier = list__match_args__[0]
164
- else:
165
- raise Exception(f"Hunter did not predict this situation.\n\t{ClassDefIdentifier = }\n\t{list__match_args__ = }\n\t{dictAttributes = }")
166
-
167
- del dictAttributes, list__match_args__
168
- # End: cope with different arguments for Python versions. ============================================================
169
-
170
- match ClassDefIdentifier:
171
- case 'Module' | 'Interactive' | 'FunctionType' | 'Expression':
172
- keywordArguments_ast_arg = None
173
- keywordArguments_ast_keyword = None
174
- case _:
175
- pass
176
-
177
- ClassDefMake.body.append(ast.FunctionDef(name=ClassDefIdentifier
178
- , args=ast.arguments(posonlyargs=[], args=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=keywordArguments_ast_arg, defaults=[])
179
- , body=[ast.Return(value=ast.Call(ClassDef_astNameOrAttribute, args=[], keywords=[keywordArguments_ast_keyword] if keywordArguments_ast_keyword else []))]
180
- , decorator_list=[staticmethodName]
181
- , returns=ClassDef_astNameOrAttribute))
182
-
183
- for attributeIdentifier in list_astDOTClassDefAttributeIdentifier:
184
- for subnode in ast.walk(astDOTClassDef):
185
- if isinstance(subnode, ast.AnnAssign) and isinstance(subnode.target, ast.Name) and subnode.target.id == attributeIdentifier:
186
- attributeAnnotation_ast_expr = Prepend_ast2astClasses(dictionaryOf_astDOTclass).visit(subnode.annotation)
187
- attributeAnnotationAsStr4TypeAliasIdentifier = ''.join([letter for letter in ast.unparse(subnode.annotation).replace('ast','').replace('|','Or') if letter in ascii_letters])
188
- del subnode
189
-
190
- if attributeIdentifier not in attributeIdentifier2Str4TypeAlias2astAnnotationAndListClassDefIdentifier:
191
- attributeIdentifier2Str4TypeAlias2astAnnotationAndListClassDefIdentifier[attributeIdentifier] = {}
192
-
193
- if attributeAnnotationAsStr4TypeAliasIdentifier not in attributeIdentifier2Str4TypeAlias2astAnnotationAndListClassDefIdentifier[attributeIdentifier]:
194
- attributeIdentifier2Str4TypeAlias2astAnnotationAndListClassDefIdentifier[attributeIdentifier][attributeAnnotationAsStr4TypeAliasIdentifier] = StuPydTypeSystemFromHell(
195
- astAnnotation = attributeAnnotation_ast_expr,
196
- listClassDefIdentifier = [ClassDefIdentifier]
197
- )
198
- else:
199
- attributeIdentifier2Str4TypeAlias2astAnnotationAndListClassDefIdentifier[attributeIdentifier][attributeAnnotationAsStr4TypeAliasIdentifier]['listClassDefIdentifier'].append(ClassDefIdentifier)
200
-
201
- append2args = None
202
- match ClassDefIdentifier:
203
- case 'Attribute':
204
- if cast(ast.FunctionDef, ClassDefMake.body[-1]).name == ClassDefIdentifier:
205
- ClassDefMake.body.pop(-1)
206
- ClassDefMake.body.append(MakeAttributeFunctionDef)
207
- continue
208
- case 'Import':
209
- if cast(ast.FunctionDef, ClassDefMake.body[-1]).name == ClassDefIdentifier:
210
- ClassDefMake.body.pop(-1)
211
- ClassDefMake.body.append(MakeImportFunctionDef)
212
- continue
213
- case _:
214
- pass
215
-
216
- match attributeIdentifier:
217
- case 'args':
218
- if 'list' in attributeAnnotationAsStr4TypeAliasIdentifier:
219
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.List([]))
220
- if 'expr' in attributeAnnotationAsStr4TypeAliasIdentifier:
221
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
222
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
223
-
224
- case 'argtypes':
225
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
226
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
227
- case 'asname':
228
- attributeIdentifier = 'asName'
229
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.Constant(None))
230
- case 'bases':
231
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.List([]))
232
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
233
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
234
- case 'body':
235
- if 'list' in attributeAnnotationAsStr4TypeAliasIdentifier:
236
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
237
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
238
- case 'comparators':
239
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
240
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
241
- case 'ctx':
242
- attributeIdentifier = 'context'
243
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.Call(ast.Attribute(ast.Name('ast', ctx=ast.Load()), attr='Load', ctx=ast.Load())))
244
- case 'decorator_list':
245
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.List([]))
246
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
247
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
248
- case 'defaults':
249
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.List([]))
250
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
251
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
252
- case 'elts':
253
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
254
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
255
- case 'finalbody':
256
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
257
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
258
- case 'func':
259
- attributeIdentifier = 'callee'
260
- case 'ifs':
261
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
262
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
263
- case 'keys':
264
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
265
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
266
- case 'kind':
267
- cast(ast.arg, cast(ast.FunctionDef, ClassDefMake.body[-1]).args.kwarg).annotation = ast.Name('intORstr', ctx=ast.Load())
268
- continue
269
- case 'keywords':
270
- attributeIdentifier = 'list_keyword'
271
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.List([]))
272
- case 'kw_defaults':
273
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.List([ast.Constant(None)]))
274
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
275
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
276
- case 'kwarg':
277
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.Constant(None))
278
- case 'kwd_patterns':
279
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
280
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
281
- case 'kwonlyargs':
282
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.List([]))
283
- case 'level':
284
- cast(ast.Call, cast(ast.Return, cast(ast.FunctionDef, ClassDefMake.body[-1]).body[0]).value).keywords.append(ast.keyword(attributeIdentifier, ast.Constant(0)))
285
- continue
286
- case 'names':
287
- if ClassDefIdentifier == 'ImportFrom':
288
- attributeIdentifier = 'list_alias'
289
- case 'ops':
290
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
291
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
292
- case 'orelse':
293
- attributeIdentifier = 'orElse'
294
- if 'list' in attributeAnnotationAsStr4TypeAliasIdentifier:
295
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.List([]))
296
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
297
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
298
- case 'patterns':
299
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
300
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
301
- case 'posonlyargs':
302
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.List([]))
303
- case 'returns':
304
- match ClassDefIdentifier:
305
- case 'FunctionType':
306
- pass
307
- case _:
308
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.Constant(None))
309
- case 'simple':
310
- cast(ast.Call, cast(ast.Return, cast(ast.FunctionDef, ClassDefMake.body[-1]).body[0]).value).keywords.append(ast.keyword(attributeIdentifier
311
- , ast.Call(func=ast.Name('int', ctx=ast.Load()), args=[ast.Call(func=ast.Name('isinstance', ctx=ast.Load()), args=[ast.Name('target', ctx=ast.Load()), ast.Attribute(value=ast.Name('ast', ctx=ast.Load()), attr='Name', ctx=ast.Load())])])))
312
- continue
313
- case 'targets':
314
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
315
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
316
- case 'type_comment':
317
- cast(ast.arg, cast(ast.FunctionDef, ClassDefMake.body[-1]).args.kwarg).annotation = ast.Name('intORstr', ctx=ast.Load())
318
- continue
319
- case 'type_ignores':
320
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.List([]))
321
- case 'type_params':
322
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
323
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
324
- match ClassDefIdentifier:
325
- case 'AsyncFunctionDef' | 'FunctionDef':
326
- cast(ast.arg, cast(ast.FunctionDef, ClassDefMake.body[-1]).args.kwarg).annotation = ast.Name('intORstrORtype_params', ctx=ast.Load())
327
- continue
328
- case 'ClassDef':
329
- cast(ast.arg, cast(ast.FunctionDef, ClassDefMake.body[-1]).args.kwarg).annotation = ast.Name('intORtype_params', ctx=ast.Load())
330
- continue
331
- case _:
332
- pass
333
- case 'values':
334
- cast(ast.Name, cast(ast.Subscript, attributeAnnotation_ast_expr).value).id = 'Sequence'
335
- append2args = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Name(attributeIdentifier, ctx=ast.Load())])
336
- case 'vararg':
337
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.defaults.append(ast.Constant(None))
338
- case _:
339
- pass
340
- if not append2args:
341
- append2args = ast.Name(attributeIdentifier, ctx=ast.Load())
342
- cast(ast.FunctionDef, ClassDefMake.body[-1]).args.args.append(ast.arg(arg=attributeIdentifier, annotation=attributeAnnotation_ast_expr))
343
- cast(ast.Call, cast(ast.Return, cast(ast.FunctionDef, ClassDefMake.body[-1]).body[0]).value).args.append(append2args)
344
-
345
- ClassDefBe.body.sort(key=lambda astFunctionDef: cast(ast.FunctionDef, astFunctionDef).name.lower())
346
- ClassDefMake.body.sort(key=lambda astFunctionDef: cast(ast.FunctionDef, astFunctionDef).name.lower())
347
-
348
- astTypesModule = ast.Module(
349
- body=[ast.Expr(ast.Constant(docstringWarning))
350
- , astImportFromClassNewInPythonVersion
351
- , ast.ImportFrom('typing', [ast.alias('Any'), ast.alias('TypeAlias', 'typing_TypeAlias')], 0)
352
- , ast.Import([ast.alias('ast')])
353
- , *handmadeTypeAlias_astTypes
354
- ]
355
- , type_ignores=[]
356
- )
357
-
358
- listAttributeIdentifier: list[ast_Identifier] = list(attributeIdentifier2Str4TypeAlias2astAnnotationAndListClassDefIdentifier.keys())
359
- listAttributeIdentifier.sort(key=lambda attributeIdentifier: attributeIdentifier.lower())
360
-
361
- for attributeIdentifier in listAttributeIdentifier:
362
- hasDOTIdentifier: ast_Identifier = 'hasDOT' + attributeIdentifier
363
- hasDOTName_Store: ast.Name = ast.Name(hasDOTIdentifier, ast.Store())
364
- hasDOTName_Load: ast.Name = ast.Name(hasDOTIdentifier, ast.Load())
365
- list_hasDOTNameTypeAliasAnnotations: list[ast.Name] = []
366
-
367
- attributeAnnotationUnifiedAsAST = None
368
-
369
- for attributeAnnotationAsStr4TypeAliasIdentifier, puckFython in attributeIdentifier2Str4TypeAlias2astAnnotationAndListClassDefIdentifier[attributeIdentifier].items():
370
- listClassDefIdentifier = puckFython['listClassDefIdentifier']
371
- attributeAnnotationAsAST = puckFython['astAnnotation']
372
- if not attributeAnnotationUnifiedAsAST:
373
- attributeAnnotationUnifiedAsAST = attributeAnnotationAsAST
374
- else:
375
- attributeAnnotationUnifiedAsAST = ast.BinOp(
376
- left=attributeAnnotationUnifiedAsAST,
377
- op=ast.BitOr(),
378
- right=attributeAnnotationAsAST
379
- )
380
-
381
- astAnnAssignValue = dictionaryOf_astDOTclass[listClassDefIdentifier[0]]
382
- if len(listClassDefIdentifier) > 1:
383
- for ClassDefIdentifier in listClassDefIdentifier[1:]:
384
- astAnnAssignValue = ast.BinOp(left=astAnnAssignValue, op=ast.BitOr(), right=dictionaryOf_astDOTclass[ClassDefIdentifier])
385
- if len(attributeIdentifier2Str4TypeAlias2astAnnotationAndListClassDefIdentifier[attributeIdentifier]) == 1:
386
- astTypesModule.body.append(ast.AnnAssign(hasDOTName_Store, typing_TypeAliasName, astAnnAssignValue, 1))
387
- else:
388
- list_hasDOTNameTypeAliasAnnotations.append(ast.Name(hasDOTIdentifier + '_' + attributeAnnotationAsStr4TypeAliasIdentifier.replace('list', 'list_'), ast.Store()))
389
- astTypesModule.body.append(ast.AnnAssign(list_hasDOTNameTypeAliasAnnotations[-1], typing_TypeAliasName, astAnnAssignValue, 1))
390
- ClassDefDOT.body.append(ast.FunctionDef(name=attributeIdentifier
391
- , args=ast.arguments(posonlyargs=[], args=[ast.arg(arg='node', annotation=ast.Name(list_hasDOTNameTypeAliasAnnotations[-1].id, ast.Load()))], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[])
392
- , body=[ast.Expr(value=ast.Constant(value=Ellipsis))]
393
- , decorator_list=[staticmethodName, overloadName]
394
- , returns=attributeAnnotationAsAST
395
- ))
396
-
397
- ClassDefDOT.body.append(ast.FunctionDef(name=attributeIdentifier
398
- , args=ast.arguments(posonlyargs=[], args=[ast.arg(arg='node', annotation=hasDOTName_Load)], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[])
399
- , body=[ast.Return(value=ast.Attribute(value=ast.Name('node', ast.Load()), attr=attributeIdentifier, ctx=ast.Load()))]
400
- , decorator_list=[staticmethodName]
401
- , returns=attributeAnnotationUnifiedAsAST
402
- ))
403
-
404
- ClassDefGrab.body.append(ast.FunctionDef(name=attributeIdentifier + 'Attribute'
405
- , args=ast.arguments(posonlyargs=[]
406
- , args=[ast.arg('action'
407
- , annotation=ast.Subscript(ast.Name('Callable', ast.Load())
408
- , slice=ast.Tuple(elts=[
409
- ast.List(elts=[attributeAnnotationUnifiedAsAST or ast.Name('Any', ast.Load())], ctx=ast.Load())
410
- , attributeAnnotationUnifiedAsAST or ast.Name('Any', ast.Load())]
411
- , ctx=ast.Load()), ctx=ast.Load()))]
412
- , vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[])
413
- , body=[ast.FunctionDef(name='workhorse',
414
- args=ast.arguments(args=[ast.arg('node', hasDOTName_Load)]),
415
- body=[ast.Assign(targets=[ast.Attribute(ast.Name('node', ast.Load()), attr=attributeIdentifier, ctx=ast.Store())],
416
- value=ast.Call(ast.Name('action', ast.Load()), args=[ast.Attribute(ast.Name('node', ast.Load()), attr=attributeIdentifier, ctx=ast.Load())]))
417
- , ast.Return(ast.Name('node', ast.Load()))],
418
- returns=hasDOTName_Load),
419
- ast.Return(ast.Name('workhorse', ctx=ast.Load()))]
420
- , decorator_list=[staticmethodName], type_comment=None
421
- , returns=ast.Subscript(ast.Name('Callable', ast.Load()), ast.Tuple([ast.List([hasDOTName_Load], ast.Load()), hasDOTName_Load], ast.Load()), ast.Load())))
422
-
423
- # `astTypesModule`: When one attribute has multiple return types
424
- if list_hasDOTNameTypeAliasAnnotations:
425
- astAnnAssignValue = list_hasDOTNameTypeAliasAnnotations[0]
426
- for index in range(1, len(list_hasDOTNameTypeAliasAnnotations)):
427
- astAnnAssignValue = ast.BinOp(left=astAnnAssignValue, op=ast.BitOr(), right=list_hasDOTNameTypeAliasAnnotations[index])
428
- astTypesModule.body.append(ast.AnnAssign(hasDOTName_Store, typing_TypeAliasName, astAnnAssignValue, 1))
429
-
430
- writeModule(astTypesModule, '_astTypes')
431
-
432
- ClassDefBe.body.insert(0, ast.Expr(value=ast.Constant(value=ClassDefDocstringBe)))
433
- ClassDefDOT.body.insert(0, ast.Expr(value=ast.Constant(value=ClassDefDocstringDOT)))
434
- ClassDefGrab.body.insert(0, ast.Expr(value=ast.Constant(value=ClassDefDocstringGrab)))
435
- ClassDefMake.body.insert(0, ast.Expr(value=ast.Constant(value=ClassDefDocstringMake)))
436
-
437
- ClassDefGrab.body.extend(handmadeMethodsGrab)
438
-
439
- writeModule(ast.Module(
440
- body=[ast.Expr(ast.Constant(docstringWarning))
441
- , astImportFromClassNewInPythonVersion
442
- , ast.ImportFrom('typing', [ast.alias('TypeGuard')], 0)
443
- , ast.Import([ast.alias('ast')])
444
- , ClassDefBe
445
- ],
446
- type_ignores=[]
447
- )
448
- , moduleIdentifierPrefix + ClassDefBe.name)
449
-
450
- writeModule(ast.Module(
451
- body=[ast.Expr(ast.Constant(docstringWarning))
452
- , ast.ImportFrom('collections.abc', [ast.alias('Sequence')], 0)
453
- , astImportFromClassNewInPythonVersion
454
- , ast.ImportFrom('mapFolding.someAssemblyRequired', [ast.alias('ast_Identifier'), ast.alias('ast_expr_Slice')], 0)
455
- , ast.ImportFrom('mapFolding.someAssemblyRequired._astTypes', [ast.alias('*')], 0)
456
- , ast.ImportFrom('typing', [ast.alias(identifier) for identifier in ['Any', 'Literal', 'overload']], 0)
457
- , ast.Import([ast.alias('ast')])
458
- # TODO but idk what
459
- , ast.Expr(ast.Constant('# ruff: noqa: F405'))
460
- , ClassDefDOT
461
- ],
462
- type_ignores=[]
463
- )
464
- , moduleIdentifierPrefix + ClassDefDOT.name)
465
-
466
- writeModule(ast.Module(
467
- body=[ast.Expr(ast.Constant(docstringWarning))
468
- , ast.ImportFrom('collections.abc', [ast.alias('Callable'), ast.alias('Sequence')], 0)
469
- , astImportFromClassNewInPythonVersion
470
- , ast.ImportFrom('mapFolding.someAssemblyRequired', [ast.alias(identifier) for identifier in ['ast_Identifier', 'ast_expr_Slice', 'NodeORattribute', 'ImaCallToName']], 0)
471
- , ast.ImportFrom('mapFolding.someAssemblyRequired._astTypes', [ast.alias('*')], 0)
472
- , ast.ImportFrom('typing', [ast.alias('Any'), ast.alias('Literal')], 0)
473
- , ast.Import([ast.alias('ast')])
474
- # TODO but idk what
475
- , ast.Expr(ast.Constant('# ruff: noqa: F405'))
476
- , ClassDefGrab
477
- ],
478
- type_ignores=[]
479
- )
480
- , moduleIdentifierPrefix + ClassDefGrab.name)
481
-
482
- writeModule(ast.Module(
483
- body=[ast.Expr(ast.Constant(docstringWarning))
484
- , ast.ImportFrom('collections.abc', [ast.alias('Sequence')], 0)
485
- , astImportFromClassNewInPythonVersion
486
- , ast.ImportFrom('mapFolding.someAssemblyRequired', [ast.alias(identifier) for identifier in ['ast_Identifier', 'ast_expr_Slice', 'intORstr', 'intORstrORtype_params', 'intORtype_params', 'str_nameDOTname']], 0)
487
- , ast.ImportFrom('typing', [ast.alias('Any'), ast.alias('Literal')], 0)
488
- , ast.Import([ast.alias('ast')])
489
- , ClassDefMake
490
- ],
491
- type_ignores=[]
492
- )
493
- , moduleIdentifierPrefix + ClassDefMake.name)
@@ -1,63 +0,0 @@
1
- from typing import Any, cast, TypeAlias as typing_TypeAlias
2
- import ast
3
-
4
- astTypes_intORstr: str ="intORstr: typing_TypeAlias = Any"
5
- astTypes_intORstrORtype_params: str ="intORstrORtype_params: typing_TypeAlias = Any"
6
- astTypes_intORtype_params: str ="intORtype_params: typing_TypeAlias = Any"
7
-
8
- handmadeTypeAlias_astTypes: list[ast.AnnAssign] = []
9
- for string in [astTypes_intORstr, astTypes_intORstrORtype_params, astTypes_intORtype_params]:
10
- astModule = ast.parse(string)
11
- for node in ast.iter_child_nodes(astModule):
12
- if isinstance(node, ast.AnnAssign):
13
- handmadeTypeAlias_astTypes.append(node)
14
-
15
- Grab_andDoAllOf: str ="""@staticmethod
16
- def andDoAllOf(listOfActions: list[Callable[[NodeORattribute], NodeORattribute]]) -> Callable[[NodeORattribute], NodeORattribute]:
17
- def workhorse(node: NodeORattribute) -> NodeORattribute:
18
- for action in listOfActions:
19
- node = action(node)
20
- return node
21
- return workhorse
22
- """
23
-
24
- Grab_funcDOTidAttribute: str ="""@staticmethod
25
- def funcDOTidAttribute(action: Callable[[ast_Identifier], Any]) -> Callable[[ImaCallToName], ImaCallToName]:
26
- def workhorse(node: ImaCallToName) -> ImaCallToName:
27
- node.func = Grab.idAttribute(action)(node.func)
28
- return node
29
- return workhorse
30
- """
31
-
32
- handmadeMethodsGrab: list[ast.FunctionDef] = []
33
- for string in [Grab_andDoAllOf, Grab_funcDOTidAttribute]:
34
- astModule = ast.parse(string)
35
- for node in ast.iter_child_nodes(astModule):
36
- if isinstance(node, ast.FunctionDef):
37
- handmadeMethodsGrab.append(node)
38
-
39
- MakeAttributeFunctionDef: ast.FunctionDef = ast.FunctionDef(
40
- name='Attribute',
41
- args=ast.arguments(args=[ast.arg(arg='value', annotation=ast.Attribute(value=ast.Name(id='ast', ctx=ast.Load()), attr='expr', ctx=ast.Load()))], vararg=ast.arg(arg='attribute', annotation=ast.Name(id='ast_Identifier', ctx=ast.Load())), kwonlyargs=[ast.arg(arg='context', annotation=ast.Attribute(value=ast.Name(id='ast', ctx=ast.Load()), attr='expr_context', ctx=ast.Load()))], kw_defaults=[ast.Call(func=ast.Attribute(value=ast.Name(id='ast', ctx=ast.Load()), attr='Load', ctx=ast.Load()))], kwarg=ast.arg(arg='keywordArguments', annotation=ast.Name(id='int', ctx=ast.Load()))),
42
- body=[
43
- ast.Expr(value=ast.Constant(value=' If two `ast_Identifier` are joined by a dot `.`, they are _usually_ an `ast.Attribute`, but see `ast.ImportFrom`.\n\tParameters:\n\t\tvalue: the part before the dot (e.g., `ast.Name`.)\n\t\tattribute: an `ast_Identifier` after a dot `.`; you can pass multiple `attribute` and they will be chained together.\n\t')),
44
- ast.FunctionDef(
45
- name='addDOTattribute',
46
- args=ast.arguments(args=[ast.arg(arg='chain', annotation=ast.Attribute(value=ast.Name(id='ast', ctx=ast.Load()), attr='expr', ctx=ast.Load())), ast.arg(arg='identifier', annotation=ast.Name(id='ast_Identifier', ctx=ast.Load())), ast.arg(arg='context', annotation=ast.Attribute(value=ast.Name(id='ast', ctx=ast.Load()), attr='expr_context', ctx=ast.Load()))], kwarg=ast.arg(arg='keywordArguments', annotation=ast.Name(id='int', ctx=ast.Load()))),
47
- body=[ast.Return(value=ast.Call(func=ast.Attribute(value=ast.Name(id='ast', ctx=ast.Load()), attr='Attribute', ctx=ast.Load()), keywords=[ast.keyword(arg='value', value=ast.Name(id='chain', ctx=ast.Load())), ast.keyword(arg='attr', value=ast.Name(id='identifier', ctx=ast.Load())), ast.keyword(arg='ctx', value=ast.Name(id='context', ctx=ast.Load())), ast.keyword(value=ast.Name(id='keywordArguments', ctx=ast.Load()))]))],
48
- returns=ast.Attribute(value=ast.Name(id='ast', ctx=ast.Load()), attr='Attribute', ctx=ast.Load())),
49
- ast.Assign(targets=[ast.Name(id='buffaloBuffalo', ctx=ast.Store())], value=ast.Call(func=ast.Name(id='addDOTattribute', ctx=ast.Load()), args=[ast.Name(id='value', ctx=ast.Load()), ast.Subscript(value=ast.Name(id='attribute', ctx=ast.Load()), slice=ast.Constant(value=0), ctx=ast.Load()), ast.Name(id='context', ctx=ast.Load())], keywords=[ast.keyword(value=ast.Name(id='keywordArguments', ctx=ast.Load()))])),
50
- ast.For(target=ast.Name(id='identifier', ctx=ast.Store()), iter=ast.Subscript(value=ast.Name(id='attribute', ctx=ast.Load()), slice=ast.Slice(lower=ast.Constant(value=1), upper=ast.Constant(value=None)), ctx=ast.Load()),
51
- body=[ast.Assign(targets=[ast.Name(id='buffaloBuffalo', ctx=ast.Store())], value=ast.Call(func=ast.Name(id='addDOTattribute', ctx=ast.Load()), args=[ast.Name(id='buffaloBuffalo', ctx=ast.Load()), ast.Name(id='identifier', ctx=ast.Load()), ast.Name(id='context', ctx=ast.Load())], keywords=[ast.keyword(value=ast.Name(id='keywordArguments', ctx=ast.Load()))]))]),
52
- ast.Return(value=ast.Name(id='buffaloBuffalo', ctx=ast.Load()))],
53
- decorator_list=[ast.Name(id='staticmethod', ctx=ast.Load())],
54
- returns=ast.Attribute(value=ast.Name(id='ast', ctx=ast.Load()), attr='Attribute', ctx=ast.Load()))
55
-
56
- MakeImportFunctionDef: ast.FunctionDef = ast.FunctionDef(name='Import', args=ast.arguments(args=[ast.arg(arg='moduleWithLogicalPath', annotation=ast.Name(id='str_nameDOTname', ctx=ast.Load())), ast.arg(arg='asName', annotation=ast.BinOp(left=ast.Name(id='ast_Identifier', ctx=ast.Load()), op=ast.BitOr(), right=ast.Constant(value=None)))], kwarg=ast.arg(arg='keywordArguments', annotation=ast.Name(id='int', ctx=ast.Load())), defaults=[ast.Constant(value=None)]), body=[ast.Return(value=ast.Call(func=ast.Attribute(value=ast.Name(id='ast', ctx=ast.Load()), attr='Import', ctx=ast.Load()), keywords=[ast.keyword(arg='names', value=ast.List(elts=[ast.Call(func=ast.Attribute(value=ast.Name(id='Make', ctx=ast.Load()), attr='alias', ctx=ast.Load()), args=[ast.Name(id='moduleWithLogicalPath', ctx=ast.Load()), ast.Name(id='asName', ctx=ast.Load())])], ctx=ast.Load())), ast.keyword(value=ast.Name(id='keywordArguments', ctx=ast.Load()))]))], decorator_list=[ast.Name(id='staticmethod', ctx=ast.Load())], returns=ast.Attribute(value=ast.Name(id='ast', ctx=ast.Load()), attr='Import', ctx=ast.Load()))
57
-
58
- # ww='''
59
- # list(targets)
60
- # '''
61
-
62
- # print(ast.dump(ast.parse(ww), indent=4))
63
- # from ast import *
@@ -1,63 +0,0 @@
1
- docstringWarning: str = """This file is generated automatically, so changes to this file will be lost."""
2
-
3
- ClassDefDocstringBe: str = (
4
- """
5
- Provide type-guard functions for safely verifying AST node types during manipulation.
6
-
7
- The be class contains static methods that perform runtime type verification of AST nodes, returning TypeGuard
8
- results that enable static type checkers to narrow node types in conditional branches. These type-guards:
9
-
10
- 1. Improve code safety by preventing operations on incompatible node types.
11
- 2. Enable IDE tooling to provide better autocompletion and error detection.
12
- 3. Document expected node types in a way that is enforced by the type system.
13
- 4. Support pattern-matching workflows where node types must be verified before access.
14
-
15
- When used with conditional statements, these type-guards allow for precise, type-safe manipulation of AST nodes
16
- while maintaining full static type checking capabilities, even in complex transformation scenarios.
17
- """
18
- )
19
-
20
- ClassDefDocstringDOT: str = (
21
- """
22
- Access attributes and sub-nodes of AST elements via consistent accessor methods.
23
-
24
- The DOT class provides static methods to access specific attributes of different types of AST nodes in a consistent
25
- way. This simplifies attribute access across various node types and improves code readability by abstracting the
26
- underlying AST structure details.
27
-
28
- DOT is designed for safe, read-only access to node properties, unlike the grab class which is designed for modifying
29
- node attributes.
30
- """
31
- )
32
-
33
- ClassDefDocstringGrab: str = (
34
- """
35
- Modify specific attributes of AST nodes while preserving the node structure.
36
-
37
- The grab class provides static methods that create transformation functions to modify specific attributes of AST
38
- nodes. Unlike DOT which provides read-only access, grab allows for targeted modifications of node attributes without
39
- replacing the entire node.
40
-
41
- Each method returns a function that takes a node, applies a transformation to a specific attribute of that node, and
42
- returns the modified node. This enables fine-grained control when transforming AST structures.
43
- """
44
- )
45
-
46
- ClassDefDocstringMake: str = (
47
- """
48
- Almost all parameters described here are only accessible through a method's `**keywordArguments` parameter.
49
-
50
- Parameters:
51
- context (ast.Load()): Are you loading from, storing to, or deleting the identifier? The `context` (also, `ctx`) value is `ast.Load()`, `ast.Store()`, or `ast.Del()`.
52
- col_offset (0): int Position information specifying the column where an AST node begins.
53
- end_col_offset (None): int|None Position information specifying the column where an AST node ends.
54
- end_lineno (None): int|None Position information specifying the line number where an AST node ends.
55
- level (0): int Module import depth level that controls relative vs absolute imports. Default 0 indicates absolute import.
56
- lineno: int Position information manually specifying the line number where an AST node begins.
57
- kind (None): str|None Used for type annotations in limited cases.
58
- type_comment (None): str|None "type_comment is an optional string with the type annotation as a comment." or `# type: ignore`.
59
- type_params: list[ast.type_param] Type parameters for generic type definitions.
60
-
61
- The `ast._Attributes`, lineno, col_offset, end_lineno, and end_col_offset, hold position information; however, they are, importantly, _not_ `ast._fields`.
62
- """
63
- )