astToolkit 0.5.0__tar.gz → 0.5.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.
Files changed (39) hide show
  1. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/PKG-INFO +8 -8
  2. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/README.md +6 -6
  3. asttoolkit-0.5.2/astToolkit/__init__.py +87 -0
  4. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit/_astTypes.py +4 -4
  5. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit/_dumpFunctionDef.py +10 -6
  6. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit/_dumpHandmade.py +33 -39
  7. asttoolkit-0.5.2/astToolkit/_theSSOT.py +22 -0
  8. asttoolkit-0.5.2/astToolkit/_toolBe.py +548 -0
  9. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit/_toolClassIsAndAttribute.py +221 -194
  10. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit/_toolDOT.py +37 -11
  11. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit/_toolGrab.py +26 -10
  12. asttoolkit-0.5.2/astToolkit/_toolIfThis.py +508 -0
  13. asttoolkit-0.5.2/astToolkit/_toolMake.py +3250 -0
  14. asttoolkit-0.5.2/astToolkit/_toolThen.py +158 -0
  15. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit/_toolkitContainers.py +95 -113
  16. asttoolkit-0.5.2/astToolkit/_toolkitNodeVisitor.py +170 -0
  17. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit.egg-info/PKG-INFO +8 -8
  18. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit.egg-info/SOURCES.txt +0 -2
  19. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit.egg-info/requires.txt +1 -1
  20. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/pyproject.toml +16 -6
  21. asttoolkit-0.5.0/astToolkit/__init__.py +0 -60
  22. asttoolkit-0.5.0/astToolkit/_dumpHandmade.pyi +0 -43
  23. asttoolkit-0.5.0/astToolkit/_theSSOT.py +0 -31
  24. asttoolkit-0.5.0/astToolkit/_toolBe.py +0 -515
  25. asttoolkit-0.5.0/astToolkit/_toolIfThis.py +0 -174
  26. asttoolkit-0.5.0/astToolkit/_toolMake.py +0 -1186
  27. asttoolkit-0.5.0/astToolkit/_toolThen.py +0 -63
  28. asttoolkit-0.5.0/astToolkit/_toolkitNodeVisitor.py +0 -69
  29. asttoolkit-0.5.0/astToolkit/_types.py +0 -27
  30. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/LICENSE +0 -0
  31. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit/_toolkitAST.py +0 -0
  32. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit/py.typed +0 -0
  33. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit/transformationTools.py +0 -0
  34. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit.egg-info/dependency_links.txt +0 -0
  35. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/astToolkit.egg-info/top_level.txt +0 -0
  36. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/setup.cfg +0 -0
  37. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/tests/conftest.py +0 -0
  38. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/tests/test_basic.py +0 -0
  39. {asttoolkit-0.5.0 → asttoolkit-0.5.2}/tests/test_joinClassmethod.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astToolkit
3
- Version: 0.5.0
3
+ Version: 0.5.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
@@ -30,7 +30,7 @@ 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
+ Requires-Dist: typing-extensions>=4.10.0
34
34
  Provides-Extra: testing
35
35
  Requires-Dist: mypy; extra == "testing"
36
36
  Requires-Dist: pytest; extra == "testing"
@@ -59,7 +59,7 @@ Don't use it for simple text-based code manipulation—use regex or string opera
59
59
  astToolkit implements a layered architecture designed for composability and type safety:
60
60
 
61
61
  1. **Core "Atomic" Classes** - The foundation of the system:
62
- - `Be`: Type guards that return `TypeGuard[ast.NodeType]` for safe type narrowing.
62
+ - `Be`: Type guards that return `TypeIs[ast.NodeType]` for safe type narrowing.
63
63
  - `DOT`: Read-only accessors that retrieve node attributes with proper typing.
64
64
  - `Grab`: Transformation functions that modify specific attributes while preserving node structure.
65
65
  - `Make`: Factory methods that create properly configured AST nodes with consistent interfaces.
@@ -192,7 +192,7 @@ class IfThis(astToolkit_IfThis):
192
192
  def isAttributeNamespaceIdentifierGreaterThan0(
193
193
  namespace: str,
194
194
  identifier: str
195
- ) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
195
+ ) -> Callable[[ast.AST], TypeIs[ast.Compare] | bool]:
196
196
 
