mapFolding 0.9.4__py3-none-any.whl → 0.10.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 (42) hide show
  1. mapFolding/__init__.py +41 -7
  2. mapFolding/basecamp.py +100 -9
  3. mapFolding/beDRY.py +7 -15
  4. mapFolding/dataBaskets.py +12 -0
  5. mapFolding/datatypes.py +4 -4
  6. mapFolding/oeis.py +2 -7
  7. mapFolding/someAssemblyRequired/RecipeJob.py +97 -3
  8. mapFolding/someAssemblyRequired/Z0Z_makeSomeModules.py +143 -42
  9. mapFolding/someAssemblyRequired/__init__.py +38 -49
  10. mapFolding/someAssemblyRequired/_astTypes.py +117 -0
  11. mapFolding/someAssemblyRequired/_theTypes.py +12 -41
  12. mapFolding/someAssemblyRequired/_toolBe.py +524 -0
  13. mapFolding/someAssemblyRequired/_toolDOT.py +493 -0
  14. mapFolding/someAssemblyRequired/_toolGrab.py +653 -0
  15. mapFolding/someAssemblyRequired/_toolIfThis.py +193 -0
  16. mapFolding/someAssemblyRequired/_toolMake.py +339 -0
  17. mapFolding/someAssemblyRequired/_toolThen.py +63 -0
  18. mapFolding/someAssemblyRequired/_toolboxAST.py +3 -3
  19. mapFolding/someAssemblyRequired/_toolboxContainers.py +124 -29
  20. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +274 -0
  21. mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +12 -11
  22. mapFolding/someAssemblyRequired/toolboxNumba.py +4 -28
  23. mapFolding/someAssemblyRequired/transformationTools.py +46 -155
  24. mapFolding/syntheticModules/daoOfMapFolding.py +74 -0
  25. mapFolding/syntheticModules/dataPacking.py +1 -1
  26. mapFolding/syntheticModules/theorem2Numba.py +2 -8
  27. mapFolding/syntheticModules/theorem2Trimmed.py +43 -0
  28. mapFolding/toolFactory/astFactory.py +493 -0
  29. mapFolding/toolFactory/astFactory_annex.py +63 -0
  30. mapFolding/toolFactory/astFactory_docstrings.py +63 -0
  31. {mapfolding-0.9.4.dist-info → mapfolding-0.10.0.dist-info}/METADATA +2 -1
  32. mapfolding-0.10.0.dist-info/RECORD +66 -0
  33. {mapfolding-0.9.4.dist-info → mapfolding-0.10.0.dist-info}/WHEEL +1 -1
  34. tests/test_computations.py +1 -1
  35. mapFolding/Z0Z_flowControl.py +0 -117
  36. mapFolding/someAssemblyRequired/_tool_Make.py +0 -134
  37. mapFolding/someAssemblyRequired/_tool_Then.py +0 -157
  38. mapFolding/someAssemblyRequired/_toolboxAntecedents.py +0 -387
  39. mapfolding-0.9.4.dist-info/RECORD +0 -57
  40. {mapfolding-0.9.4.dist-info → mapfolding-0.10.0.dist-info}/entry_points.txt +0 -0
  41. {mapfolding-0.9.4.dist-info → mapfolding-0.10.0.dist-info}/licenses/LICENSE +0 -0
  42. {mapfolding-0.9.4.dist-info → mapfolding-0.10.0.dist-info}/top_level.txt +0 -0
@@ -2,11 +2,11 @@ from mapFolding import raiseIfNoneGitHubIssueNumber3, The
2
2
  from mapFolding.someAssemblyRequired import (
3
3
  ast_Identifier,
4
4
  astModuleToIngredientsFunction,
5
- be,
5
+ Be,
6
6
  DOT,
7
7
  extractFunctionDef,
8
- grab,
9
- ifThis,
8
+ Grab,
9
+ IfThis,
10
10
  IngredientsFunction,
11
11
  IngredientsModule,
12
12
  LedgerOfImports,
@@ -35,7 +35,7 @@ sourceCallableIdentifierHARDCODED = 'count'
35
35
  logicalPathInfixHARDCODED: ast_Identifier = 'syntheticModules'
36
36
  theCountingIdentifierHARDCODED: ast_Identifier = 'groupsOfFolds'
37
37
 
38
- def makeInitializeGroupsOfFolds():
38
+ def makeInitializeGroupsOfFolds() -> None:
39
39
  callableIdentifierHARDCODED = 'initializeGroupsOfFolds'
40
40
  moduleIdentifierHARDCODED: ast_Identifier = 'initializeCount'
41
41
 
@@ -53,24 +53,93 @@ def makeInitializeGroupsOfFolds():
53
53
 
54
54
  countInitializeIngredients.astFunctionDef.name = callableIdentifier
55
55
 
56
- dataclassInstanceIdentifier = NodeTourist(be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countInitializeIngredients.astFunctionDef)
56
+ dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countInitializeIngredients.astFunctionDef)
57
57
  if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
58
58
  theCountingIdentifier = theCountingIdentifierHARDCODED
59
59
 
