Skip to content

Commit 972b0a6

Browse files
authored
Merge pull request #407 from manu-chroma/master
sorting python imports using isort
2 parents cf54c35 + 09a5afe commit 972b0a6

28 files changed

+107
-85
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ MODULE=cwltool
2626
# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
2727
# `[[` conditional expressions.
2828
PYSOURCES=$(wildcard ${MODULE}/**.py tests/*.py) setup.py
29-
DEVPKGS=pep8 diff_cover autopep8 pylint coverage pep257 flake8 pytest
29+
DEVPKGS=pep8 diff_cover autopep8 pylint coverage pep257 flake8 pytest isort
3030
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pep257 sloccount python-flake8
3131
VERSION=1.0.$(shell date +%Y%m%d%H%M%S --date=`git log --first-parent \
3232
--max-count=1 --format=format:%cI`)
@@ -65,6 +65,11 @@ clean: FORCE
6565
rm -Rf .coverage
6666
rm -f diff-cover.html
6767

68+
# Linting and code style related targets
69+
## sorting imports using isort: https://github.com/timothycrosley/isort
70+
sort_imports:
71+
isort ${MODULE}/*.py tests/*.py setup.py
72+
6873
## pep8 : check Python code style
6974
pep8: $(PYSOURCES)
7075
pep8 --exclude=_version.py --show-source --show-pep8 $^ || true

cwltool/builder.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import copy
2+
from typing import Any, Callable, Text, Type, Union
3+
4+
from six import iteritems, string_types
25

36
import avro
47
import schema_salad.validate as validate
58
from schema_salad.sourceline import SourceLine
6-
from typing import Any, Callable, Text, Type, Union
7-
from six import string_types, iteritems
89

910
from . import expression
1011
from .errors import WorkflowException
11-
from .pathmapper import PathMapper, normalizeFilesDirs, get_listing, visit_class
12+
from .mutation import MutationManager
13+
from .pathmapper import (PathMapper, get_listing, normalizeFilesDirs,
14+
visit_class)
1215
from .stdfsaccess import StdFsAccess
1316
from .utils import aslist
14-
from .mutation import MutationManager
1517

1618
CONTENT_LIMIT = 64 * 1024
1719

cwltool/cwlrdf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from typing import IO, Any, Dict, Text
2+
13
from rdflib import Graph
4+
25
from schema_salad.jsonld_context import makerdf
36
from schema_salad.ref_resolver import ContextType
4-
from typing import Any, Dict, IO, Text
57
from six.moves import urllib
68

79
from .process import Process

cwltool/docker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import subprocess
55
import sys
66
import tempfile
7+
from typing import Text
78

89
import requests
9-
from typing import Text
1010

1111
from .errors import WorkflowException
1212

cwltool/docker_uid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import print_function
2-
import subprocess
32

3+
import subprocess
44
from typing import Text
55

66

cwltool/draft2tool.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,33 @@
66
import re
77
import shutil
88
import tempfile
9-
from six.moves import urllib
10-
from six import string_types, u
119
from functools import partial
10+
from typing import Any, Callable, Dict, Generator, Optional, Text, Union, cast
11+
12+
from six import string_types, u
1213

1314
import schema_salad.validate as validate
1415
import shellescape
1516
from schema_salad.ref_resolver import file_uri, uri_file_path
1617
from schema_salad.sourceline import SourceLine, indent
17-
from typing import Any, Callable, cast, Generator, Optional, Text, Union, Dict
18+
from six.moves import urllib
1819

19-
from .builder import CONTENT_LIMIT, substitute, Builder
20-
from .pathmapper import adjustFileObjs, adjustDirObjs, visit_class
20+
from .builder import CONTENT_LIMIT, Builder, substitute
2121
from .errors import WorkflowException
22-
from .job import JobBase, CommandLineJob, DockerCommandLineJob
23-
from .pathmapper import PathMapper, get_listing, trim_listing
24-
from .process import (Process, shortname, uniquename, normalizeFilesDirs,
25-
compute_checksums, _logger_validation_warnings,
26-
UnsupportedRequirement)
22+
from .flatten import flatten
23+
from .job import CommandLineJob, DockerCommandLineJob, JobBase
24+
from .pathmapper import (PathMapper, adjustDirObjs, adjustFileObjs,
25+
get_listing, trim_listing, visit_class)
26+
from .process import (Process, UnsupportedRequirement,
27+
_logger_validation_warnings, compute_checksums,
28+
normalizeFilesDirs, shortname, uniquename)
2729
from .stdfsaccess import StdFsAccess
2830
from .utils import aslist
2931

3032
ACCEPTLIST_EN_STRICT_RE = re.compile(r"^[a-zA-Z0-9._+-]+$")
3133
ACCEPTLIST_EN_RELAXED_RE = re.compile(r".*") # Accept anything
3234
ACCEPTLIST_RE = ACCEPTLIST_EN_STRICT_RE
3335

34-
from .flatten import flatten
3536

3637
_logger = logging.getLogger("cwltool")
3738

cwltool/expression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import json
33
import logging
44
import re
5+
from typing import Any, AnyStr, Dict, List, Text, Union
56

6-
from typing import Any, AnyStr, Union, Text, Dict, List
77
from six import u
88

99
from . import sandboxjs

cwltool/factory.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import os
2-
3-
from typing import Any, Text, Union, Tuple
42
from typing import Callable as tCallable
3+
from typing import Any, Text, Tuple, Union
54

6-
from . import load_tool
7-
from . import main
8-
from . import workflow
5+
from . import load_tool, main, workflow
96
from .process import Process
107

118

cwltool/flatten.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Any, Callable, List, cast
22

3-
43
# http://rightfootin.blogspot.com/2006/09/more-on-python-flatten.html
54

65

cwltool/job.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
import subprocess
99
import sys
1010
import tempfile
11+
from typing import (IO, Any, Callable, Iterable, List, MutableMapping, Text,
12+
Tuple, Union, cast)
1113

1214
import shellescape
13-
from typing import (Any, Callable, Union, Iterable, MutableMapping,
14-
IO, Text, Tuple, cast, List)
1515

1616
from . import docker
1717
from .builder import Builder
1818
from .docker_uid import docker_vm_uid
1919
from .errors import WorkflowException
2020
from .pathmapper import PathMapper
21-
from .process import (get_feature, empty_subtree, stageFiles,
22-
UnsupportedRequirement)
21+
from .process import (UnsupportedRequirement, empty_subtree, get_feature,
22+
stageFiles)
2323

2424
_logger = logging.getLogger("cwltool")
2525

cwltool/load_tool.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
import os
66
import re
77
import uuid
8+
from typing import Any, Callable, Dict, Text, Tuple, Union, cast
89

910
import requests.sessions
11+
from six import itervalues, string_types
12+
1013
import schema_salad.schema as schema
1114
from avro.schema import Names
12-
from ruamel.yaml.comments import CommentedSeq, CommentedMap
13-
from schema_salad.ref_resolver import Loader, Fetcher, file_uri
15+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
16+
from schema_salad.ref_resolver import Fetcher, Loader, file_uri
1417
from schema_salad.sourceline import cmap
1518
from schema_salad.validate import ValidationException
16-
from typing import Any, Callable, cast, Dict, Text, Tuple, Union
1719
from six.moves import urllib
18-
from six import itervalues, string_types
1920

20-
from . import process
21-
from . import update
21+
from . import process, update
2222
from .errors import WorkflowException
2323
from .process import Process, shortname
2424

cwltool/main.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,31 @@
88
import os
99
import sys
1010
import tempfile
11+
from typing import (IO, Any, AnyStr, Callable, Dict, Sequence, Text, Tuple,
12+
Union, cast)
1113

1214
import pkg_resources # part of setuptools
1315
import requests
16+
1417
import ruamel.yaml as yaml
1518
import schema_salad.validate as validate
16-
from schema_salad.ref_resolver import Loader, Fetcher, file_uri, uri_file_path
19+
from schema_salad.ref_resolver import Fetcher, Loader, file_uri, uri_file_path
1720
from schema_salad.sourceline import strip_dup_lineno
18-
from typing import (Union, Any, AnyStr, cast, Callable, Dict, Sequence, Text,
19-
Tuple, IO)
20-
21-
from . import draft2tool
22-
from . import workflow
23-
from .pathmapper import adjustDirObjs, get_listing, adjustFileObjs, trim_listing, visit_class
24-
from .cwlrdf import printrdf, printdot
25-
from .errors import WorkflowException, UnsupportedRequirement
26-
from .load_tool import fetch_document, validate_document, make_tool
21+
22+
from . import draft2tool, workflow
23+
from .cwlrdf import printdot, printrdf
24+
from .errors import UnsupportedRequirement, WorkflowException
25+
from .load_tool import fetch_document, make_tool, validate_document
26+
from .mutation import MutationManager
2727
from .pack import pack
28-
from .process import (shortname, Process, relocateOutputs, cleanIntermediate,
29-
scandeps, normalizeFilesDirs, use_custom_schema, use_standard_schema)
30-
from .resolver import tool_resolver, ga4gh_tool_registries
28+
from .pathmapper import (adjustDirObjs, adjustFileObjs, get_listing,
29+
trim_listing, visit_class)
30+
from .process import (Process, cleanIntermediate, normalizeFilesDirs,
31+
relocateOutputs, scandeps, shortname, use_custom_schema,
32+
use_standard_schema)
33+
from .resolver import ga4gh_tool_registries, tool_resolver
3134
from .stdfsaccess import StdFsAccess
32-
from .mutation import MutationManager
33-
from .update import UPDATES, ALLUPDATES
35+
from .update import ALLUPDATES, UPDATES
3436

3537
_logger = logging.getLogger("cwltool")
3638

cwltool/mutation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from collections import namedtuple
2-
3-
from typing import Any, Callable, cast, Generator, Iterable, List, Text, Union
2+
from typing import Any, Callable, Generator, Iterable, List, Text, Union, cast
43

54
from .errors import WorkflowException
65

cwltool/pack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import copy
2+
from typing import Any, Callable, Dict, Text, Union, cast
23

34
from schema_salad.ref_resolver import Loader
4-
from typing import Union, Any, cast, Callable, Dict, Text
55
from six.moves import urllib
66

77
from .process import shortname, uniquename

cwltool/pathmapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import stat
55
import uuid
66
from functools import partial
7+
from typing import Any, Callable, Iterable, Set, Text, Tuple, Union
78

89
import schema_salad.validate as validate
910
from schema_salad.ref_resolver import uri_file_path
1011
from schema_salad.sourceline import SourceLine
11-
from typing import Any, Callable, Set, Text, Tuple, Union, Iterable
1212
from six.moves import urllib
1313

14-
from .stdfsaccess import abspath, StdFsAccess
14+
from .stdfsaccess import StdFsAccess, abspath
1515

1616
_logger = logging.getLogger("cwltool")
1717

cwltool/process.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import abc
22
import copy
33
import errno
4+
import functools
45
import hashlib
56
import json
67
import logging
@@ -11,28 +12,28 @@
1112
import urlparse
1213
import uuid
1314
from collections import Iterable
14-
import functools
15+
from typing import (Any, AnyStr, Callable, Dict, Generator, List, Text, Tuple,
16+
Union, cast)
17+
18+
from pkg_resources import resource_stream
19+
from rdflib import Graph, URIRef
20+
from rdflib.namespace import OWL, RDFS
1521

1622
import avro.schema
1723
import schema_salad.schema
1824
import schema_salad.validate as validate
19-
from pkg_resources import resource_stream
20-
from rdflib import Graph
21-
from rdflib import URIRef
22-
from rdflib.namespace import RDFS, OWL
23-
from ruamel.yaml.comments import CommentedSeq, CommentedMap
25+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
2426
from schema_salad.ref_resolver import Loader, file_uri
2527
from schema_salad.sourceline import SourceLine
26-
from typing import (Any, AnyStr, Callable, cast, Dict, List, Generator, Text,
27-
Tuple, Union)
2828

2929
from .builder import Builder
30-
from .pathmapper import adjustDirObjs, get_listing
31-
from .errors import WorkflowException, UnsupportedRequirement
32-
from .pathmapper import PathMapper, normalizeFilesDirs, visit_class
30+
from .errors import UnsupportedRequirement, WorkflowException
31+
from .pathmapper import (PathMapper, adjustDirObjs, get_listing,
32+
normalizeFilesDirs, visit_class)
3333
from .stdfsaccess import StdFsAccess
3434
from .utils import aslist, get_feature
3535

36+
3637
class LogAsDebugFilter(logging.Filter):
3738
def __init__(self, name, parent): # type: (str, logging.Logger) -> None
3839
super(LogAsDebugFilter, self).__init__(name)

cwltool/sandboxjs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import subprocess
77
import threading
88
from io import BytesIO
9+
from typing import Any, Dict, List, Mapping, Text, Tuple, Union
910

1011
from pkg_resources import resource_stream
11-
from typing import Any, Dict, List, Mapping, Text, Union, Tuple
1212

1313

1414
class JavascriptException(Exception):

cwltool/stdfsaccess.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import glob
22
import os
33
import urllib
4+
from typing import BinaryIO, Text
45

56
from schema_salad.ref_resolver import file_uri, uri_file_path
6-
from typing import BinaryIO, Text
7+
78

89
def abspath(src, basedir): # type: (Text, Text) -> Text
910
if src.startswith(u"file://"):

cwltool/update.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
import re
44
import traceback
55
import urlparse
6+
from typing import (Any, Callable, Dict, Text, # pylint: disable=unused-import
7+
Tuple, Union)
68

79
import schema_salad.validate
8-
from ruamel.yaml.comments import CommentedSeq, CommentedMap
10+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
911
from schema_salad.ref_resolver import Loader
10-
from typing import Any, Callable, Dict, Text, Tuple, Union # pylint: disable=unused-import
1112

1213
from .utils import aslist
1314

cwltool/workflow.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import random
66
import tempfile
77
from collections import namedtuple
8-
from ruamel.yaml.comments import CommentedSeq, CommentedMap
8+
from typing import Any, Callable, Generator, Iterable, List, Text, Union, cast
99

1010
import schema_salad.validate as validate
11+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
1112
from schema_salad.sourceline import SourceLine, cmap
12-
from typing import Any, Callable, cast, Generator, Iterable, List, Text, Union
1313

14-
from . import draft2tool
15-
from . import expression
14+
from . import draft2tool, expression
1615
from .errors import WorkflowException
1716
from .load_tool import load_tool
1817
from .process import Process, shortname, uniquename

tests/test_check.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
import cwltool.pathmapper
66
import cwltool.process
77
import cwltool.workflow
8-
from .util import get_data
98
from cwltool.main import main
109

10+
from .util import get_data
11+
12+
1113
class TestCheck(unittest.TestCase):
1214
def test_output_checking(self):
1315
self.assertEquals(main([get_data('tests/wf/badout1.cwl')]), 1)

0 commit comments

Comments
 (0)