diff --git a/planemo/autopygen/argument_parser_conversion.py b/planemo/autopygen/argument_parser_conversion.py index 514753774..7bb9bf7e3 100644 --- a/planemo/autopygen/argument_parser_conversion.py +++ b/planemo/autopygen/argument_parser_conversion.py @@ -8,12 +8,28 @@ import math import re import uuid - -from typing import Optional, Set, List, Dict, Tuple, Union, Any from argparse import ArgumentParser +from typing import ( + Any, + Dict, + List, + Optional, + Set, + Tuple, + Union, +) + +from lxml import etree -from planemo.autopygen.commands.command_utils import transform_param_info, create_element_with_body -from planemo.autopygen.param_info import ParamInfo, ParamTypeFlags, ParamDataType +from planemo.autopygen.commands.command_utils import ( + create_element_with_body, + transform_param_info, +) +from planemo.autopygen.param_info import ( + ParamDataType, + ParamInfo, + ParamTypeFlags, +) from planemo.autopygen.source_file_parsing.decoy_parser import DecoyParser from planemo.autopygen.source_file_parsing.local_module_parsing import handle_local_module_names from planemo.autopygen.source_file_parsing.parser_discovery_and_init import get_parser_init_and_actions @@ -23,8 +39,12 @@ ) from planemo.autopygen.source_file_parsing.parsing_exceptions import ArgumentParsingDiscoveryError from planemo.autopygen.source_file_parsing.unknown_names_discovery import initialize_variables_in_module -from planemo.autopygen.xml.xml_utils import repeat, options, param, formatted_xml_elem -from lxml import etree +from planemo.autopygen.xml.xml_utils import ( + formatted_xml_elem, + options, + param, + repeat, +) DEFAULT_XML_INDENT = 4 diff --git a/planemo/autopygen/commands/command_utils.py b/planemo/autopygen/commands/command_utils.py index 333a36b72..4d425af76 100644 --- a/planemo/autopygen/commands/command_utils.py +++ b/planemo/autopygen/commands/command_utils.py @@ -11,7 +11,10 @@ """ from typing import List -from planemo.autopygen.param_info import ParamInfo, ParamDataType +from planemo.autopygen.param_info import ( + ParamDataType, + ParamInfo, +) SPACE = " " DEFAULT_INDENT = 4 diff --git a/planemo/autopygen/param_info.py b/planemo/autopygen/param_info.py index 83e9f8345..734909be8 100644 --- a/planemo/autopygen/param_info.py +++ b/planemo/autopygen/param_info.py @@ -1,6 +1,12 @@ import dataclasses import enum -from typing import Any, List, Union, Optional, Dict +from typing import ( + Any, + Dict, + List, + Optional, + Union, +) from planemo.autopygen.source_file_parsing.constants import WARNING_STRING diff --git a/planemo/autopygen/source_file_parsing/local_module_parsing.py b/planemo/autopygen/source_file_parsing/local_module_parsing.py index 1b97cce31..27ff3c88b 100644 --- a/planemo/autopygen/source_file_parsing/local_module_parsing.py +++ b/planemo/autopygen/source_file_parsing/local_module_parsing.py @@ -3,8 +3,13 @@ used in argument parser """ import ast -from typing import List, Tuple, Any, Set import logging +from typing import ( + Any, + List, + Set, + Tuple, +) from planemo.autopygen.source_file_parsing.constants import WARNING_STRING from planemo.autopygen.source_file_parsing.parsing_commons import add_parents 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 7e36ef421..ef5313985 100644 --- a/planemo/autopygen/source_file_parsing/parser_discovery_and_init.py +++ b/planemo/autopygen/source_file_parsing/parser_discovery_and_init.py @@ -17,11 +17,11 @@ CustomParserUnavailableException, obtain_class_def, ) +from .parsing_commons import Discovery from .parsing_exceptions import ( ArgParseImportNotFound, ArgParserNotUsed, ) -from .parsing_commons import Discovery ARGPARSE_MODULE_NAME = "argparse" ARGUMENT_PARSER_CLASS_NAME = "ArgumentParser" diff --git a/planemo/autopygen/source_file_parsing/parsing_commons.py b/planemo/autopygen/source_file_parsing/parsing_commons.py index 381b601a0..7441c01a0 100644 --- a/planemo/autopygen/source_file_parsing/parsing_commons.py +++ b/planemo/autopygen/source_file_parsing/parsing_commons.py @@ -1,9 +1,13 @@ """ Module containing the parent class of Dicovery classes """ -import ast import abc -from typing import List, Tuple, Any +import ast +from typing import ( + Any, + List, + Tuple, +) class CustomAST(ast.AST): diff --git a/planemo/autopygen/source_file_parsing/unknown_names_discovery.py b/planemo/autopygen/source_file_parsing/unknown_names_discovery.py index a03652cec..ea2c53421 100644 --- a/planemo/autopygen/source_file_parsing/unknown_names_discovery.py +++ b/planemo/autopygen/source_file_parsing/unknown_names_discovery.py @@ -3,11 +3,16 @@ (assignments to variables) that have not been extracted yet """ import ast +import builtins +from typing import ( + Any, + List, + Set, + Tuple, +) from .constants import STD_LIB_MODULE_NAMES from .parsing_commons import CustomVisitor -from typing import Tuple, List, Any, Set -import builtins class UnknownNamesDiscovery(CustomVisitor): diff --git a/planemo/autopygen/xml/xml_utils.py b/planemo/autopygen/xml/xml_utils.py index 7868093cd..a2c5a3319 100644 --- a/planemo/autopygen/xml/xml_utils.py +++ b/planemo/autopygen/xml/xml_utils.py @@ -1,6 +1,14 @@ -from typing import Optional, List +from typing import ( + List, + Optional, +) + from lxml import etree -from planemo.autopygen.param_info import ParamInfo, ParamDataType + +from planemo.autopygen.param_info import ( + ParamDataType, + ParamInfo, +) def options(param_info: ParamInfo) -> etree._Element: diff --git a/tests/data/autopygen/autopygen_parser_extraction_test_data.py b/tests/data/autopygen/autopygen_parser_extraction_test_data.py index 25846c49c..16f18adb3 100644 --- a/tests/data/autopygen/autopygen_parser_extraction_test_data.py +++ b/tests/data/autopygen/autopygen_parser_extraction_test_data.py @@ -1,13 +1,10 @@ def import_discovery(): - import sys # noqa: F401, F841 - + import argparse as parser # noqa: F401, F841 import os # noqa: F401, F841 - - import shoud_not_be_imported as snbi # noqa: F401, F841 - + import sys # noqa: F401, F841 from os import path as asd # noqa: F401, F841 - import argparse as parser # noqa: F401, F841 + import shoud_not_be_imported as snbi # noqa: F401, F841 def parser_discovery_and_replacement(): diff --git a/tests/test_add_argument_actions_autopygen.py b/tests/test_add_argument_actions_autopygen.py index b4a965193..5fd8848b0 100644 --- a/tests/test_add_argument_actions_autopygen.py +++ b/tests/test_add_argument_actions_autopygen.py @@ -1,18 +1,27 @@ import ast import os -from typing import Tuple, Optional, Dict, Set import sys +from typing import ( + Dict, + Optional, + Set, + Tuple, +) import pytest from planemo.autopygen.argument_parser_conversion import ( command_from_decoy, - xml_from_decoy, obtain_parser, + xml_from_decoy, xml_to_string, ) from planemo.autopygen.param_info import ParamInfo -from tests.test_utils import load_function_body, TEST_AUTOPYGEN_DATA, assert_equal +from tests.test_utils import ( + assert_equal, + load_function_body, + TEST_AUTOPYGEN_DATA, +) def test_no_action_positional(): diff --git a/tests/test_autopygen_parser_discovery.py b/tests/test_autopygen_parser_discovery.py index 5cc8e0856..e6aa849fe 100644 --- a/tests/test_autopygen_parser_discovery.py +++ b/tests/test_autopygen_parser_discovery.py @@ -3,12 +3,16 @@ from planemo.autopygen.source_file_parsing.decoy_parser import obtain_class_def from planemo.autopygen.source_file_parsing.parser_discovery_and_init import ( - SimpleParserDiscoveryAndReplacement, - ImportDiscovery, - GroupAndSubparsersDiscovery, ArgumentCreationDiscovery, + GroupAndSubparsersDiscovery, + ImportDiscovery, + SimpleParserDiscoveryAndReplacement, +) +from .test_utils import ( + assert_equal, + load_function_body, + TEST_AUTOPYGEN_DATA, ) -from .test_utils import assert_equal, TEST_AUTOPYGEN_DATA, load_function_body def test_import_discovery():