60
- findThis = ifThis.isWhileAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
61
- doThat = grab.testAttribute(grab.andDoAllOf([
62
- grab.opsAttribute(Then.replaceWith([ast.Eq()])), # type: ignore
63
- grab.leftAttribute(grab.attrAttribute(Then.replaceWith(theCountingIdentifier))) # type: ignore
60
+ findThis = IfThis.isWhileAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
61
+ doThat = Grab.testAttribute(Grab.andDoAllOf([
62
+ Grab.opsAttribute(Then.replaceWith([ast.Eq()])), # type: ignore
63
+ Grab.leftAttribute(Grab.attrAttribute(Then.replaceWith(theCountingIdentifier))) # type: ignore
64
64
  ]))
65
65
  NodeChanger(findThis, doThat).visit(countInitializeIngredients.astFunctionDef.body[0])
66
66
 
67
- initializationModule = IngredientsModule(countInitializeIngredients)
67
+ ingredientsModule = IngredientsModule(countInitializeIngredients)
68
68
 
69
69
  pathFilename = PurePath(The.pathPackage, logicalPathInfix, moduleIdentifier + The.fileExtension)
70
70
 
71
- write_astModule(initializationModule, pathFilename, The.packageName)
71
+ write_astModule(ingredientsModule, pathFilename, The.packageName)
72
72
 
73
- def makeTheorem2():
73
+ def makeDaoOfMapFolding() -> PurePath:
74
+ moduleIdentifierHARDCODED: ast_Identifier = 'daoOfMapFolding'
75
+
76
+ algorithmSourceModule = algorithmSourceModuleHARDCODED
77
+ sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
78
+ logicalPathSourceModule = '.'.join([The.packageName, algorithmSourceModule])
79
+
80
+ logicalPathInfix = logicalPathInfixHARDCODED
81
+ moduleIdentifier = moduleIdentifierHARDCODED
82
+
83
+ astModule = parseLogicalPath2astModule(logicalPathSourceModule)
84
+ daoOfMapFolding = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule)
85
+ , LedgerOfImports(astModule))
86
+
87
+ dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(daoOfMapFolding.astFunctionDef)
88
+ if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
89
+ dataclass_Identifier: ast_Identifier | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
90
+ if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
91
+
92
+ dataclassLogicalPathModule = None
93
+ for moduleWithLogicalPath, listNameTuples in daoOfMapFolding.imports.dictionaryImportFrom.items():
94
+ for nameTuple in listNameTuples:
95
+ if nameTuple[0] == dataclass_Identifier:
96
+ dataclassLogicalPathModule = moduleWithLogicalPath
97
+ break
98
+ if dataclassLogicalPathModule:
99
+ break
100
+ if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
101
+ dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(daoOfMapFolding.astFunctionDef)
102
+ if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
103
+ shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
104
+
105
+ # theCountingIdentifier = theCountingIdentifierHARDCODED
106
+ # doubleTheCount = Make.AugAssign(Make.Attribute(ast.Name(dataclassInstanceIdentifier), theCountingIdentifier), ast.Mult(), Make.Constant(2))
107
+ # findThis = be.Return
108
+ # doThat = Then.insertThisAbove([doubleTheCount])
109
+ # NodeChanger(findThis, doThat).visit(daoOfMapFolding.astFunctionDef)
110
+
111
+ daoOfMapFolding.imports.update(shatteredDataclass.imports)
112
+ daoOfMapFolding = removeDataclassFromFunction(daoOfMapFolding, shatteredDataclass)
113
+
114
+ daoOfMapFolding = removeUnusedParameters(daoOfMapFolding)
115
+
116
+ daoOfMapFolding = decorateCallableWithNumba(daoOfMapFolding, parametersNumbaLight)
117
+
118
+ sourceCallableIdentifier = The.sourceCallableDispatcher
119
+
120
+ doTheNeedful: IngredientsFunction = astModuleToIngredientsFunction(astModule, sourceCallableIdentifier)
121
+ doTheNeedful.imports.update(shatteredDataclass.imports)
122
+ targetCallableIdentifier = daoOfMapFolding.astFunctionDef.name
123
+ doTheNeedful = unpackDataclassCallFunctionRepackDataclass(doTheNeedful, targetCallableIdentifier, shatteredDataclass)
124
+ astTuple: ast.Tuple | None = NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(daoOfMapFolding.astFunctionDef)
125
+ if astTuple is None: raise raiseIfNoneGitHubIssueNumber3
126
+ astTuple.ctx = ast.Store()
127
+
128
+ findThis = IfThis.isAssignAndValueIs(IfThis.isCall_Identifier(targetCallableIdentifier))
129
+ doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
130
+ changeAssignCallToTarget = NodeChanger(findThis, doThat)
131
+ changeAssignCallToTarget.visit(doTheNeedful.astFunctionDef)
132
+
133
+ ingredientsModule = IngredientsModule([daoOfMapFolding, doTheNeedful])
134
+ ingredientsModule.removeImportFromModule('numpy')
135
+
136
+ pathFilename = PurePath(The.pathPackage, logicalPathInfix, moduleIdentifier + The.fileExtension)
137
+
138
+ write_astModule(ingredientsModule, pathFilename, The.packageName)
139
+
140
+ return pathFilename
141
+
142
+ def makeTheorem2() -> PurePath:
74
143
  moduleIdentifierHARDCODED: ast_Identifier = 'theorem2'
75
144
 
76
145
  algorithmSourceModule = algorithmSourceModuleHARDCODED
@@ -84,49 +153,80 @@ def makeTheorem2():
84
153
  countTheorem2 = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule)
85
154
  , LedgerOfImports(astModule))
86
155
 
87
- dataclassInstanceIdentifier = NodeTourist(be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countTheorem2.astFunctionDef)
156
+ dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countTheorem2.astFunctionDef)
88
157
  if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
89
158
 
90
- findThis = ifThis.isWhileAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
91
- doThat = grab.testAttribute(grab.comparatorsAttribute(Then.replaceWith([Make.Constant(4)]))) # type: ignore
159
+ findThis = IfThis.isWhileAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
160
+ doThat = Grab.testAttribute(Grab.comparatorsAttribute(Then.replaceWith([Make.Constant(4)]))) # type: ignore
92
161
  NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
93
162
 
94
- findThis = ifThis.isIfAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
163
+ findThis = IfThis.isIfAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
95
164
  doThat = Then.extractIt(DOT.body)
96
165
  insertLeaf = NodeTourist(findThis, doThat).captureLastMatch(countTheorem2.astFunctionDef)
97
- findThis = ifThis.isIfAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
166
+ findThis = IfThis.isIfAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
98
167
  doThat = Then.replaceWith(insertLeaf)
99
168
  NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
100
169
 
101
- findThis = ifThis.isAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
170
+ findThis = IfThis.isAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
102
171
  doThat = Then.removeIt
103
172
  NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
104
173
 
105
- findThis = ifThis.isAttributeNamespace_IdentifierLessThanOrEqual(dataclassInstanceIdentifier, 'leaf1ndex')
174
+ findThis = IfThis.isAttributeNamespace_IdentifierLessThanOrEqual(dataclassInstanceIdentifier, 'leaf1ndex')
106
175
  doThat = Then.removeIt
107
176
  NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
108
177
 
109
178
  theCountingIdentifier = theCountingIdentifierHARDCODED
110
179
  doubleTheCount = Make.AugAssign(Make.Attribute(ast.Name(dataclassInstanceIdentifier), theCountingIdentifier), ast.Mult(), Make.Constant(2))
111
- findThis = be.Return
180
+ findThis = Be.Return
112
181
  doThat = Then.insertThisAbove([doubleTheCount])
