astToolkit 0.2.0__tar.gz → 0.2.1__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 (41) hide show
  1. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/PKG-INFO +1 -1
  2. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_toolBe.py +33 -27
  3. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_types.py +6 -6
  4. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/transformationTools.py +7 -1
  5. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit.egg-info/PKG-INFO +1 -1
  6. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit.egg-info/SOURCES.txt +6 -3
  7. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/pyproject.toml +1 -1
  8. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/toolFactory/Z0Z_hardcoded.py +16 -7
  9. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/toolFactory/Z0Z_makeAstTools.py +1 -1
  10. asttoolkit-0.2.1/toolFactory/__init__.py +27 -0
  11. asttoolkit-0.2.1/toolFactory/_snippets.py +6 -0
  12. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/toolFactory/astFactory.py +45 -44
  13. asttoolkit-0.2.1/toolFactory/databaseASTCreation.py +154 -0
  14. asttoolkit-0.2.1/toolFactory/datacenter.py +131 -0
  15. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/toolFactory/docstrings.py +20 -7
  16. asttoolkit-0.2.1/toolFactory/factory3.py +319 -0
  17. asttoolkit-0.2.0/toolFactory/astFactory_annex.py → asttoolkit-0.2.1/toolFactory/factory_annex.py +2 -1
  18. asttoolkit-0.2.0/toolFactory/__init__.py +0 -16
  19. asttoolkit-0.2.0/toolFactory/startHere.py +0 -11
  20. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/LICENSE +0 -0
  21. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/README.md +0 -0
  22. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/__init__.py +0 -0
  23. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_astTypes.py +0 -0
  24. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_toolClassIsAndAttribute.py +0 -0
  25. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_toolDOT.py +0 -0
  26. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_toolGrab.py +0 -0
  27. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_toolIfThis.py +0 -0
  28. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_toolMake.py +0 -0
  29. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_toolThen.py +0 -0
  30. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_toolkitAST.py +0 -0
  31. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_toolkitContainers.py +0 -0
  32. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_toolkitNodeVisitor.py +0 -0
  33. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/_typesSpecial.py +0 -0
  34. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/py.typed +0 -0
  35. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit/theSSOT.py +0 -0
  36. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit.egg-info/dependency_links.txt +0 -0
  37. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit.egg-info/requires.txt +0 -0
  38. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/astToolkit.egg-info/top_level.txt +0 -0
  39. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/setup.cfg +0 -0
  40. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/tests/test_basic.py +0 -0
  41. {asttoolkit-0.2.0 → asttoolkit-0.2.1}/toolFactory/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astToolkit
3
- Version: 0.2.0
3
+ Version: 0.2.1
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
@@ -1,7 +1,7 @@
1
1
  """This file is generated automatically, so changes to this file will be lost."""
2
- from astToolkit import astDOTTryStar, astDOTParamSpec, astDOTtype_param, astDOTTypeAlias, astDOTTypeVar, astDOTTypeVarTuple
3
2
  from typing import TypeGuard
4
3
  import ast
4
+ import sys
5
5
 
6
6
  class Be:
7
7
  """
@@ -159,14 +159,14 @@ 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
 
166
+ @staticmethod
167
+ def excepthandler(node: ast.AST) -> TypeGuard[ast.excepthandler]:
168
+ return isinstance(node, ast.excepthandler)
169
+
170
170
  @staticmethod
171
171
  def Expr(node: ast.AST) -> TypeGuard[ast.Expr]:
172
172
  return isinstance(node, ast.Expr)
@@ -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,10 +382,11 @@ 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):
385
386
 
386
- @staticmethod
387
- def ParamSpec(node: ast.AST) -> TypeGuard[astDOTParamSpec]:
388
- return isinstance(node, astDOTParamSpec)
387
+ @staticmethod
388
+ def ParamSpec(node: ast.AST) -> TypeGuard[ast.ParamSpec]:
389
+ return isinstance(node, ast.ParamSpec)
389
390
 
390
391
  @staticmethod
391
392
  def Pass(node: ast.AST) -> TypeGuard[ast.Pass]:
@@ -446,10 +447,11 @@ class Be:
446
447
  @staticmethod
447
448
  def Try(node: ast.AST) -> TypeGuard[ast.Try]:
448
449
  return isinstance(node, ast.Try)
450
+ if sys.version_info >= (3, 11):
449
451
 
450
- @staticmethod
451
- def TryStar(node: ast.AST) -> TypeGuard[astDOTTryStar]:
452
- return isinstance(node, astDOTTryStar)
452
+ @staticmethod
453
+ def TryStar(node: ast.AST) -> TypeGuard[ast.TryStar]:
454
+ return isinstance(node, ast.TryStar)
453
455
 
454
456
  @staticmethod
455
457
  def Tuple(node: ast.AST) -> TypeGuard[ast.Tuple]:
@@ -458,26 +460,30 @@ class Be:
458
460
  @staticmethod
459
461
  def type_ignore(node: ast.AST) -> TypeGuard[ast.type_ignore]:
460
462
  return isinstance(node, ast.type_ignore)
463
+ if sys.version_info >= (3, 12):
461
464
 
462
- @staticmethod
463
- def type_param(node: ast.AST) -> TypeGuard[astDOTtype_param]:
464
- return isinstance(node, astDOTtype_param)
465
+ @staticmethod
466
+ def type_param(node: ast.AST) -> TypeGuard[ast.type_param]:
467
+ return isinstance(node, ast.type_param)
468
+ if sys.version_info >= (3, 12):
465
469
 
466
- @staticmethod
467
- def TypeAlias(node: ast.AST) -> TypeGuard[astDOTTypeAlias]:
468
- return isinstance(node, astDOTTypeAlias)
470
+ @staticmethod
471
+ def TypeAlias(node: ast.AST) -> TypeGuard[ast.TypeAlias]:
472
+ return isinstance(node, ast.TypeAlias)
469
473
 
470
474
  @staticmethod
471
475
  def TypeIgnore(node: ast.AST) -> TypeGuard[ast.TypeIgnore]:
472
476
  return isinstance(node, ast.TypeIgnore)
477
+ if sys.version_info >= (3, 12):
473
478
 
474
- @staticmethod
475
- def TypeVar(node: ast.AST) -> TypeGuard[astDOTTypeVar]:
476
- return isinstance(node, astDOTTypeVar)
479
+ @staticmethod
480
+ def TypeVar(node: ast.AST) -> TypeGuard[ast.TypeVar]:
481
+ return isinstance(node, ast.TypeVar)
482
+ if sys.version_info >= (3, 12):
477
483
 
478
- @staticmethod
479
- def TypeVarTuple(node: ast.AST) -> TypeGuard[astDOTTypeVarTuple]:
480
- return isinstance(node, astDOTTypeVarTuple)
484
+ @staticmethod
485
+ def TypeVarTuple(node: ast.AST) -> TypeGuard[ast.TypeVarTuple]:
486
+ return isinstance(node, ast.TypeVarTuple)
481
487
 
482
488
  @staticmethod
483
489
  def UAdd(node: ast.AST) -> TypeGuard[ast.UAdd]:
@@ -4,12 +4,6 @@ import ast
4
4
 
5
5
  # TODO understand typing.
6
6
 
7
- # NOTE Prototype of an idea to subclass composable methods so that typing information
8
- # can extend beyond the top level of the ast node.
9
- # To cover all cases, quantity of necessary classes = sum of (for each class: for each attribute: attribute * number of valid types). If an attribute has type ast.expr, for example, then there are 27 valid types just for that attribute. There would be thousands of subclasses like ImaCallToName.
10
- # class ImaCallToName(ast.Call):
11
- # func: ast.Name # pyright: ignore[reportIncompatibleVariableOverride]
12
-
13
7
  # Type hints through TypeAlias or type "hints" through the identifier name.
14
8
  ast_expr_Slice: typing_TypeAlias = ast.expr
15
9
  ast_Identifier: typing_TypeAlias = str
@@ -35,3 +29,9 @@ Ima_ast_type_param: typing_TypeAlias = astDOTtype_param | astDOTParamSpec | astD
35
29
  Ima_ast_unaryop: typing_TypeAlias = ast.unaryop | ast.Invert | ast.Not | ast.UAdd | ast.USub
36
30
 
37
31
  Ima_ast_orphan = ast.alias | ast.arg | ast.arguments | ast.comprehension | ast.keyword | ast.match_case | ast.withitem
32
+
33
+ # NOTE Prototype of an old idea to subclass composable methods so that typing information
34
+ # can extend beyond the top level of the ast node.
35
+ # To cover all cases, quantity of necessary classes = sum of (for each class: for each attribute: attribute * number of valid types). If an attribute has type ast.expr, for example, then there are 27 valid types just for that attribute. There would be thousands of subclasses like ImaCallToName.
36
+ # class ImaCallToName(ast.Call):
37
+ # func: ast.Name # pyright: ignore[reportIncompatibleVariableOverride]
@@ -19,7 +19,7 @@ from collections.abc import Callable, Mapping
19
19
  from copy import deepcopy
20
20
  from os import PathLike
21
21
  from pathlib import PurePath
22
- from typing import Any, cast
22
+ from typing import Any, cast, overload
23
23
  from Z0Z_tools import writeStringToHere
24
24
  import ast
25
25
 
@@ -191,6 +191,10 @@ def unparseFindReplace(astTree: 个, mappingFindReplaceNodes: Mapping[ast.AST, a
191
191
  astTree = deepcopy(newTree)
192
192
  return newTree
193
193
 
194
+ # @overload
195
+ # def write_astModule(astModule: ast.AST, pathFilename: PathLike[Any] | PurePath, packageName: ast_Identifier | None = None) -> None:...
196
+ # @overload
197
+ # def write_astModule(ingredients: IngredientsModule, pathFilename: PathLike[Any] | PurePath, packageName: ast_Identifier | None = None) -> None:...
194
198
  def write_astModule(ingredients: IngredientsModule, pathFilename: PathLike[Any] | PurePath, packageName: ast_Identifier | None = None) -> None:
195
199
  """
