mapFolding 0.10.0__py3-none-any.whl → 0.11.1__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 (27) hide show
  1. mapFolding/__init__.py +12 -27
  2. mapFolding/someAssemblyRequired/Z0Z_makeSomeModules.py +9 -11
  3. mapFolding/someAssemblyRequired/__init__.py +20 -24
  4. mapFolding/someAssemblyRequired/_toolIfThis.py +5 -139
  5. mapFolding/someAssemblyRequired/_toolboxContainers.py +20 -293
  6. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +6 -6
  7. mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +7 -6
  8. mapFolding/someAssemblyRequired/toolboxNumba.py +2 -2
  9. mapFolding/someAssemblyRequired/transformationTools.py +9 -216
  10. {mapfolding-0.10.0.dist-info → mapfolding-0.11.1.dist-info}/METADATA +2 -1
  11. {mapfolding-0.10.0.dist-info → mapfolding-0.11.1.dist-info}/RECORD +15 -27
  12. {mapfolding-0.10.0.dist-info → mapfolding-0.11.1.dist-info}/WHEEL +1 -1
  13. mapFolding/someAssemblyRequired/_astTypes.py +0 -117
  14. mapFolding/someAssemblyRequired/_theTypes.py +0 -34
  15. mapFolding/someAssemblyRequired/_toolBe.py +0 -524
  16. mapFolding/someAssemblyRequired/_toolDOT.py +0 -493
  17. mapFolding/someAssemblyRequired/_toolGrab.py +0 -653
  18. mapFolding/someAssemblyRequired/_toolMake.py +0 -339
  19. mapFolding/someAssemblyRequired/_toolThen.py +0 -63
  20. mapFolding/someAssemblyRequired/_toolboxAST.py +0 -57
  21. mapFolding/someAssemblyRequired/_toolboxPython.py +0 -188
  22. mapFolding/toolFactory/astFactory.py +0 -493
  23. mapFolding/toolFactory/astFactory_annex.py +0 -63
  24. mapFolding/toolFactory/astFactory_docstrings.py +0 -63
  25. {mapfolding-0.10.0.dist-info → mapfolding-0.11.1.dist-info}/entry_points.txt +0 -0
  26. {mapfolding-0.10.0.dist-info → mapfolding-0.11.1.dist-info}/licenses/LICENSE +0 -0
  27. {mapfolding-0.10.0.dist-info → mapfolding-0.11.1.dist-info}/top_level.txt +0 -0
mapFolding/__init__.py CHANGED
@@ -47,38 +47,22 @@ foundation for exploring advanced code transformation techniques.
47
47
  from typing import Any, TypeAlias
48
48
  import sys
49
49
 
50
- stuPyd: TypeAlias = Any
51
-
52
- if sys.version_info >= (3, 12):
53
- from ast import (
54
- ParamSpec as astDOTParamSpec,
55
- type_param as astDOTtype_param,
56
- TypeAlias as astDOTTypeAlias,
57
- TypeVar as astDOTTypeVar,
58
- TypeVarTuple as astDOTTypeVarTuple,
59
- )
60
- else:
61
- astDOTParamSpec: TypeAlias = stuPyd
62
- astDOTtype_param: TypeAlias = stuPyd
63
- astDOTTypeAlias: TypeAlias = stuPyd
64
- astDOTTypeVar: TypeAlias = stuPyd
65
- astDOTTypeVarTuple: TypeAlias = stuPyd
50
+ yourPythonIsOld: TypeAlias = Any
51
+ # ruff: noqa: E402
66
52
 
67
53
  if sys.version_info >= (3, 11):
68
- from ast import TryStar as astDOTTryStar
69
54
  from typing import TypedDict as TypedDict
70
55
  from typing import NotRequired as NotRequired
71
56
  else:
72
- astDOTTryStar: TypeAlias = stuPyd
73
57
  try:
74
58
  from typing_extensions import TypedDict as TypedDict
