Skip to content

Commit e927039

Browse files
committed
flake8 inspired fixes
1 parent 7c820d2 commit e927039

File tree

8 files changed

+20
-19
lines changed

8 files changed

+20
-19
lines changed

cwltool/builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@ def formatSubclassOf(
8989

9090
uriRefFmt = URIRef(fmt)
9191

92-
for s, p, o in ontology.triples((uriRefFmt, RDFS.subClassOf, None)):
92+
for _s, _p, o in ontology.triples((uriRefFmt, RDFS.subClassOf, None)):
9393
# Find parent classes of `fmt` and search upward
9494
if formatSubclassOf(o, cls, ontology, visited):
9595
return True
9696

97-
for s, p, o in ontology.triples((uriRefFmt, OWL.equivalentClass, None)):
97+
for _s, _p, o in ontology.triples((uriRefFmt, OWL.equivalentClass, None)):
9898
# Find equivalent classes of `fmt` and search horizontally
9999
if formatSubclassOf(o, cls, ontology, visited):
100100
return True
101101

102-
for s, p, o in ontology.triples((None, OWL.equivalentClass, uriRefFmt)):
102+
for s, _p, _o in ontology.triples((None, OWL.equivalentClass, uriRefFmt)):
103103
# Find equivalent classes of `fmt` and search horizontally
104104
if formatSubclassOf(s, cls, ontology, visited):
105105
return True

cwltool/command_line_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ def collect_output(
11461146
)
11471147
]
11481148
)
1149-
except (OSError, IOError) as e:
1149+
except (OSError) as e:
11501150
_logger.warning(str(e))
11511151
except Exception:
11521152
_logger.error(

cwltool/cwlrdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def dot_without_parameters(g: Graph, stdout: Union[TextIO, StreamWriter]) -> Non
138138
)
139139

140140
currentwf = None # type: Optional[str]
141-
for wf, step, run, runtype in qres:
141+
for wf, step, _run, runtype in qres:
142142
if step not in dotname:
143143
dotname[step] = lastpart(step)
144144

cwltool/job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ def docker_monitor(
867867
try:
868868
with open(cidfile) as cidhandle:
869869
cid = cidhandle.readline().strip()
870-
except (OSError, IOError):
870+
except (OSError):
871871
cid = None
872872
max_mem = psutil.virtual_memory().total
873873
tmp_dir, tmp_prefix = os.path.split(tmpdir_prefix)

cwltool/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ def main(
876876

877877
if not args.workflow:
878878
if os.path.isfile("CWLFile"):
879-
setattr(args, "workflow", "CWLFile")
879+
args.workflow = "CWLFile"
880880
else:
881881
_logger.error("CWL document required, no input file was provided")
882882
arg_parser().print_help()

cwltool/mpi.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import re
33
import inspect
4-
from typing import List, Type, TypeVar, MutableMapping, Mapping, Union
4+
from typing import List, Type, TypeVar, Optional, MutableMapping, Mapping, Union
55
from ruamel import yaml
66

77

@@ -16,10 +16,10 @@ def __init__(
1616
runner: str = "mpirun",
1717
nproc_flag: str = "-n",
1818
default_nproc: Union[int, str] = 1,
19-
extra_flags: List[str] = [],
20-
env_pass: List[str] = [],
21-
env_pass_regex: List[str] = [],
22-
env_set: Mapping[str, str] = {},
19+
extra_flags: Optional[List[str]] = None,
20+
env_pass: Optional[List[str]] = None,
21+
env_pass_regex: Optional[List[str]] = None,
22+
env_set: Optional[Mapping[str, str]] = None,
2323
) -> None:
2424
"""
2525
Initialize from the argument mapping.
@@ -38,10 +38,10 @@ def __init__(
3838
self.runner = runner
3939
self.nproc_flag = nproc_flag
4040
self.default_nproc = int(default_nproc)
41-
self.extra_flags = extra_flags
42-
self.env_pass = env_pass
43-
self.env_pass_regex = env_pass_regex
44-
self.env_set = env_set
41+
self.extra_flags = extra_flags or []
42+
self.env_pass = env_pass or []
43+
self.env_pass_regex = env_pass_regex or []
44+
self.env_set = env_set or {}
4545

4646
@classmethod
4747
def load(cls: Type[MpiConfigT], config_file_name: str) -> MpiConfigT:

cwltool/provenance_profile.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
versionstring,
4646
)
4747
from .workflow_job import WorkflowJob
48+
from .job import CommandLineJob, JobBase
4849

4950
if TYPE_CHECKING:
5051
from .provenance import ResearchObject
@@ -258,8 +259,8 @@ def record_process_start(
258259
elif not hasattr(job, "workflow"):
259260
# commandline tool execution as part of workflow
260261
name = ""
261-
if hasattr(job, "name"):
262-
name = getattr(job, "name")
262+
if isinstance(job, (CommandLineJob, JobBase, WorkflowJob)):
263+
name = job.name
263264
process_name = urllib.parse.quote(name, safe=":/,#")
264265
process_run_id = self.start_process(process_name, datetime.datetime.now())
265266
return process_run_id

cwltool/singularity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def get_image(
155155
if is_version_2_6() and "SINGULARITY_PULLFOLDER" in os.environ:
156156
targets.append(os.environ["SINGULARITY_PULLFOLDER"])
157157
for target in targets:
158-
for dirpath, subdirs, files in os.walk(target):
158+
for dirpath, _subdirs, files in os.walk(target):
159159
for entry in files:
160160
if entry in candidates:
161161
path = os.path.join(dirpath, entry)

0 commit comments

Comments
 (0)