196
200
  Convert an IngredientsModule to Python source code and write it to a file.
@@ -217,6 +221,8 @@ def write_astModule(ingredients: IngredientsModule, pathFilename: PathLike[Any]
217
221
  Raises:
218
222
  FREAKOUT: If the generated source code is empty.
219
223
  """
224
+ # if ingredients:
225
+ # astModule = Make.Module(ingredients.body, ingredients.type_ignores)
220
226
  astModule = Make.Module(ingredients.body, ingredients.type_ignores)
221
227
  ast.fix_missing_locations(astModule)
222
228
  pythonSource: str = ast.unparse(astModule)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astToolkit
3
- Version: 0.2.0
3
+ Version: 0.2.1
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
@@ -27,8 +27,11 @@ tests/test_basic.py
27
27
  toolFactory/Z0Z_hardcoded.py
28
28
  toolFactory/Z0Z_makeAstTools.py
29
29
  toolFactory/__init__.py
30
+ toolFactory/_snippets.py
30
31
  toolFactory/astFactory.py
31
- toolFactory/astFactory_annex.py
32
+ toolFactory/databaseASTCreation.py
33
+ toolFactory/datacenter.py
32
34
  toolFactory/docstrings.py
33
- toolFactory/py.typed
34
- toolFactory/startHere.py
35
+ toolFactory/factory3.py
36
+ toolFactory/factory_annex.py
37
+ toolFactory/py.typed
@@ -36,7 +36,7 @@ optional-dependencies = { testing = [
36
36
  readme = { file = "README.md", content-type = "text/markdown" }
37
37
  requires-python = ">=3.10"
38
38
  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" }
39
- version = "0.2.0"
39
+ version = "0.2.1"
40
40
 
41
41
  [tool.coverage]
42
42
  report = { exclude_lines = [
@@ -1,17 +1,26 @@
1
1
  from pathlib import Path
2
2
  from typing import TypeAlias as typing_TypeAlias
3
+ import ast
3
4
 
4
5
  ast_Identifier: typing_TypeAlias = str
5
- fileExtension: str = '.py'
6
+ str_nameDOTname: typing_TypeAlias = str
7
+
8
+ pythonVersionMinorMinimum: int = 10
9
+ sys_version_infoMinimum: tuple[int, int] = (3, 10)
10
+ sys_version_infoTarget: tuple[int, int] = (3, 13)
11
+
12
+ class FREAKOUT(Exception): pass
13
+
14
+ # filesystem and namespace ===============================================
6
15
  packageName: ast_Identifier = 'astToolkit'
16
+ moduleIdentifierPrefix: str = '_tool'
17
+ keywordArgumentsIdentifier: ast_Identifier = 'keywordArguments'
18
+
7
19
  pathRoot = Path('/apps') / packageName
8
20
  pathPackage = pathRoot / packageName
21
+ pathToolFactory = pathRoot / 'toolFactory'
9
22
  pathTypeshed = pathRoot / 'typeshed' / 'stdlib'
10
- str_nameDOTname: typing_TypeAlias = str
11
- sys_version_infoMinimum: tuple[int, int] = (3, 10)
12
- sys_version_infoTarget: tuple[int, int] = (3, 13)
13
23
 
14
- listASTSubclasses: list[str] = ['_Slice', 'AST', 'binaryop', 'boolop', 'cmpop', 'excepthandler', 'expr_context', 'expr', 'mod', 'operator', 'pattern', 'stmt', 'type_ignore', 'type_param', 'unaryop',]
24
+ pathFilenameDatabaseAST = pathToolFactory / 'databaseAST.csv'
15
25
 
16
- class FREAKOUT(Exception):
17
- pass
26
+ fileExtension: str = '.py'
@@ -1,6 +1,6 @@
1
1
  from collections.abc import Callable, Sequence
2
2
  import typeshed_client.finder
3
- from toolFactory import FREAKOUT, pathTypeshed, Z0Z_typesSpecial, makeTools
3
+ from toolFactory import FREAKOUT, pathTypeshed, makeTools
4
4
  from pathlib import Path
5
5
  from typing import Any, TypeAlias as typing_TypeAlias, TypeVar as typing_TypeVar
6
6
  import ast
@@ -0,0 +1,27 @@
1
+ from toolFactory.Z0Z_hardcoded import (
2
+ ast_Identifier as ast_Identifier,
3
+ fileExtension as fileExtension,
4
+ FREAKOUT as FREAKOUT,
5
+ keywordArgumentsIdentifier as keywordArgumentsIdentifier,
6
+ moduleIdentifierPrefix as moduleIdentifierPrefix,
7
+ packageName as packageName,
8
+ pathFilenameDatabaseAST as pathFilenameDatabaseAST,
9
+ pathPackage as pathPackage,
10
+ pathTypeshed as pathTypeshed,
11
+ pythonVersionMinorMinimum as pythonVersionMinorMinimum,
12
+ str_nameDOTname as str_nameDOTname,
13
+ sys_version_infoMinimum as sys_version_infoMinimum,
14
+ sys_version_infoTarget as sys_version_infoTarget,
15
+ )
16
+
17
+ from toolFactory._snippets import (
18
+ astName_overload as astName_overload,
19
+ astName_staticmethod as astName_staticmethod,
20
+ astName_typing_TypeAlias as astName_typing_TypeAlias,
21
+ )
22
+
23
+ from toolFactory.datacenter import (
24
+ getElementsBe as getElementsBe,
25
+ )
26
+
27
+ from toolFactory.astFactory import makeTools as makeTools
@@ -0,0 +1,6 @@
1
+ from typing import cast
2
+ import ast
3
+
4
+ astName_overload = ast.Name('overload')
5
+ astName_staticmethod = ast.Name('staticmethod')
6
+ astName_typing_TypeAlias: ast.expr = cast(ast.expr, ast.Name('typing_TypeAlias'))
@@ -1,7 +1,9 @@
1
1
  from pathlib import PurePosixPath
2
2
  from string import ascii_letters
3
- from toolFactory import ast_Identifier, fileExtension, list_astDOTnew, listASTSubclasses, pathPackage, str_nameDOTname, sys_version_infoTarget
4
- from toolFactory.astFactory_annex import (
3
+ from toolFactory import ast_Identifier, fileExtension, pathPackage, str_nameDOTname, sys_version_infoTarget
4
+ from toolFactory.Z0Z_hardcoded import keywordArgumentsIdentifier, moduleIdentifierPrefix
5
+ from toolFactory._snippets import astName_overload, astName_staticmethod, astName_typing_TypeAlias
6
+ from toolFactory.factory_annex import (
5
7
  astImportFromClassNewInPythonVersion,
6
8
  FunctionDefMake_Attribute,
7
9
  handmadeMethodsGrab,
@@ -14,16 +16,20 @@ from typing import cast, TypedDict
14
16
  from Z0Z_tools import writeStringToHere
15
17
  import ast
16
18
 
19
+ """
20
+ class Name(expr):
21
+ ...
22
+ ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
23
+
24
+ TODO protect against AttributeError (I guess) in DOT, Grab, and ClassIsAndAttribute
25
+ add docstrings to warn of problem, including in Make
26
+
27
+ """
28
+
17
29
  class AnnotationsAndDefs(TypedDict):
18
30
  astAnnotation: ast.expr
19
31
  listClassDefIdentifier: list[ast_Identifier | str_nameDOTname]
20
32
 
21
- keywordArgumentsIdentifier: ast_Identifier = 'keywordArguments'
22
- moduleIdentifierPrefix: str = '_tool'
23
- overloadName = ast.Name('overload')
24
- staticmethodName = ast.Name('staticmethod')
25
- typing_TypeAliasName: ast.expr = cast(ast.expr, ast.Name('typing_TypeAlias'))
26
-
27
33
  class MakeDictionaryOf_astClassAnnotations(ast.NodeVisitor):
28
34
  def __init__(self, astAST: ast.AST) -> None:
29
35
  super().__init__()
@@ -36,10 +42,7 @@ class MakeDictionaryOf_astClassAnnotations(ast.NodeVisitor):
36
42
  }
37
43
 
38
44
  def visit_ClassDef(self, node: ast.ClassDef) -> None:
39
- if 'astDOT' + node.name in list_astDOTnew:
40
- NameOrAttribute: ast.Attribute | ast.Name = ast.Name('astDOT' + node.name)
41
- else:
42
- NameOrAttribute = ast.Attribute(value=ast.Name('ast'), attr=node.name)
45
+ NameOrAttribute = ast.Attribute(value=ast.Name('ast'), attr=node.name)
43
46
  self.dictionarySubstitutions[node.name] = NameOrAttribute
44
47
 
45
48
  def getDictionary(self) -> dict[ast_Identifier, ast.Attribute | ast.Name]:
@@ -110,7 +113,7 @@ def makeTools(astStubFile: ast.AST) -> None:
110
113
 
111
114
  # Create each ClassDef and add directly to it instead of creating unnecessary intermediate structures, which requires more identifiers.
112
115
  # fewer identifiers == fewer bugs
113
- ClassDefBe = ast.ClassDef(name='Be', bases=[], keywords=[], body=[], decorator_list=[])
116
+ # ClassDefBe = ast.ClassDef(name='Be', bases=[], keywords=[], body=[], decorator_list=[])
114
117
  ClassDefClassIsAndAttribute = ast.ClassDef(name='ClassIsAndAttribute', bases=[], keywords=[], body=[], decorator_list=[])
115
118
  ClassDefDOT = ast.ClassDef(name='DOT', bases=[], keywords=[], body=[], decorator_list=[])
116
119
  ClassDefMake = ast.ClassDef(name='Make', bases=[], keywords=[], body=[], decorator_list=[])
@@ -129,8 +132,6 @@ def makeTools(astStubFile: ast.AST) -> None:
129
132
  continue
130
133
  if node.name.startswith('_'):
131
134
  continue
132
- if not (node.name == 'AST' or (node.bases and isinstance(node.bases[0], ast.Name) and node.bases[0].id in listASTSubclasses)):
133
- continue
134
135
 
135
136
  # Change the identifier solely for the benefit of clarity as you read this code.
136
137
  astDOTClassDef = node
@@ -143,11 +144,11 @@ def makeTools(astStubFile: ast.AST) -> None:
143
144
  keywordArguments_ast_arg: ast.arg | None = ast.arg(keywordArgumentsIdentifier, ast.Name('int'))
144
145
  keywordArguments_ast_keyword: ast.keyword | None = ast.keyword(None, ast.Name(keywordArgumentsIdentifier))
145
146
 
146
- ClassDefBe.body.append(ast.FunctionDef(name=ClassDefIdentifier
147
- , args=ast.arguments(posonlyargs=[], args=[ast.arg(arg='node', annotation=ast.Name('ast.AST'))], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[])
148
- , body=[ast.Return(value=ast.Call(func=ast.Name('isinstance'), args=[ast.Name('node'), ClassDef_astNameOrAttribute], keywords=[]))]
149
- , decorator_list=[staticmethodName]
150
- , returns=ast.Subscript(value=ast.Name('TypeGuard'), slice=ClassDef_astNameOrAttribute)))
147
+ # ClassDefBe.body.append(ast.FunctionDef(name=ClassDefIdentifier
148
+ # , args=ast.arguments(posonlyargs=[], args=[ast.arg(arg='node', annotation=ast.Name('ast.AST'))], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[])
149
+ # , body=[ast.Return(value=ast.Call(func=ast.Name('isinstance'), args=[ast.Name('node'), ClassDef_astNameOrAttribute], keywords=[]))]
150
+ # , decorator_list=[astName_staticmethod]
151
+ # , returns=ast.Subscript(value=ast.Name('TypeGuard'), slice=ClassDef_astNameOrAttribute)))
151
152
 
152
153
  # Start: cope with different arguments for Python versions. ==============================================================
153
154
  # NOTE: I would love suggestions to improve this section.
@@ -164,7 +165,7 @@ def makeTools(astStubFile: ast.AST) -> None:
164
165
  sys_version_info: tuple[int, int] = ast.literal_eval(subnode.test.comparators[0])
165
166
  if sys_version_info > sys_version_infoTarget:
166
167
  continue
167
- if any(sys_version_info < key for key in dictAttributes.keys()): # pyright: ignore[reportOperatorIssue]
168
+ if any(sys_version_info < key for key in dictAttributes.keys()):
168
169
  continue
169
170
  dictAttributes[sys_version_info] = []
170
171
  for astAST in subnode.body[0].value.elts:
@@ -204,7 +205,7 @@ def makeTools(astStubFile: ast.AST) -> None:
204
205
  ClassDefMake.body.append(ast.FunctionDef(name=ClassDefIdentifier
205
206
  , args=ast.arguments(posonlyargs=[], args=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=keywordArguments_ast_arg, defaults=[])
206
207
  , body=[ast.Return(value=ast.Call(ClassDef_astNameOrAttribute, args=[], keywords=[keywordArguments_ast_keyword] if keywordArguments_ast_keyword else []))]
207
- , decorator_list=[staticmethodName]
208
+ , decorator_list=[astName_staticmethod]
208
209
  , returns=ClassDef_astNameOrAttribute))
209
210
 
210
211
  for attributeIdentifier in list_astDOTClassDefAttributeIdentifier:
@@ -354,7 +355,7 @@ def makeTools(astStubFile: ast.AST) -> None:
354
355
  cast(ast.FunctionDef, ClassDefMake.body[-1]).args.args.append(ast.arg(arg=attributeIdentifier, annotation=attributeAnnotation_ast_expr))
355
356
  cast(ast.Call, cast(ast.Return, cast(ast.FunctionDef, ClassDefMake.body[-1]).body[0]).value).args.append(append2args)
356
357
 
357
- ClassDefBe.body.sort(key=lambda astFunctionDef: cast(ast.FunctionDef, astFunctionDef).name.lower())
358
+ # ClassDefBe.body.sort(key=lambda astFunctionDef: cast(ast.FunctionDef, astFunctionDef).name.lower())
358
359
  ClassDefMake.body.sort(key=lambda astFunctionDef: cast(ast.FunctionDef, astFunctionDef).name.lower())
359
360
 
360
361
  astTypesModule = ast.Module(
@@ -395,10 +396,10 @@ def makeTools(astStubFile: ast.AST) -> None:
395
396
  for ClassDefIdentifier in listClassDefIdentifier[1:]:
396
397
  astAnnAssignValue = ast.BinOp(left=astAnnAssignValue, op=ast.BitOr(), right=dictionaryOf_astDOTclass[ClassDefIdentifier])
397
398
  if len(attributeIdentifier2Str4TypeAlias2astAnnotationAndListClassDefIdentifier[attributeIdentifier]) == 1:
398
- astTypesModule.body.append(ast.AnnAssign(hasDOTName_Store, typing_TypeAliasName, astAnnAssignValue, 1))
399
+ astTypesModule.body.append(ast.AnnAssign(hasDOTName_Store, astName_typing_TypeAlias, astAnnAssignValue, 1))
399
400
  else:
400
401
  list_hasDOTNameTypeAliasAnnotations.append(ast.Name(hasDOTIdentifier + '_' + attributeAnnotationAsStr4TypeAliasIdentifier.replace('list', 'list_'), ast.Store()))
401
- astTypesModule.body.append(ast.AnnAssign(list_hasDOTNameTypeAliasAnnotations[-1], typing_TypeAliasName, astAnnAssignValue, 1))
402
+ astTypesModule.body.append(ast.AnnAssign(list_hasDOTNameTypeAliasAnnotations[-1], astName_typing_TypeAlias, astAnnAssignValue, 1))
402
403
  # overload definitions for `ClassIsAndAttribute` class
403
404
  potentiallySuperComplicatedAnnotationORbool = ast.Name('bool')
404
405
  buffaloBuffalo_workhorse_returnsAnnotation = ast.BinOp(ast.Subscript(ast.Name('TypeGuard'), list_hasDOTNameTypeAliasAnnotations[-1]), ast.BitOr(), ast.Name('bool'))
@@ -408,14 +409,14 @@ def makeTools(astStubFile: ast.AST) -> None:
408
409
  , ast.arg('attributeCondition', annotation=ast.Subscript(ast.Name('Callable'), ast.Tuple([ast.List([attributeAnnotationAsAST]), potentiallySuperComplicatedAnnotationORbool])))
409
410
  ], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[])
410
411
  , body=[ast.Expr(value=ast.Constant(value=Ellipsis))]
411
- , decorator_list=[staticmethodName, overloadName]
412
+ , decorator_list=[astName_staticmethod, astName_overload]
412
413
  , returns=ast.Subscript(ast.Name('Callable'), ast.Tuple([ast.List([ast.Attribute(ast.Name('ast'), attr='AST')]), buffaloBuffalo_workhorse_returnsAnnotation]))
413
414
  ))
414
415
  # overload definitions for `DOT` class
415
416
  ClassDefDOT.body.append(ast.FunctionDef(name=attributeIdentifier
416
417
  , args=ast.arguments(posonlyargs=[], args=[ast.arg(arg='node', annotation=ast.Name(list_hasDOTNameTypeAliasAnnotations[-1].id))], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[])
417
418
  , body=[ast.Expr(value=ast.Constant(value=Ellipsis))]
418
- , decorator_list=[staticmethodName, overloadName]
419
+ , decorator_list=[astName_staticmethod, astName_overload]
419
420
  , returns=attributeAnnotationAsAST
420
421
  ))
421
422
 
@@ -449,14 +450,14 @@ def makeTools(astStubFile: ast.AST) -> None:
449
450
  , body=[ast.Return(workhorseReturnValue)]
450
451
  , returns=buffaloBuffalo_workhorse_returnsAnnotation)
451
452
  , ast.Return(ast.Name('workhorse'))]
452
- , decorator_list=[staticmethodName]
453
+ , decorator_list=[astName_staticmethod]
453
454
  , returns=ast.Subscript(ast.Name('Callable'), ast.Tuple([ast.List([ast.Attribute(ast.Name('ast'), attr='AST')]), buffaloBuffalo_workhorse_returnsAnnotation]))
454
455
  ))
455
456
 
456
457
  ClassDefDOT.body.append(ast.FunctionDef(name=attributeIdentifier
457
458
  , args=ast.arguments(posonlyargs=[], args=[ast.arg(arg='node', annotation=hasDOTName_Load)], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[])
458
459
  , body=[ast.Return(value=ast.Attribute(value=ast.Name('node'), attr=attributeIdentifier))]
459
- , decorator_list=[staticmethodName]
460
+ , decorator_list=[astName_staticmethod]
460
461
  , returns=attributeAnnotationUnifiedAsAST
461
462
  ))
462
463
 
@@ -465,7 +466,7 @@ def makeTools(astStubFile: ast.AST) -> None:
465
466
  astAnnAssignValue = list_hasDOTNameTypeAliasAnnotations[0]
466
467
  for index in range(1, len(list_hasDOTNameTypeAliasAnnotations)):
467
468
  astAnnAssignValue = ast.BinOp(left=astAnnAssignValue, op=ast.BitOr(), right=list_hasDOTNameTypeAliasAnnotations[index])
468
- astTypesModule.body.append(ast.AnnAssign(hasDOTName_Store, typing_TypeAliasName, astAnnAssignValue, 1))
469
+ astTypesModule.body.append(ast.AnnAssign(hasDOTName_Store, astName_typing_TypeAlias, astAnnAssignValue, 1))
469
470
  astAssignValue = ast.Call(ast.Name('action'), args=[ast.Attribute(ast.Name('node'), attr=attributeIdentifier)])
470
471
  if (isinstance(attributeAnnotationUnifiedAsAST, ast.Subscript) and isinstance(attributeAnnotationUnifiedAsAST.value, ast.Name) and attributeAnnotationUnifiedAsAST.value.id == 'Sequence'
471
472
  or isinstance(attributeAnnotationUnifiedAsAST, ast.BinOp) and isinstance(attributeAnnotationUnifiedAsAST.right, ast.Subscript) and isinstance(attributeAnnotationUnifiedAsAST.right.value, ast.Name) and attributeAnnotationUnifiedAsAST.right.value.id == 'Sequence'):
@@ -486,32 +487,32 @@ def makeTools(astStubFile: ast.AST) -> None:
486
487
  , ast.Return(ast.Name('node'))],
487
488
  returns=hasDOTName_Load),
488
489
  ast.Return(ast.Name('workhorse'))]
489
- , decorator_list=[staticmethodName], type_comment=None
490
+ , decorator_list=[astName_staticmethod], type_comment=None
490
491
  , returns=ast.Subscript(ast.Name('Callable'), ast.Tuple([ast.List([hasDOTName_Load]), hasDOTName_Load]))))
491
492
 
492
493
  del attributeAnnotationUnifiedAsAST
493
494
 
494
495
  writeModule(astTypesModule, '_astTypes')
495
496
 
496
- ClassDefBe.body.insert(0, ast.Expr(value=ast.Constant(value=ClassDefDocstringBe)))
497
+ # ClassDefBe.body.insert(0, ast.Expr(value=ast.Constant(value=ClassDefDocstringBe)))
497
498
  ClassDefDOT.body.insert(0, ast.Expr(value=ast.Constant(value=ClassDefDocstringDOT)))
498
499
  ClassDefGrab.body.insert(0, ast.Expr(value=ast.Constant(value=ClassDefDocstringGrab)))
499
500
  ClassDefMake.body.insert(0, ast.Expr(value=ast.Constant(value=ClassDefDocstringMake)))
500
501
 
501
502
  ClassDefGrab.body.extend(handmadeMethodsGrab)
502
503
 
503
- ClassDef = ClassDefBe
504
- writeModule(ast.Module(
505
- body=[ast.Expr(ast.Constant(docstringWarning))
506
- , astImportFromClassNewInPythonVersion
507
- , ast.ImportFrom('typing', [ast.alias('TypeGuard')], 0)
508
- , ast.Import([ast.alias('ast')])
509
- , ClassDef
510
- ],
511
- type_ignores=[]
512
- )
513
- , moduleIdentifierPrefix + ClassDef.name)
514
- del ClassDef
504
+ # ClassDef = ClassDefBe
505
+ # writeModule(ast.Module(
506
+ # body=[ast.Expr(ast.Constant(docstringWarning))
507
+ # , astImportFromClassNewInPythonVersion
508
+ # , ast.ImportFrom('typing', [ast.alias('TypeGuard')], 0)
509
+ # , ast.Import([ast.alias('ast')])
510
+ # , ClassDef
511
+ # ],
512
+ # type_ignores=[]
513
+ # )
514
+ # , moduleIdentifierPrefix + ClassDef.name)
515
+ # del ClassDef
515
516
 
516
517
  ClassDef = ClassDefClassIsAndAttribute
517
518
  writeModule(ast.Module(