75
59
  from typing_extensions import NotRequired as NotRequired
76
60
  except Exception:
77
- TypedDict = dict[stuPyd, stuPyd]
61
+ TypedDict = dict[yourPythonIsOld, yourPythonIsOld]
78
62
  from collections.abc import Iterable
79
63
  NotRequired: TypeAlias = Iterable
80
64
 
81
- from mapFolding.datatypes import ( # noqa: E402
65
+ from mapFolding.datatypes import (
82
66
  Array1DElephino as Array1DElephino,
83
67
  Array1DFoldsTotal as Array1DFoldsTotal,
84
68
  Array1DLeavesTotal as Array1DLeavesTotal,
@@ -92,18 +76,18 @@ from mapFolding.datatypes import ( # noqa: E402
92
76
  NumPyLeavesTotal as NumPyLeavesTotal,
93
77
  )
94
78
 
95
- from mapFolding.theSSOT import ( # noqa: E402
79
+ from mapFolding.theSSOT import (
96
80
  ComputationState as ComputationState,
97
81
  raiseIfNoneGitHubIssueNumber3 as raiseIfNoneGitHubIssueNumber3,
98
82
  The as The,
99
83
  )
100
84
 
101
- from mapFolding.theDao import ( # noqa: E402
85
+ from mapFolding.theDao import (
102
86
  countInitialize as countInitialize,
103
87
  doTheNeedful as doTheNeedful,
104
88
  )
105
89
 
106
- from mapFolding.beDRY import ( # noqa: E402
90
+ from mapFolding.beDRY import (
107
91
  getLeavesTotal as getLeavesTotal,
108
92
  getTaskDivisions as getTaskDivisions,
109
93
  outfitCountFolds as outfitCountFolds,
@@ -111,17 +95,18 @@ from mapFolding.beDRY import ( # noqa: E402
111
95
  validateListDimensions as validateListDimensions,
112
96
  )
113
97
 
114
- from mapFolding.toolboxFilesystem import ( # noqa: E402
98
+ from mapFolding.toolboxFilesystem import (
115
99
  getPathFilenameFoldsTotal as getPathFilenameFoldsTotal,
116
100
  getPathRootJobDEFAULT as getPathRootJobDEFAULT,
117
101
  saveFoldsTotal as saveFoldsTotal,
118
102
  saveFoldsTotalFAILearly as saveFoldsTotalFAILearly,
119
- writeStringToHere as writeStringToHere,
120
103
  )
121
104
 
122
- from mapFolding.basecamp import countFolds as countFolds # noqa: E402
105
+ from Z0Z_tools import writeStringToHere as writeStringToHere
106
+
107
+ from mapFolding.basecamp import countFolds as countFolds
123
108
 
124
- from mapFolding.oeis import ( # noqa: E402
109
+ from mapFolding.oeis import (
125
110
  clearOEIScache as clearOEIScache,
126
111
  getFoldsTotalKnown as getFoldsTotalKnown,
127
112
  getOEISids as getOEISids,
@@ -9,24 +9,24 @@ from mapFolding.someAssemblyRequired import (
9
9
  IfThis,
10
10
  IngredientsFunction,
11
11
  IngredientsModule,
12
+ inlineFunctionDef,
12
13
  LedgerOfImports,
13
14
  Make,
14
15
  NodeChanger,
15
16
  NodeTourist,
16
17
  parseLogicalPath2astModule,
17
18
  parsePathFilename2astModule,
18
- Then,
19
+ removeUnusedParameters,
19
20
  str_nameDOTname,
21
+ Then,
22
+ write_astModule,
20
23
  )
21
24
  from mapFolding.someAssemblyRequired.toolboxNumba import decorateCallableWithNumba, parametersNumbaLight
22
25
  from mapFolding.someAssemblyRequired.transformationTools import (
23
- inlineFunctionDef,
24
26
  removeDataclassFromFunction,
25
- removeUnusedParameters,
26
27
  shatter_dataclassesDOTdataclass,
27
28
  unpackDataclassCallFunctionRepackDataclass,
28
- write_astModule,
29
- )
29
+ )
30
30
  from pathlib import PurePath
31
31
  import ast
32
32
 
@@ -58,10 +58,7 @@ def makeInitializeGroupsOfFolds() -> None:
58
58
  theCountingIdentifier = theCountingIdentifierHARDCODED
59
59
 
60
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
- ]))
61
+ doThat = Grab.testAttribute(Grab.andDoAllOf([ Grab.opsAttribute(Then.replaceWith([ast.Eq()])), Grab.leftAttribute(Grab.attrAttribute(Then.replaceWith(theCountingIdentifier))) ])) # type: ignore
65
62
  NodeChanger(findThis, doThat).visit(countInitializeIngredients.astFunctionDef.body[0])
66
63
 
67
64
  ingredientsModule = IngredientsModule(countInitializeIngredients)
@@ -171,7 +168,7 @@ def makeTheorem2() -> PurePath:
171
168
  doThat = Then.removeIt
172
169
  NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
173
170
 
174
- findThis = IfThis.isAttributeNamespace_IdentifierLessThanOrEqual(dataclassInstanceIdentifier, 'leaf1ndex')
171
+ findThis = IfThis.isAttributeNamespace_IdentifierLessThanOrEqual0(dataclassInstanceIdentifier, 'leaf1ndex')
175
172
  doThat = Then.removeIt
176
173
  NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
177
174
 
@@ -301,7 +298,8 @@ def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
301
298
  doTheNeedful.imports.addAst(astImportFrom)
302
299
  targetCallableIdentifier = astImportFrom.names[0].name
303
300
  doTheNeedful = unpackDataclassCallFunctionRepackDataclass(doTheNeedful, targetCallableIdentifier, shatteredDataclass)
304
- targetFunctionDef = extractFunctionDef(parseLogicalPath2astModule(astImportFrom.module), targetCallableIdentifier) # type: ignore
301
+ if astImportFrom.module is None: raise raiseIfNoneGitHubIssueNumber3
302
+ targetFunctionDef = extractFunctionDef(parseLogicalPath2astModule(astImportFrom.module), targetCallableIdentifier)
305
303
  if targetFunctionDef is None: raise raiseIfNoneGitHubIssueNumber3
306
304
  astTuple: ast.Tuple | None = NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(targetFunctionDef)
307
305
  if astTuple is None: raise raiseIfNoneGitHubIssueNumber3
@@ -44,45 +44,41 @@ optimizations - while maintaining the ability to verify correctness at each tran
44
44
  test suite.
45
45
  """
46
46
 
47
- from mapFolding.someAssemblyRequired._theTypes import (
47
+ from astToolkit import (
48
48
  ast_expr_Slice as ast_expr_Slice,
49
49
  ast_Identifier as ast_Identifier,
50
- ImaCallToName as ImaCallToName,
51
- NodeORattribute as NodeORattribute,
52
- str_nameDOTname as str_nameDOTname,
53
- as 个,
54
- )
55
-
56
- from mapFolding.someAssemblyRequired._astTypes import * # noqa: F403
57
-
58
- from mapFolding.someAssemblyRequired._toolboxPython import (
50
+ astModuleToIngredientsFunction as astModuleToIngredientsFunction,
51
+ Be as Be,
52
+ DOT as DOT,
53
+ extractClassDef as extractClassDef,
54
+ extractFunctionDef as extractFunctionDef,
55
+ Grab as Grab,
59
56
  importLogicalPath2Callable as importLogicalPath2Callable,
60
57
  importPathFilename2Callable as importPathFilename2Callable,
58
+ IngredientsFunction as IngredientsFunction,
59
+ IngredientsModule as IngredientsModule,
60
+ LedgerOfImports as LedgerOfImports,
61
+ Make as Make,
61
62
  NodeChanger as NodeChanger,
63
+ NodeORattribute as NodeORattribute,
62
64
  NodeTourist as NodeTourist,
63
65
  parseLogicalPath2astModule as parseLogicalPath2astModule,
64
66
  parsePathFilename2astModule as parsePathFilename2astModule,
67
+ str_nameDOTname as str_nameDOTname,
68
+ Then as Then,
65
69
  )
66
70
 
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
+ from astToolkit.transformationTools import (
72
+ inlineFunctionDef as inlineFunctionDef,
73
+ removeUnusedParameters as removeUnusedParameters,
74
+ unparseFindReplace as unparseFindReplace,
75
+ write_astModule as write_astModule,
76
+ )
71
77
 
72
78
  from mapFolding.someAssemblyRequired._toolIfThis import IfThis as IfThis
73
- from mapFolding.someAssemblyRequired._toolThen import Then as Then
74
79
 
75
80
  from mapFolding.someAssemblyRequired._toolboxContainers import (
76
81
  DeReConstructField2ast as DeReConstructField2ast,
77
- IngredientsFunction as IngredientsFunction,
78
- IngredientsModule as IngredientsModule,
79
- LedgerOfImports as LedgerOfImports,
80
82
  RecipeSynthesizeFlow as RecipeSynthesizeFlow,
81
83
  ShatteredDataclass as ShatteredDataclass,
82
84
  )
83
-
84
- from mapFolding.someAssemblyRequired._toolboxAST import (
85
- astModuleToIngredientsFunction as astModuleToIngredientsFunction,
86
- extractClassDef as extractClassDef,
87
- extractFunctionDef as extractFunctionDef,
88
- )
@@ -19,17 +19,13 @@ they implement a declarative approach to AST manipulation that separates node id
19
19
  (be), and data access (DOT).
20
20
  """
21
21
 
22
+ from astToolkit import IfThis as astToolkit_IfThis
22
23
  from collections.abc import Callable
23
- from mapFolding.someAssemblyRequired import (
24
- ast_Identifier,
25
- Be,
26
- DOT,
27
- ImaCallToName,
28
- )
29
- from typing import Any, TypeGuard
24
+ from mapFolding.someAssemblyRequired import ast_Identifier, Be
25
+ from typing import TypeGuard
30
26
  import ast
31
27
 
32
- class IfThis:
28
+ class IfThis(astToolkit_IfThis):
33
29
  """
34
30
  Provide predicate functions for matching and filtering AST nodes based on various criteria.
35
31
 
@@ -40,75 +36,12 @@ class IfThis:
40
36
  The class provides predicates for matching various node types, attributes, identifiers, and structural patterns,
41
37
  enabling precise targeting of AST elements for analysis or transformation.
42
38
  """
43
- @staticmethod
44
- def _Identifier(identifier: ast_Identifier) -> Callable[[ast_Identifier | None], TypeGuard[ast_Identifier] | bool]:
45
- return lambda node: node == identifier
46
- @staticmethod
47
- def _nested_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Attribute | ast.Starred | ast.Subscript] | bool]:
48
- def workhorse(node: ast.AST) -> TypeGuard[ast.Attribute | ast.Starred | ast.Subscript] | bool:
49
- return IfThis.isName_Identifier(identifier)(node) or IfThis.isAttribute_Identifier(identifier)(node) or IfThis.isSubscript_Identifier(identifier)(node) or IfThis.isStarred_Identifier(identifier)(node)
50
- return workhorse
51
-
52
- @staticmethod
53
- def is_arg_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.arg] | bool]:
54
- """see also `isArgument_Identifier`"""
55
- return lambda node: Be.arg(node) and IfThis._Identifier(identifier)(DOT.arg(node))
56
- @staticmethod
57
- def is_keyword_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.keyword] | bool]:
58
- """see also `isArgument_Identifier`"""
59
- return lambda node: Be.keyword(node) and IfThis._Identifier(identifier)(DOT.arg(node))
60
-
61
- @staticmethod
62
- def isAnnAssign_targetIs(targetPredicate: Callable[[ast.expr], TypeGuard[ast.expr] | bool]) -> Callable[[ast.AST], TypeGuard[ast.AnnAssign] | bool]:
63
- def workhorse(node: ast.AST) -> TypeGuard[ast.AnnAssign] | bool:
64
- return Be.AnnAssign(node) and targetPredicate(DOT.target(node))
65
- return workhorse
66
-
67
- @staticmethod
68
- def isArgument_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.arg | ast.keyword] | bool]:
69
- return lambda node: (Be.arg(node) or Be.keyword(node)) and IfThis._Identifier(identifier)(DOT.arg(node))
70
-
71
- @staticmethod
72
- def isAssignAndTargets0Is(targets0Predicate: Callable[[ast.AST], bool]) -> Callable[[ast.AST], TypeGuard[ast.AnnAssign] | bool]:
73
- """node is Assign and node.targets[0] matches `targets0Predicate`."""
74
- return lambda node: Be.Assign(node) and targets0Predicate(node.targets[0])
75
- @staticmethod
76
- def isAssignAndValueIs(valuePredicate: Callable[[ast.AST], bool]) -> Callable[[ast.AST], TypeGuard[ast.Assign] | bool]:
77
- """node is ast.Assign and node.value matches `valuePredicate`. """
78
- return lambda node: Be.Assign(node) and valuePredicate(DOT.value(node))
79
-
80
- @staticmethod
81
- def isAttribute_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Attribute] | bool]:
82
- """node is `ast.Attribute` and the top-level `ast.Name` is `identifier`"""
83
- def workhorse(node: ast.AST) -> TypeGuard[ast.Attribute]:
84
- return Be.Attribute(node) and IfThis._nested_Identifier(identifier)(DOT.value(node))
85
- return workhorse
86
- @staticmethod
87
- def isAttributeName(node: ast.AST) -> TypeGuard[ast.Attribute]:
88
- """ Displayed as Name.attribute."""
89
- return Be.Attribute(node) and Be.Name(DOT.value(node))
90
- @staticmethod
91
- def isAttributeNamespace_Identifier(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Attribute] | bool]:
92
- return lambda node: IfThis.isAttributeName(node) and IfThis.isName_Identifier(namespace)(DOT.value(node)) and IfThis._Identifier(identifier)(DOT.attr(node))
93
-
94
39
  @staticmethod
