Skip to content

Commit 5c7799a

Browse files
authored
clean up docs (#1127)
1 parent 4c3656e commit 5c7799a

34 files changed

+152
-150
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ diff_pycodestyle_report: pycodestyle_report.txt
100100
pep257: pydocstyle
101101
## pydocstyle : check Python code style
102102
pydocstyle: $(PYSOURCES)
103-
pydocstyle --ignore=D100,D101,D102,D103 $^ || true
103+
pydocstyle --add-ignore=D100,D101,D102,D103 $^ || true
104104

105105
pydocstyle_report.txt: $(PYSOURCES)
106106
pydocstyle setup.py $^ > $@ 2>&1 || true
107107

108108
diff_pydocstyle_report: pydocstyle_report.txt
109-
diff-quality --violations=pycodestyle $^
109+
diff-quality --violations=pycodestyle --fail-under=100 $^
110110

111111
## autopep8 : fix most Python code indentation and formatting
112112
autopep8: $(PYSOURCES)

cwltool/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
"""Reference implementation of the CWL standards."""
12
from __future__ import absolute_import
23
__author__ = '[email protected]'

cwltool/argparser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,7 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
318318

319319
def get_default_args():
320320
# type: () -> Dict[str, Any]
321-
"""
322-
Get default values of cwltool's command line options
323-
"""
321+
"""Get default values of cwltool's command line options."""
324322
ap = arg_parser()
325323
args = ap.parse_args([])
326324
return vars(args)
@@ -331,6 +329,7 @@ class FSAction(argparse.Action):
331329

332330
def __init__(self, option_strings, dest, nargs=None, **kwargs):
333331
# type: (List[Text], Text, Any, **Any) -> None
332+
"""Fail if nargs is used."""
334333
if nargs is not None:
335334
raise ValueError("nargs not allowed")
336335
super(FSAction, self).__init__(option_strings, dest, **kwargs)
@@ -348,6 +347,7 @@ class FSAppendAction(argparse.Action):
348347

349348
def __init__(self, option_strings, dest, nargs=None, **kwargs):
350349
# type: (List[Text], Text, Any, **Any) -> None
350+
"""Initialize."""
351351
if nargs is not None:
352352
raise ValueError("nargs not allowed")
353353
super(FSAppendAction, self).__init__(option_strings, dest, **kwargs)

cwltool/builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def substitute(value, replace): # type: (Text, Text) -> Text
6161
def formatSubclassOf(fmt, cls, ontology, visited):
6262
# type: (Text, Text, Optional[Graph], Set[Text]) -> bool
6363
"""Determine if `fmt` is a subclass of `cls`."""
64-
6564
if URIRef(fmt) == URIRef(cls):
6665
return True
6766

@@ -96,7 +95,7 @@ def check_format(actual_file, # type: Union[Dict[Text, Any], List, Text]
9695
input_formats, # type: Union[List[Text], Text]
9796
ontology # type: Optional[Graph]
9897
): # type: (...) -> None
99-
""" Confirms that the format present is valid for the allowed formats."""
98+
"""Confirm that the format present is valid for the allowed formats."""
10099
for afile in aslist(actual_file):
101100
if not afile:
102101
continue
@@ -114,6 +113,7 @@ def check_format(actual_file, # type: Union[Dict[Text, Any], List, Text]
114113

115114
class HasReqsHints(object):
116115
def __init__(self):
116+
"""Initialize this reqs decorator."""
117117
self.requirements = [] # List[Dict[Text, Any]]
118118
self.hints = [] # List[Dict[Text, Any]]
119119

@@ -152,7 +152,7 @@ def __init__(self,
152152
tmpdir, # type: Text
153153
stagedir # type: Text
154154
): # type: (...) -> None
155-
155+
"""Initialize this Builder."""
156156
self.job = job
157157
self.files = files
158158
self.bindings = bindings

cwltool/checker.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ def _get_type(tp):
2323

2424
def check_types(srctype, sinktype, linkMerge, valueFrom):
2525
# type: (Any, Any, Optional[Text], Optional[Text]) -> Text
26-
"""Check if the source and sink types are "pass", "warning", or "exception".
2726
"""
27+
Check if the source and sink types are correct.
2828
29+
Acceptable types are "pass", "warning", or "exception".
30+
"""
2931
if valueFrom is not None:
3032
return "pass"
3133
if linkMerge is None:
@@ -44,9 +46,7 @@ def check_types(srctype, sinktype, linkMerge, valueFrom):
4446

4547
def merge_flatten_type(src):
4648
# type: (Any) -> Any
47-
"""Return the merge flattened type of the source type
48-
"""
49-
49+
"""Return the merge flattened type of the source type."""
5050
if isinstance(src, MutableSequence):
5151
return [merge_flatten_type(t) for t in src]
5252
if isinstance(src, MutableMapping) and src.get("type") == "array":
@@ -55,15 +55,15 @@ def merge_flatten_type(src):
5555

5656

5757
def can_assign_src_to_sink(src, sink, strict=False): # type: (Any, Any, bool) -> bool
58-
"""Check for identical type specifications, ignoring extra keys like inputBinding.
58+
"""
59+
Check for identical type specifications, ignoring extra keys like inputBinding.
5960
6061
src: admissible source types
6162
sink: admissible sink types
6263
6364
In non-strict comparison, at least one source type must match one sink type.
6465
In strict comparison, all source types must match at least one sink type.
6566
"""
66-
6767
if src == "Any" or sink == "Any":
6868
return True
6969
if isinstance(src, MutableMapping) and isinstance(sink, MutableMapping):
@@ -100,12 +100,12 @@ def can_assign_src_to_sink(src, sink, strict=False): # type: (Any, Any, bool) -
100100

101101
def _compare_records(src, sink, strict=False):
102102
# type: (MutableMapping[Text, Any], MutableMapping[Text, Any], bool) -> bool
103-
"""Compare two records, ensuring they have compatible fields.
103+
"""
104+
Compare two records, ensuring they have compatible fields.
104105
105106
This handles normalizing record names, which will be relative to workflow
106107
step, so that they can be compared.
107108
"""
108-
109109
def _rec_fields(rec): # type: (MutableMapping[Text, Any]) -> MutableMapping[Text, Any]
110110
out = {}
111111
for field in rec["fields"]:
@@ -136,9 +136,7 @@ def missing_subset(fullset, subset):
136136

137137
def static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs, param_to_step):
138138
# type: (List[Dict[Text, Any]], List[Dict[Text, Any]], List[Dict[Text, Any]], List[Dict[Text, Any]], Dict[Text, Dict[Text, Any]]) -> None
139-
"""Check if all source and sink types of a workflow are compatible before run time.
140-
"""
141-
139+
"""Check if all source and sink types of a workflow are compatible before run time."""
142140
# source parameters: workflow_inputs and step_outputs
143141
# sink parameters: step_inputs and workflow_outputs
144142

@@ -225,10 +223,11 @@ def static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs,
225223

226224
def check_all_types(src_dict, sinks, sourceField):
227225
# type: (Dict[Text, Any], List[Dict[Text, Any]], Text) -> Dict[Text, List[SrcSink]]
228-
# sourceField is either "soure" or "outputSource"
229-
"""Given a list of sinks, check if their types match with the types of their sources.
230226
"""
227+
Given a list of sinks, check if their types match with the types of their sources.
231228
229+
sourceField is either "soure" or "outputSource"
230+
"""
232231
validation = {"warning": [], "exception": []} # type: Dict[Text, List[SrcSink]]
233232
for sink in sinks:
234233
if sourceField in sink:

cwltool/command_line_tool.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575

7676
class ExpressionTool(Process):
7777
class ExpressionJob(object):
78+
"""Job for ExpressionTools."""
7879

7980
def __init__(self,
8081
builder, # type: Builder
@@ -85,6 +86,7 @@ def __init__(self,
8586
outdir=None, # type: Optional[Text]
8687
tmpdir=None, # type: Optional[Text]
8788
): # type: (...) -> None
89+
"""Initializet this ExpressionJob."""
8890
self.builder = builder
8991
self.requirements = requirements
9092
self.hints = hints
@@ -131,14 +133,13 @@ def remove_path(f): # type: (Dict[Text, Any]) -> None
131133

132134
def revmap_file(builder, outdir, f):
133135
# type: (Builder, Text, Dict[Text, Any]) -> Union[Dict[Text, Any], None]
134-
135-
"""Remap a file from internal path to external path.
136+
"""
137+
Remap a file from internal path to external path.
136138
137139
For Docker, this maps from the path inside tho container to the path
138140
outside the container. Recognizes files in the pathmapper or remaps
139141
internal output directories to the external directory.
140142
"""
141-
142143
split = urllib.parse.urlsplit(outdir)
143144
if not split.scheme:
144145
outdir = file_uri(str(outdir))
@@ -184,6 +185,7 @@ def revmap_file(builder, outdir, f):
184185
class CallbackJob(object):
185186
def __init__(self, job, output_callback, cachebuilder, jobcache):
186187
# type: (CommandLineTool, Callable[[Any, Any], Any], Builder, Text) -> None
188+
"""Initialize this CallbackJob."""
187189
self.job = job
188190
self.output_callback = output_callback
189191
self.cachebuilder = cachebuilder
@@ -207,7 +209,6 @@ def check_adjust(builder, file_o):
207209
We need to also explicitly walk over input, as implicit reassignment
208210
doesn't reach everything in builder.bindings
209211
"""
210-
211212
if not builder.pathmapper:
212213
raise ValueError("Do not call check_adjust using a builder that doesn't have a pathmapper.")
213214
file_o["path"] = docker_windows_path_adjust(
@@ -243,6 +244,7 @@ def check_valid_locations(fs_access, ob):
243244
class CommandLineTool(Process):
244245
def __init__(self, toolpath_object, loadingContext):
245246
# type: (MutableMapping[Text, Any], LoadingContext) -> None
247+
"""Initialize this CommandLineTool."""
246248
super(CommandLineTool, self).__init__(toolpath_object, loadingContext)
247249
self.prov_obj = loadingContext.prov_obj
248250

cwltool/context.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
ProvenanceProfile)
2525

2626
class ContextBase(object):
27-
def __init__(self, kwargs=None):
28-
# type: (Optional[Dict[str, Any]]) -> None
27+
def __init__(self, kwargs=None): # type: (Optional[Dict[str, Any]]) -> None
28+
"""Initialize."""
2929
if kwargs:
3030
for k, v in kwargs.items():
3131
if hasattr(self, k):
@@ -41,8 +41,8 @@ def make_tool_notimpl(toolpath_object, # type: MutableMapping[Text, Any]
4141

4242
class LoadingContext(ContextBase):
4343

44-
def __init__(self, kwargs=None):
45-
# type: (Optional[Dict[str, Any]]) -> None
44+
def __init__(self, kwargs=None): # type: (Optional[Dict[str, Any]]) -> None
45+
"""Initialize the LoadingContext from the kwargs."""
4646
self.debug = False # type: bool
4747
self.metadata = {} # type: Dict[Text, Any]
4848
self.requirements = None
@@ -74,8 +74,8 @@ def copy(self):
7474
return copy.copy(self)
7575

7676
class RuntimeContext(ContextBase):
77-
def __init__(self, kwargs=None):
78-
# type: (Optional[Dict[str, Any]]) -> None
77+
def __init__(self, kwargs=None): # type: (Optional[Dict[str, Any]]) -> None
78+
"""Initializet the RuntimeContext from the kwargs."""
7979
select_resources_callable = Callable[ # pylint: disable=unused-variable
8080
[Dict[str, int], RuntimeContext], Dict[str, int]]
8181
self.user_space_docker_cmd = "" # type: Text

cwltool/docker_id.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
def docker_vm_id(): # type: () -> Tuple[Optional[int], Optional[int]]
1313
"""
14-
Returns the User ID and Group ID of the default docker user inside the VM
14+
Return the User ID and Group ID of the default docker user inside the VM.
1515
1616
When a host is using boot2docker or docker-machine to run docker with
1717
boot2docker.iso (As on Mac OS X), the UID that mounts the shared filesystem
@@ -28,8 +28,9 @@ def docker_vm_id(): # type: () -> Tuple[Optional[int], Optional[int]]
2828

2929
def check_output_and_strip(cmd): # type: (List[Text]) -> Optional[Text]
3030
"""
31-
Passes a command list to subprocess.check_output, returning None
32-
if an expected exception is raised
31+
Pass a command list to subprocess.check_output.
32+
33+
Returning None if an expected exception is raised
3334
:param cmd: The command to execute
3435
:return: Stripped string output of the command, or None if error
3536
"""
@@ -45,7 +46,8 @@ def check_output_and_strip(cmd): # type: (List[Text]) -> Optional[Text]
4546

4647
def docker_machine_name(): # type: () -> Optional[Text]
4748
"""
48-
Get the machine name of the active docker-machine machine
49+
Get the machine name of the active docker-machine machine.
50+
4951
:return: Name of the active machine or None if error
5052
"""
5153
return check_output_and_strip(['docker-machine', 'active'])
@@ -54,7 +56,8 @@ def docker_machine_name(): # type: () -> Optional[Text]
5456
def cmd_output_matches(check_cmd, expected_status):
5557
# type: (List[Text], Text) -> bool
5658
"""
57-
Runs a command and compares output to expected
59+
Run a command and compares output to expected.
60+
5861
:param check_cmd: Command list to execute
5962
:param expected_status: Expected output, e.g. "Running" or "poweroff"
6063
:return: Boolean value, indicating whether or not command result matched
@@ -64,15 +67,17 @@ def cmd_output_matches(check_cmd, expected_status):
6467

6568
def boot2docker_running(): # type: () -> bool
6669
"""
67-
Checks if boot2docker CLI reports that boot2docker vm is running
70+
Check if boot2docker CLI reports that boot2docker vm is running.
71+
6872
:return: True if vm is running, False otherwise
6973
"""
7074
return cmd_output_matches(['boot2docker', 'status'], 'running')
7175

7276

7377
def docker_machine_running(): # type: () -> bool
7478
"""
75-
Asks docker-machine for active machine and checks if its VM is running
79+
Ask docker-machine for the active machine and checks if its VM is running.
80+
7681
:return: True if vm is running, False otherwise
7782
"""
7883
machine_name = docker_machine_name()
@@ -83,7 +88,8 @@ def docker_machine_running(): # type: () -> bool
8388

8489
def cmd_output_to_int(cmd): # type: (List[Text]) -> Optional[int]
8590
"""
86-
Runs the provided command and returns the integer value of the result
91+
Run the provided command and returns the integer value of the result.
92+
8793
:param cmd: The command to run
8894
:return: Integer value of result, or None if an error occurred
8995
"""
@@ -99,7 +105,8 @@ def cmd_output_to_int(cmd): # type: (List[Text]) -> Optional[int]
99105

100106
def boot2docker_id(): # type: () -> Tuple[Optional[int], Optional[int]]
101107
"""
102-
Gets the UID and GID of the docker user inside a running boot2docker vm
108+
Get the UID and GID of the docker user inside a running boot2docker vm.
109+
103110
:return: Tuple (UID, GID), or (None, None) if error (e.g. boot2docker not present or stopped)
104111
"""
105112
uid = cmd_output_to_int(['boot2docker', 'ssh', 'id', '-u'])
@@ -108,7 +115,8 @@ def boot2docker_id(): # type: () -> Tuple[Optional[int], Optional[int]]
108115

109116
def docker_machine_id(): # type: () -> Tuple[Optional[int], Optional[int]]
110117
"""
111-
Asks docker-machine for active machine and gets the UID of the docker user
118+
Ask docker-machine for active machine and gets the UID of the docker user.
119+
112120
inside the vm
113121
:return: tuple (UID, GID), or (None, None) if error (e.g. docker-machine not present or stopped)
114122
"""

0 commit comments

Comments
 (0)