astToolkit 0.3.7__tar.gz → 0.4.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.
Files changed (33) hide show
  1. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/PKG-INFO +3 -1
  2. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_astTypes.py +7 -6
  3. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_toolClassIsAndAttribute.py +3 -3
  4. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_toolDOT.py +31 -30
  5. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_toolMake.py +8 -7
  6. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit.egg-info/PKG-INFO +3 -1
  7. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit.egg-info/requires.txt +2 -0
  8. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/pyproject.toml +3 -2
  9. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/tests/test_joinClassmethod.py +17 -28
  10. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/LICENSE +0 -0
  11. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/README.md +0 -0
  12. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/__init__.py +0 -0
  13. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_dumpFunctionDef.py +0 -0
  14. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_dumpHandmade.py +0 -0
  15. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_dumpHandmade.pyi +0 -0
  16. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_joinClassmethod.py +0 -0
  17. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_theSSOT.py +0 -0
  18. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_toolBe.py +0 -0
  19. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_toolGrab.py +0 -0
  20. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_toolIfThis.py +0 -0
  21. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_toolThen.py +0 -0
  22. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_toolkitAST.py +0 -0
  23. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_toolkitContainers.py +0 -0
  24. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_toolkitNodeVisitor.py +0 -0
  25. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/_types.py +0 -0
  26. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/py.typed +0 -0
  27. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit/transformationTools.py +0 -0
  28. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit.egg-info/SOURCES.txt +0 -0
  29. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit.egg-info/dependency_links.txt +0 -0
  30. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/astToolkit.egg-info/top_level.txt +0 -0
  31. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/setup.cfg +0 -0
  32. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/tests/conftest.py +0 -0
  33. {asttoolkit-0.3.7 → asttoolkit-0.4.0}/tests/test_basic.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astToolkit
3
- Version: 0.3.7
3
+ Version: 0.4.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
@@ -30,12 +30,14 @@ Requires-Dist: Z0Z_tools
30
30
  Requires-Dist: autoflake
31
31
  Requires-Dist: python_minifier
32
32
  Requires-Dist: tomli
33
+ Requires-Dist: typing-extensions
33
34
  Provides-Extra: testing
34
35
  Requires-Dist: mypy; extra == "testing"
35
36
  Requires-Dist: pytest; extra == "testing"
36
37
  Requires-Dist: pytest-cov; extra == "testing"
37
38
  Requires-Dist: pytest-xdist; extra == "testing"
38
39
  Requires-Dist: pyupgrade; extra == "testing"
40
+ Requires-Dist: setuptools-scm; extra == "testing"
39
41
  Requires-Dist: trove_classifiers; extra == "testing"
40
42
  Dynamic: license-file
41
43
 
@@ -51,8 +51,9 @@ hasDOTcontext_expr: typing_TypeAlias = ast.withitem
51
51
  hasDOTconversion: typing_TypeAlias = ast.FormattedValue
52
52
  hasDOTctx: typing_TypeAlias = ast.Attribute | ast.List | ast.Name | ast.Starred | ast.Subscript | ast.Tuple
53
53
  hasDOTdecorator_list: typing_TypeAlias = ast.AsyncFunctionDef | ast.ClassDef | ast.FunctionDef
54
- if sys.version_info >= (3, 13):
55
- hasDOTdefault_value: typing_TypeAlias = ast.ParamSpec | ast.TypeVar | ast.TypeVarTuple
54
+ match sys.version_info:
55
+ case version if version >= (3, 13):
56
+ hasDOTdefault_value: typing_TypeAlias = ast.ParamSpec | ast.TypeVar | ast.TypeVarTuple
56
57
  hasDOTdefaults: typing_TypeAlias = ast.arguments
57
58
  hasDOTelt: typing_TypeAlias = ast.GeneratorExp | ast.ListComp | ast.SetComp
58
59
  hasDOTelts: typing_TypeAlias = ast.List | ast.Set | ast.Tuple
@@ -117,10 +118,10 @@ hasDOTslice: typing_TypeAlias = ast.Subscript
117
118
  hasDOTstep: typing_TypeAlias = ast.Slice
118
119
  hasDOTsubject: typing_TypeAlias = ast.Match
119
120
  hasDOTtag: typing_TypeAlias = ast.TypeIgnore
