astToolkit 0.2.2__tar.gz → 0.3.0__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.2.2 → asttoolkit-0.3.0}/PKG-INFO +22 -22
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/README.md +20 -20
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/__init__.py +1 -8
- asttoolkit-0.3.0/astToolkit/_astTypes.py +117 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/_toolBe.py +36 -42
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/_toolClassIsAndAttribute.py +100 -91
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/_toolDOT.py +64 -68
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/_toolGrab.py +87 -86
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/_toolIfThis.py +27 -27
- asttoolkit-0.3.0/astToolkit/_toolMake.py +390 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/_toolThen.py +3 -3
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/_toolkitAST.py +11 -10
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/_toolkitContainers.py +10 -10
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/_toolkitNodeVisitor.py +2 -2
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/_types.py +4 -8
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/transformationTools.py +41 -25
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit.egg-info/PKG-INFO +22 -22
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit.egg-info/SOURCES.txt +0 -4
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/pyproject.toml +2 -2
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/toolFactory/Z0Z_hardcoded.py +43 -18
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/toolFactory/__init__.py +9 -7
- asttoolkit-0.3.0/toolFactory/_snippets.py +16 -0
- asttoolkit-0.3.0/toolFactory/datacenter.py +263 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/toolFactory/docstrings.py +20 -2
- asttoolkit-0.3.0/toolFactory/factory3.py +593 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/toolFactory/factory_annex.py +29 -73
- asttoolkit-0.2.2/astToolkit/_astTypes.py +0 -130
- asttoolkit-0.2.2/astToolkit/_toolMake.py +0 -339
- asttoolkit-0.2.2/astToolkit/_typesSpecial.py +0 -16
- asttoolkit-0.2.2/toolFactory/Z0Z_makeAstTools.py +0 -42
- asttoolkit-0.2.2/toolFactory/_snippets.py +0 -6
- asttoolkit-0.2.2/toolFactory/astFactory.py +0 -572
- asttoolkit-0.2.2/toolFactory/databaseASTCreation.py +0 -154
- asttoolkit-0.2.2/toolFactory/datacenter.py +0 -267
- asttoolkit-0.2.2/toolFactory/factory3.py +0 -301
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/LICENSE +0 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/py.typed +0 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit/theSSOT.py +0 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit.egg-info/dependency_links.txt +0 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit.egg-info/requires.txt +0 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/astToolkit.egg-info/top_level.txt +0 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/setup.cfg +0 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/tests/test_basic.py +0 -0
- {asttoolkit-0.2.2 → asttoolkit-0.3.0}/toolFactory/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astToolkit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
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
|
|
@@ -25,7 +25,7 @@ Classifier: Typing :: Typed
|
|
|
25
25
|
Classifier: Topic :: Software Development :: Code Generators
|
|
26
26
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
27
|
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
28
|
-
Requires-Python: >=3.
|
|
28
|
+
Requires-Python: >=3.12
|
|
29
29
|
Description-Content-Type: text/markdown
|
|
30
30
|
License-File: LICENSE
|
|
31
31
|
Requires-Dist: autoflake
|
|
@@ -183,32 +183,32 @@ print(ast.unparse(tree))
|
|
|
183
183
|
This example shows a more complex transformation inspired by the mapFolding package:
|
|
184
184
|
|
|
185
185
|
```python
|
|
186
|
-
from astToolkit import
|
|
186
|
+
from astToolkit import str, Be, DOT, Grab, IfThis as astToolkit_IfThis, Make, NodeChanger, Then
|
|
187
187
|
import ast
|
|
188
188
|
|
|
189
189
|
# Define custom predicates by extending IfThis
|
|
190
190
|
class IfThis(astToolkit_IfThis):
|
|
191
191
|
@staticmethod
|
|
192
|
-
def
|
|
193
|
-
namespace:
|
|
194
|
-
identifier:
|
|
192
|
+
def isAttributeNamespaceIdentifierGreaterThan0(
|
|
193
|
+
namespace: str,
|
|
194
|
+
identifier: str
|
|
195
195
|
) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
|
|
196
196
|
|
|
197
197
|
return lambda node: (
|
|
198
198
|
Be.Compare(node)
|
|
199
|
-
and IfThis.
|
|
199
|
+
and IfThis.isAttributeNamespaceIdentifier(namespace, identifier)(DOT.left(node))
|
|
200
200
|
and Be.Gt(node.ops[0])
|
|
201
201
|
and IfThis.isConstant_value(0)(node.comparators[0]))
|
|
202
202
|
|
|
203
203
|
@staticmethod
|
|
204
|
-
def
|
|
205
|
-
namespace:
|
|
206
|
-
identifier:
|
|
204
|
+
def isWhileAttributeNamespaceIdentifierGreaterThan0(
|
|
205
|
+
namespace: str,
|
|
206
|
+
identifier: str
|
|
207
207
|
) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
|
|
208
208
|
|
|
209
209
|
return lambda node: (
|
|
210
210
|
Be.While(node)
|
|
211
|
-
and IfThis.
|
|
211
|
+
and IfThis.isAttributeNamespaceIdentifierGreaterThan0(namespace, identifier)(DOT.test(node)))
|
|
212
212
|
|
|
213
213
|
# Parse some code
|
|
214
214
|
code = """
|
|
@@ -219,7 +219,7 @@ while claude.counter > 0:
|
|
|
219
219
|
tree = ast.parse(code)
|
|
220
220
|
|
|
221
221
|
# Find the while loop with our custom predicate
|
|
222
|
-
find_while_loop = IfThis.
|
|
222
|
+
find_while_loop = IfThis.isWhileAttributeNamespaceIdentifierGreaterThan0("claude", "counter")
|
|
223
223
|
|
|
224
224
|
# Replace counter > 0 with counter > 1
|
|
225
225
|
change_condition = Grab.testAttribute(
|
|
@@ -255,7 +255,7 @@ module_ast = parseLogicalPath2astModule("my_package.source_module")
|
|
|
255
255
|
# Extract a function and track its imports
|
|
256
256
|
function_name = "target_function"
|
|
257
257
|
function_def = NodeTourist(
|
|
258
|
-
IfThis.
|
|
258
|
+
IfThis.isFunctionDefIdentifier(function_name),
|
|
259
259
|
Then.extractIt
|
|
260
260
|
).captureLastMatch(module_ast)
|
|
261
261
|
|
|
@@ -290,34 +290,34 @@ if function_def:
|
|
|
290
290
|
To create specialized patterns for your codebase, extend the core classes:
|
|
291
291
|
|
|
292
292
|
```python
|
|
293
|
-
from astToolkit import
|
|
293
|
+
from astToolkit import str, Be, IfThis as astToolkit_IfThis
|
|
294
294
|
from collections.abc import Callable
|
|
295
295
|
from typing import TypeGuard
|
|
296
296
|
import ast
|
|
297
297
|
|
|
298
298
|
class IfThis(astToolkit_IfThis):
|
|
299
299
|
@staticmethod
|
|
300
|
-
def
|
|
301
|
-
namespace:
|
|
302
|
-
identifier:
|
|
300
|
+
def isAttributeNamespaceIdentifierGreaterThan0(
|
|
301
|
+
namespace: str,
|
|
302
|
+
identifier: str
|
|
303
303
|
) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
|
|
304
304
|
"""Find comparisons like 'state.counter > 0'"""
|
|
305
305
|
return lambda node: (
|
|
306
306
|
Be.Compare(node)
|
|
307
|
-
and IfThis.
|
|
307
|
+
and IfThis.isAttributeNamespaceIdentifier(namespace, identifier)(node.left)
|
|
308
308
|
and Be.Gt(node.ops[0])
|
|
309
309
|
and IfThis.isConstant_value(0)(node.comparators[0])
|
|
310
310
|
)
|
|
311
311
|
|
|
312
312
|
@staticmethod
|
|
313
|
-
def
|
|
314
|
-
namespace:
|
|
315
|
-
identifier:
|
|
313
|
+
def isWhileAttributeNamespaceIdentifierGreaterThan0(
|
|
314
|
+
namespace: str,
|
|
315
|
+
identifier: str
|
|
316
316
|
) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
|
|
317
317
|
"""Find while loops like 'while state.counter > 0:'"""
|
|
318
318
|
return lambda node: (
|
|
319
319
|
Be.While(node)
|
|
320
|
-
and IfThis.
|
|
320
|
+
and IfThis.isAttributeNamespaceIdentifierGreaterThan0(namespace, identifier)(node.test)
|
|
321
321
|
)
|
|
322
322
|
```
|
|
323
323
|
|
|
@@ -140,32 +140,32 @@ print(ast.unparse(tree))
|
|
|
140
140
|
This example shows a more complex transformation inspired by the mapFolding package:
|
|
141
141
|
|
|
142
142
|
```python
|
|
143
|
-
from astToolkit import
|
|
143
|
+
from astToolkit import str, Be, DOT, Grab, IfThis as astToolkit_IfThis, Make, NodeChanger, Then
|
|
144
144
|
import ast
|
|
145
145
|
|
|
146
146
|
# Define custom predicates by extending IfThis
|
|
147
147
|
class IfThis(astToolkit_IfThis):
|
|
148
148
|
@staticmethod
|
|
149
|
-
def
|
|
150
|
-
namespace:
|
|
151
|
-
identifier:
|
|
149
|
+
def isAttributeNamespaceIdentifierGreaterThan0(
|
|
150
|
+
namespace: str,
|
|
151
|
+
identifier: str
|
|
152
152
|
) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
|
|
153
153
|
|
|
154
154
|
return lambda node: (
|
|
155
155
|
Be.Compare(node)
|
|
156
|
-
and IfThis.
|
|
156
|
+
and IfThis.isAttributeNamespaceIdentifier(namespace, identifier)(DOT.left(node))
|
|
157
157
|
and Be.Gt(node.ops[0])
|
|
158
158
|
and IfThis.isConstant_value(0)(node.comparators[0]))
|
|
159
159
|
|
|
160
160
|
@staticmethod
|
|
161
|
-
def
|
|
162
|
-
namespace:
|
|
163
|
-
identifier:
|
|
161
|
+
def isWhileAttributeNamespaceIdentifierGreaterThan0(
|
|
162
|
+
namespace: str,
|
|
163
|
+
identifier: str
|
|
164
164
|
) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
|
|
165
165
|
|
|
166
166
|
return lambda node: (
|
|
167
167
|
Be.While(node)
|
|
168
|
-
and IfThis.
|
|
168
|
+
and IfThis.isAttributeNamespaceIdentifierGreaterThan0(namespace, identifier)(DOT.test(node)))
|
|
169
169
|
|
|
170
170
|
# Parse some code
|
|
171
171
|
code = """
|
|
@@ -176,7 +176,7 @@ while claude.counter > 0:
|
|
|
176
176
|
tree = ast.parse(code)
|
|
177
177
|
|
|
178
178
|
# Find the while loop with our custom predicate
|
|
179
|
-
find_while_loop = IfThis.
|
|
179
|
+
find_while_loop = IfThis.isWhileAttributeNamespaceIdentifierGreaterThan0("claude", "counter")
|
|
180
180
|
|
|
181
181
|
# Replace counter > 0 with counter > 1
|
|
182
182
|
change_condition = Grab.testAttribute(
|
|
@@ -212,7 +212,7 @@ module_ast = parseLogicalPath2astModule("my_package.source_module")
|
|
|
212
212
|
# Extract a function and track its imports
|
|
213
213
|
function_name = "target_function"
|
|
214
214
|
function_def = NodeTourist(
|
|
215
|
-
IfThis.
|
|
215
|
+
IfThis.isFunctionDefIdentifier(function_name),
|
|
216
216
|
Then.extractIt
|
|
217
217
|
).captureLastMatch(module_ast)
|
|
218
218
|
|
|
@@ -247,34 +247,34 @@ if function_def:
|
|
|
247
247
|
To create specialized patterns for your codebase, extend the core classes:
|
|
248
248
|
|
|
249
249
|
```python
|
|
250
|
-
from astToolkit import
|
|
250
|
+
from astToolkit import str, Be, IfThis as astToolkit_IfThis
|
|
251
251
|
from collections.abc import Callable
|
|
252
252
|
from typing import TypeGuard
|
|
253
253
|
import ast
|
|
254
254
|
|
|
255
255
|
class IfThis(astToolkit_IfThis):
|
|
256
256
|
@staticmethod
|
|
257
|
-
def
|
|
258
|
-
namespace:
|
|
259
|
-
identifier:
|
|
257
|
+
def isAttributeNamespaceIdentifierGreaterThan0(
|
|
258
|
+
namespace: str,
|
|
259
|
+
identifier: str
|
|
260
260
|
) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
|
|
261
261
|
"""Find comparisons like 'state.counter > 0'"""
|
|
262
262
|
return lambda node: (
|
|
263
263
|
Be.Compare(node)
|
|
264
|
-
and IfThis.
|
|
264
|
+
and IfThis.isAttributeNamespaceIdentifier(namespace, identifier)(node.left)
|
|
265
265
|
and Be.Gt(node.ops[0])
|
|
266
266
|
and IfThis.isConstant_value(0)(node.comparators[0])
|
|
267
267
|
)
|
|
268
268
|
|
|
269
269
|
@staticmethod
|
|
270
|
-
def
|
|
271
|
-
namespace:
|
|
272
|
-
identifier:
|
|
270
|
+
def isWhileAttributeNamespaceIdentifierGreaterThan0(
|
|
271
|
+
namespace: str,
|
|
272
|
+
identifier: str
|
|
273
273
|
) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
|
|
274
274
|
"""Find while loops like 'while state.counter > 0:'"""
|
|
275
275
|
return lambda node: (
|
|
276
276
|
Be.While(node)
|
|
277
|
-
and IfThis.
|
|
277
|
+
and IfThis.isAttributeNamespaceIdentifierGreaterThan0(namespace, identifier)(node.test)
|
|
278
278
|
)
|
|
279
279
|
```
|
|
280
280
|
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
from astToolkit._typesSpecial import (
|
|
2
|
-
NotRequired as NotRequired,
|
|
3
|
-
TypedDict as TypedDict,
|
|
4
|
-
)
|
|
5
|
-
|
|
6
1
|
from astToolkit._astTypes import * # noqa: F403
|
|
7
2
|
|
|
8
3
|
from astToolkit.theSSOT import FREAKOUT as FREAKOUT, The as The
|
|
9
4
|
|
|
10
5
|
from astToolkit._types import (
|
|
11
|
-
ast_expr_Slice as ast_expr_Slice,
|
|
12
|
-
ast_Identifier as ast_Identifier,
|
|
13
6
|
NodeORattribute as NodeORattribute,
|
|
14
7
|
str_nameDOTname as str_nameDOTname,
|
|
15
8
|
个 as 个,
|
|
@@ -22,8 +15,8 @@ from astToolkit._toolkitNodeVisitor import (
|
|
|
22
15
|
)
|
|
23
16
|
|
|
24
17
|
from astToolkit._toolBe import Be as Be
|
|
25
|
-
from astToolkit._toolDOT import DOT as DOT
|
|
26
18
|
from astToolkit._toolClassIsAndAttribute import ClassIsAndAttribute as ClassIsAndAttribute
|
|
19
|
+
from astToolkit._toolDOT import DOT as DOT
|
|
27
20
|
from astToolkit._toolGrab import Grab as Grab
|
|
28
21
|
from astToolkit._toolMake import Make as Make
|
|
29
22
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""This file is generated automatically, so changes to this file will be lost."""
|
|
2
|
+
from typing import Any, TypeAlias as typing_TypeAlias
|
|
3
|
+
import ast
|
|
4
|
+
import sys
|
|
5
|
+
intORstr: typing_TypeAlias = Any
|
|
6
|
+
intORstrORtype_params: typing_TypeAlias = Any
|
|
7
|
+
intORtype_params: typing_TypeAlias = Any
|
|
8
|
+
hasDOTannotation_expr: typing_TypeAlias = ast.AnnAssign
|
|
9
|
+
hasDOTannotation_exprOrNone: typing_TypeAlias = ast.arg
|
|
10
|
+
hasDOTannotation: typing_TypeAlias = hasDOTannotation_expr | hasDOTannotation_exprOrNone
|
|
11
|
+
hasDOTarg_str: typing_TypeAlias = ast.arg
|
|
12
|
+
hasDOTarg_strOrNone: typing_TypeAlias = ast.keyword
|
|
13
|
+
hasDOTarg: typing_TypeAlias = hasDOTarg_str | hasDOTarg_strOrNone
|
|
14
|
+
hasDOTargs_arguments: typing_TypeAlias = ast.AsyncFunctionDef | ast.FunctionDef | ast.Lambda
|
|
15
|
+
hasDOTargs_list_arg: typing_TypeAlias = ast.arguments
|
|
16
|
+
hasDOTargs_list_expr: typing_TypeAlias = ast.Call
|
|
17
|
+
hasDOTargs: typing_TypeAlias = hasDOTargs_arguments | hasDOTargs_list_arg | hasDOTargs_list_expr
|
|
18
|
+
hasDOTargtypes: typing_TypeAlias = ast.FunctionType
|
|
19
|
+
hasDOTasname: typing_TypeAlias = ast.alias
|
|
20
|
+
hasDOTattr: typing_TypeAlias = ast.Attribute
|
|
21
|
+
hasDOTbases: typing_TypeAlias = ast.ClassDef
|
|
22
|
+
hasDOTbody_expr: typing_TypeAlias = ast.Expression | ast.IfExp | ast.Lambda
|
|
23
|
+
hasDOTbody_list_stmt: typing_TypeAlias = ast.AsyncFor | ast.AsyncFunctionDef | ast.AsyncWith | ast.ClassDef | ast.ExceptHandler | ast.For | ast.FunctionDef | ast.If | ast.Interactive | ast.match_case | ast.Module | ast.Try | ast.TryStar | ast.While | ast.With
|
|
24
|
+
hasDOTbody: typing_TypeAlias = hasDOTbody_expr | hasDOTbody_list_stmt
|
|
25
|
+
hasDOTbound: typing_TypeAlias = ast.TypeVar
|
|
26
|
+
hasDOTcases: typing_TypeAlias = ast.Match
|
|
27
|
+
hasDOTcause: typing_TypeAlias = ast.Raise
|
|
28
|
+
hasDOTcls: typing_TypeAlias = ast.MatchClass
|
|
29
|
+
hasDOTcomparators: typing_TypeAlias = ast.Compare
|
|
30
|
+
hasDOTcontext_expr: typing_TypeAlias = ast.withitem
|
|
31
|
+
hasDOTconversion: typing_TypeAlias = ast.FormattedValue
|
|
32
|
+
hasDOTctx: typing_TypeAlias = ast.Attribute | ast.List | ast.Name | ast.Starred | ast.Subscript | ast.Tuple
|
|
33
|
+
hasDOTdecorator_list: typing_TypeAlias = ast.AsyncFunctionDef | ast.ClassDef | ast.FunctionDef
|
|
34
|
+
if sys.version_info >= (3, 13):
|
|
35
|
+
hasDOTdefault_value: typing_TypeAlias = ast.ParamSpec | ast.TypeVar | ast.TypeVarTuple
|
|
36
|
+
hasDOTdefaults: typing_TypeAlias = ast.arguments
|
|
37
|
+
hasDOTelt: typing_TypeAlias = ast.GeneratorExp | ast.ListComp | ast.SetComp
|
|
38
|
+
hasDOTelts: typing_TypeAlias = ast.List | ast.Set | ast.Tuple
|
|
39
|
+
hasDOTexc: typing_TypeAlias = ast.Raise
|
|
40
|
+
hasDOTfinalbody: typing_TypeAlias = ast.Try | ast.TryStar
|
|
41
|
+
hasDOTformat_spec: typing_TypeAlias = ast.FormattedValue
|
|
42
|
+
hasDOTfunc: typing_TypeAlias = ast.Call
|
|
43
|
+
hasDOTgenerators: typing_TypeAlias = ast.DictComp | ast.GeneratorExp | ast.ListComp | ast.SetComp
|
|
44
|
+
hasDOTguard: typing_TypeAlias = ast.match_case
|
|
45
|
+
hasDOThandlers: typing_TypeAlias = ast.Try | ast.TryStar
|
|
46
|
+
hasDOTid: typing_TypeAlias = ast.Name
|
|
47
|
+
hasDOTifs: typing_TypeAlias = ast.comprehension
|
|
48
|
+
hasDOTis_async: typing_TypeAlias = ast.comprehension
|
|
49
|
+
hasDOTitems: typing_TypeAlias = ast.AsyncWith | ast.With
|
|
50
|
+
hasDOTiter: typing_TypeAlias = ast.AsyncFor | ast.comprehension | ast.For
|
|
51
|
+
hasDOTkey: typing_TypeAlias = ast.DictComp
|
|
52
|
+
hasDOTkeys_list_expr: typing_TypeAlias = ast.MatchMapping
|
|
53
|
+
hasDOTkeys_list_exprOrNone: typing_TypeAlias = ast.Dict
|
|
54
|
+
hasDOTkeys: typing_TypeAlias = hasDOTkeys_list_expr | hasDOTkeys_list_exprOrNone
|
|
55
|
+
hasDOTkeywords: typing_TypeAlias = ast.Call | ast.ClassDef
|
|
56
|
+
hasDOTkind: typing_TypeAlias = ast.Constant
|
|
57
|
+
hasDOTkw_defaults: typing_TypeAlias = ast.arguments
|
|
58
|
+
hasDOTkwarg: typing_TypeAlias = ast.arguments
|
|
59
|
+
hasDOTkwd_attrs: typing_TypeAlias = ast.MatchClass
|
|
60
|
+
hasDOTkwd_patterns: typing_TypeAlias = ast.MatchClass
|
|
61
|
+
hasDOTkwonlyargs: typing_TypeAlias = ast.arguments
|
|
62
|
+
hasDOTleft: typing_TypeAlias = ast.BinOp | ast.Compare
|
|
63
|
+
hasDOTlevel: typing_TypeAlias = ast.ImportFrom
|
|
64
|
+
hasDOTlineno: typing_TypeAlias = ast.TypeIgnore
|
|
65
|
+
hasDOTlower: typing_TypeAlias = ast.Slice
|
|
66
|
+
hasDOTmodule: typing_TypeAlias = ast.ImportFrom
|
|
67
|
+
hasDOTmsg: typing_TypeAlias = ast.Assert
|
|
68
|
+
hasDOTname_Name: typing_TypeAlias = ast.TypeAlias
|
|
69
|
+
hasDOTname_str: typing_TypeAlias = ast.alias | ast.AsyncFunctionDef | ast.ClassDef | ast.FunctionDef | ast.ParamSpec | ast.TypeVar | ast.TypeVarTuple
|
|
70
|
+
hasDOTname_strOrNone: typing_TypeAlias = ast.ExceptHandler | ast.MatchAs | ast.MatchStar
|
|
71
|
+
hasDOTname: typing_TypeAlias = hasDOTname_Name | hasDOTname_str | hasDOTname_strOrNone
|
|
72
|
+
hasDOTnames_list_alias: typing_TypeAlias = ast.Import | ast.ImportFrom
|
|
73
|
+
hasDOTnames_list_str: typing_TypeAlias = ast.Global | ast.Nonlocal
|
|
74
|
+
hasDOTnames: typing_TypeAlias = hasDOTnames_list_alias | hasDOTnames_list_str
|
|
75
|
+
hasDOTop_boolop: typing_TypeAlias = ast.BoolOp
|
|
76
|
+
hasDOTop_operator: typing_TypeAlias = ast.AugAssign | ast.BinOp
|
|
77
|
+
hasDOTop_unaryop: typing_TypeAlias = ast.UnaryOp
|
|
78
|
+
hasDOTop: typing_TypeAlias = hasDOTop_boolop | hasDOTop_operator | hasDOTop_unaryop
|
|
79
|
+
hasDOToperand: typing_TypeAlias = ast.UnaryOp
|
|
80
|
+
hasDOTops: typing_TypeAlias = ast.Compare
|
|
81
|
+
hasDOToptional_vars: typing_TypeAlias = ast.withitem
|
|
82
|
+
hasDOTorelse_expr: typing_TypeAlias = ast.IfExp
|
|
83
|
+
hasDOTorelse_list_stmt: typing_TypeAlias = ast.AsyncFor | ast.For | ast.If | ast.Try | ast.TryStar | ast.While
|
|
84
|
+
hasDOTorelse: typing_TypeAlias = hasDOTorelse_expr | hasDOTorelse_list_stmt
|
|
85
|
+
hasDOTpattern_pattern: typing_TypeAlias = ast.match_case
|
|
86
|
+
hasDOTpattern_patternOrNone: typing_TypeAlias = ast.MatchAs
|
|
87
|
+
hasDOTpattern: typing_TypeAlias = hasDOTpattern_pattern | hasDOTpattern_patternOrNone
|
|
88
|
+
hasDOTpatterns: typing_TypeAlias = ast.MatchClass | ast.MatchMapping | ast.MatchOr | ast.MatchSequence
|
|
89
|
+
hasDOTposonlyargs: typing_TypeAlias = ast.arguments
|
|
90
|
+
hasDOTrest: typing_TypeAlias = ast.MatchMapping
|
|
91
|
+
hasDOTreturns_expr: typing_TypeAlias = ast.FunctionType
|
|
92
|
+
hasDOTreturns_exprOrNone: typing_TypeAlias = ast.AsyncFunctionDef | ast.FunctionDef
|
|
93
|
+
hasDOTreturns: typing_TypeAlias = hasDOTreturns_expr | hasDOTreturns_exprOrNone
|
|
94
|
+
hasDOTright: typing_TypeAlias = ast.BinOp
|
|
95
|
+
hasDOTsimple: typing_TypeAlias = ast.AnnAssign
|
|
96
|
+
hasDOTslice: typing_TypeAlias = ast.Subscript
|
|
97
|
+
hasDOTstep: typing_TypeAlias = ast.Slice
|
|
98
|
+
hasDOTsubject: typing_TypeAlias = ast.Match
|
|
99
|
+
hasDOTtag: typing_TypeAlias = ast.TypeIgnore
|
|
100
|
+
hasDOTtarget_Name: typing_TypeAlias = ast.NamedExpr
|
|
101
|
+
hasDOTtarget_NameOrAttributeOrSubscript: typing_TypeAlias = ast.AnnAssign | ast.AugAssign
|
|
102
|
+
hasDOTtarget_expr: typing_TypeAlias = ast.AsyncFor | ast.comprehension | ast.For
|
|
103
|
+
hasDOTtarget: typing_TypeAlias = hasDOTtarget_Name | hasDOTtarget_NameOrAttributeOrSubscript | hasDOTtarget_expr
|
|
104
|
+
hasDOTtargets: typing_TypeAlias = ast.Assign | ast.Delete
|
|
105
|
+
hasDOTtest: typing_TypeAlias = ast.Assert | ast.If | ast.IfExp | ast.While
|
|
106
|
+
hasDOTtype: typing_TypeAlias = ast.ExceptHandler
|
|
107
|
+
hasDOTtype_comment: typing_TypeAlias = ast.arg | ast.Assign | ast.AsyncFor | ast.AsyncFunctionDef | ast.AsyncWith | ast.For | ast.FunctionDef | ast.With
|
|
108
|
+
hasDOTtype_ignores: typing_TypeAlias = ast.Module
|
|
109
|
+
hasDOTtype_params: typing_TypeAlias = ast.AsyncFunctionDef | ast.ClassDef | ast.FunctionDef | ast.TypeAlias
|
|
110
|
+
hasDOTupper: typing_TypeAlias = ast.Slice
|
|
111
|
+
hasDOTvalue_Any: typing_TypeAlias = ast.Constant
|
|
112
|
+
hasDOTvalue_boolOrNone: typing_TypeAlias = ast.MatchSingleton
|
|
113
|
+
hasDOTvalue_expr: typing_TypeAlias = ast.Assign | ast.Attribute | ast.AugAssign | ast.Await | ast.DictComp | ast.Expr | ast.FormattedValue | ast.keyword | ast.MatchValue | ast.NamedExpr | ast.Starred | ast.Subscript | ast.TypeAlias | ast.YieldFrom
|
|
114
|
+
hasDOTvalue_exprOrNone: typing_TypeAlias = ast.AnnAssign | ast.Return | ast.Yield
|
|
115
|
+
hasDOTvalue: typing_TypeAlias = hasDOTvalue_Any | hasDOTvalue_boolOrNone | hasDOTvalue_expr | hasDOTvalue_exprOrNone
|
|
116
|
+
hasDOTvalues: typing_TypeAlias = ast.BoolOp | ast.Dict | ast.JoinedStr
|
|
117
|
+
hasDOTvararg: typing_TypeAlias = ast.arguments
|
|
@@ -95,14 +95,14 @@ class Be:
|
|
|
95
95
|
def BitXor(node: ast.AST) -> TypeGuard[ast.BitXor]:
|
|
96
96
|
return isinstance(node, ast.BitXor)
|
|
97
97
|
|
|
98
|
-
@staticmethod
|
|
99
|
-
def BoolOp(node: ast.AST) -> TypeGuard[ast.BoolOp]:
|
|
100
|
-
return isinstance(node, ast.BoolOp)
|
|
101
|
-
|
|
102
98
|
@staticmethod
|
|
103
99
|
def boolop(node: ast.AST) -> TypeGuard[ast.boolop]:
|
|
104
100
|
return isinstance(node, ast.boolop)
|
|
105
101
|
|
|
102
|
+
@staticmethod
|
|
103
|
+
def BoolOp(node: ast.AST) -> TypeGuard[ast.BoolOp]:
|
|
104
|
+
return isinstance(node, ast.BoolOp)
|
|
105
|
+
|
|
106
106
|
@staticmethod
|
|
107
107
|
def Break(node: ast.AST) -> TypeGuard[ast.Break]:
|
|
108
108
|
return isinstance(node, ast.Break)
|
|
@@ -159,22 +159,22 @@ class Be:
|
|
|
159
159
|
def Eq(node: ast.AST) -> TypeGuard[ast.Eq]:
|
|
160
160
|
return isinstance(node, ast.Eq)
|
|
161
161
|
|
|
162
|
-
@staticmethod
|
|
163
|
-
def ExceptHandler(node: ast.AST) -> TypeGuard[ast.ExceptHandler]:
|
|
164
|
-
return isinstance(node, ast.ExceptHandler)
|
|
165
|
-
|
|
166
162
|
@staticmethod
|
|
167
163
|
def excepthandler(node: ast.AST) -> TypeGuard[ast.excepthandler]:
|
|
168
164
|
return isinstance(node, ast.excepthandler)
|
|
169
165
|
|
|
170
166
|
@staticmethod
|
|
171
|
-
def
|
|
172
|
-
return isinstance(node, ast.
|
|
167
|
+
def ExceptHandler(node: ast.AST) -> TypeGuard[ast.ExceptHandler]:
|
|
168
|
+
return isinstance(node, ast.ExceptHandler)
|
|
173
169
|
|
|
174
170
|
@staticmethod
|
|
175
171
|
def expr(node: ast.AST) -> TypeGuard[ast.expr]:
|
|
176
172
|
return isinstance(node, ast.expr)
|
|
177
173
|
|
|
174
|
+
@staticmethod
|
|
175
|
+
def Expr(node: ast.AST) -> TypeGuard[ast.Expr]:
|
|
176
|
+
return isinstance(node, ast.Expr)
|
|
177
|
+
|
|
178
178
|
@staticmethod
|
|
179
179
|
def expr_context(node: ast.AST) -> TypeGuard[ast.expr_context]:
|
|
180
180
|
return isinstance(node, ast.expr_context)
|
|
@@ -335,14 +335,14 @@ class Be:
|
|
|
335
335
|
def MatMult(node: ast.AST) -> TypeGuard[ast.MatMult]:
|
|
336
336
|
return isinstance(node, ast.MatMult)
|
|
337
337
|
|
|
338
|
-
@staticmethod
|
|
339
|
-
def Mod(node: ast.AST) -> TypeGuard[ast.Mod]:
|
|
340
|
-
return isinstance(node, ast.Mod)
|
|
341
|
-
|
|
342
338
|
@staticmethod
|
|
343
339
|
def mod(node: ast.AST) -> TypeGuard[ast.mod]:
|
|
344
340
|
return isinstance(node, ast.mod)
|
|
345
341
|
|
|
342
|
+
@staticmethod
|
|
343
|
+
def Mod(node: ast.AST) -> TypeGuard[ast.Mod]:
|
|
344
|
+
return isinstance(node, ast.Mod)
|
|
345
|
+
|
|
346
346
|
@staticmethod
|
|
347
347
|
def Module(node: ast.AST) -> TypeGuard[ast.Module]:
|
|
348
348
|
return isinstance(node, ast.Module)
|
|
@@ -382,11 +382,10 @@ class Be:
|
|
|
382
382
|
@staticmethod
|
|
383
383
|
def Or(node: ast.AST) -> TypeGuard[ast.Or]:
|
|
384
384
|
return isinstance(node, ast.Or)
|
|
385
|
-
if sys.version_info >= (3, 12):
|
|
386
385
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
386
|
+
@staticmethod
|
|
387
|
+
def ParamSpec(node: ast.AST) -> TypeGuard[ast.ParamSpec]:
|
|
388
|
+
return isinstance(node, ast.ParamSpec)
|
|
390
389
|
|
|
391
390
|
@staticmethod
|
|
392
391
|
def Pass(node: ast.AST) -> TypeGuard[ast.Pass]:
|
|
@@ -447,11 +446,10 @@ class Be:
|
|
|
447
446
|
@staticmethod
|
|
448
447
|
def Try(node: ast.AST) -> TypeGuard[ast.Try]:
|
|
449
448
|
return isinstance(node, ast.Try)
|
|
450
|
-
if sys.version_info >= (3, 11):
|
|
451
449
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
450
|
+
@staticmethod
|
|
451
|
+
def TryStar(node: ast.AST) -> TypeGuard[ast.TryStar]:
|
|
452
|
+
return isinstance(node, ast.TryStar)
|
|
455
453
|
|
|
456
454
|
@staticmethod
|
|
457
455
|
def Tuple(node: ast.AST) -> TypeGuard[ast.Tuple]:
|
|
@@ -460,43 +458,39 @@ class Be:
|
|
|
460
458
|
@staticmethod
|
|
461
459
|
def type_ignore(node: ast.AST) -> TypeGuard[ast.type_ignore]:
|
|
462
460
|
return isinstance(node, ast.type_ignore)
|
|
463
|
-
if sys.version_info >= (3, 12):
|
|
464
461
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
if sys.version_info >= (3, 12):
|
|
462
|
+
@staticmethod
|
|
463
|
+
def type_param(node: ast.AST) -> TypeGuard[ast.type_param]:
|
|
464
|
+
return isinstance(node, ast.type_param)
|
|
469
465
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
466
|
+
@staticmethod
|
|
467
|
+
def TypeAlias(node: ast.AST) -> TypeGuard[ast.TypeAlias]:
|
|
468
|
+
return isinstance(node, ast.TypeAlias)
|
|
473
469
|
|
|
474
470
|
@staticmethod
|
|
475
471
|
def TypeIgnore(node: ast.AST) -> TypeGuard[ast.TypeIgnore]:
|
|
476
472
|
return isinstance(node, ast.TypeIgnore)
|
|
477
|
-
if sys.version_info >= (3, 12):
|
|
478
473
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
if sys.version_info >= (3, 12):
|
|
474
|
+
@staticmethod
|
|
475
|
+
def TypeVar(node: ast.AST) -> TypeGuard[ast.TypeVar]:
|
|
476
|
+
return isinstance(node, ast.TypeVar)
|
|
483
477
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
478
|
+
@staticmethod
|
|
479
|
+
def TypeVarTuple(node: ast.AST) -> TypeGuard[ast.TypeVarTuple]:
|
|
480
|
+
return isinstance(node, ast.TypeVarTuple)
|
|
487
481
|
|
|
488
482
|
@staticmethod
|
|
489
483
|
def UAdd(node: ast.AST) -> TypeGuard[ast.UAdd]:
|
|
490
484
|
return isinstance(node, ast.UAdd)
|
|
491
485
|
|
|
492
|
-
@staticmethod
|
|
493
|
-
def UnaryOp(node: ast.AST) -> TypeGuard[ast.UnaryOp]:
|
|
494
|
-
return isinstance(node, ast.UnaryOp)
|
|
495
|
-
|
|
496
486
|
@staticmethod
|
|
497
487
|
def unaryop(node: ast.AST) -> TypeGuard[ast.unaryop]:
|
|
498
488
|
return isinstance(node, ast.unaryop)
|
|
499
489
|
|
|
490
|
+
@staticmethod
|
|
491
|
+
def UnaryOp(node: ast.AST) -> TypeGuard[ast.UnaryOp]:
|
|
492
|
+
return isinstance(node, ast.UnaryOp)
|
|
493
|
+
|
|
500
494
|
@staticmethod
|
|
501
495
|
def USub(node: ast.AST) -> TypeGuard[ast.USub]:
|
|
502
496
|
return isinstance(node, ast.USub)
|