Skip to content

Commit

Permalink
import ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
bernt-matthias committed Aug 28, 2023
1 parent 1f9b3cf commit 40311e9
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 29 deletions.
32 changes: 26 additions & 6 deletions planemo/autopygen/argument_parser_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
5 changes: 4 additions & 1 deletion planemo/autopygen/commands/command_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion planemo/autopygen/param_info.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 6 additions & 2 deletions planemo/autopygen/source_file_parsing/parsing_commons.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 10 additions & 2 deletions planemo/autopygen/xml/xml_utils.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
9 changes: 3 additions & 6 deletions tests/data/autopygen/autopygen_parser_extraction_test_data.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
15 changes: 12 additions & 3 deletions tests/test_add_argument_actions_autopygen.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
12 changes: 8 additions & 4 deletions tests/test_autopygen_parser_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 40311e9

Please sign in to comment.