22from string import ascii_letters
33from toolFactory import ast_Identifier , fileExtension , listASTSubclassesHARDCODED , pathPackage , str_nameDOTname , sys_version_infoTarget
44from toolFactory .Z0Z_hardcoded import keywordArgumentsIdentifier , listASTClassesPostPythonVersionMinimum , moduleIdentifierPrefix
5- from toolFactory ._snippets import overloadName , staticmethodName , typing_TypeAliasName
5+ from toolFactory ._snippets import astName_overload , astName_staticmethod , astName_typing_TypeAlias
66from toolFactory .astFactory_annex import (
77 astImportFromClassNewInPythonVersion ,
88 FunctionDefMake_Attribute ,
@@ -152,7 +152,7 @@ def writeModule(astModule: ast.Module, moduleIdentifier: ast_Identifier) -> None
152152 ClassDefBe .body .append (ast .FunctionDef (name = ClassDefIdentifier
153153 , args = ast .arguments (posonlyargs = [], args = [ast .arg (arg = 'node' , annotation = ast .Name ('ast.AST' ))], vararg = None , kwonlyargs = [], kw_defaults = [], kwarg = None , defaults = [])
154154 , body = [ast .Return (value = ast .Call (func = ast .Name ('isinstance' ), args = [ast .Name ('node' ), ClassDef_astNameOrAttribute ], keywords = []))]
155- , decorator_list = [staticmethodName ]
155+ , decorator_list = [astName_staticmethod ]
156156 , returns = ast .Subscript (value = ast .Name ('TypeGuard' ), slice = ClassDef_astNameOrAttribute )))
157157
158158 # Start: cope with different arguments for Python versions. ==============================================================
@@ -210,7 +210,7 @@ def writeModule(astModule: ast.Module, moduleIdentifier: ast_Identifier) -> None
210210 ClassDefMake .body .append (ast .FunctionDef (name = ClassDefIdentifier
211211 , args = ast .arguments (posonlyargs = [], args = [], vararg = None , kwonlyargs = [], kw_defaults = [], kwarg = keywordArguments_ast_arg , defaults = [])
212212 , body = [ast .Return (value = ast .Call (ClassDef_astNameOrAttribute , args = [], keywords = [keywordArguments_ast_keyword ] if keywordArguments_ast_keyword else []))]
213- , decorator_list = [staticmethodName ]
213+ , decorator_list = [astName_staticmethod ]
214214 , returns = ClassDef_astNameOrAttribute ))
215215
216216 for attributeIdentifier in list_astDOTClassDefAttributeIdentifier :
@@ -401,10 +401,10 @@ def list2Sequence():
401401 for ClassDefIdentifier in listClassDefIdentifier [1 :]:
402402 astAnnAssignValue = ast .BinOp (left = astAnnAssignValue , op = ast .BitOr (), right = dictionaryOf_astDOTclass [ClassDefIdentifier ])
403403 if len (attributeIdentifier2Str4TypeAlias2astAnnotationAndListClassDefIdentifier [attributeIdentifier ]) == 1 :
404- astTypesModule .body .append (ast .AnnAssign (hasDOTName_Store , typing_TypeAliasName , astAnnAssignValue , 1 ))
404+ astTypesModule .body .append (ast .AnnAssign (hasDOTName_Store , astName_typing_TypeAlias , astAnnAssignValue , 1 ))
405405 else :
406406 list_hasDOTNameTypeAliasAnnotations .append (ast .Name (hasDOTIdentifier + '_' + attributeAnnotationAsStr4TypeAliasIdentifier .replace ('list' , 'list_' ), ast .Store ()))
407- astTypesModule .body .append (ast .AnnAssign (list_hasDOTNameTypeAliasAnnotations [- 1 ], typing_TypeAliasName , astAnnAssignValue , 1 ))
407+ astTypesModule .body .append (ast .AnnAssign (list_hasDOTNameTypeAliasAnnotations [- 1 ], astName_typing_TypeAlias , astAnnAssignValue , 1 ))
408408 # overload definitions for `ClassIsAndAttribute` class
409409 potentiallySuperComplicatedAnnotationORbool = ast .Name ('bool' )
410410 buffaloBuffalo_workhorse_returnsAnnotation = ast .BinOp (ast .Subscript (ast .Name ('TypeGuard' ), list_hasDOTNameTypeAliasAnnotations [- 1 ]), ast .BitOr (), ast .Name ('bool' ))
@@ -414,14 +414,14 @@ def list2Sequence():
414414 , ast .arg ('attributeCondition' , annotation = ast .Subscript (ast .Name ('Callable' ), ast .Tuple ([ast .List ([attributeAnnotationAsAST ]), potentiallySuperComplicatedAnnotationORbool ])))
415415 ], vararg = None , kwonlyargs = [], kw_defaults = [], kwarg = None , defaults = [])
416416 , body = [ast .Expr (value = ast .Constant (value = Ellipsis ))]
417- , decorator_list = [staticmethodName , overloadName ]
417+ , decorator_list = [astName_staticmethod , astName_overload ]
418418 , returns = ast .Subscript (ast .Name ('Callable' ), ast .Tuple ([ast .List ([ast .Attribute (ast .Name ('ast' ), attr = 'AST' )]), buffaloBuffalo_workhorse_returnsAnnotation ]))
419419 ))
420420 # overload definitions for `DOT` class
421421 ClassDefDOT .body .append (ast .FunctionDef (name = attributeIdentifier
422422 , args = ast .arguments (posonlyargs = [], args = [ast .arg (arg = 'node' , annotation = ast .Name (list_hasDOTNameTypeAliasAnnotations [- 1 ].id ))], vararg = None , kwonlyargs = [], kw_defaults = [], kwarg = None , defaults = [])
423423 , body = [ast .Expr (value = ast .Constant (value = Ellipsis ))]
424- , decorator_list = [staticmethodName , overloadName ]
424+ , decorator_list = [astName_staticmethod , astName_overload ]
425425 , returns = attributeAnnotationAsAST
426426 ))
427427
@@ -455,14 +455,14 @@ def list2Sequence():
455455 , body = [ast .Return (workhorseReturnValue )]
456456 , returns = buffaloBuffalo_workhorse_returnsAnnotation )
457457 , ast .Return (ast .Name ('workhorse' ))]
458- , decorator_list = [staticmethodName ]
458+ , decorator_list = [astName_staticmethod ]
459459 , returns = ast .Subscript (ast .Name ('Callable' ), ast .Tuple ([ast .List ([ast .Attribute (ast .Name ('ast' ), attr = 'AST' )]), buffaloBuffalo_workhorse_returnsAnnotation ]))
460460 ))
461461
462462 ClassDefDOT .body .append (ast .FunctionDef (name = attributeIdentifier
463463 , args = ast .arguments (posonlyargs = [], args = [ast .arg (arg = 'node' , annotation = hasDOTName_Load )], vararg = None , kwonlyargs = [], kw_defaults = [], kwarg = None , defaults = [])
464464 , body = [ast .Return (value = ast .Attribute (value = ast .Name ('node' ), attr = attributeIdentifier ))]
465- , decorator_list = [staticmethodName ]
465+ , decorator_list = [astName_staticmethod ]
466466 , returns = attributeAnnotationUnifiedAsAST
467467 ))
468468
@@ -471,7 +471,7 @@ def list2Sequence():
471471 astAnnAssignValue = list_hasDOTNameTypeAliasAnnotations [0 ]
472472 for index in range (1 , len (list_hasDOTNameTypeAliasAnnotations )):
473473 astAnnAssignValue = ast .BinOp (left = astAnnAssignValue , op = ast .BitOr (), right = list_hasDOTNameTypeAliasAnnotations [index ])
474- astTypesModule .body .append (ast .AnnAssign (hasDOTName_Store , typing_TypeAliasName , astAnnAssignValue , 1 ))
474+ astTypesModule .body .append (ast .AnnAssign (hasDOTName_Store , astName_typing_TypeAlias , astAnnAssignValue , 1 ))
475475 astAssignValue = ast .Call (ast .Name ('action' ), args = [ast .Attribute (ast .Name ('node' ), attr = attributeIdentifier )])
476476 if (isinstance (attributeAnnotationUnifiedAsAST , ast .Subscript ) and isinstance (attributeAnnotationUnifiedAsAST .value , ast .Name ) and attributeAnnotationUnifiedAsAST .value .id == 'Sequence'
477477 or isinstance (attributeAnnotationUnifiedAsAST , ast .BinOp ) and isinstance (attributeAnnotationUnifiedAsAST .right , ast .Subscript ) and isinstance (attributeAnnotationUnifiedAsAST .right .value , ast .Name ) and attributeAnnotationUnifiedAsAST .right .value .id == 'Sequence' ):
@@ -492,7 +492,7 @@ def list2Sequence():
492492 , ast .Return (ast .Name ('node' ))],
493493 returns = hasDOTName_Load ),
494494 ast .Return (ast .Name ('workhorse' ))]
495- , decorator_list = [staticmethodName ], type_comment = None
495+ , decorator_list = [astName_staticmethod ], type_comment = None
496496 , returns = ast .Subscript (ast .Name ('Callable' ), ast .Tuple ([ast .List ([hasDOTName_Load ]), hasDOTName_Load ]))))
497497
498498 del attributeAnnotationUnifiedAsAST
0 commit comments