197
197
  return lambda node: (
198
198
  Be.Compare(node)
@@ -204,7 +204,7 @@ class IfThis(astToolkit_IfThis):
204
204
  def isWhileAttributeNamespaceIdentifierGreaterThan0(
205
205
  namespace: str,
206
206
  identifier: str
207
- ) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
207
+ ) -> Callable[[ast.AST], TypeIs[ast.While] | bool]:
208
208
 
209
209
  return lambda node: (
210
210
  Be.While(node)
@@ -292,7 +292,7 @@ To create specialized patterns for your codebase, extend the core classes:
292
292
  ```python
293
293
  from astToolkit import str, Be, IfThis as astToolkit_IfThis
294
294
  from collections.abc import Callable
295
- from typing import TypeGuard
295
+ from typing import TypeIs
296
296
  import ast
297
297
 
298
298
  class IfThis(astToolkit_IfThis):
@@ -300,7 +300,7 @@ class IfThis(astToolkit_IfThis):
300
300
  def isAttributeNamespaceIdentifierGreaterThan0(
301
301
  namespace: str,
302
302
  identifier: str
303
- ) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
303
+ ) -> Callable[[ast.AST], TypeIs[ast.Compare] | bool]:
304
304
  """Find comparisons like 'state.counter > 0'"""
305
305
  return lambda node: (
306
306
  Be.Compare(node)
@@ -313,7 +313,7 @@ class IfThis(astToolkit_IfThis):
313
313
  def isWhileAttributeNamespaceIdentifierGreaterThan0(
314
314
  namespace: str,
315
315
  identifier: str
316
- ) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
316
+ ) -> Callable[[ast.AST], TypeIs[ast.While] | bool]:
317
317
  """Find while loops like 'while state.counter > 0:'"""
318
318
  return lambda node: (
319
319
  Be.While(node)
@@ -16,7 +16,7 @@ Don't use it for simple text-based code manipulation—use regex or string opera
16
16
  astToolkit implements a layered architecture designed for composability and type safety:
17
17
 
18
18
  1. **Core "Atomic" Classes** - The foundation of the system:
19
- - `Be`: Type guards that return `TypeGuard[ast.NodeType]` for safe type narrowing.
19
+ - `Be`: Type guards that return `TypeIs[ast.NodeType]` for safe type narrowing.
20
20
  - `DOT`: Read-only accessors that retrieve node attributes with proper typing.
21
21
  - `Grab`: Transformation functions that modify specific attributes while preserving node structure.
22
22
  - `Make`: Factory methods that create properly configured AST nodes with consistent interfaces.
@@ -149,7 +149,7 @@ class IfThis(astToolkit_IfThis):
149
149
  def isAttributeNamespaceIdentifierGreaterThan0(
150
150
  namespace: str,
151
151
  identifier: str
152
- ) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
152
+ ) -> Callable[[ast.AST], TypeIs[ast.Compare] | bool]:
153
153
 
154
154
  return lambda node: (
155
155
  Be.Compare(node)
@@ -161,7 +161,7 @@ class IfThis(astToolkit_IfThis):
161
161
  def isWhileAttributeNamespaceIdentifierGreaterThan0(
162
162
  namespace: str,
163
163
  identifier: str
164
- ) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
164
+ ) -> Callable[[ast.AST], TypeIs[ast.While] | bool]:
165
165
 
166
166
  return lambda node: (
167
167
  Be.While(node)
@@ -249,7 +249,7 @@ To create specialized patterns for your codebase, extend the core classes:
249
249
  ```python
250
250
  from astToolkit import str, Be, IfThis as astToolkit_IfThis
251
251
  from collections.abc import Callable
252
- from typing import TypeGuard
252
+ from typing import TypeIs
253
253
  import ast
254
254
 
255
255
  class IfThis(astToolkit_IfThis):
@@ -257,7 +257,7 @@ class IfThis(astToolkit_IfThis):
257
257
  def isAttributeNamespaceIdentifierGreaterThan0(
258
258
  namespace: str,
259
259
  identifier: str
260
- ) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
260
+ ) -> Callable[[ast.AST], TypeIs[ast.Compare] | bool]:
261
261
  """Find comparisons like 'state.counter > 0'"""