121
+ hasDOTtarget_expr: typing_TypeAlias = ast.AsyncFor | ast.comprehension | ast.For
120
122
  hasDOTtarget_Name: typing_TypeAlias = ast.NamedExpr
121
123
  hasDOTtarget_NameOrAttributeOrSubscript: typing_TypeAlias = ast.AnnAssign | ast.AugAssign
122
- hasDOTtarget_expr: typing_TypeAlias = ast.AsyncFor | ast.comprehension | ast.For
123
- hasDOTtarget: typing_TypeAlias = hasDOTtarget_Name | hasDOTtarget_NameOrAttributeOrSubscript | hasDOTtarget_expr
124
+ hasDOTtarget: typing_TypeAlias = hasDOTtarget_expr | hasDOTtarget_Name | hasDOTtarget_NameOrAttributeOrSubscript
124
125
  hasDOTtargets: typing_TypeAlias = ast.Assign | ast.Delete
125
126
  hasDOTtest: typing_TypeAlias = ast.Assert | ast.If | ast.IfExp | ast.While
126
127
  hasDOTtype: typing_TypeAlias = ast.ExceptHandler
@@ -128,10 +129,10 @@ hasDOTtype_comment: typing_TypeAlias = ast.arg | ast.Assign | ast.AsyncFor | ast
128
129
  hasDOTtype_ignores: typing_TypeAlias = ast.Module
129
130
  hasDOTtype_params: typing_TypeAlias = ast.AsyncFunctionDef | ast.ClassDef | ast.FunctionDef | ast.TypeAlias
130
131
  hasDOTupper: typing_TypeAlias = ast.Slice
131
- hasDOTvalue_ConstantValueType: typing_TypeAlias = ast.Constant
132
132
  hasDOTvalue_boolOrNone: typing_TypeAlias = ast.MatchSingleton
133
+ hasDOTvalue_ConstantValueType: typing_TypeAlias = ast.Constant
133
134
  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
134
135
  hasDOTvalue_exprOrNone: typing_TypeAlias = ast.AnnAssign | ast.Return | ast.Yield
135
- hasDOTvalue: typing_TypeAlias = hasDOTvalue_ConstantValueType | hasDOTvalue_boolOrNone | hasDOTvalue_expr | hasDOTvalue_exprOrNone
136
+ hasDOTvalue: typing_TypeAlias = hasDOTvalue_boolOrNone | hasDOTvalue_ConstantValueType | hasDOTvalue_expr | hasDOTvalue_exprOrNone
136
137
  hasDOTvalues: typing_TypeAlias = ast.BoolOp | ast.Dict | ast.JoinedStr
137
138
  hasDOTvararg: typing_TypeAlias = ast.arguments
@@ -72,7 +72,7 @@ class ClassIsAndAttribute:
72
72
  ...
73
73
 
74
74
  @staticmethod
75
- def argsIs(astClass: type[hasDOTargs], attributeCondition: Callable[[ast.arguments], bool] | Callable[[Sequence[ast.expr]], bool] | Callable[[list[ast.arg]], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTargs] | bool]:
75
+ def argsIs(astClass: type[hasDOTargs], attributeCondition: Callable[[ast.arguments], bool] | Callable[[list[ast.arg]], bool] | Callable[[Sequence[ast.expr]], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTargs] | bool]:
76
76
 
77
77
  def workhorse(node: ast.AST) -> TypeGuard[hasDOTargs] | bool:
78
78
  return isinstance(node, astClass) and attributeCondition(node.args)
@@ -626,7 +626,7 @@ class ClassIsAndAttribute:
626
626
  ...
627
627
 
628
628
  @staticmethod
629
- def targetIs(astClass: type[hasDOTtarget], attributeCondition: Callable[[ast.Name], bool] | Callable[[ast.expr], bool] | Callable[[ast.Name | ast.Attribute | ast.Subscript], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTtarget] | bool]:
629
+ def targetIs(astClass: type[hasDOTtarget], attributeCondition: Callable[[ast.expr], bool] | Callable[[ast.Name], bool] | Callable[[ast.Name | ast.Attribute | ast.Subscript], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTtarget] | bool]:
630
630
 
631
631
  def workhorse(node: ast.AST) -> TypeGuard[hasDOTtarget] | bool:
632
632
  return isinstance(node, astClass) and attributeCondition(node.target)
@@ -702,7 +702,7 @@ class ClassIsAndAttribute:
702
702
  ...
703
703
 
704
704
  @staticmethod
705
- def valueIs(astClass: type[hasDOTvalue], attributeCondition: Callable[[ast.expr], bool] | Callable[[ConstantValueType], bool] | Callable[[bool], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTvalue] | bool]:
705
+ def valueIs(astClass: type[hasDOTvalue], attributeCondition: Callable[[ast.expr], bool] | Callable[[bool], bool] | Callable[[ConstantValueType], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTvalue] | bool]:
706
706
 
707
707
  def workhorse(node: ast.AST) -> TypeGuard[hasDOTvalue] | bool:
708
708
  return isinstance(node, astClass) and node.value is not None and attributeCondition(node.value)
@@ -1,3 +1,4 @@
1
+ # pyright: reportReturnType=false
1
2
  # ruff: noqa: F403, F405
2
3
  """This file is generated automatically, so changes to this file will be lost."""
3
4
  from astToolkit._astTypes import *
@@ -30,7 +31,7 @@ class DOT:
30
31
 
31
32
  @staticmethod
32
33
  def annotation(node: hasDOTannotation) -> ast.expr:
33
- return node.annotation # pyright: ignore[reportReturnType]
34
+ return node.annotation
34
35
 
35
36
  @staticmethod
36
37
  @overload
@@ -44,7 +45,7 @@ class DOT:
44
45
 
45
46
  @staticmethod
46
47
  def arg(node: hasDOTarg) -> str:
47
- return node.arg # pyright: ignore[reportReturnType]
48
+ return node.arg
48
49
 
49
50
  @staticmethod
50
51
  @overload
@@ -62,7 +63,7 @@ class DOT:
62
63
  ...
63
64
 
64
65
  @staticmethod
65
- def args(node: hasDOTargs) -> ast.arguments | Sequence[ast.expr] | list[ast.arg]:
66
+ def args(node: hasDOTargs) -> ast.arguments | list[ast.arg] | Sequence[ast.expr]:
66
67
  return node.args
67
68
 
68
69
  @staticmethod
@@ -71,7 +72,7 @@ class DOT:
71
72
 
72
73
  @staticmethod
73
74
  def asname(node: hasDOTasname) -> str:
74
- return node.asname # pyright: ignore[reportReturnType]
75
+ return node.asname
75
76
 
76
77
  @staticmethod
77
78
  def attr(node: hasDOTattr) -> str:
@@ -97,7 +98,7 @@ class DOT:
97
98
 
98
99
  @staticmethod
99
100
  def bound(node: hasDOTbound) -> ast.expr:
100
- return node.bound # pyright: ignore[reportReturnType]
101
+ return node.bound
101
102
 
102
103
  @staticmethod
103
104
  def cases(node: hasDOTcases) -> Sequence[ast.match_case]:
@@ -105,7 +106,7 @@ class DOT:
105
106
 
106
107
  @staticmethod
107
108
  def cause(node: hasDOTcause) -> ast.expr:
108
- return node.cause # pyright: ignore[reportReturnType]
109
+ return node.cause
109
110
 
110
111
  @staticmethod
111
112
  def cls(node: hasDOTcls) -> ast.expr:
@@ -134,7 +135,7 @@ class DOT:
134
135
 
135
136
  @staticmethod
136
137
  def default_value(node: hasDOTdefault_value) -> ast.expr:
137
- return node.default_value # pyright: ignore[reportReturnType]
138
+ return node.default_value
138
139
 
139
140
  @staticmethod
140
141
  def defaults(node: hasDOTdefaults) -> Sequence[ast.expr]:
@@ -150,7 +151,7 @@ class DOT:
150
151
 
151
152
  @staticmethod
152
153
  def exc(node: hasDOTexc) -> ast.expr:
153
- return node.exc # pyright: ignore[reportReturnType]
154
+ return node.exc
154
155
 
155
156
  @staticmethod
156
157
  def finalbody(node: hasDOTfinalbody) -> Sequence[ast.stmt]:
@@ -158,7 +159,7 @@ class DOT:
158
159
 
159
160
  @staticmethod