95
40
  def isAttributeNamespace_IdentifierGreaterThan0(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
96
41
  return lambda node: (Be.Compare(node)
97
42
  and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(node.left)
98
43
  and Be.Gt(node.ops[0])
99
44
  and IfThis.isConstant_value(0)(node.comparators[0]))
100
-
101
- @staticmethod
102
- def isUnaryNotAttributeNamespace_Identifier(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.UnaryOp] | bool]:
103
- return lambda node: (Be.UnaryOp(node)
104
- and Be.Not(node.op)
105
- and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(node.operand))
106
-
107
- @staticmethod
108
- def isIfUnaryNotAttributeNamespace_Identifier(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.If] | bool]:
109
- return lambda node: (Be.If(node)
110
- and IfThis.isUnaryNotAttributeNamespace_Identifier(namespace, identifier)(node.test))
111
-
112
45
  @staticmethod
113
46
  def isIfAttributeNamespace_IdentifierGreaterThan0(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.If] | bool]:
114
47
  return lambda node: (Be.If(node)
@@ -120,74 +53,7 @@ class IfThis:
120
53
  and IfThis.isAttributeNamespace_IdentifierGreaterThan0(namespace, identifier)(node.test))
121
54
 
122
55
  @staticmethod
123
- def isAttributeNamespace_IdentifierLessThanOrEqual(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
56
+ def isAttributeNamespace_IdentifierLessThanOrEqual0(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
124
57
  return lambda node: (Be.Compare(node)
125
58
  and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(node.left)
126
59
  and Be.LtE(node.ops[0]))
127
-
128
- @staticmethod
129
- def isAugAssign_targetIs(targetPredicate: Callable[[ast.expr], TypeGuard[ast.expr] | bool]) -> Callable[[ast.AST], TypeGuard[ast.AugAssign] | bool]:
130
- def workhorse(node: ast.AST) -> TypeGuard[ast.AugAssign] | bool:
131
- return Be.AugAssign(node) and targetPredicate(DOT.target(node))
132
- return workhorse
133
-
134
- @staticmethod
135
- def isCall_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ImaCallToName] | bool]:
136
- def workhorse(node: ast.AST) -> TypeGuard[ImaCallToName] | bool:
137
- return IfThis.isCallToName(node) and IfThis._Identifier(identifier)(DOT.id(DOT.func(node)))
138
- return workhorse
139
-
140
- @staticmethod
141
- def isCallAttributeNamespace_Identifier(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Call] | bool]:
142
- def workhorse(node: ast.AST) -> TypeGuard[ast.Call] | bool:
143
- return Be.Call(node) and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(DOT.func(node))
144
- return workhorse
145
- @staticmethod
146
- def isCallToName(node: ast.AST) -> TypeGuard[ImaCallToName]:
147
- return Be.Call(node) and Be.Name(DOT.func(node))
148
-
149
- @staticmethod
150
- def isClassDef_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.ClassDef] | bool]:
151
- return lambda node: Be.ClassDef(node) and IfThis._Identifier(identifier)(DOT.name(node))
152
-
153
- @staticmethod
154
- def isConstant_value(value: Any) -> Callable[[ast.AST], TypeGuard[ast.Constant] | bool]:
155
- return lambda node: Be.Constant(node) and DOT.value(node) == value
156
-
157
- @staticmethod
158
- def isFunctionDef_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.FunctionDef] | bool]:
159
- return lambda node: Be.FunctionDef(node) and IfThis._Identifier(identifier)(DOT.name(node))
160
-
161
- @staticmethod
162
- def isName_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Name] | bool]:
163
- return lambda node: Be.Name(node) and IfThis._Identifier(identifier)(DOT.id(node))
164
-
165
- @staticmethod
166
- def isStarred_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Starred] | bool]:
167
- """node is `ast.Starred` and the top-level `ast.Name` is `identifier`"""
168
- def workhorse(node: ast.AST) -> TypeGuard[ast.Starred]:
169
- return Be.Starred(node) and IfThis._nested_Identifier(identifier)(DOT.value(node))
170
- return workhorse
171
- @staticmethod
172
- def isSubscript_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Subscript] | bool]:
173
- """node is `ast.Subscript` and the top-level `ast.Name` is `identifier`"""
174
- def workhorse(node: ast.AST) -> TypeGuard[ast.Subscript]:
175
- return Be.Subscript(node) and IfThis._nested_Identifier(identifier)(DOT.value(node))
176
- return workhorse
177
-
178
- @staticmethod
179
- def matchesMeButNotAnyDescendant(predicate: Callable[[ast.AST], bool]) -> Callable[[ast.AST], bool]:
180
- return lambda node: predicate(node) and IfThis.matchesNoDescendant(predicate)(node)
181
- @staticmethod
182
- def matchesNoDescendant(predicate: Callable[[ast.AST], bool]) -> Callable[[ast.AST], bool]:
183
- def workhorse(node: ast.AST) -> bool:
184
- for descendant in ast.walk(node):
185
- if descendant is not node and predicate(descendant):
186
- return False
187
- return True
188
- return workhorse
189
-
190
- @staticmethod
191
- def Z0Z_unparseIs(astAST: ast.AST) -> Callable[[ast.AST], bool]:
192
- def workhorse(node: ast.AST) -> bool: return ast.unparse(node) == ast.unparse(astAST)
193
- return workhorse