astToolkit 0.3.5__tar.gz → 0.3.6__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 (34) hide show
  1. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/PKG-INFO +5 -5
  2. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/__init__.py +2 -1
  3. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_astTypes.py +1 -2
  4. asttoolkit-0.3.6/astToolkit/_dumpHandmade.py +91 -0
  5. asttoolkit-0.3.6/astToolkit/_dumpHandmade.pyi +43 -0
  6. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit.egg-info/PKG-INFO +5 -5
  7. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit.egg-info/SOURCES.txt +2 -0
  8. asttoolkit-0.3.6/pyproject.toml +87 -0
  9. asttoolkit-0.3.5/pyproject.toml +0 -63
  10. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/LICENSE +0 -0
  11. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/README.md +0 -0
  12. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_dumpFunctionDef.py +0 -0
  13. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_joinClassmethod.py +0 -0
  14. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_theSSOT.py +0 -0
  15. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_toolBe.py +0 -0
  16. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_toolClassIsAndAttribute.py +0 -0
  17. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_toolDOT.py +0 -0
  18. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_toolGrab.py +0 -0
  19. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_toolIfThis.py +0 -0
  20. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_toolMake.py +0 -0
  21. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_toolThen.py +0 -0
  22. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_toolkitAST.py +0 -0
  23. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_toolkitContainers.py +0 -0
  24. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_toolkitNodeVisitor.py +0 -0
  25. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/_types.py +0 -0
  26. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/py.typed +0 -0
  27. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit/transformationTools.py +0 -0
  28. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit.egg-info/dependency_links.txt +0 -0
  29. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit.egg-info/requires.txt +1 -1
  30. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/astToolkit.egg-info/top_level.txt +0 -0
  31. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/setup.cfg +0 -0
  32. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/tests/conftest.py +0 -0
  33. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/tests/test_basic.py +0 -0
  34. {asttoolkit-0.3.5 → asttoolkit-0.3.6}/tests/test_joinClassmethod.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astToolkit
3
- Version: 0.3.5
3
+ Version: 0.3.6
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
@@ -8,7 +8,7 @@ Project-URL: Donate, https://www.patreon.com/integrated
8
8
  Project-URL: Homepage, https://github.com/hunterhogan/astToolkit
9
9
  Project-URL: Issues, https://github.com/hunterhogan/astToolkit/issues
10
10
  Project-URL: Repository, https://github.com/hunterhogan/astToolkit.git
11
- Keywords: ast,abstract syntax tree,code generation,code transformation,ast-analysis,ast-manipulation,ast-traversal,ast-visitor,code-analysis,code-refactoring,static-analysis,python-ast,metaprogramming,visitor-pattern,typed-ast,type-safe,composable-apis,function-inlining,source-code-generation,ast-predicate
11
+ Keywords: abstract syntax tree,ast,ast-analysis,ast-manipulation,ast-predicate,ast-traversal,ast-visitor,code generation,code transformation,code-analysis,code-refactoring,composable-apis,function-inlining,metaprogramming,python-ast,source-code-generation,static-analysis,type-safe,typed-ast,visitor-pattern
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Environment :: Console
14
14
  Classifier: Intended Audience :: Developers
@@ -19,17 +19,17 @@ Classifier: Programming Language :: Python
19
19
  Classifier: Programming Language :: Python :: 3
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
- Classifier: Typing :: Typed
22
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
23
23
  Classifier: Topic :: Software Development :: Code Generators
24
24
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
- Classifier: Topic :: Scientific/Engineering :: Information Analysis
25
+ Classifier: Typing :: Typed
26
26
  Requires-Python: >=3.12
27
27
  Description-Content-Type: text/markdown
28
28
  License-File: LICENSE
29
+ Requires-Dist: Z0Z_tools
29
30
  Requires-Dist: autoflake
30
31
  Requires-Dist: python_minifier
31
32
  Requires-Dist: tomli
32
- Requires-Dist: Z0Z_tools
33
33
  Provides-Extra: testing
34
34
  Requires-Dist: mypy; extra == "testing"
35
35
  Requires-Dist: pytest; extra == "testing"
@@ -28,7 +28,8 @@ from astToolkit._types import (
28
28
  str_nameDOTname as str_nameDOTname,
29
29
  )
30
30
 
31
- from astToolkit._dumpFunctionDef import dump as dump
31
+ # from astToolkit._dumpFunctionDef import dump as dump
32
+ from astToolkit._dumpHandmade import dump as dump
32
33
 