160
161
  def format_spec(node: hasDOTformat_spec) -> ast.expr:
161
- return node.format_spec # pyright: ignore[reportReturnType]
162
+ return node.format_spec
162
163
 
163
164
  @staticmethod
164
165
  def func(node: hasDOTfunc) -> ast.expr:
@@ -170,7 +171,7 @@ class DOT:
170
171
 
171
172
  @staticmethod
172
173
  def guard(node: hasDOTguard) -> ast.expr:
173
- return node.guard # pyright: ignore[reportReturnType]
174
+ return node.guard
174
175
 
175
176
  @staticmethod
176
177
  def handlers(node: hasDOThandlers) -> list[ast.ExceptHandler]:
@@ -212,7 +213,7 @@ class DOT:
212
213
 
213
214
  @staticmethod
214
215
  def keys(node: hasDOTkeys) -> Sequence[ast.expr]:
215
- return node.keys # pyright: ignore[reportReturnType]
216
+ return node.keys
216
217
 
217
218
  @staticmethod
218
219
  def keywords(node: hasDOTkeywords) -> Sequence[ast.keyword]:
@@ -220,22 +221,22 @@ class DOT:
220
221
 
221
222
  @staticmethod
222
223
  def kind(node: hasDOTkind) -> str:
223
- return node.kind # pyright: ignore[reportReturnType]
224
+ return node.kind
224
225
 
225
226
  @staticmethod
226
227
  def kw_defaults(node: hasDOTkw_defaults) -> Sequence[ast.expr]:
227
- return node.kw_defaults # pyright: ignore[reportReturnType]
228
+ return node.kw_defaults
228
229
 
229
230
  @staticmethod
230
231
  def kwarg(node: hasDOTkwarg) -> ast.arg:
231
- return node.kwarg # pyright: ignore[reportReturnType]
232
+ return node.kwarg
232
233
 
233
234
  @staticmethod
234
235
  def kwd_attrs(node: hasDOTkwd_attrs) -> list[str]:
235
236
  return node.kwd_attrs
236
237
 
237
238
  @staticmethod
238
- def kwd_patterns(node: hasDOTkwd_patterns) -> list[ast.pattern]:
239
+ def kwd_patterns(node: hasDOTkwd_patterns) -> Sequence[ast.pattern]:
239
240
  return node.kwd_patterns
240
241
 
241
242
  @staticmethod
@@ -256,15 +257,15 @@ class DOT:
256
257
 
257
258
  @staticmethod
258
259
  def lower(node: hasDOTlower) -> ast.expr:
259
- return node.lower # pyright: ignore[reportReturnType]
260
+ return node.lower
260
261
 
261
262
  @staticmethod
262
263
  def module(node: hasDOTmodule) -> str:
263
- return node.module # pyright: ignore[reportReturnType]
264
+ return node.module
264
265
 
265
266
  @staticmethod
266
267
  def msg(node: hasDOTmsg) -> ast.expr:
267
- return node.msg # pyright: ignore[reportReturnType]
268
+ return node.msg
268
269
 
269
270
  @staticmethod
270
271
  @overload
@@ -283,7 +284,7 @@ class DOT:
283
284
 
284
285
  @staticmethod
285
286
  def name(node: hasDOTname) -> ast.Name | str:
286
- return node.name # pyright: ignore[reportReturnType]
287
+ return node.name
287
288
 
288
289
  @staticmethod
289
290
  @overload
@@ -328,7 +329,7 @@ class DOT:
328
329
 
329
330
  @staticmethod
330
331
  def optional_vars(node: hasDOToptional_vars) -> ast.expr:
331
- return node.optional_vars # pyright: ignore[reportReturnType]
332
+ return node.optional_vars
332
333
 
333
334
  @staticmethod
334
335
  @overload
@@ -356,7 +357,7 @@ class DOT:
356
357
 
357
358
  @staticmethod
358
359
  def pattern(node: hasDOTpattern) -> ast.pattern:
359
- return node.pattern # pyright: ignore[reportReturnType]
360
+ return node.pattern
360
361
 
361
362
  @staticmethod
362
363
  def patterns(node: hasDOTpatterns) -> Sequence[ast.pattern]:
@@ -368,7 +369,7 @@ class DOT:
368
369
 