113
182
  NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
114
183
 
115
- moduleTheorem2 = IngredientsModule(countTheorem2)
184
+ ingredientsModule = IngredientsModule(countTheorem2)
116
185
 
117
186
  pathFilename = PurePath(The.pathPackage, logicalPathInfix, moduleIdentifier + The.fileExtension)
118
187
 
119
- write_astModule(moduleTheorem2, pathFilename, The.packageName)
188
+ write_astModule(ingredientsModule, pathFilename, The.packageName)
189
+
190
+ return pathFilename
191
+
192
+ def trimTheorem2(pathFilenameSource: PurePath) -> PurePath:
193
+ logicalPathInfix = logicalPathInfixHARDCODED
194
+ sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
195
+ ingredientsFunction = astModuleToIngredientsFunction(parsePathFilename2astModule(pathFilenameSource), sourceCallableIdentifier)
196
+
197
+ dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
198
+ if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
199
+
200
+ findThis = IfThis.isIfUnaryNotAttributeNamespace_Identifier(dataclassInstanceIdentifier, 'dimensionsUnconstrained')
201
+ doThat = Then.removeIt
202
+ NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
203
+
204
+ ingredientsModule = IngredientsModule(ingredientsFunction)
205
+ ingredientsModule.removeImportFromModule('numpy')
206
+
207
+ pathFilename = pathFilenameSource.with_stem(pathFilenameSource.stem + 'Trimmed')
208
+
209
+ write_astModule(ingredientsModule, pathFilename, The.packageName)
210
+
211
+ logicalPath: list[str] = []
212
+ if The.packageName:
213
+ logicalPath.append(The.packageName)
214
+ if logicalPathInfix:
215
+ logicalPath.append(logicalPathInfix)
216
+ logicalPath.append(pathFilename.stem)
217
+ moduleWithLogicalPath: str_nameDOTname = '.'.join(logicalPath)
218
+
219
+ astImportFrom: ast.ImportFrom = Make.ImportFrom(moduleWithLogicalPath, list_alias=[Make.alias(ingredientsFunction.astFunctionDef.name)])
120
220
 
121
221
  return pathFilename
122
222
 
123
- def numbaOnTheorem2(pathFilenameSource: PurePath):
223
+ def numbaOnTheorem2(pathFilenameSource: PurePath) -> ast.ImportFrom:
124
224
  logicalPathInfix = logicalPathInfixHARDCODED
125
225
  sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
126
226
  countNumbaTheorem2 = astModuleToIngredientsFunction(parsePathFilename2astModule(pathFilenameSource), sourceCallableIdentifier)