33
34
  from astToolkit._toolkitNodeVisitor import (
34
35
  NodeChanger as NodeChanger,
@@ -1,9 +1,8 @@
1
1
  """This file is generated automatically, so changes to this file will be lost."""
2
2
  from types import EllipsisType, NotImplementedType
3
- from typing import Any, TypeAlias as typing_TypeAlias, TypedDict, TypeVar as typing_TypeVar
3
+ from typing import Any, TypeAlias as typing_TypeAlias, TypeVar as typing_TypeVar, TypedDict
4
4
  import ast
5
5
  import sys
6
-
7
6
  intORstr: typing_TypeAlias = Any
8
7
  intORstrORtype_params: typing_TypeAlias = Any
9
8
  intORtype_params: typing_TypeAlias = Any
@@ -0,0 +1,91 @@
1
+ from ast import AST, Constant, MatchSingleton
2
+
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.
20
+ """
21
+ def _format(node, level=0):
22
+ if indent_str is not None:
23
+ level += 1
24
+ prefix = '\n' + indent_str * level
25
+ sep = ',\n' + indent_str * level
26
+ else:
27
+ prefix = ''
28
+ sep = ', '
29
+ if isinstance(node, AST):
30
+ cls = type(node)
31
+ args = []
32
+ args_buffer = []
33
+ allsimple = True
34
+ keywords = annotate_fields
35
+ for name in node._fields:
36
+ try:
37
+ value = getattr(node, name)
38
+ except AttributeError:
39
+ keywords = True
40
+ continue
41
+ if value is None and getattr(cls, name, ...) is None:
42
+ if show_empty:
43
+ args.append('%s=%s' % (name, value))
44
+ keywords = True
45
+ 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 = []
58
+ value_formatted, simple = _format(value, level)
59
+ allsimple = allsimple and simple
60
+ if keywords:
61
+ args.append('%s=%s' % (name, value_formatted))
62
+ else:
63
+ args.append(value_formatted)
64
+ if include_attributes and node._attributes:
65
+ for name_attributes in node._attributes:
66
+ try:
67
+ value_attributes = getattr(node, name_attributes)
68
+ except AttributeError:
69
+ continue
70
+ if value_attributes is None and getattr(cls, name_attributes, ...) is None:
71
+ continue
72
+ value_attributes_formatted, simple = _format(value_attributes, level)
73
+ allsimple = allsimple and simple
74
+ args.append('%s=%s' % (name_attributes, value_attributes_formatted))
75
+ if allsimple and len(args) <= 3:
76
+ return ('%s(%s)' % (f"{node.__class__.__module__}.{node.__class__.__name__}", ', '.join(args)), not args)
77
+ return ('%s(%s%s)' % (f"{node.__class__.__module__}.{node.__class__.__name__}", prefix, sep.join(args)), False)
78
+ elif isinstance(node, list):
79
+ if not node:
80
+ return ('[]', True)
81
+ return '[%s%s]' % (prefix, sep.join(_format(x, level)[0] for x in node)), False
82
+ return (repr(node), True)
83
+
84
+ if not isinstance(node, AST):
85
+ raise TypeError('expected AST, got %r' % node.__class__.__name__)
86
+ if indent is not None and not isinstance(indent, str):
87
+ indent_str = ' ' * indent
88
+ else:
89
+ indent_str = indent
90
+ return _format(node)[0]
91
+
@@ -0,0 +1,43 @@
1
+ from ast import AST
2
+ from types import EllipsisType, NotImplementedType
3
+ from typing import TypeAlias
4
+
5
+ _Constant: TypeAlias = bool | bytes | complex | EllipsisType | float | int | None | NotImplementedType | range | str
6
+
7
+ ConstantType: TypeAlias = _Constant | frozenset['ConstantType'] | tuple['ConstantType', ...]
8
+
9
+ def dump(
10
+ node: AST,
11
+ annotate_fields: bool = ...,
12
+ include_attributes: bool = ...,
13
+ *,
14
+ indent: int | str | None = ...,
15
+ show_empty: bool = ...,
16
+ ) -> str:
17
+ def _format(node: ConstantType | AST | list[AST] | list[str], level: int = ...) -> tuple[str, bool]:
18
+ # Local variables in _format function
19
+ prefix: str
20
+ sep: str
21
+ cls: type[AST]
22
+ args: list[str]
23
+ args_buffer: list[str]
24
+ allsimple: bool
25
+ keywords: bool
26
+
27
+ name: str
28
+ value: AST | list[AST] | list[str] | ConstantType | bool | bytes | complex | float | int | str
29
+ value_formatted: str
30
+ simple: bool
31
+
32
+ name_attributes: str
33
+ value_attributes: int | None
34
+ value_attributes_formatted: str
35
+
36
+ x: AST | str
37
+
38
+ ...
39
+
40
+ # Local variables in dump function
41
+ indent_str: str | None
42
+
43
+ ...
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astToolkit
3
- Version: 0.3.5
3
+ Version: 0.3.6
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
@@ -8,7 +8,7 @@ Project-URL: Donate, https://www.patreon.com/integrated
8
8
  Project-URL: Homepage, https://github.com/hunterhogan/astToolkit
9
9
  Project-URL: Issues, https://github.com/hunterhogan/astToolkit/issues
10
10
  Project-URL: Repository, https://github.com/hunterhogan/astToolkit.git
11
- Keywords: ast,abstract syntax tree,code generation,code transformation,ast-analysis,ast-manipulation,ast-traversal,ast-visitor,code-analysis,code-refactoring,static-analysis,python-ast,metaprogramming,visitor-pattern,typed-ast,type-safe,composable-apis,function-inlining,source-code-generation,ast-predicate
11
+ Keywords: abstract syntax tree,ast,ast-analysis,ast-manipulation,ast-predicate,ast-traversal,ast-visitor,code generation,code transformation,code-analysis,code-refactoring,composable-apis,function-inlining,metaprogramming,python-ast,source-code-generation,static-analysis,type-safe,typed-ast,visitor-pattern
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Environment :: Console
14
14
  Classifier: Intended Audience :: Developers
@@ -19,17 +19,17 @@ Classifier: Programming Language :: Python
19
19
  Classifier: Programming Language :: Python :: 3
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
- Classifier: Typing :: Typed
22
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
23
23
  Classifier: Topic :: Software Development :: Code Generators
24
24
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
- Classifier: Topic :: Scientific/Engineering :: Information Analysis
25
+ Classifier: Typing :: Typed
26
26
  Requires-Python: >=3.12
27
27
  Description-Content-Type: text/markdown
28
28
  License-File: LICENSE
29
+ Requires-Dist: Z0Z_tools
29
30
  Requires-Dist: autoflake
30
31
  Requires-Dist: python_minifier
31
32
  Requires-Dist: tomli
32
- Requires-Dist: Z0Z_tools
33
33
  Provides-Extra: testing
34
34
  Requires-Dist: mypy; extra == "testing"
35
35
  Requires-Dist: pytest; extra == "testing"
@@ -4,6 +4,8 @@ pyproject.toml
4
4
  astToolkit/__init__.py
5
5
  astToolkit/_astTypes.py
6
6
  astToolkit/_dumpFunctionDef.py
7
+ astToolkit/_dumpHandmade.py
8
+ astToolkit/_dumpHandmade.pyi
7
9
  astToolkit/_joinClassmethod.py
8
10
  astToolkit/_theSSOT.py
9
11
  astToolkit/_toolBe.py
@@ -0,0 +1,87 @@
1
+ [project]
2
+ name = "astToolkit"
3
+ version = "0.3.6"
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
+ readme = { file = "README.md", content-type = "text/markdown" }
6
+ requires-python = ">=3.12"
7
+ license = { 'text' = "CC-BY-NC-4.0" }
8
+ authors = [{ name = "Hunter Hogan", email = "HunterHogan@pm.me" }]
9
+ keywords = [
10
+ "abstract syntax tree",
11
+ "ast",
12
+ "ast-analysis",
13
+ "ast-manipulation",
14
+ "ast-predicate",
15
+ "ast-traversal",
16
+ "ast-visitor",
17
+ "code generation",
18
+ "code transformation",
19
+ "code-analysis",
20
+ "code-refactoring",
21
+ "composable-apis",
22
+ "function-inlining",
23
+ "metaprogramming",
24
+ "python-ast",
25
+ "source-code-generation",
26
+ "static-analysis",
27
+ "type-safe",
28
+ "typed-ast",
29
+ "visitor-pattern",
30
+ ]
31
+ classifiers = [
32
+ "Development Status :: 4 - Beta",
33
+ "Environment :: Console",
34
+ "Intended Audience :: Developers",
35
+ "Intended Audience :: Science/Research",
36
+ "Natural Language :: English",
37
+ "Operating System :: OS Independent",
38
+ "Programming Language :: Python",
39
+ "Programming Language :: Python :: 3",
40
+ "Programming Language :: Python :: 3.12",
41
+ "Programming Language :: Python :: 3.13",
42
+ "Topic :: Scientific/Engineering :: Information Analysis",
43
+ "Topic :: Software Development :: Code Generators",
44
+ "Topic :: Software Development :: Libraries :: Python Modules",
45
+ "Typing :: Typed",
46
+ ]
47
+ 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" }
48
+ dependencies = ["Z0Z_tools", "autoflake", "python_minifier", "tomli"]
49
+ optional-dependencies = { testing = [
50
+ "mypy",
51
+ "pytest",
52
+ "pytest-cov",
53
+ "pytest-xdist",
54
+ "pyupgrade",
55
+ "trove_classifiers",
56
+ ] }
57
+
58
+ [build-system]
59
+ requires = ["setuptools"]
60
+ build-backend = "setuptools.build_meta"
61
+
62
+ [tool.coverage]
63
+ report = { exclude_lines = [
64
+ "if TYPE_CHECKING:",
65
+ "if __name__ == \"__main__\":",
66
+ ], ignore_errors = false }
67
+ run = { branch = true, concurrency = [
68
+ "multiprocessing",
69
+ ], data_file = "tests/coverage/.coverage", omit = [
70
+ "tests/*",
71
+ ], parallel = true, source = [
72
+ ".",
73
+ ] }
74
+ xml = { output = "tests/coverage/coverage.xml" }
75
+
76
+ [tool.pytest.ini_options]
77
+ addopts = ["--color=auto"]
78
+ log_auto_indent = true
79
+ testpaths = ["tests"]
80
+
81
+ [tool.setuptools]
82
+ package-data = { "*" = ["py.typed"] }
83
+ packages = { find = { } }
84
+
85
+ [tool.updateCitation]
86
+ filenameCitationDOTcff = "CITATION.cff"
87
+ pathFilenameCitationSSOT = "citations/CITATION.cff"
@@ -1,63 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- authors = [{ name = "Hunter Hogan", email = "HunterHogan@pm.me" }]
7
- classifiers = [
8
- "Development Status :: 4 - Beta",
9
- "Environment :: Console",
10
- "Intended Audience :: Developers",
11
- "Intended Audience :: Science/Research",
12
- "Natural Language :: English",
13
- "Operating System :: OS Independent",
14
- "Programming Language :: Python",
15
- "Programming Language :: Python :: 3",
16
- "Programming Language :: Python :: 3.12",
17
- "Programming Language :: Python :: 3.13",
18
- "Typing :: Typed",
19
- "Topic :: Software Development :: Code Generators",
20
- "Topic :: Software Development :: Libraries :: Python Modules",
21
- "Topic :: Scientific/Engineering :: Information Analysis",]
22
- dependencies = ["autoflake", "python_minifier", "tomli", "Z0Z_tools"]
23
- 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."
24
- keywords = ["ast", "abstract syntax tree", "code generation", "code transformation", "ast-analysis", "ast-manipulation", "ast-traversal", "ast-visitor", "code-analysis", "code-refactoring", "static-analysis", "python-ast", "metaprogramming", "visitor-pattern", "typed-ast", "type-safe", "composable-apis", "function-inlining", "source-code-generation", "ast-predicate"]
25
- license = { 'text' = "CC-BY-NC-4.0" }
26
- name = "astToolkit"
27
- optional-dependencies = { testing = [
28
- "mypy",
29
- "pytest",
30
- "pytest-cov",
31
- "pytest-xdist",
32
- "pyupgrade",
33
- "trove_classifiers",] }
34
- readme = { file = "README.md", content-type = "text/markdown" }
35
- requires-python = ">=3.12"
36
- 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" }
37
- version = "0.3.5"
38
-
39
- [tool.coverage]
40
- report = { exclude_lines = [
41
- "if TYPE_CHECKING:",
42
- "if __name__ == \"__main__\":",
43
- ], ignore_errors = false }
44
- run = { branch = true, concurrency = [
45
- "multiprocessing",
46
- ], data_file = "tests/coverage/.coverage", omit = [
47
- "tests/*",
48
- ], parallel = true, source = [
49
- ".",] }
50
- xml = { output = "tests/coverage/coverage.xml" }
51
-
52
- [tool.pytest.ini_options]
53
- log_auto_indent = true
54
- addopts = ["--color=auto"]
55
- testpaths = ["tests"]
56
-
57
- [tool.setuptools]
58
- package-data = { "*" = ["py.typed"] }
59
- packages = { find = {} }
60
-
61
- [tool.updateCitation]
62
- filenameCitationDOTcff = 'CITATION.cff'
63
- pathFilenameCitationSSOT = "citations/CITATION.cff"
File without changes
File without changes
@@ -1,7 +1,7 @@
1
+ Z0Z_tools
1
2
  autoflake
2
3
  python_minifier
3
4
  tomli
4
- Z0Z_tools
5
5
 
6
6
  [testing]
7
7
  mypy
File without changes
File without changes