diff --git a/planemo/autopygen/source_file_parsing/local_module_parsing.py b/planemo/autopygen/source_file_parsing/local_module_parsing.py index 53ddc0def..4269ec10d 100644 --- a/planemo/autopygen/source_file_parsing/local_module_parsing.py +++ b/planemo/autopygen/source_file_parsing/local_module_parsing.py @@ -36,7 +36,7 @@ def __init__(self, unknown: Set[str]): # currently able to resolve add_argument calls containing unknown names, # and list comprehension assignment - def _reach_top(self, node: ast.Name) -> Tuple[ast.Call, ast.AST]: + def _reach_top(self, node: ast.Name) -> Tuple[ast.Call, ast.Name]: current = node parent = current.parent # type: ignore @@ -99,14 +99,14 @@ def visit_Name(self, node: ast.Name) -> Any: ) -def handle_local_module_names(actions: List[ast.AST], unknown_names: Set[str]) -> ast.Module: +def handle_local_module_names(actions: List[ast.stmt], unknown_names: Set[str]) -> ast.Module: """ Function used to remove assignments and list comprehensions which can't be resolved Parameters ---------- - actions: List[ast.AST] + actions: List[ast.stmt] list of actions extracted so far unknown_names: set of unknown names that have to be extracted diff --git a/planemo/autopygen/source_file_parsing/parser_discovery_and_init.py b/planemo/autopygen/source_file_parsing/parser_discovery_and_init.py index 7f36e50cd..a25c6d9e5 100644 --- a/planemo/autopygen/source_file_parsing/parser_discovery_and_init.py +++ b/planemo/autopygen/source_file_parsing/parser_discovery_and_init.py @@ -48,7 +48,7 @@ class ImportDiscovery(Discovery): Class responsible for discovery and extraction of import statements """ - def __init__(self, actions: List[ast.AST]): + def __init__(self, actions: List[ast.stmt]): super(ImportDiscovery, self).__init__(actions) self.argparse_module_alias: Optional[str] = None self.argument_parser_alias: Optional[str] = None @@ -80,7 +80,7 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> Any: if name == ARGPARSE_MODULE_NAME and item.name == ARGUMENT_PARSER_CLASS_NAME: self.argument_parser_alias = alias - def report_findings(self) -> Tuple[List[ast.AST], Optional[str], Optional[str], Set[str]]: + def report_findings(self) -> Tuple[List[ast.stmt], Optional[str], Optional[str], Set[str]]: if self.argparse_module_alias is None and self.argument_parser_alias is None: raise ArgParseImportNotFound("No argparse import found") @@ -95,7 +95,7 @@ class SimpleParserDiscoveryAndReplacement(Discovery): """ def __init__( - self, actions: List[ast.AST], argparse_alias: str, argument_parser_alias: str, custom_parser_def: ast.ClassDef + self, actions: List[ast.stmt], argparse_alias: str, argument_parser_alias: str, custom_parser_def: ast.ClassDef ): self.argument_parser_alias = argument_parser_alias self.argparse_module_alias = argparse_alias @@ -179,7 +179,7 @@ class GroupAndSubparsersDiscovery(Discovery): groups and subparsers """ - def __init__(self, actions: List[ast.AST], known_names: Set[str], main_name: str): + def __init__(self, actions: List[ast.stmt], known_names: Set[str], main_name: str): self.main_name = main_name self.known_names = known_names super(GroupAndSubparsersDiscovery, self).__init__(actions) @@ -205,7 +205,7 @@ class ArgumentCreationDiscovery(Discovery): and on the argument groups extracted by GroupDiscovery """ - def __init__(self, actions: List[ast.AST], main_name: str): + def __init__(self, actions: List[ast.stmt], main_name: str): self.main_name = main_name super(ArgumentCreationDiscovery, self).__init__(actions) @@ -219,11 +219,11 @@ def visit_Call(self, node: ast.Call) -> Any: self.generic_visit(node) - def report_findings(self) -> Tuple[List[ast.AST]]: + def report_findings(self) -> Tuple[List[ast.stmt]]: return (self.actions,) -def get_parser_init_and_actions(source: ast.Module) -> Tuple[List[ast.AST], str, Set[str]]: +def get_parser_init_and_actions(source: ast.Module) -> Tuple[List[ast.stmt], str, Set[str]]: """ Function used to extract necessary imports, parser and argument creation function calls @@ -239,7 +239,7 @@ def get_parser_init_and_actions(source: ast.Module) -> Tuple[List[ast.AST], str, section names """ - actions: List[ast.AST] = [] + actions: List[ast.stmt] = [] custom_parser_class_def = obtain_class_def() if custom_parser_class_def is None: diff --git a/planemo/autopygen/source_file_parsing/parsing_commons.py b/planemo/autopygen/source_file_parsing/parsing_commons.py index fe3b1e82a..39fcfdd6d 100644 --- a/planemo/autopygen/source_file_parsing/parsing_commons.py +++ b/planemo/autopygen/source_file_parsing/parsing_commons.py @@ -11,7 +11,7 @@ ) -class CustomAST(ast.AST): +class CustomAST(ast.stmt): def __init__(self, *args: Any, **kwargs: Any): super().__init__(*args, **kwargs) self.parent = None @@ -22,13 +22,13 @@ class CustomVisitor(ast.NodeVisitor, abc.ABC): def report_findings(self) -> Tuple: pass - def visit_and_report(self, source: ast.AST): + def visit_and_report(self, source: ast.Module): self.visit(source) return self.report_findings() class Discovery(CustomVisitor, abc.ABC): - def __init__(self, actions: List[ast.AST]): + def __init__(self, actions: List[ast.stmt]): self.actions = actions diff --git a/planemo/autopygen/source_file_parsing/unknown_names_discovery.py b/planemo/autopygen/source_file_parsing/unknown_names_discovery.py index dcfafefd9..d050934b4 100644 --- a/planemo/autopygen/source_file_parsing/unknown_names_discovery.py +++ b/planemo/autopygen/source_file_parsing/unknown_names_discovery.py @@ -77,7 +77,7 @@ def report_findings(self) -> Tuple: return self.variable_definitions, self.class_definitions, self.new_known_names -def _insert_into_actions(actions: List[ast.AST], assignments: List[ast.Assign], class_defs: List[ast.ClassDef]): +def _insert_into_actions(actions: List[ast.stmt], assignments: List[ast.Assign], class_defs: List[ast.ClassDef]): def find_end_of_imports(): index = 0 for item in actions: @@ -111,8 +111,8 @@ def find_end_of_assignments(start: int): def initialize_variables_in_module( - original_module: ast.Module, parser_name: str, actions: List[ast.AST], imported_names: Set[str] -) -> Tuple[List[ast.AST], Set[str]]: + original_module: ast.Module, parser_name: str, actions: List[ast.stmt], imported_names: Set[str] +) -> Tuple[List[ast.stmt], Set[str]]: """ Function used to initialize variables that have constant values @@ -123,7 +123,7 @@ def initialize_variables_in_module( AST of the original source file parser_name : str default name of the parser - actions : List[ast.AST] + actions : List[ast.stmt] list of actions extracted so far imported_names : Set[str] list of names imported from modules