astToolkit 0.3.1__tar.gz → 0.3.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.3.1 → asttoolkit-0.3.2}/PKG-INFO +1 -1
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_toolClassIsAndAttribute.py +36 -36
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_toolDOT.py +36 -36
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_toolGrab.py +47 -47
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_toolIfThis.py +3 -3
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit.egg-info/PKG-INFO +1 -1
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/pyproject.toml +1 -1
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/LICENSE +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/README.md +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/__init__.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_astTypes.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_theSSOT.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_toolBe.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_toolMake.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_toolThen.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_toolkitAST.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_toolkitContainers.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_toolkitNodeVisitor.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/_types.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/py.typed +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit/transformationTools.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit.egg-info/SOURCES.txt +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit.egg-info/dependency_links.txt +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit.egg-info/requires.txt +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/astToolkit.egg-info/top_level.txt +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/setup.cfg +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/tests/test_basic.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/toolFactory/Z0Z_hardcoded.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/toolFactory/__init__.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/toolFactory/_snippets.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/toolFactory/datacenter.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/toolFactory/docstrings.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/toolFactory/factory3.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/toolFactory/factory_annex.py +0 -0
- {asttoolkit-0.3.1 → asttoolkit-0.3.2}/toolFactory/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astToolkit
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: A powerfully composable, type-safe toolkit for Python abstract syntax tree (AST) manipulation, analysis, transformation, and code generation with a layered architecture designed for building sophisticated code processing assembly-lines.
|
|
5
5
|
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
6
|
License: CC-BY-NC-4.0
|
|
@@ -28,11 +28,11 @@ class ClassIsAndAttribute:
|
|
|
28
28
|
|
|
29
29
|
@staticmethod
|
|
30
30
|
@overload
|
|
31
|
-
def annotationIs(astClass: type[hasDOTannotation_exprOrNone], attributeCondition: Callable[[ast.expr
|
|
31
|
+
def annotationIs(astClass: type[hasDOTannotation_exprOrNone], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTannotation_exprOrNone] | bool]:
|
|
32
32
|
...
|
|
33
33
|
|
|
34
34
|
@staticmethod
|
|
35
|
-
def annotationIs(astClass: type[hasDOTannotation], attributeCondition: Callable[[ast.expr], bool]
|
|
35
|
+
def annotationIs(astClass: type[hasDOTannotation], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTannotation] | bool]:
|
|
36
36
|
|
|
37
37
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTannotation] | bool:
|
|
38
38
|
return isinstance(node, astClass) and node.annotation is not None and attributeCondition(node.annotation)
|
|
@@ -45,11 +45,11 @@ class ClassIsAndAttribute:
|
|
|
45
45
|
|
|
46
46
|
@staticmethod
|
|
47
47
|
@overload
|
|
48
|
-
def argIs(astClass: type[hasDOTarg_strOrNone], attributeCondition: Callable[[str
|
|
48
|
+
def argIs(astClass: type[hasDOTarg_strOrNone], attributeCondition: Callable[[str], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTarg_strOrNone] | bool]:
|
|
49
49
|
...
|
|
50
50
|
|
|
51
51
|
@staticmethod
|
|
52
|
-
def argIs(astClass: type[hasDOTarg], attributeCondition: Callable[[str], bool]
|
|
52
|
+
def argIs(astClass: type[hasDOTarg], attributeCondition: Callable[[str], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTarg] | bool]:
|
|
53
53
|
|
|
54
54
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTarg] | bool:
|
|
55
55
|
return isinstance(node, astClass) and node.arg is not None and attributeCondition(node.arg)
|
|
@@ -85,7 +85,7 @@ class ClassIsAndAttribute:
|
|
|
85
85
|
return workhorse
|
|
86
86
|
|
|
87
87
|
@staticmethod
|
|
88
|
-
def asnameIs(astClass: type[hasDOTasname], attributeCondition: Callable[[str
|
|
88
|
+
def asnameIs(astClass: type[hasDOTasname], attributeCondition: Callable[[str], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTasname] | bool]:
|
|
89
89
|
|
|
90
90
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTasname] | bool:
|
|
91
91
|
return isinstance(node, astClass) and node.asname is not None and attributeCondition(node.asname)
|
|
@@ -123,7 +123,7 @@ class ClassIsAndAttribute:
|
|
|
123
123
|
return workhorse
|
|
124
124
|
|
|
125
125
|
@staticmethod
|
|
126
|
-
def boundIs(astClass: type[hasDOTbound], attributeCondition: Callable[[ast.expr
|
|
126
|
+
def boundIs(astClass: type[hasDOTbound], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTbound] | bool]:
|
|
127
127
|
|
|
128
128
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTbound] | bool:
|
|
129
129
|
return isinstance(node, astClass) and node.bound is not None and attributeCondition(node.bound)
|
|
@@ -137,7 +137,7 @@ class ClassIsAndAttribute:
|
|
|
137
137
|
return workhorse
|
|
138
138
|
|
|
139
139
|
@staticmethod
|
|
140
|
-
def causeIs(astClass: type[hasDOTcause], attributeCondition: Callable[[ast.expr
|
|
140
|
+
def causeIs(astClass: type[hasDOTcause], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTcause] | bool]:
|
|
141
141
|
|
|
142
142
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTcause] | bool:
|
|
143
143
|
return isinstance(node, astClass) and node.cause is not None and attributeCondition(node.cause)
|
|
@@ -187,7 +187,7 @@ class ClassIsAndAttribute:
|
|
|
187
187
|
if sys.version_info >= (3, 13):
|
|
188
188
|
|
|
189
189
|
@staticmethod
|
|
190
|
-
def default_valueIs(astClass: type[hasDOTdefault_value], attributeCondition: Callable[[ast.expr
|
|
190
|
+
def default_valueIs(astClass: type[hasDOTdefault_value], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTdefault_value] | bool]:
|
|
191
191
|
|
|
192
192
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTdefault_value] | bool:
|
|
193
193
|
return isinstance(node, astClass) and node.default_value is not None and attributeCondition(node.default_value)
|
|
@@ -215,7 +215,7 @@ class ClassIsAndAttribute:
|
|
|
215
215
|
return workhorse
|
|
216
216
|
|
|
217
217
|
@staticmethod
|
|
218
|
-
def excIs(astClass: type[hasDOTexc], attributeCondition: Callable[[ast.expr
|
|
218
|
+
def excIs(astClass: type[hasDOTexc], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTexc] | bool]:
|
|
219
219
|
|
|
220
220
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTexc] | bool:
|
|
221
221
|
return isinstance(node, astClass) and node.exc is not None and attributeCondition(node.exc)
|
|
@@ -229,7 +229,7 @@ class ClassIsAndAttribute:
|
|
|
229
229
|
return workhorse
|
|
230
230
|
|
|
231
231
|
@staticmethod
|
|
232
|
-
def format_specIs(astClass: type[hasDOTformat_spec], attributeCondition: Callable[[ast.expr
|
|
232
|
+
def format_specIs(astClass: type[hasDOTformat_spec], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTformat_spec] | bool]:
|
|
233
233
|
|
|
234
234
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTformat_spec] | bool:
|
|
235
235
|
return isinstance(node, astClass) and node.format_spec is not None and attributeCondition(node.format_spec)
|
|
@@ -250,7 +250,7 @@ class ClassIsAndAttribute:
|
|
|
250
250
|
return workhorse
|
|
251
251
|
|
|
252
252
|
@staticmethod
|
|
253
|
-
def guardIs(astClass: type[hasDOTguard], attributeCondition: Callable[[ast.expr
|
|
253
|
+
def guardIs(astClass: type[hasDOTguard], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTguard] | bool]:
|
|
254
254
|
|
|
255
255
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTguard] | bool:
|
|
256
256
|
return isinstance(node, astClass) and node.guard is not None and attributeCondition(node.guard)
|
|
@@ -312,11 +312,11 @@ class ClassIsAndAttribute:
|
|
|
312
312
|
|
|
313
313
|
@staticmethod
|
|
314
314
|
@overload
|
|
315
|
-
def keysIs(astClass: type[hasDOTkeys_list_exprOrNone], attributeCondition: Callable[[list[ast.expr
|
|
315
|
+
def keysIs(astClass: type[hasDOTkeys_list_exprOrNone], attributeCondition: Callable[[list[ast.expr]], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTkeys_list_exprOrNone] | bool]:
|
|
316
316
|
...
|
|
317
317
|
|
|
318
318
|
@staticmethod
|
|
319
|
-
def keysIs(astClass: type[hasDOTkeys], attributeCondition: Callable[[list[ast.expr]], bool]
|
|
319
|
+
def keysIs(astClass: type[hasDOTkeys], attributeCondition: Callable[[list[ast.expr]], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTkeys] | bool]:
|
|
320
320
|
|
|
321
321
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTkeys] | bool:
|
|
322
322
|
return isinstance(node, astClass) and node.keys != [None] and attributeCondition(node.keys)
|
|
@@ -330,21 +330,21 @@ class ClassIsAndAttribute:
|
|
|
330
330
|
return workhorse
|
|
331
331
|
|
|
332
332
|
@staticmethod
|
|
333
|
-
def kindIs(astClass: type[hasDOTkind], attributeCondition: Callable[[str
|
|
333
|
+
def kindIs(astClass: type[hasDOTkind], attributeCondition: Callable[[str], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTkind] | bool]:
|
|
334
334
|
|
|
335
335
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTkind] | bool:
|
|
336
336
|
return isinstance(node, astClass) and node.kind is not None and attributeCondition(node.kind)
|
|
337
337
|
return workhorse
|
|
338
338
|
|
|
339
339
|
@staticmethod
|
|
340
|
-
def kw_defaultsIs(astClass: type[hasDOTkw_defaults], attributeCondition: Callable[[list[ast.expr
|
|
340
|
+
def kw_defaultsIs(astClass: type[hasDOTkw_defaults], attributeCondition: Callable[[list[ast.expr]], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTkw_defaults] | bool]:
|
|
341
341
|
|
|
342
342
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTkw_defaults] | bool:
|
|
343
343
|
return isinstance(node, astClass) and node.kw_defaults != [None] and attributeCondition(node.kw_defaults)
|
|
344
344
|
return workhorse
|
|
345
345
|
|
|
346
346
|
@staticmethod
|
|
347
|
-
def kwargIs(astClass: type[hasDOTkwarg], attributeCondition: Callable[[ast.arg
|
|
347
|
+
def kwargIs(astClass: type[hasDOTkwarg], attributeCondition: Callable[[ast.arg], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTkwarg] | bool]:
|
|
348
348
|
|
|
349
349
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTkwarg] | bool:
|
|
350
350
|
return isinstance(node, astClass) and node.kwarg is not None and attributeCondition(node.kwarg)
|
|
@@ -393,21 +393,21 @@ class ClassIsAndAttribute:
|
|
|
393
393
|
return workhorse
|
|
394
394
|
|
|
395
395
|
@staticmethod
|
|
396
|
-
def lowerIs(astClass: type[hasDOTlower], attributeCondition: Callable[[ast.expr
|
|
396
|
+
def lowerIs(astClass: type[hasDOTlower], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTlower] | bool]:
|
|
397
397
|
|
|
398
398
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTlower] | bool:
|
|
399
399
|
return isinstance(node, astClass) and node.lower is not None and attributeCondition(node.lower)
|
|
400
400
|
return workhorse
|
|
401
401
|
|
|
402
402
|
@staticmethod
|
|
403
|
-
def moduleIs(astClass: type[hasDOTmodule], attributeCondition: Callable[[str
|
|
403
|
+
def moduleIs(astClass: type[hasDOTmodule], attributeCondition: Callable[[str], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTmodule] | bool]:
|
|
404
404
|
|
|
405
405
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTmodule] | bool:
|
|
406
406
|
return isinstance(node, astClass) and node.module is not None and attributeCondition(node.module)
|
|
407
407
|
return workhorse
|
|
408
408
|
|
|
409
409
|
@staticmethod
|
|
410
|
-
def msgIs(astClass: type[hasDOTmsg], attributeCondition: Callable[[ast.expr
|
|
410
|
+
def msgIs(astClass: type[hasDOTmsg], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTmsg] | bool]:
|
|
411
411
|
|
|
412
412
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTmsg] | bool:
|
|
413
413
|
return isinstance(node, astClass) and node.msg is not None and attributeCondition(node.msg)
|
|
@@ -425,11 +425,11 @@ class ClassIsAndAttribute:
|
|
|
425
425
|
|
|
426
426
|
@staticmethod
|
|
427
427
|
@overload
|
|
428
|
-
def nameIs(astClass: type[hasDOTname_strOrNone], attributeCondition: Callable[[str
|
|
428
|
+
def nameIs(astClass: type[hasDOTname_strOrNone], attributeCondition: Callable[[str], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTname_strOrNone] | bool]:
|
|
429
429
|
...
|
|
430
430
|
|
|
431
431
|
@staticmethod
|
|
432
|
-
def nameIs(astClass: type[hasDOTname], attributeCondition: Callable[[ast.Name], bool] | Callable[[str], bool]
|
|
432
|
+
def nameIs(astClass: type[hasDOTname], attributeCondition: Callable[[ast.Name], bool] | Callable[[str], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTname] | bool]:
|
|
433
433
|
|
|
434
434
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTname] | bool:
|
|
435
435
|
return isinstance(node, astClass) and node.name is not None and attributeCondition(node.name)
|
|
@@ -489,7 +489,7 @@ class ClassIsAndAttribute:
|
|
|
489
489
|
return workhorse
|
|
490
490
|
|
|
491
491
|
@staticmethod
|
|
492
|
-
def optional_varsIs(astClass: type[hasDOToptional_vars], attributeCondition: Callable[[ast.expr
|
|
492
|
+
def optional_varsIs(astClass: type[hasDOToptional_vars], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOToptional_vars] | bool]:
|
|
493
493
|
|
|
494
494
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOToptional_vars] | bool:
|
|
495
495
|
return isinstance(node, astClass) and node.optional_vars is not None and attributeCondition(node.optional_vars)
|
|
@@ -519,11 +519,11 @@ class ClassIsAndAttribute:
|
|
|
519
519
|
|
|
520
520
|
@staticmethod
|
|
521
521
|
@overload
|
|
522
|
-
def patternIs(astClass: type[hasDOTpattern_patternOrNone], attributeCondition: Callable[[ast.pattern
|
|
522
|
+
def patternIs(astClass: type[hasDOTpattern_patternOrNone], attributeCondition: Callable[[ast.pattern], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTpattern_patternOrNone] | bool]:
|
|
523
523
|
...
|
|
524
524
|
|
|
525
525
|
@staticmethod
|
|
526
|
-
def patternIs(astClass: type[hasDOTpattern], attributeCondition: Callable[[ast.pattern], bool]
|
|
526
|
+
def patternIs(astClass: type[hasDOTpattern], attributeCondition: Callable[[ast.pattern], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTpattern] | bool]:
|
|
527
527
|
|
|
528
528
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTpattern] | bool:
|
|
529
529
|
return isinstance(node, astClass) and node.pattern is not None and attributeCondition(node.pattern)
|
|
@@ -544,7 +544,7 @@ class ClassIsAndAttribute:
|
|
|
544
544
|
return workhorse
|
|
545
545
|
|
|
546
546
|
@staticmethod
|
|
547
|
-
def restIs(astClass: type[hasDOTrest], attributeCondition: Callable[[str
|
|
547
|
+
def restIs(astClass: type[hasDOTrest], attributeCondition: Callable[[str], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTrest] | bool]:
|
|
548
548
|
|
|
549
549
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTrest] | bool:
|
|
550
550
|
return isinstance(node, astClass) and node.rest is not None and attributeCondition(node.rest)
|
|
@@ -557,11 +557,11 @@ class ClassIsAndAttribute:
|
|
|
557
557
|
|
|
558
558
|
@staticmethod
|
|
559
559
|
@overload
|
|
560
|
-
def returnsIs(astClass: type[hasDOTreturns_exprOrNone], attributeCondition: Callable[[ast.expr
|
|
560
|
+
def returnsIs(astClass: type[hasDOTreturns_exprOrNone], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTreturns_exprOrNone] | bool]:
|
|
561
561
|
...
|
|
562
562
|
|
|
563
563
|
@staticmethod
|
|
564
|
-
def returnsIs(astClass: type[hasDOTreturns], attributeCondition: Callable[[ast.expr], bool]
|
|
564
|
+
def returnsIs(astClass: type[hasDOTreturns], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTreturns] | bool]:
|
|
565
565
|
|
|
566
566
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTreturns] | bool:
|
|
567
567
|
return isinstance(node, astClass) and node.returns is not None and attributeCondition(node.returns)
|
|
@@ -589,7 +589,7 @@ class ClassIsAndAttribute:
|
|
|
589
589
|
return workhorse
|
|
590
590
|
|
|
591
591
|
@staticmethod
|
|
592
|
-
def stepIs(astClass: type[hasDOTstep], attributeCondition: Callable[[ast.expr
|
|
592
|
+
def stepIs(astClass: type[hasDOTstep], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTstep] | bool]:
|
|
593
593
|
|
|
594
594
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTstep] | bool:
|
|
595
595
|
return isinstance(node, astClass) and node.step is not None and attributeCondition(node.step)
|
|
@@ -646,14 +646,14 @@ class ClassIsAndAttribute:
|
|
|
646
646
|
return workhorse
|
|
647
647
|
|
|
648
648
|
@staticmethod
|
|
649
|
-
def typeIs(astClass: type[hasDOTtype], attributeCondition: Callable[[ast.expr
|
|
649
|
+
def typeIs(astClass: type[hasDOTtype], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTtype] | bool]:
|
|
650
650
|
|
|
651
651
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTtype] | bool:
|
|
652
652
|
return isinstance(node, astClass) and node.type is not None and attributeCondition(node.type)
|
|
653
653
|
return workhorse
|
|
654
654
|
|
|
655
655
|
@staticmethod
|
|
656
|
-
def type_commentIs(astClass: type[hasDOTtype_comment], attributeCondition: Callable[[str
|
|
656
|
+
def type_commentIs(astClass: type[hasDOTtype_comment], attributeCondition: Callable[[str], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTtype_comment] | bool]:
|
|
657
657
|
|
|
658
658
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTtype_comment] | bool:
|
|
659
659
|
return isinstance(node, astClass) and node.type_comment is not None and attributeCondition(node.type_comment)
|
|
@@ -674,7 +674,7 @@ class ClassIsAndAttribute:
|
|
|
674
674
|
return workhorse
|
|
675
675
|
|
|
676
676
|
@staticmethod
|
|
677
|
-
def upperIs(astClass: type[hasDOTupper], attributeCondition: Callable[[ast.expr
|
|
677
|
+
def upperIs(astClass: type[hasDOTupper], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTupper] | bool]:
|
|
678
678
|
|
|
679
679
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTupper] | bool:
|
|
680
680
|
return isinstance(node, astClass) and node.upper is not None and attributeCondition(node.upper)
|
|
@@ -687,7 +687,7 @@ class ClassIsAndAttribute:
|
|
|
687
687
|
|
|
688
688
|
@staticmethod
|
|
689
689
|
@overload
|
|
690
|
-
def valueIs(astClass: type[hasDOTvalue_boolOrNone], attributeCondition: Callable[[bool
|
|
690
|
+
def valueIs(astClass: type[hasDOTvalue_boolOrNone], attributeCondition: Callable[[bool], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTvalue_boolOrNone] | bool]:
|
|
691
691
|
...
|
|
692
692
|
|
|
693
693
|
@staticmethod
|
|
@@ -697,11 +697,11 @@ class ClassIsAndAttribute:
|
|
|
697
697
|
|
|
698
698
|
@staticmethod
|
|
699
699
|
@overload
|
|
700
|
-
def valueIs(astClass: type[hasDOTvalue_exprOrNone], attributeCondition: Callable[[ast.expr
|
|
700
|
+
def valueIs(astClass: type[hasDOTvalue_exprOrNone], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTvalue_exprOrNone] | bool]:
|
|
701
701
|
...
|
|
702
702
|
|
|
703
703
|
@staticmethod
|
|
704
|
-
def valueIs(astClass: type[hasDOTvalue], attributeCondition: Callable[[Any], bool] | Callable[[bool
|
|
704
|
+
def valueIs(astClass: type[hasDOTvalue], attributeCondition: Callable[[Any], bool] | Callable[[bool], bool] | Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTvalue] | bool]:
|
|
705
705
|
|
|
706
706
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTvalue] | bool:
|
|
707
707
|
return isinstance(node, astClass) and node.value is not None and attributeCondition(node.value)
|
|
@@ -715,8 +715,8 @@ class ClassIsAndAttribute:
|
|
|
715
715
|
return workhorse
|
|
716
716
|
|
|
717
717
|
@staticmethod
|
|
718
|
-
def varargIs(astClass: type[hasDOTvararg], attributeCondition: Callable[[ast.arg
|
|
718
|
+
def varargIs(astClass: type[hasDOTvararg], attributeCondition: Callable[[ast.arg], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTvararg] | bool]:
|
|
719
719
|
|
|
720
720
|
def workhorse(node: ast.AST) -> TypeGuard[hasDOTvararg] | bool:
|
|
721
721
|
return isinstance(node, astClass) and node.vararg is not None and attributeCondition(node.vararg)
|
|
722
|
-
return workhorse
|
|
722
|
+
return workhorse
|
|
@@ -25,11 +25,11 @@ class DOT:
|
|
|
25
25
|
|
|
26
26
|
@staticmethod
|
|
27
27
|
@overload
|
|
28
|
-
def annotation(node: hasDOTannotation_exprOrNone) -> ast.expr
|
|
28
|
+
def annotation(node: hasDOTannotation_exprOrNone) -> ast.expr:
|
|
29
29
|
...
|
|
30
30
|
|
|
31
31
|
@staticmethod
|
|
32
|
-
def annotation(node: hasDOTannotation) -> ast.expr
|
|
32
|
+
def annotation(node: hasDOTannotation) -> ast.expr:
|
|
33
33
|
return node.annotation
|
|
34
34
|
|
|
35
35
|
@staticmethod
|
|
@@ -39,11 +39,11 @@ class DOT:
|
|
|
39
39
|
|
|
40
40
|
@staticmethod
|
|
41
41
|
@overload
|
|
42
|
-
def arg(node: hasDOTarg_strOrNone) -> str
|
|
42
|
+
def arg(node: hasDOTarg_strOrNone) -> str:
|
|
43
43
|
...
|
|
44
44
|
|
|
45
45
|
@staticmethod
|
|
46
|
-
def arg(node: hasDOTarg) -> str
|
|
46
|
+
def arg(node: hasDOTarg) -> str:
|
|
47
47
|
return node.arg
|
|
48
48
|
|
|
49
49
|
@staticmethod
|
|
@@ -70,7 +70,7 @@ class DOT:
|
|
|
70
70
|
return node.argtypes
|
|
71
71
|
|
|
72
72
|
@staticmethod
|
|
73
|
-
def asname(node: hasDOTasname) -> str
|
|
73
|
+
def asname(node: hasDOTasname) -> str:
|
|
74
74
|
return node.asname
|
|
75
75
|
|
|
76
76
|
@staticmethod
|
|
@@ -96,7 +96,7 @@ class DOT:
|
|
|
96
96
|
return node.body
|
|
97
97
|
|
|
98
98
|
@staticmethod
|
|
99
|
-
def bound(node: hasDOTbound) -> ast.expr
|
|
99
|
+
def bound(node: hasDOTbound) -> ast.expr:
|
|
100
100
|
return node.bound
|
|
101
101
|
|
|
102
102
|
@staticmethod
|
|
@@ -104,7 +104,7 @@ class DOT:
|
|
|
104
104
|
return node.cases
|
|
105
105
|
|
|
106
106
|
@staticmethod
|
|
107
|
-
def cause(node: hasDOTcause) -> ast.expr
|
|
107
|
+
def cause(node: hasDOTcause) -> ast.expr:
|
|
108
108
|
return node.cause
|
|
109
109
|
|
|
110
110
|
@staticmethod
|
|
@@ -133,7 +133,7 @@ class DOT:
|
|
|
133
133
|
if sys.version_info >= (3, 13):
|
|
134
134
|
|
|
135
135
|
@staticmethod
|
|
136
|
-
def default_value(node: hasDOTdefault_value) -> ast.expr
|
|
136
|
+
def default_value(node: hasDOTdefault_value) -> ast.expr:
|
|
137
137
|
return node.default_value
|
|
138
138
|
|
|
139
139
|
@staticmethod
|
|
@@ -149,7 +149,7 @@ class DOT:
|
|
|
149
149
|
return node.elts
|
|
150
150
|
|
|
151
151
|
@staticmethod
|
|
152
|
-
def exc(node: hasDOTexc) -> ast.expr
|
|
152
|
+
def exc(node: hasDOTexc) -> ast.expr:
|
|
153
153
|
return node.exc
|
|
154
154
|
|
|
155
155
|
@staticmethod
|
|
@@ -157,7 +157,7 @@ class DOT:
|
|
|
157
157
|
return node.finalbody
|
|
158
158
|
|
|
159
159
|
@staticmethod
|
|
160
|
-
def format_spec(node: hasDOTformat_spec) -> ast.expr
|
|
160
|
+
def format_spec(node: hasDOTformat_spec) -> ast.expr:
|
|
161
161
|
return node.format_spec
|
|
162
162
|
|
|
163
163
|
@staticmethod
|
|
@@ -169,7 +169,7 @@ class DOT:
|
|
|
169
169
|
return node.generators
|
|
170
170
|
|
|
171
171
|
@staticmethod
|
|
172
|
-
def guard(node: hasDOTguard) -> ast.expr
|
|
172
|
+
def guard(node: hasDOTguard) -> ast.expr:
|
|
173
173
|
return node.guard
|
|
174
174
|
|
|
175
175
|
@staticmethod
|
|
@@ -207,11 +207,11 @@ class DOT:
|
|
|
207
207
|
|
|
208
208
|
@staticmethod
|
|
209
209
|
@overload
|
|
210
|
-
def keys(node: hasDOTkeys_list_exprOrNone) -> list[ast.expr
|
|
210
|
+
def keys(node: hasDOTkeys_list_exprOrNone) -> list[ast.expr]:
|
|
211
211
|
...
|
|
212
212
|
|
|
213
213
|
@staticmethod
|
|
214
|
-
def keys(node: hasDOTkeys) -> list[ast.expr]
|
|
214
|
+
def keys(node: hasDOTkeys) -> list[ast.expr]:
|
|
215
215
|
return node.keys
|
|
216
216
|
|
|
217
217
|
@staticmethod
|
|
@@ -219,15 +219,15 @@ class DOT:
|
|
|
219
219
|
return node.keywords
|
|
220
220
|
|
|
221
221
|
@staticmethod
|
|
222
|
-
def kind(node: hasDOTkind) -> str
|
|
222
|
+
def kind(node: hasDOTkind) -> str:
|
|
223
223
|
return node.kind
|
|
224
224
|
|
|
225
225
|
@staticmethod
|
|
226
|
-
def kw_defaults(node: hasDOTkw_defaults) -> list[ast.expr
|
|
226
|
+
def kw_defaults(node: hasDOTkw_defaults) -> list[ast.expr]:
|
|
227
227
|
return node.kw_defaults
|
|
228
228
|
|
|
229
229
|
@staticmethod
|
|
230
|
-
def kwarg(node: hasDOTkwarg) -> ast.arg
|
|
230
|
+
def kwarg(node: hasDOTkwarg) -> ast.arg:
|
|
231
231
|
return node.kwarg
|
|
232
232
|
|
|
233
233
|
@staticmethod
|
|
@@ -255,15 +255,15 @@ class DOT:
|
|
|
255
255
|
return node.lineno
|
|
256
256
|
|
|
257
257
|
@staticmethod
|
|
258
|
-
def lower(node: hasDOTlower) -> ast.expr
|
|
258
|
+
def lower(node: hasDOTlower) -> ast.expr:
|
|
259
259
|
return node.lower
|
|
260
260
|
|
|
261
261
|
@staticmethod
|
|
262
|
-
def module(node: hasDOTmodule) -> str
|
|
262
|
+
def module(node: hasDOTmodule) -> str:
|
|
263
263
|
return node.module
|
|
264
264
|
|
|
265
265
|
@staticmethod
|
|
266
|
-
def msg(node: hasDOTmsg) -> ast.expr
|
|
266
|
+
def msg(node: hasDOTmsg) -> ast.expr:
|
|
267
267
|
return node.msg
|
|
268
268
|
|
|
269
269
|
@staticmethod
|
|
@@ -278,11 +278,11 @@ class DOT:
|
|
|
278
278
|
|
|
279
279
|
@staticmethod
|
|
280
280
|
@overload
|
|
281
|
-
def name(node: hasDOTname_strOrNone) -> str
|
|
281
|
+
def name(node: hasDOTname_strOrNone) -> str:
|
|
282
282
|
...
|
|
283
283
|
|
|
284
284
|
@staticmethod
|
|
285
|
-
def name(node: hasDOTname) -> ast.Name | str
|
|
285
|
+
def name(node: hasDOTname) -> ast.Name | str:
|
|
286
286
|
return node.name
|
|
287
287
|
|
|
288
288
|
@staticmethod
|
|
@@ -327,7 +327,7 @@ class DOT:
|
|
|
327
327
|
return node.ops
|
|
328
328
|
|
|
329
329
|
@staticmethod
|
|
330
|
-
def optional_vars(node: hasDOToptional_vars) -> ast.expr
|
|
330
|
+
def optional_vars(node: hasDOToptional_vars) -> ast.expr:
|
|
331
331
|
return node.optional_vars
|
|
332
332
|
|
|
333
333
|
@staticmethod
|
|
@@ -351,11 +351,11 @@ class DOT:
|
|
|
351
351
|
|
|
352
352
|
@staticmethod
|
|
353
353
|
@overload
|
|
354
|
-
def pattern(node: hasDOTpattern_patternOrNone) -> ast.pattern
|
|
354
|
+
def pattern(node: hasDOTpattern_patternOrNone) -> ast.pattern:
|
|
355
355
|
...
|
|
356
356
|
|
|
357
357
|
@staticmethod
|
|
358
|
-
def pattern(node: hasDOTpattern) -> ast.pattern
|
|
358
|
+
def pattern(node: hasDOTpattern) -> ast.pattern:
|
|
359
359
|
return node.pattern
|
|
360
360
|
|
|
361
361
|
@staticmethod
|
|
@@ -367,7 +367,7 @@ class DOT:
|
|
|
367
367
|
return node.posonlyargs
|
|
368
368
|
|
|
369
369
|
@staticmethod
|
|
370
|
-
def rest(node: hasDOTrest) -> str
|
|
370
|
+
def rest(node: hasDOTrest) -> str:
|
|
371
371
|
return node.rest
|
|
372
372
|
|
|
373
373
|
@staticmethod
|
|
@@ -377,11 +377,11 @@ class DOT:
|
|
|
377
377
|
|
|
378
378
|
@staticmethod
|
|
379
379
|
@overload
|
|
380
|
-
def returns(node: hasDOTreturns_exprOrNone) -> ast.expr
|
|
380
|
+
def returns(node: hasDOTreturns_exprOrNone) -> ast.expr:
|
|
381
381
|
...
|
|
382
382
|
|
|
383
383
|
@staticmethod
|
|
384
|
-
def returns(node: hasDOTreturns) -> ast.expr
|
|
384
|
+
def returns(node: hasDOTreturns) -> ast.expr:
|
|
385
385
|
return node.returns
|
|
386
386
|
|
|
387
387
|
@staticmethod
|
|
@@ -397,7 +397,7 @@ class DOT:
|
|
|
397
397
|
return node.slice
|
|
398
398
|
|
|
399
399
|
@staticmethod
|
|
400
|
-
def step(node: hasDOTstep) -> ast.expr
|
|
400
|
+
def step(node: hasDOTstep) -> ast.expr:
|
|
401
401
|
return node.step
|
|
402
402
|
|
|
403
403
|
@staticmethod
|
|
@@ -436,11 +436,11 @@ class DOT:
|
|
|
436
436
|
return node.test
|
|
437
437
|
|
|
438
438
|
@staticmethod
|
|
439
|
-
def type(node: hasDOTtype) -> ast.expr
|
|
439
|
+
def type(node: hasDOTtype) -> ast.expr:
|
|
440
440
|
return node.type
|
|
441
441
|
|
|
442
442
|
@staticmethod
|
|
443
|
-
def type_comment(node: hasDOTtype_comment) -> str
|
|
443
|
+
def type_comment(node: hasDOTtype_comment) -> str:
|
|
444
444
|
return node.type_comment
|
|
445
445
|
|
|
446
446
|
@staticmethod
|
|
@@ -452,7 +452,7 @@ class DOT:
|
|
|
452
452
|
return node.type_params
|
|
453
453
|
|
|
454
454
|
@staticmethod
|
|
455
|
-
def upper(node: hasDOTupper) -> ast.expr
|
|
455
|
+
def upper(node: hasDOTupper) -> ast.expr:
|
|
456
456
|
return node.upper
|
|
457
457
|
|
|
458
458
|
@staticmethod
|
|
@@ -462,7 +462,7 @@ class DOT:
|
|
|
462
462
|
|
|
463
463
|
@staticmethod
|
|
464
464
|
@overload
|
|
465
|
-
def value(node: hasDOTvalue_boolOrNone) -> bool
|
|
465
|
+
def value(node: hasDOTvalue_boolOrNone) -> bool:
|
|
466
466
|
...
|
|
467
467
|
|
|
468
468
|
@staticmethod
|
|
@@ -472,11 +472,11 @@ class DOT:
|
|
|
472
472
|
|
|
473
473
|
@staticmethod
|
|
474
474
|
@overload
|
|
475
|
-
def value(node: hasDOTvalue_exprOrNone) -> ast.expr
|
|
475
|
+
def value(node: hasDOTvalue_exprOrNone) -> ast.expr:
|
|
476
476
|
...
|
|
477
477
|
|
|
478
478
|
@staticmethod
|
|
479
|
-
def value(node: hasDOTvalue) -> Any |
|
|
479
|
+
def value(node: hasDOTvalue) -> Any | bool | ast.expr:
|
|
480
480
|
return node.value
|
|
481
481
|
|
|
482
482
|
@staticmethod
|
|
@@ -484,5 +484,5 @@ class DOT:
|
|
|
484
484
|
return node.values
|
|
485
485
|
|
|
486
486
|
@staticmethod
|
|
487
|
-
def vararg(node: hasDOTvararg) -> ast.arg
|
|
488
|
-
return node.vararg
|
|
487
|
+
def vararg(node: hasDOTvararg) -> ast.arg:
|
|
488
|
+
return node.vararg
|
|
@@ -29,7 +29,7 @@ class Grab:
|
|
|
29
29
|
return workhorse
|
|
30
30
|
|
|
31
31
|
@staticmethod
|
|
32
|
-
def annotationAttribute(action: Callable[[ast.expr], ast.expr]
|
|
32
|
+
def annotationAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTannotation], hasDOTannotation]:
|
|
33
33
|
|
|
34
34
|
def workhorse(node: hasDOTannotation) -> hasDOTannotation:
|
|
35
35
|
node.annotation = action(node.annotation) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
@@ -37,7 +37,7 @@ class Grab:
|
|
|
37
37
|
return workhorse
|
|
38
38
|
|
|
39
39
|
@staticmethod
|
|
40
|
-
def argAttribute(action: Callable[[str
|
|
40
|
+
def argAttribute(action: Callable[[str], str]) -> Callable[[hasDOTarg], hasDOTarg]:
|
|
41
41
|
|
|
42
42
|
def workhorse(node: hasDOTarg) -> hasDOTarg:
|
|
43
43
|
node.arg = action(node.arg) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
@@ -61,10 +61,10 @@ class Grab:
|
|
|
61
61
|
return workhorse
|
|
62
62
|
|
|
63
63
|
@staticmethod
|
|
64
|
-
def asnameAttribute(action: Callable[[str
|
|
64
|
+
def asnameAttribute(action: Callable[[str], str]) -> Callable[[hasDOTasname], hasDOTasname]:
|
|
65
65
|
|
|
66
66
|
def workhorse(node: hasDOTasname) -> hasDOTasname:
|
|
67
|
-
node.asname = action(node.asname)
|
|
67
|
+
node.asname = action(node.asname) # pyright: ignore[reportArgumentType]
|
|
68
68
|
return node
|
|
69
69
|
return workhorse
|
|
70
70
|
|
|
@@ -93,10 +93,10 @@ class Grab:
|
|
|
93
93
|
return workhorse
|
|
94
94
|
|
|
95
95
|
@staticmethod
|
|
96
|
-
def boundAttribute(action: Callable[[ast.expr
|
|
96
|
+
def boundAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTbound], hasDOTbound]:
|
|
97
97
|
|
|
98
98
|
def workhorse(node: hasDOTbound) -> hasDOTbound:
|
|
99
|
-
node.bound = action(node.bound)
|
|
99
|
+
node.bound = action(node.bound) # pyright: ignore[reportArgumentType]
|
|
100
100
|
return node
|
|
101
101
|
return workhorse
|
|
102
102
|
|
|
@@ -109,10 +109,10 @@ class Grab:
|
|
|
109
109
|
return workhorse
|
|
110
110
|
|
|
111
111
|
@staticmethod
|
|
112
|
-
def causeAttribute(action: Callable[[ast.expr
|
|
112
|
+
def causeAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTcause], hasDOTcause]:
|
|
113
113
|
|
|
114
114
|
def workhorse(node: hasDOTcause) -> hasDOTcause:
|
|
115
|
-
node.cause = action(node.cause)
|
|
115
|
+
node.cause = action(node.cause) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
116
116
|
return node
|
|
117
117
|
return workhorse
|
|
118
118
|
|
|
@@ -166,10 +166,10 @@ class Grab:
|
|
|
166
166
|
if sys.version_info >= (3, 13):
|
|
167
167
|
|
|
168
168
|
@staticmethod
|
|
169
|
-
def default_valueAttribute(action: Callable[[ast.expr
|
|
169
|
+
def default_valueAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTdefault_value], hasDOTdefault_value]:
|
|
170
170
|
|
|
171
171
|
def workhorse(node: hasDOTdefault_value) -> hasDOTdefault_value:
|
|
172
|
-
node.default_value = action(node.default_value)
|
|
172
|
+
node.default_value = action(node.default_value) # pyright: ignore[reportArgumentType]
|
|
173
173
|
return node
|
|
174
174
|
return workhorse
|
|
175
175
|
|
|
@@ -198,10 +198,10 @@ class Grab:
|
|
|
198
198
|
return workhorse
|
|
199
199
|
|
|
200
200
|
@staticmethod
|
|
201
|
-
def excAttribute(action: Callable[[ast.expr
|
|
201
|
+
def excAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTexc], hasDOTexc]:
|
|
202
202
|
|
|
203
203
|
def workhorse(node: hasDOTexc) -> hasDOTexc:
|
|
204
|
-
node.exc = action(node.exc)
|
|
204
|
+
node.exc = action(node.exc) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
205
205
|
return node
|
|
206
206
|
return workhorse
|
|
207
207
|
|
|
@@ -214,10 +214,10 @@ class Grab:
|
|
|
214
214
|
return workhorse
|
|
215
215
|
|
|
216
216
|
@staticmethod
|
|
217
|
-
def format_specAttribute(action: Callable[[ast.expr
|
|
217
|
+
def format_specAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTformat_spec], hasDOTformat_spec]:
|
|
218
218
|
|
|
219
219
|
def workhorse(node: hasDOTformat_spec) -> hasDOTformat_spec:
|
|
220
|
-
node.format_spec = action(node.format_spec)
|
|
220
|
+
node.format_spec = action(node.format_spec) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
221
221
|
return node
|
|
222
222
|
return workhorse
|
|
223
223
|
|
|
@@ -238,10 +238,10 @@ class Grab:
|
|
|
238
238
|
return workhorse
|
|
239
239
|
|
|
240
240
|
@staticmethod
|
|
241
|
-
def guardAttribute(action: Callable[[ast.expr
|
|
241
|
+
def guardAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTguard], hasDOTguard]:
|
|
242
242
|
|
|
243
243
|
def workhorse(node: hasDOTguard) -> hasDOTguard:
|
|
244
|
-
node.guard = action(node.guard)
|
|
244
|
+
node.guard = action(node.guard) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
245
245
|
return node
|
|
246
246
|
return workhorse
|
|
247
247
|
|
|
@@ -302,7 +302,7 @@ class Grab:
|
|
|
302
302
|
return workhorse
|
|
303
303
|
|
|
304
304
|
@staticmethod
|
|
305
|
-
def keysAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]
|
|
305
|
+
def keysAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]) -> Callable[[hasDOTkeys], hasDOTkeys]:
|
|
306
306
|
|
|
307
307
|
def workhorse(node: hasDOTkeys) -> hasDOTkeys:
|
|
308
308
|
node.keys = action(node.keys) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
@@ -318,15 +318,15 @@ class Grab:
|
|
|
318
318
|
return workhorse
|
|
319
319
|
|
|
320
320
|
@staticmethod
|
|
321
|
-
def kindAttribute(action: Callable[[str
|
|
321
|
+
def kindAttribute(action: Callable[[str], str]) -> Callable[[hasDOTkind], hasDOTkind]:
|
|
322
322
|
|
|
323
323
|
def workhorse(node: hasDOTkind) -> hasDOTkind:
|
|
324
|
-
node.kind = action(node.kind)
|
|
324
|
+
node.kind = action(node.kind) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
325
325
|
return node
|
|
326
326
|
return workhorse
|
|
327
327
|
|
|
328
328
|
@staticmethod
|
|
329
|
-
def kw_defaultsAttribute(action: Callable[[Sequence[ast.expr
|
|
329
|
+
def kw_defaultsAttribute(action: Callable[[Sequence[ast.expr]], Sequence[ast.expr]]) -> Callable[[hasDOTkw_defaults], hasDOTkw_defaults]:
|
|
330
330
|
|
|
331
331
|
def workhorse(node: hasDOTkw_defaults) -> hasDOTkw_defaults:
|
|
332
332
|
node.kw_defaults = action(node.kw_defaults) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
@@ -334,10 +334,10 @@ class Grab:
|
|
|
334
334
|
return workhorse
|
|
335
335
|
|
|
336
336
|
@staticmethod
|
|
337
|
-
def kwargAttribute(action: Callable[[ast.arg
|
|
337
|
+
def kwargAttribute(action: Callable[[ast.arg], ast.arg]) -> Callable[[hasDOTkwarg], hasDOTkwarg]:
|
|
338
338
|
|
|
339
339
|
def workhorse(node: hasDOTkwarg) -> hasDOTkwarg:
|
|
340
|
-
node.kwarg = action(node.kwarg)
|
|
340
|
+
node.kwarg = action(node.kwarg) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
341
341
|
return node
|
|
342
342
|
return workhorse
|
|
343
343
|
|
|
@@ -390,31 +390,31 @@ class Grab:
|
|
|
390
390
|
return workhorse
|
|
391
391
|
|
|
392
392
|
@staticmethod
|
|
393
|
-
def lowerAttribute(action: Callable[[ast.expr
|
|
393
|
+
def lowerAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTlower], hasDOTlower]:
|
|
394
394
|
|
|
395
395
|
def workhorse(node: hasDOTlower) -> hasDOTlower:
|
|
396
|
-
node.lower = action(node.lower)
|
|
396
|
+
node.lower = action(node.lower) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
397
397
|
return node
|
|
398
398
|
return workhorse
|
|
399
399
|
|
|
400
400
|
@staticmethod
|
|
401
|
-
def moduleAttribute(action: Callable[[str
|
|
401
|
+
def moduleAttribute(action: Callable[[str], str]) -> Callable[[hasDOTmodule], hasDOTmodule]:
|
|
402
402
|
|
|
403
403
|
def workhorse(node: hasDOTmodule) -> hasDOTmodule:
|
|
404
|
-
node.module = action(node.module)
|
|
404
|
+
node.module = action(node.module) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
405
405
|
return node
|
|
406
406
|
return workhorse
|
|
407
407
|
|
|
408
408
|
@staticmethod
|
|
409
|
-
def msgAttribute(action: Callable[[ast.expr
|
|
409
|
+
def msgAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTmsg], hasDOTmsg]:
|
|
410
410
|
|
|
411
411
|
def workhorse(node: hasDOTmsg) -> hasDOTmsg:
|
|
412
|
-
node.msg = action(node.msg)
|
|
412
|
+
node.msg = action(node.msg) # pyright: ignore[reportArgumentType]
|
|
413
413
|
return node
|
|
414
414
|
return workhorse
|
|
415
415
|
|
|
416
416
|
@staticmethod
|
|
417
|
-
def nameAttribute(action: Callable[[ast.Name], ast.Name] | Callable[[str
|
|
417
|
+
def nameAttribute(action: Callable[[ast.Name], ast.Name] | Callable[[str], str]) -> Callable[[hasDOTname], hasDOTname]:
|
|
418
418
|
|
|
419
419
|
def workhorse(node: hasDOTname) -> hasDOTname:
|
|
420
420
|
node.name = action(node.name) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
@@ -454,10 +454,10 @@ class Grab:
|
|
|
454
454
|
return workhorse
|
|
455
455
|
|
|
456
456
|
@staticmethod
|
|
457
|
-
def optional_varsAttribute(action: Callable[[ast.expr
|
|
457
|
+
def optional_varsAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOToptional_vars], hasDOToptional_vars]:
|
|
458
458
|
|
|
459
459
|
def workhorse(node: hasDOToptional_vars) -> hasDOToptional_vars:
|
|
460
|
-
node.optional_vars = action(node.optional_vars)
|
|
460
|
+
node.optional_vars = action(node.optional_vars) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
461
461
|
return node
|
|
462
462
|
return workhorse
|
|
463
463
|
|
|
@@ -470,7 +470,7 @@ class Grab:
|
|
|
470
470
|
return workhorse
|
|
471
471
|
|
|
472
472
|
@staticmethod
|
|
473
|
-
def patternAttribute(action: Callable[[ast.pattern], ast.pattern]
|
|
473
|
+
def patternAttribute(action: Callable[[ast.pattern], ast.pattern]) -> Callable[[hasDOTpattern], hasDOTpattern]:
|
|
474
474
|
|
|
475
475
|
def workhorse(node: hasDOTpattern) -> hasDOTpattern:
|
|
476
476
|
node.pattern = action(node.pattern) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
@@ -494,15 +494,15 @@ class Grab:
|
|
|
494
494
|
return workhorse
|
|
495
495
|
|
|
496
496
|
@staticmethod
|
|
497
|
-
def restAttribute(action: Callable[[str
|
|
497
|
+
def restAttribute(action: Callable[[str], str]) -> Callable[[hasDOTrest], hasDOTrest]:
|
|
498
498
|
|
|
499
499
|
def workhorse(node: hasDOTrest) -> hasDOTrest:
|
|
500
|
-
node.rest = action(node.rest)
|
|
500
|
+
node.rest = action(node.rest) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
501
501
|
return node
|
|
502
502
|
return workhorse
|
|
503
503
|
|
|
504
504
|
@staticmethod
|
|
505
|
-
def returnsAttribute(action: Callable[[ast.expr], ast.expr]
|
|
505
|
+
def returnsAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTreturns], hasDOTreturns]:
|
|
506
506
|
|
|
507
507
|
def workhorse(node: hasDOTreturns) -> hasDOTreturns:
|
|
508
508
|
node.returns = action(node.returns) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
@@ -534,10 +534,10 @@ class Grab:
|
|
|
534
534
|
return workhorse
|
|
535
535
|
|
|
536
536
|
@staticmethod
|
|
537
|
-
def stepAttribute(action: Callable[[ast.expr
|
|
537
|
+
def stepAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTstep], hasDOTstep]:
|
|
538
538
|
|
|
539
539
|
def workhorse(node: hasDOTstep) -> hasDOTstep:
|
|
540
|
-
node.step = action(node.step)
|
|
540
|
+
node.step = action(node.step) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
541
541
|
return node
|
|
542
542
|
return workhorse
|
|
543
543
|
|
|
@@ -582,18 +582,18 @@ class Grab:
|
|
|
582
582
|
return workhorse
|
|
583
583
|
|
|
584
584
|
@staticmethod
|
|
585
|
-
def typeAttribute(action: Callable[[ast.expr
|
|
585
|
+
def typeAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTtype], hasDOTtype]:
|
|
586
586
|
|
|
587
587
|
def workhorse(node: hasDOTtype) -> hasDOTtype:
|
|
588
|
-
node.type = action(node.type)
|
|
588
|
+
node.type = action(node.type) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
589
589
|
return node
|
|
590
590
|
return workhorse
|
|
591
591
|
|
|
592
592
|
@staticmethod
|
|
593
|
-
def type_commentAttribute(action: Callable[[str
|
|
593
|
+
def type_commentAttribute(action: Callable[[str], str]) -> Callable[[hasDOTtype_comment], hasDOTtype_comment]:
|
|
594
594
|
|
|
595
595
|
def workhorse(node: hasDOTtype_comment) -> hasDOTtype_comment:
|
|
596
|
-
node.type_comment = action(node.type_comment)
|
|
596
|
+
node.type_comment = action(node.type_comment) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
597
597
|
return node
|
|
598
598
|
return workhorse
|
|
599
599
|
|
|
@@ -614,15 +614,15 @@ class Grab:
|
|
|
614
614
|
return workhorse
|
|
615
615
|
|
|
616
616
|
@staticmethod
|
|
617
|
-
def upperAttribute(action: Callable[[ast.expr
|
|
617
|
+
def upperAttribute(action: Callable[[ast.expr], ast.expr]) -> Callable[[hasDOTupper], hasDOTupper]:
|
|
618
618
|
|
|
619
619
|
def workhorse(node: hasDOTupper) -> hasDOTupper:
|
|
620
|
-
node.upper = action(node.upper)
|
|
620
|
+
node.upper = action(node.upper) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
621
621
|
return node
|
|
622
622
|
return workhorse
|
|
623
623
|
|
|
624
624
|
@staticmethod
|
|
625
|
-
def valueAttribute(action: Callable[[ast.expr], ast.expr] | Callable[[
|
|
625
|
+
def valueAttribute(action: Callable[[ast.expr], ast.expr] | Callable[[bool], bool] | Callable[[Any], Any]) -> Callable[[hasDOTvalue], hasDOTvalue]:
|
|
626
626
|
|
|
627
627
|
def workhorse(node: hasDOTvalue) -> hasDOTvalue:
|
|
628
628
|
node.value = action(node.value) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
@@ -638,9 +638,9 @@ class Grab:
|
|
|
638
638
|
return workhorse
|
|
639
639
|
|
|
640
640
|
@staticmethod
|
|
641
|
-
def varargAttribute(action: Callable[[ast.arg
|
|
641
|
+
def varargAttribute(action: Callable[[ast.arg], ast.arg]) -> Callable[[hasDOTvararg], hasDOTvararg]:
|
|
642
642
|
|
|
643
643
|
def workhorse(node: hasDOTvararg) -> hasDOTvararg:
|
|
644
|
-
node.vararg = action(node.vararg)
|
|
644
|
+
node.vararg = action(node.vararg) # pyright: ignore[reportArgumentType, reportAttributeAccessIssue]
|
|
645
645
|
return node
|
|
646
|
-
return workhorse
|
|
646
|
+
return workhorse
|
|
@@ -42,11 +42,11 @@ class IfThis:
|
|
|
42
42
|
@staticmethod
|
|
43
43
|
def is_keywordIdentifier(identifier: str) -> Callable[[ast.AST], TypeGuard[ast.keyword] | bool]:
|
|
44
44
|
"""see also `isArgumentIdentifier`"""
|
|
45
|
-
return lambda node: Be.keyword(node) and IfThis.isIdentifier(identifier)(
|
|
45
|
+
return lambda node: Be.keyword(node) and node.arg is not None and IfThis.isIdentifier(identifier)(node.arg)
|
|
46
46
|
|
|
47
47
|
@staticmethod
|
|
48
48
|
def isArgumentIdentifier(identifier: str) -> Callable[[ast.AST], TypeGuard[ast.arg | ast.keyword] | bool]:
|
|
49
|
-
return lambda node: (Be.arg(node) or Be.keyword(node)) and IfThis.isIdentifier(identifier)(
|
|
49
|
+
return lambda node: (Be.arg(node) or Be.keyword(node)) and node.arg is not None and IfThis.isIdentifier(identifier)(node.arg)
|
|
50
50
|
|
|
51
51
|
@staticmethod
|
|
52
52
|
def isAssignAndTargets0Is(targets0Predicate: Callable[[ast.AST], bool]) -> Callable[[ast.AST], TypeGuard[ast.AnnAssign] | bool]:
|
|
@@ -101,7 +101,7 @@ class IfThis:
|
|
|
101
101
|
return lambda node: Be.FunctionDef(node) and IfThis.isIdentifier(identifier)(DOT.name(node))
|
|
102
102
|
|
|
103
103
|
@staticmethod
|
|
104
|
-
def isIdentifier(identifier: str) -> Callable[[str
|
|
104
|
+
def isIdentifier(identifier: str) -> Callable[[str], TypeGuard[str] | bool]:
|
|
105
105
|
return lambda node: node == identifier
|
|
106
106
|
|
|
107
107
|
@staticmethod
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astToolkit
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: A powerfully composable, type-safe toolkit for Python abstract syntax tree (AST) manipulation, analysis, transformation, and code generation with a layered architecture designed for building sophisticated code processing assembly-lines.
|
|
5
5
|
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
6
|
License: CC-BY-NC-4.0
|
|
@@ -36,7 +36,7 @@ optional-dependencies = { testing = [
|
|
|
36
36
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
37
37
|
requires-python = ">=3.12"
|
|
38
38
|
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" }
|
|
39
|
-
version = "0.3.
|
|
39
|
+
version = "0.3.2"
|
|
40
40
|
|
|
41
41
|
[tool.coverage]
|
|
42
42
|
report = { exclude_lines = [
|
|
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
|
|
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
|