369
370
  @staticmethod
370
371
  def rest(node: hasDOTrest) -> str:
371
- return node.rest # pyright: ignore[reportReturnType]
372
+ return node.rest
372
373
 
373
374
  @staticmethod
374
375
  @overload
@@ -382,7 +383,7 @@ class DOT:
382
383
 
383
384
  @staticmethod
384
385
  def returns(node: hasDOTreturns) -> ast.expr:
385
- return node.returns # pyright: ignore[reportReturnType]
386
+ return node.returns
386
387
 
387
388
  @staticmethod
388
389
  def right(node: hasDOTright) -> ast.expr:
@@ -398,7 +399,7 @@ class DOT:
398
399
 
399
400
  @staticmethod
400
401
  def step(node: hasDOTstep) -> ast.expr:
401
- return node.step # pyright: ignore[reportReturnType]
402
+ return node.step
402
403
 
403
404
  @staticmethod
404
405
  def subject(node: hasDOTsubject) -> ast.expr:
@@ -424,7 +425,7 @@ class DOT:
424
425
  ...
425
426
 
426
427
  @staticmethod
427
- def target(node: hasDOTtarget) -> ast.Name | ast.expr | (ast.Name | ast.Attribute | ast.Subscript):
428
+ def target(node: hasDOTtarget) -> ast.expr | ast.Name | (ast.Name | ast.Attribute | ast.Subscript):
428
429
  return node.target
429
430
 
430
431
  @staticmethod
@@ -437,11 +438,11 @@ class DOT:
437
438
 
438
439
  @staticmethod
439
440
  def type(node: hasDOTtype) -> ast.expr:
440
- return node.type # pyright: ignore[reportReturnType]
441
+ return node.type
441
442
 
442
443
  @staticmethod
443
444
  def type_comment(node: hasDOTtype_comment) -> str:
444
- return node.type_comment # pyright: ignore[reportReturnType]
445
+ return node.type_comment
445
446
 
446
447
  @staticmethod
447
448
  def type_ignores(node: hasDOTtype_ignores) -> list[ast.TypeIgnore]:
@@ -453,7 +454,7 @@ class DOT:
453
454
 
454
455
  @staticmethod
455
456
  def upper(node: hasDOTupper) -> ast.expr:
456
- return node.upper # pyright: ignore[reportReturnType]
457
+ return node.upper
457
458
 
458
459
  @staticmethod
459
460
  @overload
@@ -476,7 +477,7 @@ class DOT:
476
477
  ...
477
478
 
478
479
  @staticmethod
479
- def value(node: hasDOTvalue) -> ast.expr | ConstantValueType | bool:
480
+ def value(node: hasDOTvalue) -> ast.expr | bool | ConstantValueType:
480
481
  return node.value
481
482
 
482
483
  @staticmethod
@@ -485,4 +486,4 @@ class DOT:
485
486
 
486
487
  @staticmethod
487
488
  def vararg(node: hasDOTvararg) -> ast.arg:
488
- return node.vararg # pyright: ignore[reportReturnType]
489
+ return node.vararg
@@ -4,7 +4,8 @@ from astToolkit import (
4
4
  identifierDotAttribute,
5
5
  )
6
6
  from collections.abc import Sequence
7
- from typing import overload, Unpack
7
+ from typing import overload
8
+ from typing_extensions import Unpack
8
9
  import ast
9
10
  import sys
10
11
 
@@ -116,8 +117,8 @@ class Make:
116
117
  return ast.comprehension(target=target, iter=iter, ifs=list(ifs), is_async=is_async)
117
118
 
118
119
  @staticmethod
119
- def Constant(value: ConstantValueType, **keywordArguments: Unpack[ast_attributes_type_comment]) -> ast.Constant:
120
- return ast.Constant(value=value, kind=None, **keywordArguments) # pyright: ignore[reportArgumentType]
120
+ def Constant(value: ConstantValueType, kind: str | None=None, **keywordArguments: Unpack[ast_attributes]) -> ast.Constant:
121
+ return ast.Constant(value=value, kind=kind, **keywordArguments) # pyright: ignore[reportArgumentType]
121
122
 
122
123
  @staticmethod
123
124
  def Continue(**keywordArguments: Unpack[ast_attributes]) -> ast.Continue:
@@ -188,12 +189,12 @@ class Make:
188
189
  return ast.IfExp(test=test, body=body, orelse=orElse, **keywordArguments)
189
190
 
190
191
  @staticmethod
191
- def Import(moduleWithLogicalPath: identifierDotAttribute, asName: str | None=None, **keywordArguments: Unpack[ast_attributes]) -> ast.Import:
192
- return ast.Import(names=[Make.alias(moduleWithLogicalPath, asName)], **keywordArguments)
192
+ def Import(dotModule: identifierDotAttribute, asName: str | None=None, **keywordArguments: Unpack[ast_attributes]) -> ast.Import:
193
+ return ast.Import(names=[Make.alias(dotModule, asName)], **keywordArguments)
193
194
 
194
195
  @staticmethod
195
- def ImportFrom(module: str, list_alias: list[ast.alias], **keywordArguments: Unpack[ast_attributes]) -> ast.ImportFrom:
196
- return ast.ImportFrom(module=module, names=list_alias, level=0, **keywordArguments)
196
+ def ImportFrom(module: str | None, list_alias: list[ast.alias], level: int=0, **keywordArguments: Unpack[ast_attributes]) -> ast.ImportFrom:
197
+ return ast.ImportFrom(module=module, names=list_alias, level=level, **keywordArguments)
197
198
 
198
199
  @staticmethod
199
200
  def Interactive(body: Sequence[ast.stmt]) -> ast.Interactive:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astToolkit
3
- Version: 0.3.7
3
+ Version: 0.4.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
@@ -30,12 +30,14 @@ Requires-Dist: Z0Z_tools
30
30
  Requires-Dist: autoflake
31
31
  Requires-Dist: python_minifier
32
32
  Requires-Dist: tomli
33
+ Requires-Dist: typing-extensions
33
34
  Provides-Extra: testing
34
35
  Requires-Dist: mypy; extra == "testing"
35
36
  Requires-Dist: pytest; extra == "testing"
36
37
  Requires-Dist: pytest-cov; extra == "testing"
37
38
  Requires-Dist: pytest-xdist; extra == "testing"
38
39
  Requires-Dist: pyupgrade; extra == "testing"
40
+ Requires-Dist: setuptools-scm; extra == "testing"
39
41
  Requires-Dist: trove_classifiers; extra == "testing"
40
42
  Dynamic: license-file
41
43
 
@@ -2,6 +2,7 @@ Z0Z_tools
2
2
  autoflake
3
3
  python_minifier
4
4
  tomli
5
+ typing-extensions
5
6
 
6
7
  [testing]
7
8
  mypy
@@ -9,4 +10,5 @@ pytest
9
10
  pytest-cov
10
11
  pytest-xdist
11
12
  pyupgrade
13
+ setuptools-scm
12
14
  trove_classifiers
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "astToolkit"
3
- version = "0.3.7"
3
+ version = "0.4.0"
4
4
  description = "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
  readme = { file = "README.md", content-type = "text/markdown" }
6
6
  requires-python = ">=3.12"
@@ -43,13 +43,14 @@ classifiers = [
43
43
  "Topic :: Software Development :: Libraries :: Python Modules",
44
44
  "Typing :: Typed",]
45
45
  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" }
46
- dependencies = ["Z0Z_tools", "autoflake", "python_minifier", "tomli"]
46
+ dependencies = ["Z0Z_tools", "autoflake", "python_minifier", "tomli", "typing-extensions"]
47
47
  optional-dependencies = { testing = [
48
48
  "mypy",
49
49
  "pytest",
50
50
  "pytest-cov",
51
51
  "pytest-xdist",
52
52
  "pyupgrade",
53
+ "setuptools-scm",
53
54
  "trove_classifiers",] }
54
55
 
55
56
  [build-system]
@@ -1,33 +1,21 @@
1
- import ast
2
- import pytest
3
- from collections.abc import Callable
4
-
5
- from astToolkit import Make
1
+ from astToolkit import ast_attributes, Make
6
2
  from astToolkit._joinClassmethod import (
7
- Add,
8
- BitAnd,
9
- BitOr,
10
- BitXor,
11
- Div,
12
- FloorDiv,
13
- LShift,
14
- MatMult,
15
- Mod,
16
- Mult,
17
- Pow,
18
- RShift,
19
- Sub,
3
+ Add, BitAnd, BitOr, BitXor, Div, FloorDiv, LShift, MatMult, Mod, Mult, Pow, RShift, Sub,
20
4
  )