127
- dataclassName: ast.expr | None = NodeTourist(be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(countNumbaTheorem2.astFunctionDef)
227
+ dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(countNumbaTheorem2.astFunctionDef)
128
228
  if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
129
- dataclass_Identifier: ast_Identifier | None = NodeTourist(be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
229
+ dataclass_Identifier: ast_Identifier | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
130
230
  if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
131
231
 
132
232
  dataclassLogicalPathModule = None
@@ -138,7 +238,7 @@ def numbaOnTheorem2(pathFilenameSource: PurePath):
138
238
  if dataclassLogicalPathModule:
139
239
  break
140
240
  if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
141
- dataclassInstanceIdentifier = NodeTourist(be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countNumbaTheorem2.astFunctionDef)
241
+ dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countNumbaTheorem2.astFunctionDef)
142
242
  if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
143
243
  shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
144
244
 
@@ -149,12 +249,12 @@ def numbaOnTheorem2(pathFilenameSource: PurePath):
149
249
 
150
250
  countNumbaTheorem2 = decorateCallableWithNumba(countNumbaTheorem2, parametersNumbaLight)
151
251
 
152
- moduleNumbaTheorem2 = IngredientsModule(countNumbaTheorem2)
153
- moduleNumbaTheorem2.removeImportFromModule('numpy')
252
+ ingredientsModule = IngredientsModule(countNumbaTheorem2)
253
+ ingredientsModule.removeImportFromModule('numpy')
154
254
 
155
- pathFilename = pathFilenameSource.with_stem(pathFilenameSource.stem + 'Numba')
255
+ pathFilename = pathFilenameSource.with_stem(pathFilenameSource.stem.replace('Trimmed', '') + 'Numba')
156
256
 
157
- write_astModule(moduleNumbaTheorem2, pathFilename, The.packageName)
257
+ write_astModule(ingredientsModule, pathFilename, The.packageName)
158
258
 
159
259
  logicalPath: list[str] = []
160
260
  if The.packageName:
@@ -164,25 +264,24 @@ def numbaOnTheorem2(pathFilenameSource: PurePath):
164
264
  logicalPath.append(pathFilename.stem)
165
265
  moduleWithLogicalPath: str_nameDOTname = '.'.join(logicalPath)
166
266
 
167
- astImportFrom: ast.ImportFrom = Make.ImportFrom(moduleWithLogicalPath, list_astAlias=[Make.alias(countNumbaTheorem2.astFunctionDef.name)])
267
+ astImportFrom: ast.ImportFrom = Make.ImportFrom(moduleWithLogicalPath, list_alias=[Make.alias(countNumbaTheorem2.astFunctionDef.name)])
168
268
 
169
269
  return astImportFrom
170
270
 
171
- def makeUnRePackDataclass(astImportFrom: ast.ImportFrom):
271
+ def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
172
272
  moduleIdentifierHARDCODED: ast_Identifier = 'dataPacking'
173
273
 
174
274
  algorithmSourceModule = algorithmSourceModuleHARDCODED
175
275
  sourceCallableIdentifier = The.sourceCallableDispatcher
176
276
  logicalPathSourceModule = '.'.join([The.packageName, algorithmSourceModule])
177
277
 
178
- callableIdentifier = sourceCallableIdentifier
179
278
  logicalPathInfix = logicalPathInfixHARDCODED
180
279
  moduleIdentifier = moduleIdentifierHARDCODED
181
280
 
182
281
  doTheNeedful: IngredientsFunction = astModuleToIngredientsFunction(parseLogicalPath2astModule(logicalPathSourceModule), sourceCallableIdentifier)
183
- dataclassName: ast.expr | None = NodeTourist(be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(doTheNeedful.astFunctionDef)
282
+ dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(doTheNeedful.astFunctionDef)
184
283
  if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
185
- dataclass_Identifier: ast_Identifier | None = NodeTourist(be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
284
+ dataclass_Identifier: ast_Identifier | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
186
285
  if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
187
286
 
188
287
  dataclassLogicalPathModule = None
@@ -194,7 +293,7 @@ def makeUnRePackDataclass(astImportFrom: ast.ImportFrom):
194
293
  if dataclassLogicalPathModule:
195
294
  break
196
295
  if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
197
- dataclassInstanceIdentifier = NodeTourist(be.arg, Then.extractIt(DOT.arg)).captureLastMatch(doTheNeedful.astFunctionDef)
296
+ dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(doTheNeedful.astFunctionDef)
198
297
  if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
199
298
  shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
200
299
 
@@ -204,23 +303,25 @@ def makeUnRePackDataclass(astImportFrom: ast.ImportFrom):
204
303
  doTheNeedful = unpackDataclassCallFunctionRepackDataclass(doTheNeedful, targetCallableIdentifier, shatteredDataclass)
205
304
  targetFunctionDef = extractFunctionDef(parseLogicalPath2astModule(astImportFrom.module), targetCallableIdentifier) # type: ignore
206
305
  if targetFunctionDef is None: raise raiseIfNoneGitHubIssueNumber3
207
- astTuple: ast.Tuple | None = NodeTourist(be.Return, Then.extractIt(DOT.value)).captureLastMatch(targetFunctionDef)
306
+ astTuple: ast.Tuple | None = NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(targetFunctionDef)
208
307
  if astTuple is None: raise raiseIfNoneGitHubIssueNumber3
209
308
  astTuple.ctx = ast.Store()
210
309
 
211
- findThis = ifThis.isAssignAndValueIs(ifThis.isCall_Identifier(targetCallableIdentifier))
212
- doThat = Then.replaceWith(Make.Assign(listTargets=[astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
310
+ findThis = IfThis.isAssignAndValueIs(IfThis.isCall_Identifier(targetCallableIdentifier))
311
+ doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
213
312
  NodeChanger(findThis, doThat).visit(doTheNeedful.astFunctionDef)
214
313
 
215
- moduleDoTheNeedful = IngredientsModule(doTheNeedful)
216
- moduleDoTheNeedful.removeImportFromModule('numpy')
314
+ ingredientsModule = IngredientsModule(doTheNeedful)
315
+ ingredientsModule.removeImportFromModule('numpy')
217
316
 
218
317
  pathFilename = PurePath(The.pathPackage, logicalPathInfix, moduleIdentifier + The.fileExtension)
219
318
 
220
- write_astModule(moduleDoTheNeedful, pathFilename, The.packageName)
319
+ write_astModule(ingredientsModule, pathFilename, The.packageName)
221
320
 
222
321
  if __name__ == '__main__':
223
322
  makeInitializeGroupsOfFolds()
224
323
  pathFilename = makeTheorem2()
324
+ pathFilename = trimTheorem2(pathFilename)
225
325
  astImportFrom = numbaOnTheorem2(pathFilename)
226
326
  makeUnRePackDataclass(astImportFrom)
327
+ makeDaoOfMapFolding()
@@ -1,75 +1,59 @@
1
1
  """
2
2
  Code Transformation Framework for Algorithm Optimization and Testing
3
3
 
4
- This package implements a comprehensive framework for programmatically analyzing,
5
- transforming, and generating optimized Python code. It serves as the algorithmic
6
- optimization engine for the mapFolding package, enabling the conversion of readable,
7
- functional implementations into highly-optimized variants with verified correctness.
4
+ This package implements a comprehensive framework for programmatically analyzing, transforming, and generating optimized
5
+ Python code. It serves as the algorithmic optimization engine for the mapFolding package, enabling the conversion of
6
+ readable, functional implementations into highly-optimized variants with verified correctness.
8
7
 
9
8
  ## Core Architecture Components
10
9
 
11
10
  1. **AST Manipulation Tools**
12
- - Pattern recognition with composable predicates (ifThis)
13
- - Node access with consistent interfaces (DOT)
14
- - AST traversal and transformation (NodeChanger, NodeTourist)
15
- - AST construction with sane defaults (Make)
16
- - Node transformation operations (grab, Then)
11
+ - Pattern recognition with composable predicates (ifThis)
12
+ - Node access with consistent interfaces (DOT)
13
+ - AST traversal and transformation (NodeChanger, NodeTourist)
14
+ - AST construction with sane defaults (Make)
15
+ - Node transformation operations (grab, Then)
17
16
 
18
17
  2. **Container and Organization**
19
- - Import tracking and management (LedgerOfImports)
20
- - Function packaging with dependencies (IngredientsFunction)
21
- - Module assembly with structured components (IngredientsModule)
22
- - Recipe configuration for generating optimized code (RecipeSynthesizeFlow)
23
- - Dataclass decomposition for compatibility (ShatteredDataclass)
18
+ - Import tracking and management (LedgerOfImports)
19
+ - Function packaging with dependencies (IngredientsFunction)
20
+ - Module assembly with structured components (IngredientsModule)
21
+ - Recipe configuration for generating optimized code (RecipeSynthesizeFlow)
22
+ - Dataclass decomposition for compatibility (ShatteredDataclass)
24
23
 
25
24
  3. **Optimization assembly lines**
26
- - General-purpose Numba acceleration (makeNumbaFlow)
27
- - Job-specific optimization for concrete parameters (makeJobNumba)
28
- - Specialized component transformation (decorateCallableWithNumba)
25
+ - General-purpose Numba acceleration (makeNumbaFlow)
26
+ - Job-specific optimization for concrete parameters (makeJobNumba)
27
+ - Specialized component transformation (decorateCallableWithNumba)
29
28
 
30
29
  ## Integration with Testing Framework
31
30
 
32
- The transformation components are extensively tested through the package's test suite,
33
- which provides specialized fixtures and utilities for validating both the transformation
34
- process and the resulting optimized code:
31
+ The transformation components are extensively tested through the package's test suite, which provides specialized
32
+ fixtures and utilities for validating both the transformation process and the resulting optimized code:
35
33
 
36
- - **syntheticDispatcherFixture**: Creates and tests a complete Numba-optimized module
37
- using RecipeSynthesizeFlow configuration
34
+ - **syntheticDispatcherFixture**: Creates and tests a complete Numba-optimized module using RecipeSynthesizeFlow
35
+ configuration
38
36
 
39
37
  - **test_writeJobNumba**: Tests the job-specific optimization process with RecipeJob
40
38
 
41
- These fixtures enable users to test their own custom recipes and job configurations
42
- with minimal effort. See the documentation in tests/__init__.py for details on
43
- extending the test suite for custom implementations.
39
+ These fixtures enable users to test their own custom recipes and job configurations with minimal effort. See the
40
+ documentation in tests/__init__.py for details on extending the test suite for custom implementations.
44
41
 
45
- The framework balances multiple optimization levels - from general algorithmic
46
- improvements to parameter-specific optimizations - while maintaining the ability
47
- to verify correctness at each transformation stage through the integrated test suite.
42
+ The framework balances multiple optimization levels - from general algorithmic improvements to parameter-specific
43
+ optimizations - while maintaining the ability to verify correctness at each transformation stage through the integrated
44
+ test suite.
48
45
  """
49
46
 
50
47
  from mapFolding.someAssemblyRequired._theTypes import (
51
48
  ast_expr_Slice as ast_expr_Slice,
52
49
  ast_Identifier as ast_Identifier,
53
- astClassHasDOTbody as astClassHasDOTbody,
54
- astClassHasDOTbody_expr as astClassHasDOTbody_expr,
55
- astClassHasDOTbodyList_stmt as astClassHasDOTbodyList_stmt,
56
- astClassHasDOTnameNotName as astClassHasDOTnameNotName,
57
- astClassHasDOTnameNotNameAlways as astClassHasDOTnameNotNameAlways,
58
- astClassHasDOTnameNotNameOptionally as astClassHasDOTnameNotNameOptionally,
59
- astClassHasDOTtarget as astClassHasDOTtarget,
60
- astClassHasDOTtarget_expr as astClassHasDOTtarget_expr,
61
- astClassHasDOTtargetAttributeNameSubscript as astClassHasDOTtargetAttributeNameSubscript,
62
- astClassHasDOTvalue as astClassHasDOTvalue,
63
- astClassHasDOTvalue_expr as astClassHasDOTvalue_expr,
64
- astClassHasDOTvalue_exprNone as astClassHasDOTvalue_exprNone,
65
50
  ImaCallToName as ImaCallToName,
66
- intORlist_ast_type_paramORstr_orNone as intORlist_ast_type_paramORstr_orNone,
67
- intORstr_orNone as intORstr_orNone,
68
- list_ast_type_paramORstr_orNone as list_ast_type_paramORstr_orNone,
69
51
  NodeORattribute as NodeORattribute,
70
52
  str_nameDOTname as str_nameDOTname,
71
53
  个 as 个,
72
- )
54
+ )
55
+
56
+ from mapFolding.someAssemblyRequired._astTypes import * # noqa: F403
73
57
 
74
58
  from mapFolding.someAssemblyRequired._toolboxPython import (
75
59
  importLogicalPath2Callable as importLogicalPath2Callable,
@@ -78,13 +62,18 @@ from mapFolding.someAssemblyRequired._toolboxPython import (
78
62
  NodeTourist as NodeTourist,
79
63
  parseLogicalPath2astModule as parseLogicalPath2astModule,
80
64
  parsePathFilename2astModule as parsePathFilename2astModule,
81
- )
65
+ )
82
66
 
83
- from mapFolding.someAssemblyRequired._toolboxAntecedents import be as be, DOT as DOT, ifThis as ifThis
84
- from mapFolding.someAssemblyRequired._tool_Make import Make as Make
85
- from mapFolding.someAssemblyRequired._tool_Then import grab as grab, Then as Then
67
+ from mapFolding.someAssemblyRequired._toolBe import Be as Be
68
+ from mapFolding.someAssemblyRequired._toolDOT import DOT as DOT
69
+ from mapFolding.someAssemblyRequired._toolGrab import Grab as Grab
70
+ from mapFolding.someAssemblyRequired._toolMake import Make as Make
71
+
72
+ from mapFolding.someAssemblyRequired._toolIfThis import IfThis as IfThis
73
+ from mapFolding.someAssemblyRequired._toolThen import Then as Then
86
74
 
87
75
  from mapFolding.someAssemblyRequired._toolboxContainers import (
76
+ DeReConstructField2ast as DeReConstructField2ast,
88
77
  IngredientsFunction as IngredientsFunction,
89
78
  IngredientsModule as IngredientsModule,
90
79
  LedgerOfImports as LedgerOfImports,
@@ -96,4 +85,4 @@ from mapFolding.someAssemblyRequired._toolboxAST import (
96
85
  astModuleToIngredientsFunction as astModuleToIngredientsFunction,
97
86
  extractClassDef as extractClassDef,
98
87
  extractFunctionDef as extractFunctionDef,
99
- )
88
+ )
@@ -0,0 +1,117 @@
1
+ """This file is generated automatically, so changes to this file will be lost."""
2
+ from mapFolding import astDOTParamSpec, astDOTTryStar, astDOTTypeAlias, astDOTTypeVar, astDOTTypeVarTuple, astDOTtype_param
3
+ from typing import Any, TypeAlias as typing_TypeAlias
4
+ import ast
5
+ intORstr: typing_TypeAlias = Any
6
+ intORstrORtype_params: typing_TypeAlias = Any
7
+ intORtype_params: typing_TypeAlias = Any
8
+ hasDOTannotation_expr: typing_TypeAlias = ast.AnnAssign
9
+ hasDOTannotation_exprOrNone: typing_TypeAlias = ast.arg
10
+ hasDOTannotation: typing_TypeAlias = hasDOTannotation_expr | hasDOTannotation_exprOrNone
11
+ hasDOTarg_Identifier: typing_TypeAlias = ast.arg
12
+ hasDOTarg_IdentifierOrNone: typing_TypeAlias = ast.keyword
13
+ hasDOTarg: typing_TypeAlias = hasDOTarg_Identifier | hasDOTarg_IdentifierOrNone
14
+ hasDOTargs_arguments: typing_TypeAlias = ast.FunctionDef | ast.AsyncFunctionDef | ast.Lambda
15
+ hasDOTargs_list_expr: typing_TypeAlias = ast.Call
16
+ hasDOTargs_list_arg: typing_TypeAlias = ast.arguments
17
+ hasDOTargs: typing_TypeAlias = hasDOTargs_arguments | hasDOTargs_list_expr | hasDOTargs_list_arg
18
+ hasDOTargtypes: typing_TypeAlias = ast.FunctionType
19
+ hasDOTasname: typing_TypeAlias = ast.alias
20
+ hasDOTattr: typing_TypeAlias = ast.Attribute
21
+ hasDOTbases: typing_TypeAlias = ast.ClassDef
22
+ hasDOTbody_list_stmt: typing_TypeAlias = ast.Module | ast.Interactive | ast.FunctionDef | ast.AsyncFunctionDef | ast.ClassDef | ast.For | ast.AsyncFor | ast.While | ast.If | ast.With | ast.AsyncWith | ast.Try | ast.ExceptHandler | astDOTTryStar | ast.match_case
23
+ hasDOTbody_expr: typing_TypeAlias = ast.Expression | ast.Lambda | ast.IfExp
24
+ hasDOTbody: typing_TypeAlias = hasDOTbody_list_stmt | hasDOTbody_expr
25
+ hasDOTbound: typing_TypeAlias = astDOTTypeVar
26
+ hasDOTcases: typing_TypeAlias = ast.Match
27
+ hasDOTcause: typing_TypeAlias = ast.Raise
28
+ hasDOTcls: typing_TypeAlias = ast.MatchClass
29
+ hasDOTcomparators: typing_TypeAlias = ast.Compare
30
+ hasDOTcontext_expr: typing_TypeAlias = ast.withitem
31
+ hasDOTconversion: typing_TypeAlias = ast.FormattedValue
32
+ hasDOTctx: typing_TypeAlias = ast.Attribute | ast.Subscript | ast.Starred | ast.Name | ast.List | ast.Tuple
33
+ hasDOTdecorator_list: typing_TypeAlias = ast.FunctionDef | ast.AsyncFunctionDef | ast.ClassDef
34
+ hasDOTdefault_value: typing_TypeAlias = astDOTTypeVar | astDOTParamSpec | astDOTTypeVarTuple
35
+ hasDOTdefaults: typing_TypeAlias = ast.arguments
36
+ hasDOTelt: typing_TypeAlias = ast.ListComp | ast.SetComp | ast.GeneratorExp
37
+ hasDOTelts: typing_TypeAlias = ast.Set | ast.List | ast.Tuple
38
+ hasDOTexc: typing_TypeAlias = ast.Raise
39
+ hasDOTfinalbody: typing_TypeAlias = ast.Try | astDOTTryStar
40
+ hasDOTformat_spec: typing_TypeAlias = ast.FormattedValue
41
+ hasDOTfunc: typing_TypeAlias = ast.Call
42
+ hasDOTgenerators: typing_TypeAlias = ast.ListComp | ast.SetComp | ast.DictComp | ast.GeneratorExp
43
+ hasDOTguard: typing_TypeAlias = ast.match_case
44
+ hasDOThandlers: typing_TypeAlias = ast.Try | astDOTTryStar
45
+ hasDOTid: typing_TypeAlias = ast.Name
46
+ hasDOTifs: typing_TypeAlias = ast.comprehension
47
+ hasDOTis_async: typing_TypeAlias = ast.comprehension
48
+ hasDOTitems: typing_TypeAlias = ast.With | ast.AsyncWith
49
+ hasDOTiter: typing_TypeAlias = ast.For | ast.AsyncFor | ast.comprehension
50
+ hasDOTkey: typing_TypeAlias = ast.DictComp
51
+ hasDOTkeys_list_exprOrNone: typing_TypeAlias = ast.Dict
52
+ hasDOTkeys_list_expr: typing_TypeAlias = ast.MatchMapping
53
+ hasDOTkeys: typing_TypeAlias = hasDOTkeys_list_exprOrNone | hasDOTkeys_list_expr
54
+ hasDOTkeywords: typing_TypeAlias = ast.ClassDef | ast.Call
55
+ hasDOTkind: typing_TypeAlias = ast.Constant
56
+ hasDOTkw_defaults: typing_TypeAlias = ast.arguments
57
+ hasDOTkwarg: typing_TypeAlias = ast.arguments
58
+ hasDOTkwd_attrs: typing_TypeAlias = ast.MatchClass
59
+ hasDOTkwd_patterns: typing_TypeAlias = ast.MatchClass
60
+ hasDOTkwonlyargs: typing_TypeAlias = ast.arguments
61
+ hasDOTleft: typing_TypeAlias = ast.BinOp | ast.Compare
62
+ hasDOTlevel: typing_TypeAlias = ast.ImportFrom
63
+ hasDOTlineno: typing_TypeAlias = ast.TypeIgnore
64
+ hasDOTlower: typing_TypeAlias = ast.Slice
65
+ hasDOTmodule: typing_TypeAlias = ast.ImportFrom
66
+ hasDOTmsg: typing_TypeAlias = ast.Assert
67
+ hasDOTname_Identifier: typing_TypeAlias = ast.FunctionDef | ast.AsyncFunctionDef | ast.ClassDef | astDOTTypeVar | astDOTParamSpec | astDOTTypeVarTuple
68
+ hasDOTname_IdentifierOrNone: typing_TypeAlias = ast.ExceptHandler | ast.MatchStar | ast.MatchAs
69
+ hasDOTname_str: typing_TypeAlias = ast.alias
70
+ hasDOTname_Name: typing_TypeAlias = astDOTTypeAlias
71
+ hasDOTname: typing_TypeAlias = hasDOTname_Identifier | hasDOTname_IdentifierOrNone | hasDOTname_str | hasDOTname_Name
72
+ hasDOTnames_list_alias: typing_TypeAlias = ast.Import | ast.ImportFrom
73
+ hasDOTnames_list_Identifier: typing_TypeAlias = ast.Global | ast.Nonlocal
74
+ hasDOTnames: typing_TypeAlias = hasDOTnames_list_alias | hasDOTnames_list_Identifier
75
+ hasDOTop_operator: typing_TypeAlias = ast.AugAssign | ast.BinOp
76
+ hasDOTop_boolop: typing_TypeAlias = ast.BoolOp
77
+ hasDOTop_unaryop: typing_TypeAlias = ast.UnaryOp
78
+ hasDOTop: typing_TypeAlias = hasDOTop_operator | hasDOTop_boolop | hasDOTop_unaryop
79
+ hasDOToperand: typing_TypeAlias = ast.UnaryOp
80
+ hasDOTops: typing_TypeAlias = ast.Compare
81
+ hasDOToptional_vars: typing_TypeAlias = ast.withitem
82
+ hasDOTorelse_list_stmt: typing_TypeAlias = ast.For | ast.AsyncFor | ast.While | ast.If | ast.Try | astDOTTryStar
83
+ hasDOTorelse_expr: typing_TypeAlias = ast.IfExp
84
+ hasDOTorelse: typing_TypeAlias = hasDOTorelse_list_stmt | hasDOTorelse_expr
85
+ hasDOTpattern_pattern: typing_TypeAlias = ast.match_case
86
+ hasDOTpattern_patternOrNone: typing_TypeAlias = ast.MatchAs
87
+ hasDOTpattern: typing_TypeAlias = hasDOTpattern_pattern | hasDOTpattern_patternOrNone
88
+ hasDOTpatterns: typing_TypeAlias = ast.MatchSequence | ast.MatchMapping | ast.MatchClass | ast.MatchOr
89
+ hasDOTposonlyargs: typing_TypeAlias = ast.arguments
90
+ hasDOTrest: typing_TypeAlias = ast.MatchMapping
91
+ hasDOTreturns_expr: typing_TypeAlias = ast.FunctionType
92
+ hasDOTreturns_exprOrNone: typing_TypeAlias = ast.FunctionDef | ast.AsyncFunctionDef
93
+ hasDOTreturns: typing_TypeAlias = hasDOTreturns_expr | hasDOTreturns_exprOrNone
94
+ hasDOTright: typing_TypeAlias = ast.BinOp
95
+ hasDOTsimple: typing_TypeAlias = ast.AnnAssign
96
+ hasDOTslice: typing_TypeAlias = ast.Subscript
97
+ hasDOTstep: typing_TypeAlias = ast.Slice
98
+ hasDOTsubject: typing_TypeAlias = ast.Match
99
+ hasDOTtag: typing_TypeAlias = ast.TypeIgnore
100
+ hasDOTtarget_NameOrAttributeOrSubscript: typing_TypeAlias = ast.AugAssign | ast.AnnAssign
101
+ hasDOTtarget_expr: typing_TypeAlias = ast.For | ast.AsyncFor | ast.comprehension
102
+ hasDOTtarget_Name: typing_TypeAlias = ast.NamedExpr
103
+ hasDOTtarget: typing_TypeAlias = hasDOTtarget_NameOrAttributeOrSubscript | hasDOTtarget_expr | hasDOTtarget_Name
104
+ hasDOTtargets: typing_TypeAlias = ast.Delete | ast.Assign
105
+ hasDOTtest: typing_TypeAlias = ast.While | ast.If | ast.Assert | ast.IfExp
106
+ hasDOTtype: typing_TypeAlias = ast.ExceptHandler
107
+ hasDOTtype_comment: typing_TypeAlias = ast.FunctionDef | ast.AsyncFunctionDef | ast.Assign | ast.For | ast.AsyncFor | ast.With | ast.AsyncWith | ast.arg
108
+ hasDOTtype_ignores: typing_TypeAlias = ast.Module
109
+ hasDOTtype_params: typing_TypeAlias = ast.FunctionDef | ast.AsyncFunctionDef | ast.ClassDef | astDOTTypeAlias
110
+ hasDOTupper: typing_TypeAlias = ast.Slice
111
+ hasDOTvalue_exprOrNone: typing_TypeAlias = ast.Return | ast.AnnAssign | ast.Yield
112
+ hasDOTvalue_expr: typing_TypeAlias = ast.Assign | ast.AugAssign | ast.Expr | ast.NamedExpr | ast.DictComp | ast.Await | ast.YieldFrom | ast.FormattedValue | ast.Attribute | ast.Subscript | ast.Starred | ast.keyword | astDOTTypeAlias | ast.MatchValue
113
+ hasDOTvalue_Any: typing_TypeAlias = ast.Constant
114
+ hasDOTvalue_LiteralTrueFalseOrNone: typing_TypeAlias = ast.MatchSingleton
115
+ hasDOTvalue: typing_TypeAlias = hasDOTvalue_exprOrNone | hasDOTvalue_expr | hasDOTvalue_Any | hasDOTvalue_LiteralTrueFalseOrNone
116
+ hasDOTvalues: typing_TypeAlias = ast.BoolOp | ast.Dict | ast.JoinedStr
117
+ hasDOTvararg: typing_TypeAlias = ast.arguments
@@ -1,49 +1,24 @@
1
- from typing import Any, TYPE_CHECKING, TypeAlias as typing_TypeAlias, TypeVar as typing_TypeVar
1
+ from mapFolding import astDOTParamSpec, astDOTTryStar, astDOTtype_param, astDOTTypeAlias, astDOTTypeVar, astDOTTypeVarTuple
2
+ from typing import Any, TypeAlias as typing_TypeAlias, TypeVar as typing_TypeVar
2
3
  import ast
3
- # TODO understand typing.
4
-
5
- stuPyd: typing_TypeAlias = str
6
- if TYPE_CHECKING:
7
- """ 3.12 new: ast.ParamSpec, ast.type_param, ast.TypeAlias, ast.TypeVar, ast.TypeVarTuple
8
- 3.11 new: ast.TryStar"""
9
- astClassHasDOTbodyList_stmt: typing_TypeAlias = ast.AsyncFor | ast.AsyncWith | ast.ClassDef | ast.ExceptHandler | ast.For | ast.FunctionDef | ast.If | ast.Interactive | ast.match_case | ast.Module | ast.Try | ast.TryStar | ast.While | ast.With
10
- astClassHasDOTnameNotNameAlways: typing_TypeAlias = ast.alias | ast.AsyncFunctionDef | ast.ClassDef | ast.FunctionDef | ast.ParamSpec | ast.TypeVar | ast.TypeVarTuple
11
- astClassHasDOTvalue_expr: typing_TypeAlias = ast.Assign | ast.Attribute | ast.AugAssign | ast.Await | ast.DictComp | ast.Expr | ast.FormattedValue | ast.keyword | ast.MatchValue | ast.NamedExpr | ast.Starred | ast.Subscript | ast.TypeAlias | ast.YieldFrom
12
4
 
13
- else:
14
- astClassHasDOTbodyList_stmt = stuPyd
15
- astClassHasDOTnameNotNameAlways = stuPyd
16
- astClassHasDOTvalue_expr = stuPyd
5
+ # TODO understand typing.
17
6
 
7
+ # NOTE Prototype of an idea to subclass composable methods so that typing information
8
+ # can extend beyond the top level of the ast node.
18
9
  class ImaCallToName(ast.Call):
19
- func: ast.Name # pyright: ignore[reportIncompatibleVariableOverride]
20
- # assert isinstance(ast.Call.func, ast.Name), "brinkmanship"
21
- # func: ast.Name
22
-
23
- astClassHasDOTbody_expr: typing_TypeAlias = ast.Expression | ast.IfExp | ast.Lambda
24
- astClassHasDOTbody: typing_TypeAlias = astClassHasDOTbody_expr | astClassHasDOTbodyList_stmt
25
-
26
- astClassHasDOTnameNotNameOptionally: typing_TypeAlias = ast.ExceptHandler | ast.MatchAs | ast.MatchStar
27
- astClassHasDOTnameNotName: typing_TypeAlias = astClassHasDOTnameNotNameAlways | astClassHasDOTnameNotNameOptionally
28
-
29
- astClassHasDOTtargetAttributeNameSubscript: typing_TypeAlias = ast.AnnAssign | ast.AugAssign
30
- astClassHasDOTtarget_expr: typing_TypeAlias = ast.AsyncFor | ast.comprehension | ast.For
31
- astClassHasDOTtarget: typing_TypeAlias = ast.NamedExpr | astClassHasDOTtarget_expr | astClassHasDOTtargetAttributeNameSubscript
32
-
33
- astClassHasDOTvalue_exprNone: typing_TypeAlias = ast.AnnAssign | ast.Return | ast.Yield
34
- astClassHasDOTvalue: typing_TypeAlias = ast.Constant | ast.MatchSingleton | astClassHasDOTvalue_expr | astClassHasDOTvalue_exprNone
10
+ func: ast.Name # pyright: ignore[reportIncompatibleVariableOverride]
35
11
 
12
+ # Type hints through TypeAlias or type "hints" through the identifier name.
36
13
  ast_expr_Slice: typing_TypeAlias = ast.expr
37
14
  ast_Identifier: typing_TypeAlias = str
38
- intORlist_ast_type_paramORstr_orNone: typing_TypeAlias = Any
39
- intORstr_orNone: typing_TypeAlias = Any
40
- list_ast_type_paramORstr_orNone: typing_TypeAlias = Any
41
- str_nameDOTname: typing_TypeAlias = stuPyd
15
+ str_nameDOTname: typing_TypeAlias = str
42
16
 
17
+ # Limited success with TypeVar.
43
18
  个 = typing_TypeVar('个', bound = ast.AST, covariant = True)
44
19
  NodeORattribute = typing_TypeVar('NodeORattribute', bound = ast.AST | ast_expr_Slice | ast_Identifier | str_nameDOTname | bool | Any | None, covariant = True)
45
20
 
46
- # All ast classes by subgroup:
21
+ # For my reference, all ast classes by subgroup:
47
22
  Ima_ast_boolop: typing_TypeAlias = ast.boolop | ast.And | ast.Or
48
23
  Ima_ast_cmpop: typing_TypeAlias = ast.cmpop | ast.Eq | ast.NotEq | ast.Lt | ast.LtE | ast.Gt | ast.GtE | ast.Is | ast.IsNot | ast.In | ast.NotIn
49
24
  Ima_ast_excepthandler: typing_TypeAlias = ast.excepthandler | ast.ExceptHandler
@@ -53,11 +28,7 @@ Ima_ast_mod: typing_TypeAlias = ast.mod | ast.Expression | ast.FunctionType | as
53
28
  Ima_ast_operator: typing_TypeAlias = ast.operator | ast.Add | ast.Sub | ast.Mult | ast.MatMult | ast.Div | ast.Mod | ast.Pow | ast.LShift | ast.RShift | ast.BitOr | ast.BitXor | ast.BitAnd | ast.FloorDiv
54
29
  Ima_ast_orphan = ast.alias | ast.arg | ast.arguments | ast.comprehension | ast.keyword | ast.match_case | ast.withitem
55
30
  iMa_ast_pattern: typing_TypeAlias = ast.pattern | ast.MatchAs | ast.MatchClass | ast.MatchMapping | ast.MatchOr | ast.MatchSequence | ast.MatchSingleton | ast.MatchStar | ast.MatchValue
31
+ Ima_ast_stmt: typing_TypeAlias = ast.stmt | ast.AnnAssign | ast.Assert | ast.Assign | ast.AsyncFor | ast.AsyncFunctionDef | ast.AsyncWith | ast.AugAssign | ast.Break | ast.ClassDef | ast.Continue | ast.Delete | ast.Expr | ast.For | ast.FunctionDef | ast.Global | ast.If | ast.Import | ast.ImportFrom | ast.Match | ast.Nonlocal | ast.Pass | ast.Raise | ast.Return | ast.Try | astDOTTryStar | astDOTTypeAlias | ast.While | ast.With
56
32
  Ima_ast_type_ignore: typing_TypeAlias = ast.type_ignore | ast.TypeIgnore
33
+ Ima_ast_type_param: typing_TypeAlias = astDOTtype_param | astDOTParamSpec | astDOTTypeVar | astDOTTypeVarTuple
57
34
  Ima_ast_unaryop: typing_TypeAlias = ast.unaryop | ast.Invert | ast.Not | ast.UAdd | ast.USub
58
- if TYPE_CHECKING:
59
- Ima_ast_stmt: typing_TypeAlias = ast.stmt | ast.AnnAssign | ast.Assert | ast.Assign | ast.AsyncFor | ast.AsyncFunctionDef | ast.AsyncWith | ast.AugAssign | ast.Break | ast.ClassDef | ast.Continue | ast.Delete | ast.Expr | ast.For | ast.FunctionDef | ast.Global | ast.If | ast.Import | ast.ImportFrom | ast.Match | ast.Nonlocal | ast.Pass | ast.Raise | ast.Return | ast.Try | ast.TryStar | ast.TypeAlias | ast.While | ast.With
60
- Ima_ast_type_param: typing_TypeAlias = ast.type_param | ast.ParamSpec | ast.TypeVar | ast.TypeVarTuple
61
- else:
62
- Ima_ast_stmt = stuPyd
63
- Ima_ast_type_param = stuPyd