Skip to content

Commit 2951961

Browse files
committed
remove unused imports, vars
1 parent c045a4e commit 2951961

38 files changed

+79
-124
lines changed

cwltool/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
"""Reference implementation of the CWL standards."""
2-
import sys
3-
import warnings
42

53
__author__ = "[email protected]"

cwltool/builder.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import copy
22
import logging
33
import math
4-
import os
54
from typing import (
65
IO,
76
Any,
@@ -231,7 +230,9 @@ def bind_input(
231230
lead_pos = []
232231

233232
bindings = [] # type: List[MutableMapping[str, Union[str, List[int]]]]
234-
binding = {} # type: Union[MutableMapping[str, Union[str, List[int]]], CommentedMap]
233+
binding = (
234+
{}
235+
) # type: Union[MutableMapping[str, Union[str, List[int]]], CommentedMap]
235236
value_from_expression = False
236237
if "inputBinding" in schema and isinstance(
237238
schema["inputBinding"], MutableMapping
@@ -484,7 +485,9 @@ def addsf(
484485
# Position to front of the sort key
485486
if binding:
486487
for bi in bindings:
487-
bi["position"] = cast(List[int], binding["position"]) + cast(List[int], bi["position"])
488+
bi["position"] = cast(List[int], binding["position"]) + cast(
489+
List[int], bi["position"]
490+
)
488491
bindings.append(binding)
489492

490493
return bindings

cwltool/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Shared context objects that replace use of kwargs."""
22
import copy
33
import threading
4-
from typing import Any, Callable, Dict, Iterable, List, MutableMapping, Optional, Type
4+
from typing import Any, Callable, Dict, Iterable, List, MutableMapping, Optional
55

66
# move to a regular typing import when Python 3.3-3.6 is no longer supported
77
from ruamel.yaml.comments import CommentedMap

cwltool/cwlrdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import urllib
2-
from typing import IO, Any, Dict, MutableMapping, Optional, cast
2+
from typing import IO, Any, Dict, Optional, cast
33

44
from rdflib import Graph
55
from ruamel.yaml.comments import CommentedMap

cwltool/docker.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from .context import RuntimeContext
2020
from .docker_id import docker_vm_id
2121
from .errors import WorkflowException
22-
from .expression import JSON
2322
from .job import ContainerCommandLineJob
2423
from .loghandler import _logger
2524
from .pathmapper import MapperEnt, PathMapper

cwltool/docker_id.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Helper functions for docker."""
22

33
import subprocess
4-
from typing import List, Optional, Tuple, cast
4+
from typing import List, Optional, Tuple
55

66

77
def docker_vm_id(): # type: () -> Tuple[Optional[int], Optional[int]]

cwltool/job.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from .builder import Builder, HasReqsHints
4444
from .context import RuntimeContext, getdefault
4545
from .errors import UnsupportedRequirement, WorkflowException
46-
from .expression import JSON
4746
from .loghandler import _logger
4847
from .pathmapper import MapperEnt, PathMapper
4948
from .process import stage_files
@@ -426,7 +425,7 @@ def _execute(
426425
except WorkflowException as err:
427426
_logger.error("[job %s] Job error:\n%s", self.name, str(err))
428427
processStatus = "permanentFail"
429-
except Exception as e:
428+
except Exception:
430429
_logger.exception("Exception while running job")
431430
processStatus = "permanentFail"
432431
if (
@@ -604,22 +603,19 @@ def create_runtime(
604603
self, env: MutableMapping[str, str], runtime_context: RuntimeContext,
605604
) -> Tuple[List[str], Optional[str]]:
606605
"""Return the list of commands to run the selected container engine."""
607-
pass
608606

609607
@staticmethod
610608
@abstractmethod
611609
def append_volume(
612610
runtime: List[str], source: str, target: str, writable: bool = False
613611
) -> None:
614612
"""Add binding arguments to the runtime list."""
615-
pass
616613

617614
@abstractmethod
618615
def add_file_or_directory_volume(
619616
self, runtime: List[str], volume: MapperEnt, host_outdir_tgt: Optional[str]
620617
) -> None:
621618
"""Append volume a file/dir mapping to the runtime option list."""
622-
pass
623619

624620
@abstractmethod
625621
def add_writable_file_volume(
@@ -630,7 +626,6 @@ def add_writable_file_volume(
630626
tmpdir_prefix: str,
631627
) -> None:
632628
"""Append a writable file mapping to the runtime option list."""
633-
pass
634629

635630
@abstractmethod
636631
def add_writable_directory_volume(
@@ -641,7 +636,6 @@ def add_writable_directory_volume(
641636
tmpdir_prefix: str,
642637
) -> None:
643638
"""Append a writable directory mapping to the runtime option list."""
644-
pass
645639

646640
def create_file_and_add_volume(
647641
self,

cwltool/load_tool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
cast,
2020
)
2121

22-
import requests.sessions
2322
from ruamel.yaml.comments import CommentedMap, CommentedSeq
2423
from schema_salad.exceptions import ValidationException
2524
from schema_salad.ref_resolver import (

cwltool/main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""Entry point for cwltool."""
33

44
import argparse
5-
import copy
65
import functools
76
import io
87
import logging
@@ -12,7 +11,7 @@
1211
import time
1312
import urllib
1413
from codecs import StreamWriter, getwriter
15-
from collections.abc import Iterable, MutableMapping, MutableSequence, Sequence
14+
from collections.abc import Iterable, MutableMapping, MutableSequence
1615
from typing import (
1716
IO,
1817
Any,
@@ -385,7 +384,7 @@ def init_job_order(
385384
MutableMapping[str, Any],
386385
loader.resolve_ref(cmd_line["job_order"])[0],
387386
)
388-
except Exception as err:
387+
except Exception:
389388
_logger.exception(
390389
"Failed to resolv job_order: %s", cmd_line["job_order"]
391390
)
@@ -781,7 +780,7 @@ def check_working_directories(
781780
if not os.path.exists(os.path.dirname(getattr(runtimeContext, dirprefix))):
782781
try:
783782
os.makedirs(os.path.dirname(getattr(runtimeContext, dirprefix)))
784-
except Exception as e:
783+
except Exception:
785784
_logger.exception("Failed to create directory.")
786785
return 1
787786
return None

cwltool/pathmapper.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import stat
55
import urllib
66
import uuid
7-
from functools import partial
8-
from tempfile import NamedTemporaryFile
97
from typing import (
108
Any,
119
Callable,
@@ -22,15 +20,12 @@
2220
cast,
2321
)
2422

25-
import requests
26-
from cachecontrol import CacheControl
27-
from cachecontrol.caches import FileCache
2823
from schema_salad.exceptions import ValidationException
2924
from schema_salad.ref_resolver import uri_file_path
3025
from schema_salad.sourceline import SourceLine
3126

3227
from .loghandler import _logger
33-
from .stdfsaccess import StdFsAccess, abspath
28+
from .stdfsaccess import abspath
3429
from .utils import (
3530
CWLObjectType,
3631
Directory,

cwltool/process.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import abc
22
import copy
3-
import errno
43
import functools
54
import hashlib
65
import json
@@ -664,7 +663,7 @@ def __init__(
664663
try:
665664
with open(loadingContext.js_hint_options_file) as options_file:
666665
validate_js_options = json.load(options_file)
667-
except (OSError, ValueError) as err:
666+
except (OSError, ValueError):
668667
_logger.error(
669668
"Failed to read options file %s",
670669
loadingContext.js_hint_options_file,
@@ -916,7 +915,9 @@ def inc(d): # type: (List[int]) -> None
916915
builder.resources = self.evalResources(builder, runtime_context)
917916
return builder
918917

919-
def evalResources(self, builder: Builder, runtimeContext: RuntimeContext) -> Dict[str, int]:
918+
def evalResources(
919+
self, builder: Builder, runtimeContext: RuntimeContext
920+
) -> Dict[str, int]:
920921
resourceReq, _ = self.get_requirement("ResourceRequirement")
921922
if resourceReq is None:
922923
resourceReq = {}
@@ -940,9 +941,19 @@ def evalResources(self, builder: Builder, runtimeContext: RuntimeContext) -> Dic
940941
for a in ("cores", "ram", "tmpdir", "outdir"):
941942
mn = mx = None # type: Optional[int]
942943
if resourceReq.get(a + "Min"):
943-
mn = cast(int, eval_resource(builder, cast(Union[str, int], resourceReq[a + "Min"])))
944+
mn = cast(
945+
int,
946+
eval_resource(
947+
builder, cast(Union[str, int], resourceReq[a + "Min"])
948+
),
949+
)
944950
if resourceReq.get(a + "Max"):
945-
mx = cast(int, eval_resource(builder, cast(Union[str, int], resourceReq[a + "Max"])))
951+
mx = cast(
952+
int,
953+
eval_resource(
954+
builder, cast(Union[str, int], resourceReq[a + "Max"])
955+
),
956+
)
946957
if mn is None:
947958
mn = mx
948959
elif mx is None:

cwltool/provenance.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from io import BytesIO, FileIO, TextIOWrapper, open
1616
from pathlib import Path, PurePath, PurePosixPath
1717
from socket import getfqdn
18-
from types import ModuleType
1918
from typing import (
2019
IO,
2120
Any,
@@ -33,7 +32,6 @@
3332
cast,
3433
)
3534

36-
from ruamel import yaml
3735
from schema_salad.sourceline import SourceLine
3836
from schema_salad.utils import json_dumps
3937
from typing_extensions import TYPE_CHECKING
@@ -42,7 +40,6 @@
4240
from prov.identifier import Identifier, Namespace
4341
from prov.model import PROV, ProvDocument, ProvEntity
4442

45-
from .context import RuntimeContext
4643
from .errors import WorkflowException
4744
from .loghandler import _logger
4845
from .process import Process, shortname

cwltool/resolver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"""Resolves references to CWL documents from local or remote places."""
22

33
import os
4-
import sys
54
import urllib
65
from pathlib import Path
7-
from typing import Any, Optional
6+
from typing import Optional
87

98
from schema_salad.ref_resolver import Loader
109

cwltool/singularity.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from .builder import Builder
2323
from .context import RuntimeContext
2424
from .errors import UnsupportedRequirement, WorkflowException
25-
from .expression import JSON
2625
from .job import ContainerCommandLineJob
2726
from .loghandler import _logger
2827
from .pathmapper import MapperEnt, PathMapper

cwltool/subgraph.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import copy
21
import urllib
32
from collections import namedtuple
43
from typing import Any, Dict, MutableMapping, MutableSequence, Optional, Set, Tuple
54

65
from ruamel.yaml.comments import CommentedMap
76

8-
from .process import shortname
97
from .utils import aslist
108
from .workflow import Workflow
119

cwltool/update.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import copy
2-
import re
32
from functools import partial
43
from typing import (
54
Any,

cwltool/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import uuid
1515
from functools import partial
1616
from itertools import zip_longest
17-
from pathlib import Path
1817
from tempfile import NamedTemporaryFile
1918
from types import ModuleType
2019
from typing import (

cwltool/workflow.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import random
66
import tempfile
77
import threading
8-
from collections import namedtuple
98
from typing import (
109
Any,
1110
Callable,
@@ -34,10 +33,8 @@
3433
from . import command_line_tool, context, expression, procgenerator
3534
from .builder import content_limit_respected_read
3635
from .checker import can_assign_src_to_sink, static_checker
37-
from .command_line_tool import CallbackJob, ExpressionJob, ExpressionTool
3836
from .context import LoadingContext, RuntimeContext, getdefault
3937
from .errors import WorkflowException
40-
from .job import JobBase
4138
from .load_tool import load_tool
4239
from .loghandler import _logger
4340
from .process import Process, get_overrides, shortname, uniquename

tests/test_default_path.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from schema_salad.ref_resolver import Loader
2-
31
from cwltool.load_tool import fetch_document, resolve_and_validate_document
42

53
from .util import get_data

tests/test_docker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
import py.path
44

5-
from cwltool.docker import DockerCommandLineJob
65
from cwltool.main import main
76

8-
from .util import get_data, get_main_output, needs_docker, needs_singularity
7+
from .util import get_data, get_main_output, needs_docker
98

109

1110
@needs_docker # type: ignore

tests/test_docker_paths_with_colons.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from typing import Any
22

33
from cwltool.docker import DockerCommandLineJob
4-
from cwltool.main import main
5-
6-
from .util import needs_docker
74

85

96
def test_docker_append_volume_read_only(mocker: Any) -> None:

tests/test_docker_warning.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from typing import Any, List, cast
1+
from typing import Any, cast
22

33
import pytest # type: ignore
44
from ruamel.yaml.comments import CommentedMap
55
from schema_salad.sourceline import cmap
66

7-
from cwltool import command_line_tool, loghandler
7+
from cwltool import command_line_tool
88
from cwltool.context import LoadingContext, RuntimeContext
9-
from cwltool.utils import CWLObjectType, onWindows, windows_default_container_id
9+
from cwltool.utils import onWindows, windows_default_container_id
1010

1111

1212
@pytest.mark.skip(not onWindows(), reason="MS Windows only") # type: ignore

0 commit comments

Comments
 (0)