5
+ from collections.abc import Callable
6
+ from typing import cast
7
+ import ast
8
+ import pytest
21
9
 
22
10
  constant_expression_5 = Make.Constant(5)
23
11
  constant_expression_7 = Make.Constant(7)
24
12
  constant_expression_11 = Make.Constant(11)
25
13
 
26
- keyword_arguments_set_A = {"lineno": 3, "col_offset": 8, "end_lineno": 3, "end_col_offset": 12}
27
- keyword_arguments_set_B = {"lineno": 17, "col_offset": 19, "end_lineno": 17, "end_col_offset": 25}
14
+ keyword_arguments_set_A: ast_attributes = {"lineno": 3, "col_offset": 8, "end_lineno": 3, "end_col_offset": 12}
15
+ keyword_arguments_set_B: ast_attributes = {"lineno": 17, "col_offset": 19, "end_lineno": 17, "end_col_offset": 25}
28
16
 
29
17
 
30
- def construct_expected_ast_node(ast_operator_type: type[ast.operator], input_expressions_iterable: list[ast.expr], keyword_arguments_for_operation: dict) -> ast.expr:
18
+ def construct_expected_ast_node(ast_operator_type: type[ast.operator], input_expressions_iterable: list[ast.expr], keyword_arguments_for_operation: ast_attributes) -> ast.expr:
31
19
  processed_expressions_list = list(input_expressions_iterable)
32
20
  if not processed_expressions_list:
33
21
  return Make.Constant('', **keyword_arguments_for_operation)
@@ -59,8 +47,8 @@ list_join_implementation_and_ast_operator_pairs = [
59
47
  (Sub, ast.Sub),
60
48
  ]
61
49
 
62
- list_join_method_test_scenarios_params = []
63
- raw_scenarios = [
50
+ list_join_method_test_scenarios_params: list[object] = []
51
+ raw_scenarios: list[tuple[str, list[ast.expr], ast_attributes]] = [
64
52
  ("empty_list_no_kwargs", [], {}),
65
53
  ("empty_list_with_kwargs", [], keyword_arguments_set_A),
66
54
  ("single_expr_no_kwargs", [constant_expression_5], {}),
@@ -86,8 +74,8 @@ raw_scenarios = [
86
74
 
87
75
  for scenario_id, expressions, kwargs in raw_scenarios:
88
76
  # Create a builder that captures the specific expressions and kwargs for this scenario
89
- builder = lambda op_type, bound_expressions=expressions, bound_kwargs=kwargs: \
90
- construct_expected_ast_node(op_type, bound_expressions, bound_kwargs)
77
+ def builder(op_type: type[ast.operator], bound_expressions: list[ast.expr] = expressions, bound_kwargs: ast_attributes = kwargs):
78
+ return construct_expected_ast_node(op_type, bound_expressions, bound_kwargs)
91
79
  list_join_method_test_scenarios_params.append(
92
80
  pytest.param(scenario_id, expressions, kwargs, builder, id=scenario_id)
93
81
  )
@@ -100,11 +88,12 @@ def test_join_method(
100
88
  ast_operator_type: type[ast.operator],
101
89
  scenario_identifier: str,
102
90
  expressions_for_join_method: list[ast.expr],
103
- keyword_arguments_for_join_method: dict,
104
- expected_ast_constructor: Callable
91
+ keyword_arguments_for_join_method: ast_attributes,
92
+ expected_ast_constructor: Callable[[type[ast.operator]], ast.expr]
105
93
 
106
94
  ):
107
- actual_ast_node = JoinImplementerClass.join(expressions_for_join_method, **keyword_arguments_for_join_method)
95
+ join_method = getattr(JoinImplementerClass, 'join')
96
+ actual_ast_node = cast(ast.expr, join_method(expressions_for_join_method, **keyword_arguments_for_join_method))
108
97
  expected_ast_node = expected_ast_constructor(ast_operator_type)
109
98
 
110
99
  dump_of_actual_ast_node = ast.dump(actual_ast_node)
File without changes
File without changes
File without changes
File without changes