262
262
  return lambda node: (
263
263
  Be.Compare(node)
@@ -270,7 +270,7 @@ class IfThis(astToolkit_IfThis):
270
270
  def isWhileAttributeNamespaceIdentifierGreaterThan0(
271
271
  namespace: str,
272
272
  identifier: str
273
- ) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
273
+ ) -> Callable[[ast.AST], TypeIs[ast.While] | bool]:
274
274
  """Find while loops like 'while state.counter > 0:'"""
275
275
  return lambda node: (
276
276
  Be.While(node)
@@ -0,0 +1,87 @@
1
+ import sys
2
+
3
+ from astToolkit._astTypes import (
4
+ ast_attributes as ast_attributes, ast_attributes_int as ast_attributes_int,
5
+ ast_attributes_type_comment as ast_attributes_type_comment, ConstantValueType as ConstantValueType,
6
+ hasDOTannotation as hasDOTannotation, hasDOTannotation_expr as hasDOTannotation_expr,
7
+ hasDOTannotation_exprOrNone as hasDOTannotation_exprOrNone, hasDOTarg as hasDOTarg,
8
+ hasDOTarg_str as hasDOTarg_str, hasDOTarg_strOrNone as hasDOTarg_strOrNone,
9
+ hasDOTargs as hasDOTargs, hasDOTargs_arguments as hasDOTargs_arguments,
10
+ hasDOTargs_list_arg as hasDOTargs_list_arg, hasDOTargs_list_expr as hasDOTargs_list_expr,
11
+ hasDOTargtypes as hasDOTargtypes, hasDOTasname as hasDOTasname, hasDOTattr as hasDOTattr,
12
+ hasDOTbases as hasDOTbases, hasDOTbody as hasDOTbody, hasDOTbody_expr as hasDOTbody_expr,
13
+ hasDOTbody_list_stmt as hasDOTbody_list_stmt, hasDOTbound as hasDOTbound,
14
+ hasDOTcases as hasDOTcases, hasDOTcause as hasDOTcause, hasDOTcls as hasDOTcls,
15
+ hasDOTcomparators as hasDOTcomparators, hasDOTcontext_expr as hasDOTcontext_expr,
16
+ hasDOTconversion as hasDOTconversion, hasDOTctx as hasDOTctx,
17
+ hasDOTdecorator_list as hasDOTdecorator_list,
18
+ hasDOTdefaults as hasDOTdefaults, hasDOTelt as hasDOTelt, hasDOTelts as hasDOTelts,
19
+ hasDOTexc as hasDOTexc, hasDOTfinalbody as hasDOTfinalbody, hasDOTformat_spec as hasDOTformat_spec,
20
+ hasDOTfunc as hasDOTfunc, hasDOTgenerators as hasDOTgenerators, hasDOTguard as hasDOTguard,
21
+ hasDOThandlers as hasDOThandlers, hasDOTid as hasDOTid, hasDOTifs as hasDOTifs,
22
+ hasDOTis_async as hasDOTis_async, hasDOTitems as hasDOTitems, hasDOTiter as hasDOTiter,
23
+ hasDOTkey as hasDOTkey, hasDOTkeys as hasDOTkeys, hasDOTkeys_list_expr as hasDOTkeys_list_expr,
24
+ hasDOTkeys_list_exprOrNone as hasDOTkeys_list_exprOrNone, hasDOTkeywords as hasDOTkeywords,
25
+ hasDOTkind as hasDOTkind, hasDOTkw_defaults as hasDOTkw_defaults, hasDOTkwarg as hasDOTkwarg,
26
+ hasDOTkwd_attrs as hasDOTkwd_attrs, hasDOTkwd_patterns as hasDOTkwd_patterns,
27
+ hasDOTkwonlyargs as hasDOTkwonlyargs, hasDOTleft as hasDOTleft, hasDOTlevel as hasDOTlevel,
28
+ hasDOTlineno as hasDOTlineno, hasDOTlower as hasDOTlower, hasDOTmodule as hasDOTmodule,
29
+ hasDOTmsg as hasDOTmsg, hasDOTname as hasDOTname, hasDOTname_Name as hasDOTname_Name,
30
+ hasDOTname_str as hasDOTname_str, hasDOTname_strOrNone as hasDOTname_strOrNone,
31
+ hasDOTnames as hasDOTnames, hasDOTnames_list_alias as hasDOTnames_list_alias,
32
+ hasDOTnames_list_str as hasDOTnames_list_str, hasDOTop as hasDOTop,
33
+ hasDOTop_boolop as hasDOTop_boolop, hasDOTop_operator as hasDOTop_operator,
34
+ hasDOTop_unaryop as hasDOTop_unaryop, hasDOToperand as hasDOToperand, hasDOTops as hasDOTops,
35
+ hasDOToptional_vars as hasDOToptional_vars, hasDOTorelse as hasDOTorelse,
36
+ hasDOTorelse_expr as hasDOTorelse_expr, hasDOTorelse_list_stmt as hasDOTorelse_list_stmt,
37
+ hasDOTpattern as hasDOTpattern, hasDOTpattern_pattern as hasDOTpattern_pattern,
38
+ hasDOTpattern_patternOrNone as hasDOTpattern_patternOrNone, hasDOTpatterns as hasDOTpatterns,
39
+ hasDOTposonlyargs as hasDOTposonlyargs, hasDOTrest as hasDOTrest, hasDOTreturns as hasDOTreturns,
40
+ hasDOTreturns_expr as hasDOTreturns_expr, hasDOTreturns_exprOrNone as hasDOTreturns_exprOrNone,
41
+ hasDOTright as hasDOTright, hasDOTsimple as hasDOTsimple, hasDOTslice as hasDOTslice,
42
+ hasDOTstep as hasDOTstep, hasDOTsubject as hasDOTsubject, hasDOTtag as hasDOTtag,
43
+ hasDOTtarget as hasDOTtarget, hasDOTtarget_expr as hasDOTtarget_expr,
44
+ hasDOTtarget_Name as hasDOTtarget_Name,
45
+ hasDOTtarget_NameOrAttributeOrSubscript as hasDOTtarget_NameOrAttributeOrSubscript,
46
+ hasDOTtargets as hasDOTtargets, hasDOTtest as hasDOTtest, hasDOTtype as hasDOTtype,
47
+ hasDOTtype_comment as hasDOTtype_comment, hasDOTtype_ignores as hasDOTtype_ignores,
48
+ hasDOTtype_params as hasDOTtype_params, hasDOTupper as hasDOTupper, hasDOTvalue as hasDOTvalue,
49
+ hasDOTvalue_boolOrNone as hasDOTvalue_boolOrNone,
50
+ hasDOTvalue_ConstantValueType as hasDOTvalue_ConstantValueType,
51
+ hasDOTvalue_expr as hasDOTvalue_expr, hasDOTvalue_exprOrNone as hasDOTvalue_exprOrNone,
52
+ hasDOTvalues as hasDOTvalues, hasDOTvararg as hasDOTvararg,
53
+ identifierDotAttribute as identifierDotAttribute, 个 as 个, 个return as 个return, 木 as 木,
54
+ )
55
+ if sys.version_info >= (3, 13):
56
+ from astToolkit._astTypes import hasDOTdefault_value as hasDOTdefault_value
57
+
58
+ # from astToolkit._dumpFunctionDef import dump as dump
59
+ from astToolkit._dumpHandmade import dump as dump
60
+
61
+ from astToolkit._toolkitNodeVisitor import (
62
+ NodeChanger as NodeChanger,
63
+ NodeTourist as NodeTourist,
64
+ )
65
+
66
+ from astToolkit._toolBe import Be as Be
67
+ from astToolkit._toolClassIsAndAttribute import ClassIsAndAttribute as ClassIsAndAttribute
68
+ from astToolkit._toolDOT import DOT as DOT
69
+ from astToolkit._toolGrab import Grab as Grab
70
+ from astToolkit._toolMake import Make as Make
71
+
72
+ from astToolkit._toolIfThis import IfThis as IfThis
73
+ from astToolkit._toolThen import Then as Then
74
+
75
+ from astToolkit._toolkitContainers import (
76
+ IngredientsFunction as IngredientsFunction,
77
+ IngredientsModule as IngredientsModule,
78
+ LedgerOfImports as LedgerOfImports,
79
+ )
80
+
81
+ from astToolkit._toolkitAST import (
82
+ astModuleToIngredientsFunction as astModuleToIngredientsFunction,
83
+ extractClassDef as extractClassDef,
84
+ extractFunctionDef as extractFunctionDef,
85
+ parseLogicalPath2astModule as parseLogicalPath2astModule,
86
+ parsePathFilename2astModule as parsePathFilename2astModule,
87
+ )
@@ -1,12 +1,12 @@
1
+ # pyright: reportMatchNotExhaustive=false
1
2
  """This file is generated automatically, so changes to this file will be lost."""
2
3
  from types import EllipsisType
3
- from typing import Any, TypeAlias as typing_TypeAlias, TypeVar as typing_TypeVar, TypedDict
4
+ from typing import TypeAlias as typing_TypeAlias, TypedDict, TypeVar as typing_TypeVar
4
5
  import ast
5
6
  import sys
6
- intORstr: typing_TypeAlias = Any
7
- intORstrORtype_params: typing_TypeAlias = Any
8
- intORtype_params: typing_TypeAlias = Any
7
+
9
8
  ConstantValueType: typing_TypeAlias = bool | bytes | complex | EllipsisType | float | int | None | range | str
9
+ identifierDotAttribute: typing_TypeAlias = str
10
10
  木 = typing_TypeVar('木', bound=ast.AST, covariant=True)
11
11
  个 = typing_TypeVar('个', covariant=True)
12
12
  个return = typing_TypeVar('个return', covariant=True)
@@ -38,12 +38,16 @@ def dump(node, annotate_fields=True, include_attributes=False, *, indent=None, s
38
38
  if value is None and getattr(cls, name, ...) is None:
39
39
  keywords = True
40
40
  continue
41
- if not show_empty and (value is None or value == []) and (not isinstance(node, (Constant, MatchSingleton))):
42
- args_buffer.append(repr(value))
43
- continue
44
- elif not keywords:
45
- args.extend(args_buffer)
46
- args_buffer = []
41
+ if not show_empty:
42
+ if value == []:
43
+ field_type = cls._field_types.get(name, object)
44
+ if getattr(field_type, '__origin__', ...) is list:
45
+ if not keywords:
46
+ args_buffer.append(repr(value))
47
+ continue
48
+ if not keywords:
49
+ args.extend(args_buffer)
50
+ args_buffer = []
47
51
  value, simple = _format(value, level)
48
52
  allsimple = allsimple and simple
49
53
  if keywords:
@@ -1,37 +1,33 @@
1
- from ast import AST, Constant, MatchSingleton
1
+ from ast import AST
2
+ from astToolkit import ConstantValueType
2
3
 
3
- def dump(
4
- node, annotate_fields=True, include_attributes=False,
5
- *,
6
- indent=None, show_empty=False,
7
- ):
8
- """
9
- Return a formatted dump of the tree in node. This is mainly useful for
10
- debugging purposes. If annotate_fields is true (by default),
11
- the returned string will show the names and the values for fields.
12
- If annotate_fields is false, the result string will be more compact by
13
- omitting unambiguous field names. Attributes such as line
14
- numbers and column offsets are not dumped by default. If this is wanted,
15
- include_attributes can be set to true. If indent is a non-negative
16
- integer or string, then the tree will be pretty-printed with that indent
17
- level. None (the default) selects the single line representation.
18
- If show_empty is False, then empty lists and fields that are None
19
- will be omitted from the output for better readability.
4
+ def dump(node: AST, annotate_fields: bool = True, include_attributes: bool = False, *, indent: int | str | None = None, show_empty: bool = False) -> str:
5
+ """Return a formatted string representation of an AST node.
6
+
7
+ Parameters:
8
+ node: The AST node to format
9
+ annotate_fields (True): Whether to include field names in the output
10
+ include_attributes (False): Whether to include node attributes in addition to fields
11
+ indent (None): String for indentation or number of spaces; `None` for single-line output
12
+ show_empty (False): Whether to include fields with empty list or `None` values
13
+
14
+ Returns:
15
+ formattedString: String representation of the AST node with specified formatting
20
16
  """
21
- def _format(node, level=0):
17
+ def _format(node: ConstantValueType | AST | list[AST] | list[str], level: int = 0) -> tuple[str, bool]:
22
18
  if indent_str is not None:
23
19
  level += 1
24
- prefix = '\n' + indent_str * level
25
- sep = ',\n' + indent_str * level
20
+ prefix: str = '\n' + indent_str * level
21
+ sep: str = ',\n' + indent_str * level
26
22
  else:
27
23
  prefix = ''
28
24
  sep = ', '
29
25
  if isinstance(node, AST):
30
- cls = type(node)
31
- args = []
32
- args_buffer = []
33
- allsimple = True
34
- keywords = annotate_fields
26
+ cls: type[AST] = type(node)
27
+ args: list[str] = []
28
+ args_buffer: list[str] = []
29
+ allsimple: bool = True
30
+ keywords: bool = annotate_fields
35
31
  for name in node._fields:
36
32
  try:
37
33
  value = getattr(node, name)
@@ -43,18 +39,16 @@ def dump(
43
39
  args.append('%s=%s' % (name, value))
44
40
  keywords = True
45
41
  continue
46
- elif (
47
- not show_empty
48
- and (value is None or value == [])
49
- # Special cases:
50
- # `Constant(value=None)` and `MatchSingleton(value=None)`
51
- and not isinstance(node, (Constant, MatchSingleton))
52
- ):
53
- args_buffer.append(repr(value))
54
- continue
55
- elif not keywords:
56
- args.extend(args_buffer)
57
- args_buffer = []
42
+ if not show_empty:
43
+ if value == []:
44
+ field_type = cls._field_types.get(name, object)
45
+ if getattr(field_type, '__origin__', ...) is list:
46
+ if not keywords:
47
+ args_buffer.append(repr(value))
48
+ continue
49
+ if not keywords:
50
+ args.extend(args_buffer)
51
+ args_buffer = []
58
52
  value_formatted, simple = _format(value, level)
59
53
  allsimple = allsimple and simple
60
54
  if keywords:
@@ -78,7 +72,7 @@ def dump(
78
72
  elif isinstance(node, list):
79
73
  if not node:
80
74
  return ('[]', True)
81
- return '[%s%s]' % (prefix, sep.join(_format(x, level)[0] for x in node)), False
75
+ return ('[%s%s]' % (prefix, sep.join(_format(x, level)[0] for x in node)), False)
82
76
  return (repr(node), True)
83
77
 
84
78
  if not isinstance(node, AST):
@@ -0,0 +1,22 @@
1
+ from importlib import import_module as importlib_import_module
2
+ from inspect import getfile as inspect_getfile
3
+ from pathlib import Path
4
+ import dataclasses
5
+
6
+ identifierPackage = 'astToolkit'
7
+
8
+ def getPathPackageINSTALLING() -> Path:
9
+ pathPackage: Path = Path(inspect_getfile(importlib_import_module(identifierPackage)))
10
+ if pathPackage.is_file():
11
+ pathPackage = pathPackage.parent
12
+ return pathPackage
13
+
14
+ @dataclasses.dataclass
15
+ class PackageSettings:
16
+ fileExtension: str = dataclasses.field(default='.py')
17
+ 'Default file extension for generated code files.'
18
+ packageName: str = dataclasses.field(default=identifierPackage)
19
+ 'Name of this package, used for import paths and configuration.'
20
+ pathPackage: Path = dataclasses.field(default_factory=getPathPackageINSTALLING, metadata={'evaluateWhen': 'installing'})
21
+ 'Absolute path to the installed package directory.'
22
+ packageSettings = PackageSettings()