astToolkit 0.1.0__tar.gz → 0.1.2__tar.gz
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.
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/PKG-INFO +1 -1
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/__init__.py +0 -1
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_astTypes.py +1 -1
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_toolBe.py +1 -1
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_toolDOT.py +2 -2
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_toolGrab.py +31 -39
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_toolIfThis.py +10 -12
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_toolMake.py +2 -2
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_types.py +3 -2
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/transformationTools.py +6 -6
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit.egg-info/PKG-INFO +1 -1
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/pyproject.toml +1 -1
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/toolFactory/Z0Z_hardcoded.py +5 -2
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/toolFactory/__init__.py +2 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/toolFactory/astFactory.py +34 -17
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/toolFactory/astFactory_annex.py +10 -11
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/LICENSE +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/README.md +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_toolThen.py +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_toolboxAST.py +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_toolboxContainers.py +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_toolboxPython.py +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/_typesSpecial.py +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/py.typed +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit/theSSOT.py +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit.egg-info/SOURCES.txt +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit.egg-info/dependency_links.txt +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit.egg-info/requires.txt +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/astToolkit.egg-info/top_level.txt +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/setup.cfg +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/tests/test_basic.py +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/toolFactory/Z0Z_makeAstTools.py +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/toolFactory/docstrings.py +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/toolFactory/py.typed +0 -0
- {asttoolkit-0.1.0 → asttoolkit-0.1.2}/toolFactory/startHere.py +0 -0
|
@@ -14,7 +14,6 @@ from astToolkit.theSSOT import FREAKOUT as FREAKOUT, The as The
|
|
|
14
14
|
from astToolkit._types import (
|
|
15
15
|
ast_expr_Slice as ast_expr_Slice,
|
|
16
16
|
ast_Identifier as ast_Identifier,
|
|
17
|
-
ImaCallToName as ImaCallToName,
|
|
18
17
|
NodeORattribute as NodeORattribute,
|
|
19
18
|
str_nameDOTname as str_nameDOTname,
|
|
20
19
|
个 as 个,
|
|
@@ -114,4 +114,4 @@ hasDOTvalue_Any: typing_TypeAlias = ast.Constant
|
|
|
114
114
|
hasDOTvalue_LiteralTrueFalseOrNone: typing_TypeAlias = ast.MatchSingleton
|
|
115
115
|
hasDOTvalue: typing_TypeAlias = hasDOTvalue_exprOrNone | hasDOTvalue_expr | hasDOTvalue_Any | hasDOTvalue_LiteralTrueFalseOrNone
|
|
116
116
|
hasDOTvalues: typing_TypeAlias = ast.BoolOp | ast.Dict | ast.JoinedStr
|
|
117
|
-
hasDOTvararg: typing_TypeAlias = ast.arguments
|
|
117
|
+
hasDOTvararg: typing_TypeAlias = ast.arguments
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# ruff: noqa: F403, F405
|
|
2
2
|
"""This file is generated automatically, so changes to this file will be lost."""
|
|
3
|
-
from collections.abc import Sequence
|
|
4
3
|
from astToolkit._astTypes import *
|
|
4
|
+
from collections.abc import Sequence
|
|
5
5
|
from astToolkit import ast_Identifier, ast_expr_Slice, astDOTtype_param
|
|
6
6
|
from typing import Any, Literal, overload
|
|
7
7
|
import ast
|
|
@@ -489,4 +489,4 @@ class DOT:
|
|
|
489
489
|
|
|
490
490
|
@staticmethod
|
|
491
491
|
def vararg(node: hasDOTvararg) -> ast.arg | None:
|
|
492
|
-
return node.vararg
|
|
492
|
+
return node.vararg
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# ruff: noqa: F403, F405
|
|
2
2
|
"""This file is generated automatically, so changes to this file will be lost."""
|
|
3
|
-
from collections.abc import Callable, Sequence
|
|
4
3
|
from astToolkit._astTypes import *
|
|
5
4
|
from astToolkit import astDOTParamSpec, astDOTTryStar, astDOTTypeAlias, astDOTTypeVar, astDOTTypeVarTuple, astDOTtype_param
|
|
6
|
-
from astToolkit import ast_Identifier, ast_expr_Slice, NodeORattribute
|
|
5
|
+
from astToolkit import ast_Identifier, ast_expr_Slice, NodeORattribute
|
|
6
|
+
from collections.abc import Callable, Sequence
|
|
7
7
|
from typing import Any, Literal
|
|
8
8
|
import ast
|
|
9
9
|
|
|
@@ -23,7 +23,7 @@ class Grab:
|
|
|
23
23
|
def annotationAttribute(action: Callable[[ast.expr | (ast.expr | None)], ast.expr | (ast.expr | None)]) -> Callable[[hasDOTannotation], hasDOTannotation]:
|
|
24
24
|
|
|
25
25
|
def workhorse(node: hasDOTannotation) -> hasDOTannotation:
|
|
26
|
-
node.annotation = action(node.annotation)
|
|
26
|
+
node.annotation = action(node.annotation) # type: ignore[reportAttributeAccessIssue]
|
|
27
27
|
return node
|
|
28
28
|
return workhorse
|
|
29
29
|
|
|
@@ -31,7 +31,7 @@ class Grab:
|
|
|
31
31
|
def argAttribute(action: Callable[[ast_Identifier | (ast_Identifier | None)], ast_Identifier | (ast_Identifier | None)]) -> Callable[[hasDOTarg], hasDOTarg]:
|
|
32
32
|
|
|
33
33
|
def workhorse(node: hasDOTarg) -> hasDOTarg:
|
|
34
|
-
node.arg = action(node.arg)
|
|
34
|
+
node.arg = action(node.arg) # type: ignore[reportAttributeAccessIssue]
|
|
35
35
|
return node
|
|
36
36
|
return workhorse
|
|
37
37
|
|
|
@@ -39,7 +39,7 @@ class Grab:
|
|
|
39
39
|
def argsAttribute(action: Callable[[ast.arguments | Sequence[ast.expr] | list[ast.arg]], ast.arguments | Sequence[ast.expr] | list[ast.arg]]) -> Callable[[hasDOTargs], hasDOTargs]:
|
|
40
40
|
|
|
41
41
|
def workhorse(node: hasDOTargs) -> hasDOTargs:
|
|
42
|
-
node.args = action(node.args)
|
|
42
|
+
node.args = action(node.args) # type: ignore[reportAttributeAccessIssue]
|
|
43
43
|
return node
|
|
44
44
|
return workhorse
|
|
45
45
|
|
|
@@ -47,7 +47,7 @@ class Grab:
|
|
|
47
47
|
def argtypesAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]) -> Callable[[hasDOTargtypes], hasDOTargtypes]:
|
|
48
48
|
|
|
49
49
|
def workhorse(node: hasDOTargtypes) -> hasDOTargtypes:
|
|
50
|
-
node.argtypes = action(node.argtypes)
|
|
50
|
+
node.argtypes = list(action(node.argtypes))
|
|
51
51
|
return node
|
|
52
52
|
return workhorse
|
|
53
53
|
|
|
@@ -71,7 +71,7 @@ class Grab:
|
|
|
71
71
|
def basesAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]) -> Callable[[hasDOTbases], hasDOTbases]:
|
|
72
72
|
|
|
73
73
|
def workhorse(node: hasDOTbases) -> hasDOTbases:
|
|
74
|
-
node.bases = action(node.bases)
|
|
74
|
+
node.bases = list(action(node.bases))
|
|
75
75
|
return node
|
|
76
76
|
return workhorse
|
|
77
77
|
|
|
@@ -79,7 +79,7 @@ class Grab:
|
|
|
79
79
|
def bodyAttribute(action: Callable[[Sequence[ast.stmt] | ast.expr], Sequence[ast.stmt] | ast.expr]) -> Callable[[hasDOTbody], hasDOTbody]:
|
|
80
80
|
|
|
81
81
|
def workhorse(node: hasDOTbody) -> hasDOTbody:
|
|
82
|
-
node.body = action(node.body)
|
|
82
|
+
node.body = action(node.body) # type: ignore[reportAttributeAccessIssue]
|
|
83
83
|
return node
|
|
84
84
|
return workhorse
|
|
85
85
|
|
|
@@ -119,7 +119,7 @@ class Grab:
|
|
|
119
119
|
def comparatorsAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]) -> Callable[[hasDOTcomparators], hasDOTcomparators]:
|
|
120
120
|
|
|
121
121
|
def workhorse(node: hasDOTcomparators) -> hasDOTcomparators:
|
|
122
|
-
node.comparators = action(node.comparators)
|
|
122
|
+
node.comparators = list(action(node.comparators))
|
|
123
123
|
return node
|
|
124
124
|
return workhorse
|
|
125
125
|
|
|
@@ -151,7 +151,7 @@ class Grab:
|
|
|
151
151
|
def decorator_listAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]) -> Callable[[hasDOTdecorator_list], hasDOTdecorator_list]:
|
|
152
152
|
|
|
153
153
|
def workhorse(node: hasDOTdecorator_list) -> hasDOTdecorator_list:
|
|
154
|
-
node.decorator_list = action(node.decorator_list)
|
|
154
|
+
node.decorator_list = list(action(node.decorator_list))
|
|
155
155
|
return node
|
|
156
156
|
return workhorse
|
|
157
157
|
|
|
@@ -167,7 +167,7 @@ class Grab:
|
|
|
167
167
|
def defaultsAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]) -> Callable[[hasDOTdefaults], hasDOTdefaults]:
|
|
168
168
|
|
|
169
169
|
def workhorse(node: hasDOTdefaults) -> hasDOTdefaults:
|
|
170
|
-
node.defaults = action(node.defaults)
|
|
170
|
+
node.defaults = list(action(node.defaults))
|
|
171
171
|
return node
|
|
172
172
|
return workhorse
|
|
173
173
|
|
|
@@ -183,7 +183,7 @@ class Grab:
|
|
|
183
183
|
def eltsAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]) -> Callable[[hasDOTelts], hasDOTelts]:
|
|
184
184
|
|
|
185
185
|
def workhorse(node: hasDOTelts) -> hasDOTelts:
|
|
186
|
-
node.elts = action(node.elts)
|
|
186
|
+
node.elts = list(action(node.elts))
|
|
187
187
|
return node
|
|
188
188
|
return workhorse
|
|
189
189
|
|
|
@@ -199,7 +199,7 @@ class Grab:
|
|
|
199
199
|
def finalbodyAttribute(action: Callable[[Sequence[ast.stmt]], Sequence[ast.stmt]]) -> Callable[[hasDOTfinalbody], hasDOTfinalbody]:
|
|
200
200
|
|
|
201
201
|
def workhorse(node: hasDOTfinalbody) -> hasDOTfinalbody:
|
|
202
|
-
node.finalbody = action(node.finalbody)
|
|
202
|
+
node.finalbody = list(action(node.finalbody))
|
|
203
203
|
return node
|
|
204
204
|
return workhorse
|
|
205
205
|
|
|
@@ -255,7 +255,7 @@ class Grab:
|
|
|
255
255
|
def ifsAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]) -> Callable[[hasDOTifs], hasDOTifs]:
|
|
256
256
|
|
|
257
257
|
def workhorse(node: hasDOTifs) -> hasDOTifs:
|
|
258
|
-
node.ifs = action(node.ifs)
|
|
258
|
+
node.ifs = list(action(node.ifs))
|
|
259
259
|
return node
|
|
260
260
|
return workhorse
|
|
261
261
|
|
|
@@ -295,7 +295,7 @@ class Grab:
|
|
|
295
295
|
def keysAttribute(action: Callable[[Sequence[ast.expr | None] | Sequence[ast.expr]], Sequence[ast.expr | None] | Sequence[ast.expr]]) -> Callable[[hasDOTkeys], hasDOTkeys]:
|
|
296
296
|
|
|
297
297
|
def workhorse(node: hasDOTkeys) -> hasDOTkeys:
|
|
298
|
-
node.keys = action(node.keys)
|
|
298
|
+
node.keys = list(action(node.keys)) # type: ignore[reportAttributeAccessIssue]
|
|
299
299
|
return node
|
|
300
300
|
return workhorse
|
|
301
301
|
|
|
@@ -319,7 +319,7 @@ class Grab:
|
|
|
319
319
|
def kw_defaultsAttribute(action: Callable[[Sequence[ast.expr | None]], Sequence[ast.expr | None]]) -> Callable[[hasDOTkw_defaults], hasDOTkw_defaults]:
|
|
320
320
|
|
|
321
321
|
def workhorse(node: hasDOTkw_defaults) -> hasDOTkw_defaults:
|
|
322
|
-
node.kw_defaults = action(node.kw_defaults)
|
|
322
|
+
node.kw_defaults = list(action(node.kw_defaults))
|
|
323
323
|
return node
|
|
324
324
|
return workhorse
|
|
325
325
|
|
|
@@ -343,7 +343,7 @@ class Grab:
|
|
|
343
343
|
def kwd_patternsAttribute(action: Callable[[Sequence[ast.pattern]], Sequence[ast.pattern]]) -> Callable[[hasDOTkwd_patterns], hasDOTkwd_patterns]:
|
|
344
344
|
|
|
345
345
|
def workhorse(node: hasDOTkwd_patterns) -> hasDOTkwd_patterns:
|
|
346
|
-
node.kwd_patterns = action(node.kwd_patterns)
|
|
346
|
+
node.kwd_patterns = list(action(node.kwd_patterns))
|
|
347
347
|
return node
|
|
348
348
|
return workhorse
|
|
349
349
|
|
|
@@ -407,7 +407,7 @@ class Grab:
|
|
|
407
407
|
def nameAttribute(action: Callable[[ast_Identifier | (ast_Identifier | None) | ast_Identifier | ast.Name], ast_Identifier | (ast_Identifier | None) | ast_Identifier | ast.Name]) -> Callable[[hasDOTname], hasDOTname]:
|
|
408
408
|
|
|
409
409
|
def workhorse(node: hasDOTname) -> hasDOTname:
|
|
410
|
-
node.name = action(node.name)
|
|
410
|
+
node.name = action(node.name) # type: ignore[reportAttributeAccessIssue]
|
|
411
411
|
return node
|
|
412
412
|
return workhorse
|
|
413
413
|
|
|
@@ -415,7 +415,7 @@ class Grab:
|
|
|
415
415
|
def namesAttribute(action: Callable[[list[ast.alias] | list[ast_Identifier]], list[ast.alias] | list[ast_Identifier]]) -> Callable[[hasDOTnames], hasDOTnames]:
|
|
416
416
|
|
|
417
417
|
def workhorse(node: hasDOTnames) -> hasDOTnames:
|
|
418
|
-
node.names = action(node.names)
|
|
418
|
+
node.names = action(node.names) # type: ignore[reportAttributeAccessIssue]
|
|
419
419
|
return node
|
|
420
420
|
return workhorse
|
|
421
421
|
|
|
@@ -423,7 +423,7 @@ class Grab:
|
|
|
423
423
|
def opAttribute(action: Callable[[ast.operator | ast.boolop | ast.unaryop], ast.operator | ast.boolop | ast.unaryop]) -> Callable[[hasDOTop], hasDOTop]:
|
|
424
424
|
|
|
425
425
|
def workhorse(node: hasDOTop) -> hasDOTop:
|
|
426
|
-
node.op = action(node.op)
|
|
426
|
+
node.op = action(node.op) # type: ignore[reportAttributeAccessIssue]
|
|
427
427
|
return node
|
|
428
428
|
return workhorse
|
|
429
429
|
|
|
@@ -439,7 +439,7 @@ class Grab:
|
|
|
439
439
|
def opsAttribute(action: Callable[[Sequence[ast.cmpop]], Sequence[ast.cmpop]]) -> Callable[[hasDOTops], hasDOTops]:
|
|
440
440
|
|
|
441
441
|
def workhorse(node: hasDOTops) -> hasDOTops:
|
|
442
|
-
node.ops = action(node.ops)
|
|
442
|
+
node.ops = list(action(node.ops))
|
|
443
443
|
return node
|
|
444
444
|
return workhorse
|
|
445
445
|
|
|
@@ -455,7 +455,7 @@ class Grab:
|
|
|
455
455
|
def orelseAttribute(action: Callable[[Sequence[ast.stmt] | ast.expr], Sequence[ast.stmt] | ast.expr]) -> Callable[[hasDOTorelse], hasDOTorelse]:
|
|
456
456
|
|
|
457
457
|
def workhorse(node: hasDOTorelse) -> hasDOTorelse:
|
|
458
|
-
node.orelse = action(node.orelse)
|
|
458
|
+
node.orelse = action(node.orelse) # type: ignore[reportAttributeAccessIssue]
|
|
459
459
|
return node
|
|
460
460
|
return workhorse
|
|
461
461
|
|
|
@@ -463,7 +463,7 @@ class Grab:
|
|
|
463
463
|
def patternAttribute(action: Callable[[ast.pattern | (ast.pattern | None)], ast.pattern | (ast.pattern | None)]) -> Callable[[hasDOTpattern], hasDOTpattern]:
|
|
464
464
|
|
|
465
465
|
def workhorse(node: hasDOTpattern) -> hasDOTpattern:
|
|
466
|
-
node.pattern = action(node.pattern)
|
|
466
|
+
node.pattern = action(node.pattern) # type: ignore[reportAttributeAccessIssue]
|
|
467
467
|
return node
|
|
468
468
|
return workhorse
|
|
469
469
|
|
|
@@ -471,7 +471,7 @@ class Grab:
|
|
|
471
471
|
def patternsAttribute(action: Callable[[Sequence[ast.pattern]], Sequence[ast.pattern]]) -> Callable[[hasDOTpatterns], hasDOTpatterns]:
|
|
472
472
|
|
|
473
473
|
def workhorse(node: hasDOTpatterns) -> hasDOTpatterns:
|
|
474
|
-
node.patterns = action(node.patterns)
|
|
474
|
+
node.patterns = list(action(node.patterns))
|
|
475
475
|
return node
|
|
476
476
|
return workhorse
|
|
477
477
|
|
|
@@ -495,7 +495,7 @@ class Grab:
|
|
|
495
495
|
def returnsAttribute(action: Callable[[ast.expr | (ast.expr | None)], ast.expr | (ast.expr | None)]) -> Callable[[hasDOTreturns], hasDOTreturns]:
|
|
496
496
|
|
|
497
497
|
def workhorse(node: hasDOTreturns) -> hasDOTreturns:
|
|
498
|
-
node.returns = action(node.returns)
|
|
498
|
+
node.returns = action(node.returns) # type: ignore[reportAttributeAccessIssue]
|
|
499
499
|
return node
|
|
500
500
|
return workhorse
|
|
501
501
|
|
|
@@ -551,7 +551,7 @@ class Grab:
|
|
|
551
551
|
def targetAttribute(action: Callable[[ast.Name | ast.Attribute | ast.Subscript | ast.expr | ast.Name], ast.Name | ast.Attribute | ast.Subscript | ast.expr | ast.Name]) -> Callable[[hasDOTtarget], hasDOTtarget]:
|
|
552
552
|
|
|
553
553
|
def workhorse(node: hasDOTtarget) -> hasDOTtarget:
|
|
554
|
-
node.target = action(node.target)
|
|
554
|
+
node.target = action(node.target) # type: ignore[reportAttributeAccessIssue]
|
|
555
555
|
return node
|
|
556
556
|
return workhorse
|
|
557
557
|
|
|
@@ -559,7 +559,7 @@ class Grab:
|
|
|
559
559
|
def targetsAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]) -> Callable[[hasDOTtargets], hasDOTtargets]:
|
|
560
560
|
|
|
561
561
|
def workhorse(node: hasDOTtargets) -> hasDOTtargets:
|
|
562
|
-
node.targets = action(node.targets)
|
|
562
|
+
node.targets = list(action(node.targets))
|
|
563
563
|
return node
|
|
564
564
|
return workhorse
|
|
565
565
|
|
|
@@ -599,7 +599,7 @@ class Grab:
|
|
|
599
599
|
def type_paramsAttribute(action: Callable[[Sequence[astDOTtype_param]], Sequence[astDOTtype_param]]) -> Callable[[hasDOTtype_params], hasDOTtype_params]:
|
|
600
600
|
|
|
601
601
|
def workhorse(node: hasDOTtype_params) -> hasDOTtype_params:
|
|
602
|
-
node.type_params = action(node.type_params)
|
|
602
|
+
node.type_params = list(action(node.type_params))
|
|
603
603
|
return node
|
|
604
604
|
return workhorse
|
|
605
605
|
|
|
@@ -615,7 +615,7 @@ class Grab:
|
|
|
615
615
|
def valueAttribute(action: Callable[[ast.expr | None | ast.expr | Any | (Literal[True, False] | None)], ast.expr | None | ast.expr | Any | (Literal[True, False] | None)]) -> Callable[[hasDOTvalue], hasDOTvalue]:
|
|
616
616
|
|
|
617
617
|
def workhorse(node: hasDOTvalue) -> hasDOTvalue:
|
|
618
|
-
node.value = action(node.value)
|
|
618
|
+
node.value = action(node.value) # type: ignore[reportAttributeAccessIssue]
|
|
619
619
|
return node
|
|
620
620
|
return workhorse
|
|
621
621
|
|
|
@@ -623,7 +623,7 @@ class Grab:
|
|
|
623
623
|
def valuesAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]) -> Callable[[hasDOTvalues], hasDOTvalues]:
|
|
624
624
|
|
|
625
625
|
def workhorse(node: hasDOTvalues) -> hasDOTvalues:
|
|
626
|
-
node.values = action(node.values)
|
|
626
|
+
node.values = list(action(node.values))
|
|
627
627
|
return node
|
|
628
628
|
return workhorse
|
|
629
629
|
|
|
@@ -642,12 +642,4 @@ class Grab:
|
|
|
642
642
|
for action in listOfActions:
|
|
643
643
|
node = action(node)
|
|
644
644
|
return node
|
|
645
|
-
return workhorse
|
|
646
|
-
|
|
647
|
-
@staticmethod
|
|
648
|
-
def funcDOTidAttribute(action: Callable[[ast_Identifier], Any]) -> Callable[[ImaCallToName], ImaCallToName]:
|
|
649
|
-
|
|
650
|
-
def workhorse(node: ImaCallToName) -> ImaCallToName:
|
|
651
|
-
node.func = Grab.idAttribute(action)(node.func)
|
|
652
|
-
return node
|
|
653
|
-
return workhorse
|
|
645
|
+
return workhorse
|
|
@@ -20,8 +20,8 @@ they implement a declarative approach to AST manipulation that separates node id
|
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
from collections.abc import Callable
|
|
23
|
-
from astToolkit import ast_Identifier, Be, DOT
|
|
24
|
-
from typing import Any, TypeGuard
|
|
23
|
+
from astToolkit import ast_Identifier, Be, DOT
|
|
24
|
+
from typing import Any, TypeGuard, cast
|
|
25
25
|
import ast
|
|
26
26
|
|
|
27
27
|
class IfThis:
|
|
@@ -72,20 +72,16 @@ class IfThis:
|
|
|
72
72
|
def workhorse(node: ast.AST) -> TypeGuard[ast.Attribute]:
|
|
73
73
|
return Be.Attribute(node) and IfThis.isNestedName_Identifier(identifier)(DOT.value(node))
|
|
74
74
|
return workhorse
|
|
75
|
+
|
|
75
76
|
@staticmethod
|
|
76
77
|
def isAttributeName(node: ast.AST) -> TypeGuard[ast.Attribute]:
|
|
77
78
|
""" Displayed as Name.attribute."""
|
|
78
79
|
return Be.Attribute(node) and Be.Name(DOT.value(node))
|
|
80
|
+
|
|
79
81
|
@staticmethod
|
|
80
82
|
def isAttributeNamespace_Identifier(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Attribute] | bool]:
|
|
81
83
|
return lambda node: IfThis.isAttributeName(node) and IfThis.isName_Identifier(namespace)(DOT.value(node)) and IfThis.isIdentifier(identifier)(DOT.attr(node))
|
|
82
84
|
|
|
83
|
-
@staticmethod
|
|
84
|
-
def isAttributeNamespace_IdentifierLessThanOrEqual(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
|
|
85
|
-
return lambda node: (Be.Compare(node)
|
|
86
|
-
and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(node.left)
|
|
87
|
-
and Be.LtE(node.ops[0]))
|
|
88
|
-
|
|
89
85
|
@staticmethod
|
|
90
86
|
def isAugAssignAndTargetIs(targetPredicate: Callable[[ast.expr], TypeGuard[ast.expr] | bool]) -> Callable[[ast.AST], TypeGuard[ast.AugAssign] | bool]:
|
|
91
87
|
def workhorse(node: ast.AST) -> TypeGuard[ast.AugAssign] | bool:
|
|
@@ -93,9 +89,9 @@ class IfThis:
|
|
|
93
89
|
return workhorse
|
|
94
90
|
|
|
95
91
|
@staticmethod
|
|
96
|
-
def isCall_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[
|
|
97
|
-
def workhorse(node: ast.AST) -> TypeGuard[
|
|
98
|
-
return IfThis.isCallToName(node) and IfThis.isIdentifier(identifier)(DOT.id(DOT.func(node)))
|
|
92
|
+
def isCall_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Call] | bool]:
|
|
93
|
+
def workhorse(node: ast.AST) -> TypeGuard[ast.Call] | bool:
|
|
94
|
+
return IfThis.isCallToName(node) and IfThis.isIdentifier(identifier)(DOT.id(cast(ast.Name, DOT.func(node))))
|
|
99
95
|
return workhorse
|
|
100
96
|
|
|
101
97
|
@staticmethod
|
|
@@ -103,8 +99,9 @@ class IfThis:
|
|
|
103
99
|
def workhorse(node: ast.AST) -> TypeGuard[ast.Call] | bool:
|
|
104
100
|
return Be.Call(node) and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(DOT.func(node))
|
|
105
101
|
return workhorse
|
|
102
|
+
|
|
106
103
|
@staticmethod
|
|
107
|
-
def isCallToName(node: ast.AST) -> TypeGuard[
|
|
104
|
+
def isCallToName(node: ast.AST) -> TypeGuard[ast.Call]:
|
|
108
105
|
return Be.Call(node) and Be.Name(DOT.func(node))
|
|
109
106
|
|
|
110
107
|
@staticmethod
|
|
@@ -131,6 +128,7 @@ class IfThis:
|
|
|
131
128
|
@staticmethod
|
|
132
129
|
def isName_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Name] | bool]:
|
|
133
130
|
return lambda node: Be.Name(node) and IfThis.isIdentifier(identifier)(DOT.id(node))
|
|
131
|
+
|
|
134
132
|
@staticmethod
|
|
135
133
|
def isNestedName_Identifier(identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Attribute | ast.Starred | ast.Subscript] | bool]:
|
|
136
134
|
""" `node` is `ast.Name`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""This file is generated automatically, so changes to this file will be lost."""
|
|
2
|
-
from collections.abc import Sequence
|
|
3
2
|
from astToolkit import astDOTParamSpec, astDOTTryStar, astDOTTypeAlias, astDOTTypeVar, astDOTTypeVarTuple, astDOTtype_param
|
|
4
3
|
from astToolkit import ast_Identifier, ast_expr_Slice, intORstr, intORstrORtype_params, intORtype_params, str_nameDOTname
|
|
4
|
+
from collections.abc import Sequence
|
|
5
5
|
from typing import Any, Literal
|
|
6
6
|
import ast
|
|
7
7
|
|
|
@@ -336,4 +336,4 @@ class Make:
|
|
|
336
336
|
|
|
337
337
|
@staticmethod
|
|
338
338
|
def YieldFrom(value: ast.expr, **keywordArguments: int) -> ast.YieldFrom:
|
|
339
|
-
return ast.YieldFrom(value, **keywordArguments)
|
|
339
|
+
return ast.YieldFrom(value, **keywordArguments)
|
|
@@ -6,8 +6,9 @@ import ast
|
|
|
6
6
|
|
|
7
7
|
# NOTE Prototype of an idea to subclass composable methods so that typing information
|
|
8
8
|
# can extend beyond the top level of the ast node.
|
|
9
|
-
class
|
|
10
|
-
|
|
9
|
+
# To cover all cases, quantity of necessary classes = sum of (for each class: for each attribute: attribute * number of valid types). If an attribute has type ast.expr, for example, then there are 27 valid types just for that attribute. There would be thousands of subclasses like ImaCallToName.
|
|
10
|
+
# class ImaCallToName(ast.Call):
|
|
11
|
+
# func: ast.Name # pyright: ignore[reportIncompatibleVariableOverride]
|
|
11
12
|
|
|
12
13
|
# Type hints through TypeAlias or type "hints" through the identifier name.
|
|
13
14
|
ast_expr_Slice: typing_TypeAlias = ast.expr
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from autoflake import fix_code as autoflake_fix_code
|
|
2
|
-
from collections.abc import Mapping
|
|
2
|
+
from collections.abc import Callable, Mapping
|
|
3
3
|
from copy import deepcopy
|
|
4
4
|
from astToolkit import (
|
|
5
5
|
ast_Identifier,
|
|
@@ -19,7 +19,7 @@ from astToolkit import FREAKOUT
|
|
|
19
19
|
from Z0Z_tools import writeStringToHere
|
|
20
20
|
from os import PathLike
|
|
21
21
|
from pathlib import PurePath
|
|
22
|
-
from typing import Any
|
|
22
|
+
from typing import Any, cast
|
|
23
23
|
import ast
|
|
24
24
|
|
|
25
25
|
def makeDictionaryFunctionDef(module: ast.Module) -> dict[ast_Identifier, ast.FunctionDef]:
|
|
@@ -65,7 +65,7 @@ def inlineFunctionDef(identifierToInline: ast_Identifier, module: ast.Module) ->
|
|
|
65
65
|
raise ValueError(f"FunctionDefToInline not found in dictionaryIdentifier2FunctionDef: {identifierToInline = }") from ERRORmessage
|
|
66
66
|
|
|
67
67
|
listIdentifiersCalledFunctions: list[ast_Identifier] = []
|
|
68
|
-
findIdentifiersToInline = NodeTourist(findThis = IfThis.isCallToName, doThat = Grab.
|
|
68
|
+
findIdentifiersToInline = NodeTourist(findThis = IfThis.isCallToName, doThat = Grab.funcAttribute(cast(Callable[[ast.expr], ast.expr], Grab.idAttribute(cast(Callable[[ast_Identifier], ast_Identifier], Then.appendTo(listIdentifiersCalledFunctions))))))
|
|
69
69
|
findIdentifiersToInline.visit(FunctionDefToInline)
|
|
70
70
|
|
|
71
71
|
dictionary4Inlining: dict[ast_Identifier, ast.FunctionDef] = {}
|
|
@@ -193,12 +193,12 @@ def removeUnusedParameters(ingredientsFunction: IngredientsFunction) -> Ingredie
|
|
|
193
193
|
|
|
194
194
|
return ingredientsFunction
|
|
195
195
|
|
|
196
|
-
def
|
|
196
|
+
def unparseFindReplace(astTree: 个, mappingFindReplaceNodes: Mapping[ast.AST, ast.AST]) -> 个:
|
|
197
197
|
"""
|
|
198
198
|
Recursively replace AST nodes based on a mapping of find-replace pairs.
|
|
199
199
|
|
|
200
200
|
This function applies brute-force node replacement throughout an AST tree
|
|
201
|
-
by comparing textual representations of nodes. While not the most
|
|
201
|
+
by comparing textual representations of nodes. While not the most semantic
|
|
202
202
|
approach, it provides a reliable way to replace complex nested structures
|
|
203
203
|
when more precise targeting methods are difficult to implement.
|
|
204
204
|
|
|
@@ -211,7 +211,7 @@ def Z0Z_lameFindReplace(astTree: 个, mappingFindReplaceNodes: Mapping[ast.AST,
|
|
|
211
211
|
mappingFindReplaceNodes: A mapping from source nodes to replacement nodes.
|
|
212
212
|
|
|
213
213
|
Returns:
|
|
214
|
-
The modified AST structure with all matching nodes replaced.
|
|
214
|
+
newTree: The modified AST structure with all matching nodes replaced.
|
|
215
215
|
"""
|
|
216
216
|
keepGoing = True
|
|
217
217
|
newTree = deepcopy(astTree)
|
|
@@ -32,7 +32,7 @@ optional-dependencies = { testing = [
|
|
|
32
32
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
33
33
|
requires-python = ">=3.10"
|
|
34
34
|
urls = { Donate = "https://www.patreon.com/integrated", Homepage = "https://github.com/hunterhogan/astToolkit", Issues = "https://github.com/hunterhogan/astToolkit/issues", Repository = "https://github.com/hunterhogan/astToolkit.git" }
|
|
35
|
-
version = "0.1.
|
|
35
|
+
version = "0.1.2"
|
|
36
36
|
|
|
37
37
|
[tool.coverage]
|
|
38
38
|
report = { exclude_lines = [
|
|
@@ -2,9 +2,12 @@ from pathlib import Path
|
|
|
2
2
|
from typing import TypeAlias as typing_TypeAlias
|
|
3
3
|
|
|
4
4
|
ast_Identifier: typing_TypeAlias = str
|
|
5
|
+
fileExtension: str = '.py'
|
|
5
6
|
packageName: ast_Identifier = 'astToolkit'
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
pathRoot = Path('/apps') / packageName
|
|
8
|
+
pathPackage = pathRoot / packageName
|
|
9
|
+
pathTypeshed = pathRoot / 'typeshed/stdlib'
|
|
10
|
+
str_nameDOTname: typing_TypeAlias = str
|
|
8
11
|
sys_version_infoMinimum: tuple[int, int] = (3, 10)
|
|
9
12
|
sys_version_infoTarget: tuple[int, int] = (3, 13)
|
|
10
13
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
from toolFactory.Z0Z_hardcoded import (
|
|
2
2
|
ast_Identifier as ast_Identifier,
|
|
3
|
+
fileExtension as fileExtension,
|
|
3
4
|
FREAKOUT as FREAKOUT,
|
|
4
5
|
packageName as packageName,
|
|
5
6
|
pathPackage as pathPackage,
|
|
6
7
|
pathTypeshed as pathTypeshed,
|
|
8
|
+
str_nameDOTname as str_nameDOTname,
|
|
7
9
|
sys_version_infoMinimum as sys_version_infoMinimum,
|
|
8
10
|
sys_version_infoTarget as sys_version_infoTarget,
|
|
9
11
|
)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
from astToolkit import str_nameDOTname, The
|
|
2
1
|
from pathlib import PurePosixPath
|
|
3
2
|
from string import ascii_letters
|
|
4
|
-
from toolFactory import ast_Identifier, list_astDOTnew, sys_version_infoTarget
|
|
5
|
-
from toolFactory.astFactory_annex import handmadeMethodsGrab, handmadeTypeAlias_astTypes, MakeAttributeFunctionDef, MakeImportFunctionDef
|
|
3
|
+
from toolFactory import ast_Identifier, fileExtension, list_astDOTnew, pathPackage, str_nameDOTname, sys_version_infoTarget
|
|
4
|
+
from toolFactory.astFactory_annex import handmadeMethodsGrab, handmadeTypeAlias_astTypes, listPylanceErrors, MakeAttributeFunctionDef, MakeImportFunctionDef
|
|
6
5
|
from toolFactory.docstrings import docstringWarning, ClassDefDocstringBe, ClassDefDocstringDOT, ClassDefDocstringGrab, ClassDefDocstringMake
|
|
7
6
|
from typing import cast, TypedDict
|
|
8
7
|
from Z0Z_tools import writeStringToHere
|
|
@@ -69,13 +68,25 @@ class Prepend_ast2astClasses(ast.NodeTransformer):
|
|
|
69
68
|
return self.dictionarySubstitutions[node.id]
|
|
70
69
|
return node
|
|
71
70
|
|
|
72
|
-
def makeTools(astStubFile: ast.AST
|
|
71
|
+
def makeTools(astStubFile: ast.AST) -> None:
|
|
73
72
|
def writeModule(astModule: ast.Module, moduleIdentifier: ast_Identifier) -> None:
|
|
74
73
|
ast.fix_missing_locations(astModule)
|
|
75
74
|
pythonSource: str = ast.unparse(astModule)
|
|
76
75
|
if 'Grab' in moduleIdentifier or 'DOT' in moduleIdentifier:
|
|
77
76
|
pythonSource = "# ruff: noqa: F403, F405\n" + pythonSource
|
|
78
|
-
|
|
77
|
+
if 'Grab' in moduleIdentifier:
|
|
78
|
+
listTypeIgnore: list[ast.TypeIgnore] = []
|
|
79
|
+
tag = '[reportAttributeAccessIssue]'
|
|
80
|
+
for attribute in listPylanceErrors:
|
|
81
|
+
for lineno, line in enumerate(pythonSource.splitlines()):
|
|
82
|
+
if 'node.'+attribute in line:
|
|
83
|
+
listTypeIgnore.append(ast.TypeIgnore(lineno+1, tag))
|
|
84
|
+
break
|
|
85
|
+
astModule = ast.parse(pythonSource)
|
|
86
|
+
astModule.type_ignores.extend(listTypeIgnore)
|
|
87
|
+
pythonSource: str = ast.unparse(astModule)
|
|
88
|
+
pythonSource = "# ruff: noqa: F403, F405\n" + pythonSource
|
|
89
|
+
pathFilenameModule = PurePosixPath(pathPackage, moduleIdentifier + fileExtension)
|
|
79
90
|
writeStringToHere(pythonSource, pathFilenameModule)
|
|
80
91
|
|
|
81
92
|
# Create each ClassDef and add directly to it instead of creating unnecessary intermediate structures.
|
|
@@ -373,6 +384,13 @@ def makeTools(astStubFile: ast.AST, logicalPathInfix: str_nameDOTname = None) ->
|
|
|
373
384
|
, returns=attributeAnnotationAsAST
|
|
374
385
|
))
|
|
375
386
|
|
|
387
|
+
# `astTypesModule`: When one attribute has multiple return types
|
|
388
|
+
if list_hasDOTNameTypeAliasAnnotations:
|
|
389
|
+
astAnnAssignValue = list_hasDOTNameTypeAliasAnnotations[0]
|
|
390
|
+
for index in range(1, len(list_hasDOTNameTypeAliasAnnotations)):
|
|
391
|
+
astAnnAssignValue = ast.BinOp(left=astAnnAssignValue, op=ast.BitOr(), right=list_hasDOTNameTypeAliasAnnotations[index])
|
|
392
|
+
astTypesModule.body.append(ast.AnnAssign(hasDOTName_Store, typing_TypeAliasName, astAnnAssignValue, 1))
|
|
393
|
+
|
|
376
394
|
ClassDefDOT.body.append(ast.FunctionDef(name=attributeIdentifier
|
|
377
395
|
, args=ast.arguments(posonlyargs=[], args=[ast.arg(arg='node', annotation=hasDOTName_Load)], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[])
|
|
378
396
|
, body=[ast.Return(value=ast.Attribute(value=ast.Name('node', ast.Load()), attr=attributeIdentifier, ctx=ast.Load()))]
|
|
@@ -380,6 +398,10 @@ def makeTools(astStubFile: ast.AST, logicalPathInfix: str_nameDOTname = None) ->
|
|
|
380
398
|
, returns=attributeAnnotationUnifiedAsAST
|
|
381
399
|
))
|
|
382
400
|
|
|
401
|
+
astAssignValue = ast.Call(ast.Name('action', ast.Load()), args=[ast.Attribute(ast.Name('node', ast.Load()), attr=attributeIdentifier, ctx=ast.Load())])
|
|
402
|
+
if (isinstance(attributeAnnotationUnifiedAsAST, ast.Subscript) and isinstance(attributeAnnotationUnifiedAsAST.value, ast.Name) and attributeAnnotationUnifiedAsAST.value.id == 'Sequence'
|
|
403
|
+
or isinstance(attributeAnnotationUnifiedAsAST, ast.BinOp) and isinstance(attributeAnnotationUnifiedAsAST.right, ast.Subscript) and isinstance(attributeAnnotationUnifiedAsAST.right.value, ast.Name) and attributeAnnotationUnifiedAsAST.right.value.id == 'Sequence'):
|
|
404
|
+
astAssignValue = ast.Call(ast.Name('list', ctx=ast.Load()), args=[ast.Call(ast.Name('action', ast.Load()), args=[ast.Attribute(ast.Name('node', ast.Load()), attr=attributeIdentifier, ctx=ast.Load())])])
|
|
383
405
|
ClassDefGrab.body.append(ast.FunctionDef(name=attributeIdentifier + 'Attribute'
|
|
384
406
|
, args=ast.arguments(posonlyargs=[]
|
|
385
407
|
, args=[ast.arg('action'
|
|
@@ -392,20 +414,13 @@ def makeTools(astStubFile: ast.AST, logicalPathInfix: str_nameDOTname = None) ->
|
|
|
392
414
|
, body=[ast.FunctionDef(name='workhorse',
|
|
393
415
|
args=ast.arguments(args=[ast.arg('node', hasDOTName_Load)]),
|
|
394
416
|
body=[ast.Assign(targets=[ast.Attribute(ast.Name('node', ast.Load()), attr=attributeIdentifier, ctx=ast.Store())],
|
|
395
|
-
value
|
|
417
|
+
value = astAssignValue)
|
|
396
418
|
, ast.Return(ast.Name('node', ast.Load()))],
|
|
397
419
|
returns=hasDOTName_Load),
|
|
398
420
|
ast.Return(ast.Name('workhorse', ctx=ast.Load()))]
|
|
399
421
|
, decorator_list=[staticmethodName], type_comment=None
|
|
400
422
|
, returns=ast.Subscript(ast.Name('Callable', ast.Load()), ast.Tuple([ast.List([hasDOTName_Load], ast.Load()), hasDOTName_Load], ast.Load()), ast.Load())))
|
|
401
423
|
|
|
402
|
-
# `astTypesModule`: When one attribute has multiple return types
|
|
403
|
-
if list_hasDOTNameTypeAliasAnnotations:
|
|
404
|
-
astAnnAssignValue = list_hasDOTNameTypeAliasAnnotations[0]
|
|
405
|
-
for index in range(1, len(list_hasDOTNameTypeAliasAnnotations)):
|
|
406
|
-
astAnnAssignValue = ast.BinOp(left=astAnnAssignValue, op=ast.BitOr(), right=list_hasDOTNameTypeAliasAnnotations[index])
|
|
407
|
-
astTypesModule.body.append(ast.AnnAssign(hasDOTName_Store, typing_TypeAliasName, astAnnAssignValue, 1))
|
|
408
|
-
|
|
409
424
|
writeModule(astTypesModule, '_astTypes')
|
|
410
425
|
|
|
411
426
|
ClassDefBe.body.insert(0, ast.Expr(value=ast.Constant(value=ClassDefDocstringBe)))
|
|
@@ -428,7 +443,8 @@ def makeTools(astStubFile: ast.AST, logicalPathInfix: str_nameDOTname = None) ->
|
|
|
428
443
|
|
|
429
444
|
writeModule(ast.Module(
|
|
430
445
|
body=[ast.Expr(ast.Constant(docstringWarning))
|
|
431
|
-
, ast.ImportFrom('
|
|
446
|
+
, ast.ImportFrom('astToolkit._astTypes', [ast.alias('*')], 0)
|
|
447
|
+
, ast.ImportFrom('collections.abc', [ast.alias('Sequence')], 0)
|
|
432
448
|
, ast.ImportFrom('astToolkit', [ast.alias(identifier) for identifier in ['ast_Identifier', 'ast_expr_Slice', 'astDOTtype_param']], 0)
|
|
433
449
|
, ast.ImportFrom('typing', [ast.alias(identifier) for identifier in ['Any', 'Literal', 'overload']], 0)
|
|
434
450
|
, ast.Import([ast.alias('ast')])
|
|
@@ -440,9 +456,10 @@ def makeTools(astStubFile: ast.AST, logicalPathInfix: str_nameDOTname = None) ->
|
|
|
440
456
|
|
|
441
457
|
writeModule(ast.Module(
|
|
442
458
|
body=[ast.Expr(ast.Constant(docstringWarning))
|
|
443
|
-
, ast.ImportFrom('collections.abc', [ast.alias('Callable'), ast.alias('Sequence')], 0)
|
|
444
|
-
, astImportFromClassNewInPythonVersion , ast.ImportFrom('astToolkit', [ast.alias(identifier) for identifier in ['ast_Identifier', 'ast_expr_Slice', 'NodeORattribute', 'ImaCallToName']], 0)
|
|
445
459
|
, ast.ImportFrom('astToolkit._astTypes', [ast.alias('*')], 0)
|
|
460
|
+
, astImportFromClassNewInPythonVersion
|
|
461
|
+
, ast.ImportFrom('astToolkit', [ast.alias(identifier) for identifier in ['ast_Identifier', 'ast_expr_Slice', 'NodeORattribute']], 0)
|
|
462
|
+
, ast.ImportFrom('collections.abc', [ast.alias('Callable'), ast.alias('Sequence')], 0)
|
|
446
463
|
, ast.ImportFrom('typing', [ast.alias('Any'), ast.alias('Literal')], 0)
|
|
447
464
|
, ast.Import([ast.alias('ast')])
|
|
448
465
|
, ClassDefGrab
|
|
@@ -453,9 +470,9 @@ def makeTools(astStubFile: ast.AST, logicalPathInfix: str_nameDOTname = None) ->
|
|
|
453
470
|
|
|
454
471
|
writeModule(ast.Module(
|
|
455
472
|
body=[ast.Expr(ast.Constant(docstringWarning))
|
|
456
|
-
, ast.ImportFrom('collections.abc', [ast.alias('Sequence')], 0)
|
|
457
473
|
, astImportFromClassNewInPythonVersion
|
|
458
474
|
, ast.ImportFrom('astToolkit', [ast.alias(identifier) for identifier in ['ast_Identifier', 'ast_expr_Slice', 'intORstr', 'intORstrORtype_params', 'intORtype_params', 'str_nameDOTname']], 0)
|
|
475
|
+
, ast.ImportFrom('collections.abc', [ast.alias('Sequence')], 0)
|
|
459
476
|
, ast.ImportFrom('typing', [ast.alias('Any'), ast.alias('Literal')], 0)
|
|
460
477
|
, ast.Import([ast.alias('ast')])
|
|
461
478
|
, ClassDefMake
|
|
@@ -21,16 +21,8 @@ def andDoAllOf(listOfActions: list[Callable[[NodeORattribute], NodeORattribute]]
|
|
|
21
21
|
return workhorse
|
|
22
22
|
"""
|
|
23
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
24
|
handmadeMethodsGrab: list[ast.FunctionDef] = []
|
|
33
|
-
for string in [Grab_andDoAllOf
|
|
25
|
+
for string in [Grab_andDoAllOf]:
|
|
34
26
|
astModule = ast.parse(string)
|
|
35
27
|
for node in ast.iter_child_nodes(astModule):
|
|
36
28
|
if isinstance(node, ast.FunctionDef):
|
|
@@ -55,9 +47,16 @@ MakeAttributeFunctionDef: ast.FunctionDef = ast.FunctionDef(
|
|
|
55
47
|
|
|
56
48
|
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
49
|
|
|
50
|
+
listPylanceErrors: list[str] = ['annotation', 'arg', 'args', 'body', 'keys', 'name', 'names', 'op', 'orelse', 'pattern', 'returns', 'target', 'value',]
|
|
51
|
+
|
|
58
52
|
# ww='''
|
|
59
|
-
#
|
|
53
|
+
# def argAttribute(action: Callable[[ast_Identifier | (ast_Identifier | None)], ast_Identifier | (ast_Identifier | None)]) -> Callable[[hasDOTarg], hasDOTarg]:
|
|
54
|
+
|
|
55
|
+
# def workhorse(node: hasDOTarg) -> hasDOTarg:
|
|
56
|
+
# node.arg = action(node.arg) # type: ignore[reportAttributeAccessIssue]
|
|
57
|
+
# return node
|
|
58
|
+
# return workhorse
|
|
60
59
|
# '''
|
|
61
60
|
|
|
62
|
-
# print(ast.dump(ast.parse(ww), indent=4))
|
|
61
|
+
# print(ast.dump(ast.parse(ww, type_comments=True), indent=4))
|
|
63
62
|
# from ast import *
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|