Skip to content

sorting python imports using isort #407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MODULE=cwltool
# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
# `[[` conditional expressions.
PYSOURCES=$(wildcard ${MODULE}/**.py tests/*.py) setup.py
DEVPKGS=pep8 diff_cover autopep8 pylint coverage pep257 flake8 pytest
DEVPKGS=pep8 diff_cover autopep8 pylint coverage pep257 flake8 pytest isort
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pep257 sloccount python-flake8
VERSION=1.0.$(shell date +%Y%m%d%H%M%S --date=`git log --first-parent \
--max-count=1 --format=format:%cI`)
Expand Down Expand Up @@ -65,6 +65,11 @@ clean: FORCE
rm -Rf .coverage
rm -f diff-cover.html

# Linting and code style related targets
## sorting imports using isort: https://github.com/timothycrosley/isort
sort_imports:
isort ${MODULE}/*.py tests/*.py setup.py

## pep8 : check Python code style
pep8: $(PYSOURCES)
pep8 --exclude=_version.py --show-source --show-pep8 $^ || true
Expand Down
10 changes: 6 additions & 4 deletions cwltool/builder.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import copy
from typing import Any, Callable, Text, Type, Union

from six import iteritems, string_types

import avro
import schema_salad.validate as validate
from schema_salad.sourceline import SourceLine
from typing import Any, Callable, Text, Type, Union
from six import string_types, iteritems

from . import expression
from .errors import WorkflowException
from .pathmapper import PathMapper, normalizeFilesDirs, get_listing, visit_class
from .mutation import MutationManager
from .pathmapper import (PathMapper, get_listing, normalizeFilesDirs,
visit_class)
from .stdfsaccess import StdFsAccess
from .utils import aslist
from .mutation import MutationManager

CONTENT_LIMIT = 64 * 1024

Expand Down
4 changes: 3 additions & 1 deletion cwltool/cwlrdf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import IO, Any, Dict, Text

from rdflib import Graph

from schema_salad.jsonld_context import makerdf
from schema_salad.ref_resolver import ContextType
from typing import Any, Dict, IO, Text
from six.moves import urllib

from .process import Process
Expand Down
2 changes: 1 addition & 1 deletion cwltool/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import subprocess
import sys
import tempfile
from typing import Text

import requests
from typing import Text

from .errors import WorkflowException

Expand Down
2 changes: 1 addition & 1 deletion cwltool/docker_uid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function
import subprocess

import subprocess
from typing import Text


Expand Down
23 changes: 12 additions & 11 deletions cwltool/draft2tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,33 @@
import re
import shutil
import tempfile
from six.moves import urllib
from six import string_types, u
from functools import partial
from typing import Any, Callable, Dict, Generator, Optional, Text, Union, cast

from six import string_types, u

import schema_salad.validate as validate
import shellescape
from schema_salad.ref_resolver import file_uri, uri_file_path
from schema_salad.sourceline import SourceLine, indent
from typing import Any, Callable, cast, Generator, Optional, Text, Union, Dict
from six.moves import urllib

from .builder import CONTENT_LIMIT, substitute, Builder
from .pathmapper import adjustFileObjs, adjustDirObjs, visit_class
from .builder import CONTENT_LIMIT, Builder, substitute
from .errors import WorkflowException
from .job import JobBase, CommandLineJob, DockerCommandLineJob
from .pathmapper import PathMapper, get_listing, trim_listing
from .process import (Process, shortname, uniquename, normalizeFilesDirs,
compute_checksums, _logger_validation_warnings,
UnsupportedRequirement)
from .flatten import flatten
from .job import CommandLineJob, DockerCommandLineJob, JobBase
from .pathmapper import (PathMapper, adjustDirObjs, adjustFileObjs,
get_listing, trim_listing, visit_class)
from .process import (Process, UnsupportedRequirement,
_logger_validation_warnings, compute_checksums,
normalizeFilesDirs, shortname, uniquename)
from .stdfsaccess import StdFsAccess
from .utils import aslist

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

from .flatten import flatten

_logger = logging.getLogger("cwltool")

Expand Down
2 changes: 1 addition & 1 deletion cwltool/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import json
import logging
import re
from typing import Any, AnyStr, Dict, List, Text, Union

from typing import Any, AnyStr, Union, Text, Dict, List
from six import u

from . import sandboxjs
Expand Down
7 changes: 2 additions & 5 deletions cwltool/factory.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os

from typing import Any, Text, Union, Tuple
from typing import Callable as tCallable
from typing import Any, Text, Tuple, Union

from . import load_tool
from . import main
from . import workflow
from . import load_tool, main, workflow
from .process import Process


Expand Down
1 change: 0 additions & 1 deletion cwltool/flatten.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any, Callable, List, cast


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


Expand Down
8 changes: 4 additions & 4 deletions cwltool/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
import subprocess
import sys
import tempfile
from typing import (IO, Any, Callable, Iterable, List, MutableMapping, Text,
Tuple, Union, cast)

import shellescape
from typing import (Any, Callable, Union, Iterable, MutableMapping,
IO, Text, Tuple, cast, List)

from . import docker
from .builder import Builder
from .docker_uid import docker_vm_uid
from .errors import WorkflowException
from .pathmapper import PathMapper
from .process import (get_feature, empty_subtree, stageFiles,
UnsupportedRequirement)
from .process import (UnsupportedRequirement, empty_subtree, get_feature,
stageFiles)

_logger = logging.getLogger("cwltool")

Expand Down
12 changes: 6 additions & 6 deletions cwltool/load_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
import os
import re
import uuid
from typing import Any, Callable, Dict, Text, Tuple, Union, cast

import requests.sessions
from six import itervalues, string_types

import schema_salad.schema as schema
from avro.schema import Names
from ruamel.yaml.comments import CommentedSeq, CommentedMap
from schema_salad.ref_resolver import Loader, Fetcher, file_uri
from ruamel.yaml.comments import CommentedMap, CommentedSeq
from schema_salad.ref_resolver import Fetcher, Loader, file_uri
from schema_salad.sourceline import cmap
from schema_salad.validate import ValidationException
from typing import Any, Callable, cast, Dict, Text, Tuple, Union
from six.moves import urllib
from six import itervalues, string_types

from . import process
from . import update
from . import process, update
from .errors import WorkflowException
from .process import Process, shortname

Expand Down
32 changes: 17 additions & 15 deletions cwltool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,31 @@
import os
import sys
import tempfile
from typing import (IO, Any, AnyStr, Callable, Dict, Sequence, Text, Tuple,
Union, cast)

import pkg_resources # part of setuptools
import requests

import ruamel.yaml as yaml
import schema_salad.validate as validate
from schema_salad.ref_resolver import Loader, Fetcher, file_uri, uri_file_path
from schema_salad.ref_resolver import Fetcher, Loader, file_uri, uri_file_path
from schema_salad.sourceline import strip_dup_lineno
from typing import (Union, Any, AnyStr, cast, Callable, Dict, Sequence, Text,
Tuple, IO)

from . import draft2tool
from . import workflow
from .pathmapper import adjustDirObjs, get_listing, adjustFileObjs, trim_listing, visit_class
from .cwlrdf import printrdf, printdot
from .errors import WorkflowException, UnsupportedRequirement
from .load_tool import fetch_document, validate_document, make_tool

from . import draft2tool, workflow
from .cwlrdf import printdot, printrdf
from .errors import UnsupportedRequirement, WorkflowException
from .load_tool import fetch_document, make_tool, validate_document
from .mutation import MutationManager
from .pack import pack
from .process import (shortname, Process, relocateOutputs, cleanIntermediate,
scandeps, normalizeFilesDirs, use_custom_schema, use_standard_schema)
from .resolver import tool_resolver, ga4gh_tool_registries
from .pathmapper import (adjustDirObjs, adjustFileObjs, get_listing,
trim_listing, visit_class)
from .process import (Process, cleanIntermediate, normalizeFilesDirs,
relocateOutputs, scandeps, shortname, use_custom_schema,
use_standard_schema)
from .resolver import ga4gh_tool_registries, tool_resolver
from .stdfsaccess import StdFsAccess
from .mutation import MutationManager
from .update import UPDATES, ALLUPDATES
from .update import ALLUPDATES, UPDATES

_logger = logging.getLogger("cwltool")

Expand Down
3 changes: 1 addition & 2 deletions cwltool/mutation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections import namedtuple

from typing import Any, Callable, cast, Generator, Iterable, List, Text, Union
from typing import Any, Callable, Generator, Iterable, List, Text, Union, cast

from .errors import WorkflowException

Expand Down
2 changes: 1 addition & 1 deletion cwltool/pack.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy
from typing import Any, Callable, Dict, Text, Union, cast

from schema_salad.ref_resolver import Loader
from typing import Union, Any, cast, Callable, Dict, Text
from six.moves import urllib

from .process import shortname, uniquename
Expand Down
4 changes: 2 additions & 2 deletions cwltool/pathmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import stat
import uuid
from functools import partial
from typing import Any, Callable, Iterable, Set, Text, Tuple, Union

import schema_salad.validate as validate
from schema_salad.ref_resolver import uri_file_path
from schema_salad.sourceline import SourceLine
from typing import Any, Callable, Set, Text, Tuple, Union, Iterable
from six.moves import urllib

from .stdfsaccess import abspath, StdFsAccess
from .stdfsaccess import StdFsAccess, abspath

_logger = logging.getLogger("cwltool")

Expand Down
23 changes: 12 additions & 11 deletions cwltool/process.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import abc
import copy
import errno
import functools
import hashlib
import json
import logging
Expand All @@ -11,28 +12,28 @@
import urlparse
import uuid
from collections import Iterable
import functools
from typing import (Any, AnyStr, Callable, Dict, Generator, List, Text, Tuple,
Union, cast)

from pkg_resources import resource_stream
from rdflib import Graph, URIRef
from rdflib.namespace import OWL, RDFS

import avro.schema
import schema_salad.schema
import schema_salad.validate as validate
from pkg_resources import resource_stream
from rdflib import Graph
from rdflib import URIRef
from rdflib.namespace import RDFS, OWL
from ruamel.yaml.comments import CommentedSeq, CommentedMap
from ruamel.yaml.comments import CommentedMap, CommentedSeq
from schema_salad.ref_resolver import Loader, file_uri
from schema_salad.sourceline import SourceLine
from typing import (Any, AnyStr, Callable, cast, Dict, List, Generator, Text,
Tuple, Union)

from .builder import Builder
from .pathmapper import adjustDirObjs, get_listing
from .errors import WorkflowException, UnsupportedRequirement
from .pathmapper import PathMapper, normalizeFilesDirs, visit_class
from .errors import UnsupportedRequirement, WorkflowException
from .pathmapper import (PathMapper, adjustDirObjs, get_listing,
normalizeFilesDirs, visit_class)
from .stdfsaccess import StdFsAccess
from .utils import aslist, get_feature


class LogAsDebugFilter(logging.Filter):
def __init__(self, name, parent): # type: (str, logging.Logger) -> None
super(LogAsDebugFilter, self).__init__(name)
Expand Down
2 changes: 1 addition & 1 deletion cwltool/sandboxjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import subprocess
import threading
from io import BytesIO
from typing import Any, Dict, List, Mapping, Text, Tuple, Union

from pkg_resources import resource_stream
from typing import Any, Dict, List, Mapping, Text, Union, Tuple


class JavascriptException(Exception):
Expand Down
3 changes: 2 additions & 1 deletion cwltool/stdfsaccess.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import glob
import os
import urllib
from typing import BinaryIO, Text

from schema_salad.ref_resolver import file_uri, uri_file_path
from typing import BinaryIO, Text


def abspath(src, basedir): # type: (Text, Text) -> Text
if src.startswith(u"file://"):
Expand Down
5 changes: 3 additions & 2 deletions cwltool/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import re
import traceback
import urlparse
from typing import (Any, Callable, Dict, Text, # pylint: disable=unused-import
Tuple, Union)

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

from .utils import aslist

Expand Down
7 changes: 3 additions & 4 deletions cwltool/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import random
import tempfile
from collections import namedtuple
from ruamel.yaml.comments import CommentedSeq, CommentedMap
from typing import Any, Callable, Generator, Iterable, List, Text, Union, cast

import schema_salad.validate as validate
from ruamel.yaml.comments import CommentedMap, CommentedSeq
from schema_salad.sourceline import SourceLine, cmap
from typing import Any, Callable, cast, Generator, Iterable, List, Text, Union

from . import draft2tool
from . import expression
from . import draft2tool, expression
from .errors import WorkflowException
from .load_tool import load_tool
from .process import Process, shortname, uniquename
Expand Down
4 changes: 3 additions & 1 deletion tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import cwltool.pathmapper
import cwltool.process
import cwltool.workflow
from .util import get_data
from cwltool.main import main

from .util import get_data


class TestCheck(unittest.TestCase):
def test_output_checking(self):
self.assertEquals(main([get_data('tests/wf/badout1.cwl')]), 1)
Expand Down
Loading