astToolkit 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
astToolkit/_toolDOT.py ADDED
@@ -0,0 +1,492 @@
1
+ # ruff: noqa: F403, F405
2
+ """This file is generated automatically, so changes to this file will be lost."""
3
+ from collections.abc import Sequence
4
+ from astToolkit._astTypes import *
5
+ from astToolkit import ast_Identifier, ast_expr_Slice, astDOTtype_param
6
+ from typing import Any, Literal, overload
7
+ import ast
8
+
9
+ class DOT:
10
+ """
11
+ Access attributes and sub-nodes of AST elements via consistent accessor methods.
12
+
13
+ The DOT class provides static methods to access specific attributes of different types of AST nodes in a consistent
14
+ way. This simplifies attribute access across various node types and improves code readability by abstracting the
15
+ underlying AST structure details.
16
+
17
+ DOT is designed for safe, read-only access to node properties, unlike the grab class which is designed for modifying
18
+ node attributes.
19
+ """
20
+
21
+ @staticmethod
22
+ @overload
23
+ def annotation(node: hasDOTannotation_expr) -> ast.expr:
24
+ ...
25
+
26
+ @staticmethod
27
+ @overload
28
+ def annotation(node: hasDOTannotation_exprOrNone) -> ast.expr | None:
29
+ ...
30
+
31
+ @staticmethod
32
+ def annotation(node: hasDOTannotation) -> ast.expr | (ast.expr | None):
33
+ return node.annotation
34
+
35
+ @staticmethod
36
+ @overload
37
+ def arg(node: hasDOTarg_Identifier) -> ast_Identifier:
38
+ ...
39
+
40
+ @staticmethod
41
+ @overload
42
+ def arg(node: hasDOTarg_IdentifierOrNone) -> ast_Identifier | None:
43
+ ...
44
+
45
+ @staticmethod
46
+ def arg(node: hasDOTarg) -> ast_Identifier | (ast_Identifier | None):
47
+ return node.arg
48
+
49
+ @staticmethod
50
+ @overload
51
+ def args(node: hasDOTargs_arguments) -> ast.arguments:
52
+ ...
53
+
54
+ @staticmethod
55
+ @overload
56
+ def args(node: hasDOTargs_list_expr) -> Sequence[ast.expr]:
57
+ ...
58
+
59
+ @staticmethod
60
+ @overload
61
+ def args(node: hasDOTargs_list_arg) -> list[ast.arg]:
62
+ ...
63
+
64
+ @staticmethod
65
+ def args(node: hasDOTargs) -> ast.arguments | Sequence[ast.expr] | list[ast.arg]:
66
+ return node.args
67
+
68
+ @staticmethod
69
+ def argtypes(node: hasDOTargtypes) -> Sequence[ast.expr]:
70
+ return node.argtypes
71
+
72
+ @staticmethod
73
+ def asname(node: hasDOTasname) -> ast_Identifier | None:
74
+ return node.asname
75
+
76
+ @staticmethod
77
+ def attr(node: hasDOTattr) -> ast_Identifier:
78
+ return node.attr
79
+
80
+ @staticmethod
81
+ def bases(node: hasDOTbases) -> Sequence[ast.expr]:
82
+ return node.bases
83
+
84
+ @staticmethod
85
+ @overload
86
+ def body(node: hasDOTbody_list_stmt) -> Sequence[ast.stmt]:
87
+ ...
88
+
89
+ @staticmethod
90
+ @overload
91
+ def body(node: hasDOTbody_expr) -> ast.expr:
92
+ ...
93
+
94
+ @staticmethod
95
+ def body(node: hasDOTbody) -> Sequence[ast.stmt] | ast.expr:
96
+ return node.body
97
+
98
+ @staticmethod
99
+ def bound(node: hasDOTbound) -> ast.expr | None:
100
+ return node.bound
101
+
102
+ @staticmethod
103
+ def cases(node: hasDOTcases) -> list[ast.match_case]:
104
+ return node.cases
105
+
106
+ @staticmethod
107
+ def cause(node: hasDOTcause) -> ast.expr | None:
108
+ return node.cause
109
+
110
+ @staticmethod
111
+ def cls(node: hasDOTcls) -> ast.expr:
112
+ return node.cls
113
+
114
+ @staticmethod
115
+ def comparators(node: hasDOTcomparators) -> Sequence[ast.expr]:
116
+ return node.comparators
117
+
118
+ @staticmethod
119
+ def context_expr(node: hasDOTcontext_expr) -> ast.expr:
120
+ return node.context_expr
121
+
122
+ @staticmethod
123
+ def conversion(node: hasDOTconversion) -> int:
124
+ return node.conversion
125
+
126
+ @staticmethod
127
+ def ctx(node: hasDOTctx) -> ast.expr_context:
128
+ return node.ctx
129
+
130
+ @staticmethod
131
+ def decorator_list(node: hasDOTdecorator_list) -> Sequence[ast.expr]:
132
+ return node.decorator_list
133
+
134
+ @staticmethod
135
+ def default_value(node: hasDOTdefault_value) -> ast.expr | None:
136
+ return node.default_value
137
+
138
+ @staticmethod
139
+ def defaults(node: hasDOTdefaults) -> Sequence[ast.expr]:
140
+ return node.defaults
141
+
142
+ @staticmethod
143
+ def elt(node: hasDOTelt) -> ast.expr:
144
+ return node.elt
145
+
146
+ @staticmethod
147
+ def elts(node: hasDOTelts) -> Sequence[ast.expr]:
148
+ return node.elts
149
+
150
+ @staticmethod
151
+ def exc(node: hasDOTexc) -> ast.expr | None:
152
+ return node.exc
153
+
154
+ @staticmethod
155
+ def finalbody(node: hasDOTfinalbody) -> Sequence[ast.stmt]:
156
+ return node.finalbody
157
+
158
+ @staticmethod
159
+ def format_spec(node: hasDOTformat_spec) -> ast.expr | None:
160
+ return node.format_spec
161
+
162
+ @staticmethod
163
+ def func(node: hasDOTfunc) -> ast.expr:
164
+ return node.func
165
+
166
+ @staticmethod
167
+ def generators(node: hasDOTgenerators) -> list[ast.comprehension]:
168
+ return node.generators
169
+
170
+ @staticmethod
171
+ def guard(node: hasDOTguard) -> ast.expr | None:
172
+ return node.guard
173
+
174
+ @staticmethod
175
+ def handlers(node: hasDOThandlers) -> list[ast.ExceptHandler]:
176
+ return node.handlers
177
+
178
+ @staticmethod
179
+ def id(node: hasDOTid) -> ast_Identifier:
180
+ return node.id
181
+
182
+ @staticmethod
183
+ def ifs(node: hasDOTifs) -> Sequence[ast.expr]:
184
+ return node.ifs
185
+
186
+ @staticmethod
187
+ def is_async(node: hasDOTis_async) -> int:
188
+ return node.is_async
189
+
190
+ @staticmethod
191
+ def items(node: hasDOTitems) -> list[ast.withitem]:
192
+ return node.items
193
+
194
+ @staticmethod
195
+ def iter(node: hasDOTiter) -> ast.expr:
196
+ return node.iter
197
+
198
+ @staticmethod
199
+ def key(node: hasDOTkey) -> ast.expr:
200
+ return node.key
201
+
202
+ @staticmethod
203
+ @overload
204
+ def keys(node: hasDOTkeys_list_exprOrNone) -> Sequence[ast.expr | None]:
205
+ ...
206
+
207
+ @staticmethod
208
+ @overload
209
+ def keys(node: hasDOTkeys_list_expr) -> Sequence[ast.expr]:
210
+ ...
211
+
212
+ @staticmethod
213
+ def keys(node: hasDOTkeys) -> Sequence[ast.expr | None] | Sequence[ast.expr]:
214
+ return node.keys
215
+
216
+ @staticmethod
217
+ def keywords(node: hasDOTkeywords) -> list[ast.keyword]:
218
+ return node.keywords
219
+
220
+ @staticmethod
221
+ def kind(node: hasDOTkind) -> ast_Identifier | None:
222
+ return node.kind
223
+
224
+ @staticmethod
225
+ def kw_defaults(node: hasDOTkw_defaults) -> Sequence[ast.expr | None]:
226
+ return node.kw_defaults
227
+
228
+ @staticmethod
229
+ def kwarg(node: hasDOTkwarg) -> ast.arg | None:
230
+ return node.kwarg
231
+
232
+ @staticmethod
233
+ def kwd_attrs(node: hasDOTkwd_attrs) -> list[ast_Identifier]:
234
+ return node.kwd_attrs
235
+
236
+ @staticmethod
237
+ def kwd_patterns(node: hasDOTkwd_patterns) -> Sequence[ast.pattern]:
238
+ return node.kwd_patterns
239
+
240
+ @staticmethod
241
+ def kwonlyargs(node: hasDOTkwonlyargs) -> list[ast.arg]:
242
+ return node.kwonlyargs
243
+
244
+ @staticmethod
245
+ def left(node: hasDOTleft) -> ast.expr:
246
+ return node.left
247
+
248
+ @staticmethod
249
+ def level(node: hasDOTlevel) -> int:
250
+ return node.level
251
+
252
+ @staticmethod
253
+ def lineno(node: hasDOTlineno) -> int:
254
+ return node.lineno
255
+
256
+ @staticmethod
257
+ def lower(node: hasDOTlower) -> ast.expr | None:
258
+ return node.lower
259
+
260
+ @staticmethod
261
+ def module(node: hasDOTmodule) -> ast_Identifier | None:
262
+ return node.module
263
+
264
+ @staticmethod
265
+ def msg(node: hasDOTmsg) -> ast.expr | None:
266
+ return node.msg
267
+
268
+ @staticmethod
269
+ @overload
270
+ def name(node: hasDOTname_Identifier) -> ast_Identifier:
271
+ ...
272
+
273
+ @staticmethod
274
+ @overload
275
+ def name(node: hasDOTname_IdentifierOrNone) -> ast_Identifier | None:
276
+ ...
277
+
278
+ @staticmethod
279
+ @overload
280
+ def name(node: hasDOTname_str) -> ast_Identifier:
281
+ ...
282
+
283
+ @staticmethod
284
+ @overload
285
+ def name(node: hasDOTname_Name) -> ast.Name:
286
+ ...
287
+
288
+ @staticmethod
289
+ def name(node: hasDOTname) -> ast_Identifier | (ast_Identifier | None) | ast_Identifier | ast.Name:
290
+ return node.name
291
+
292
+ @staticmethod
293
+ @overload
294
+ def names(node: hasDOTnames_list_alias) -> list[ast.alias]:
295
+ ...
296
+
297
+ @staticmethod
298
+ @overload
299
+ def names(node: hasDOTnames_list_Identifier) -> list[ast_Identifier]:
300
+ ...
301
+
302
+ @staticmethod
303
+ def names(node: hasDOTnames) -> list[ast.alias] | list[ast_Identifier]:
304
+ return node.names
305
+
306
+ @staticmethod
307
+ @overload
308
+ def op(node: hasDOTop_operator) -> ast.operator:
309
+ ...
310
+
311
+ @staticmethod
312
+ @overload
313
+ def op(node: hasDOTop_boolop) -> ast.boolop:
314
+ ...
315
+
316
+ @staticmethod
317
+ @overload
318
+ def op(node: hasDOTop_unaryop) -> ast.unaryop:
319
+ ...
320
+
321
+ @staticmethod
322
+ def op(node: hasDOTop) -> ast.operator | ast.boolop | ast.unaryop:
323
+ return node.op
324
+
325
+ @staticmethod
326
+ def operand(node: hasDOToperand) -> ast.expr:
327
+ return node.operand
328
+
329
+ @staticmethod
330
+ def ops(node: hasDOTops) -> Sequence[ast.cmpop]:
331
+ return node.ops
332
+
333
+ @staticmethod
334
+ def optional_vars(node: hasDOToptional_vars) -> ast.expr | None:
335
+ return node.optional_vars
336
+
337
+ @staticmethod
338
+ @overload
339
+ def orelse(node: hasDOTorelse_list_stmt) -> Sequence[ast.stmt]:
340
+ ...
341
+
342
+ @staticmethod
343
+ @overload
344
+ def orelse(node: hasDOTorelse_expr) -> ast.expr:
345
+ ...
346
+
347
+ @staticmethod
348
+ def orelse(node: hasDOTorelse) -> Sequence[ast.stmt] | ast.expr:
349
+ return node.orelse
350
+
351
+ @staticmethod
352
+ @overload
353
+ def pattern(node: hasDOTpattern_Pattern) -> ast.pattern:
354
+ ...
355
+
356
+ @staticmethod
357
+ @overload
358
+ def pattern(node: hasDOTpattern_patternOrNone) -> ast.pattern | None:
359
+ ...
360
+
361
+ @staticmethod
362
+ def pattern(node: hasDOTpattern) -> ast.pattern | (ast.pattern | None):
363
+ return node.pattern
364
+
365
+ @staticmethod
366
+ def patterns(node: hasDOTpatterns) -> Sequence[ast.pattern]:
367
+ return node.patterns
368
+
369
+ @staticmethod
370
+ def posonlyargs(node: hasDOTposonlyargs) -> list[ast.arg]:
371
+ return node.posonlyargs
372
+
373
+ @staticmethod
374
+ def rest(node: hasDOTrest) -> ast_Identifier | None:
375
+ return node.rest
376
+
377
+ @staticmethod
378
+ @overload
379
+ def returns(node: hasDOTreturns_expr) -> ast.expr:
380
+ ...
381
+
382
+ @staticmethod
383
+ @overload
384
+ def returns(node: hasDOTreturns_exprOrNone) -> ast.expr | None:
385
+ ...
386
+
387
+ @staticmethod
388
+ def returns(node: hasDOTreturns) -> ast.expr | (ast.expr | None):
389
+ return node.returns
390
+
391
+ @staticmethod
392
+ def right(node: hasDOTright) -> ast.expr:
393
+ return node.right
394
+
395
+ @staticmethod
396
+ def simple(node: hasDOTsimple) -> int:
397
+ return node.simple
398
+
399
+ @staticmethod
400
+ def slice(node: hasDOTslice) -> ast_expr_Slice:
401
+ return node.slice
402
+
403
+ @staticmethod
404
+ def step(node: hasDOTstep) -> ast.expr | None:
405
+ return node.step
406
+
407
+ @staticmethod
408
+ def subject(node: hasDOTsubject) -> ast.expr:
409
+ return node.subject
410
+
411
+ @staticmethod
412
+ def tag(node: hasDOTtag) -> ast_Identifier:
413
+ return node.tag
414
+
415
+ @staticmethod
416
+ @overload
417
+ def target(node: hasDOTtarget_NameOrAttributeOrSubscript) -> ast.Name | ast.Attribute | ast.Subscript:
418
+ ...
419
+
420
+ @staticmethod
421
+ @overload
422
+ def target(node: hasDOTtarget_expr) -> ast.expr:
423
+ ...
424
+
425
+ @staticmethod
426
+ @overload
427
+ def target(node: hasDOTtarget_Name) -> ast.Name:
428
+ ...
429
+
430
+ @staticmethod
431
+ def target(node: hasDOTtarget) -> ast.Name | ast.Attribute | ast.Subscript | ast.expr | ast.Name:
432
+ return node.target
433
+
434
+ @staticmethod
435
+ def targets(node: hasDOTtargets) -> Sequence[ast.expr]:
436
+ return node.targets
437
+
438
+ @staticmethod
439
+ def test(node: hasDOTtest) -> ast.expr:
440
+ return node.test
441
+
442
+ @staticmethod
443
+ def type(node: hasDOTtype) -> ast.expr | None:
444
+ return node.type
445
+
446
+ @staticmethod
447
+ def type_comment(node: hasDOTtype_comment) -> ast_Identifier | None:
448
+ return node.type_comment
449
+
450
+ @staticmethod
451
+ def type_ignores(node: hasDOTtype_ignores) -> list[ast.TypeIgnore]:
452
+ return node.type_ignores
453
+
454
+ @staticmethod
455
+ def type_params(node: hasDOTtype_params) -> Sequence[astDOTtype_param]:
456
+ return node.type_params
457
+
458
+ @staticmethod
459
+ def upper(node: hasDOTupper) -> ast.expr | None:
460
+ return node.upper
461
+
462
+ @staticmethod
463
+ @overload
464
+ def value(node: hasDOTvalue_exprOrNone) -> ast.expr | None:
465
+ ...
466
+
467
+ @staticmethod
468
+ @overload
469
+ def value(node: hasDOTvalue_expr) -> ast.expr:
470
+ ...
471
+
472
+ @staticmethod
473
+ @overload
474
+ def value(node: hasDOTvalue_Any) -> Any:
475
+ ...
476
+
477
+ @staticmethod
478
+ @overload
479
+ def value(node: hasDOTvalue_LiteralTrueFalseOrNone) -> Literal[True, False] | None:
480
+ ...
481
+
482
+ @staticmethod
483
+ def value(node: hasDOTvalue) -> ast.expr | None | ast.expr | Any | (Literal[True, False] | None):
484
+ return node.value
485
+
486
+ @staticmethod
487
+ def values(node: hasDOTvalues) -> Sequence[ast.expr]:
488
+ return node.values
489
+
490
+ @staticmethod
491
+ def vararg(node: hasDOTvararg) -> ast.arg | None:
492
+ return node.vararg