Skip to content

Commit

Permalink
Merge pull request #277 from common-workflow-language/dependabot/pip/…
Browse files Browse the repository at this point in the history
…black-approx-eq-24.1

Update black requirement from ~=23.12 to ~=24.1
  • Loading branch information
mr-c authored Jan 31, 2024
2 parents b3f0a82 + c95e06a commit e3f0704
Show file tree
Hide file tree
Showing 21 changed files with 158 additions and 124 deletions.
3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[flake8]
ignore = E203,W503
max-line-length = 100
select = B,C,E,F,W,T4
exclude = cwltool/schemas
extend-ignore = E501,B905
extend-ignore = E203,E501,E704,B905,W503
# when Python 3.10 is the minimum version, re-enable check B905 for zip + strict
extend-select = B9
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# black + isort
69e709fde4a3afada10d441cb9e0a85f8a95a3d4

# black 2024
af096c2301d5ae81daa41bf0b96417cebda76d05
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ EXTRAS=
PYSOURCES=$(filter-out $(MODULE)/parser/cwl_v%,$(shell find $(MODULE) -name "*.py")) \
$(wildcard tests/*.py) create_cwl_from_objects.py load_cwl_by_path.py \
${MODULE}/parser/cwl_v1_?_utils.py docs/conf.py
DEVPKGS=build diff_cover pylint pep257 pydocstyle flake8 'tox<4' tox-pyenv \
isort wheel autoflake pyupgrade bandit auto-walrus \
DEVPKGS=build diff_cover pylint pep257 pydocstyle 'tox<4' tox-pyenv \
wheel autoflake pyupgrade bandit auto-walrus \
-rlint-requirements.txt -rtest-requirements.txt -rmypy-requirements.txt
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pydocstyle sloccount \
python-flake8 python-mock shellcheck
Expand Down
56 changes: 31 additions & 25 deletions cwl_utils/cwl_v1_0_expression_refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,21 +355,27 @@ def generate_etool_from_expr(
cwl.InputParameter(
id="self",
label=self_type.label if not isinstance(self_type, list) else None,
secondaryFiles=self_type.secondaryFiles
if not isinstance(self_type, list)
else None,
streamable=self_type.streamable
if not isinstance(self_type, list)
else None,
secondaryFiles=(
self_type.secondaryFiles
if not isinstance(self_type, list)
else None
),
streamable=(
self_type.streamable if not isinstance(self_type, list) else None
),
doc=self_type.doc if not isinstance(self_type, list) else None,
format=self_type.format if not isinstance(self_type, list) else None,
type_=new_type,
extension_fields=self_type.extension_fields
if not isinstance(self_type, list)
else None,
loadingOptions=self_type.loadingOptions
if not isinstance(self_type, list)
else None,
extension_fields=(
self_type.extension_fields
if not isinstance(self_type, list)
else None
),
loadingOptions=(
self_type.loadingOptions
if not isinstance(self_type, list)
else None
),
)
)
outputs = yaml.comments.CommentedSeq()
Expand Down Expand Up @@ -818,10 +824,10 @@ def process_workflow_reqs_and_hints(
None,
replace_etool,
)
iwdr.listing[
index
] = "$(inputs._iwdr_listing_{}".format(
index
iwdr.listing[index] = (
"$(inputs._iwdr_listing_{}".format(
index
)
)
generated_iwdr_reqs.append(
(etool_id, index)
Expand Down Expand Up @@ -859,9 +865,9 @@ def process_workflow_reqs_and_hints(
None,
replace_etool,
)
iwdr.listing[
index
] = f"$(inputs._iwdr_listing_{index}"
iwdr.listing[index] = (
f"$(inputs._iwdr_listing_{index}"
)
generated_iwdr_reqs.append((etool_id, index))

elif entry.entryname:
Expand All @@ -885,9 +891,9 @@ def process_workflow_reqs_and_hints(
None,
replace_etool,
)
iwdr.listing[
index
] = f"$(inputs._iwdr_listing_{index}"
iwdr.listing[index] = (
f"$(inputs._iwdr_listing_{index}"
)
generated_iwdr_reqs.append((etool_id, index))
if generated_iwdr_reqs:
prop_reqs += (cwl.InitialWorkDirRequirement,)
Expand Down Expand Up @@ -1413,9 +1419,9 @@ def traverse_CommandLineTool(
inp.linkMerge = None
if replace_etool:
processes = [parent]
final_etool: Union[
cwl.CommandLineTool, cwl.ExpressionTool
] = etool_to_cltool(etool, find_expressionLib(processes))
final_etool: Union[cwl.CommandLineTool, cwl.ExpressionTool] = (
etool_to_cltool(etool, find_expressionLib(processes))
)
else:
final_etool = etool
etool_step = cwl.WorkflowStep(
Expand Down
56 changes: 31 additions & 25 deletions cwl_utils/cwl_v1_1_expression_refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,21 +353,27 @@ def generate_etool_from_expr(
cwl.WorkflowInputParameter(
id="self",
label=self_type.label if not isinstance(self_type, list) else None,
secondaryFiles=self_type.secondaryFiles
if not isinstance(self_type, list)
else None,
streamable=self_type.streamable
if not isinstance(self_type, list)
else None,
secondaryFiles=(
self_type.secondaryFiles
if not isinstance(self_type, list)
else None
),
streamable=(
self_type.streamable if not isinstance(self_type, list) else None
),
doc=self_type.doc if not isinstance(self_type, list) else None,
format=self_type.format if not isinstance(self_type, list) else None,
type_=new_type,
extension_fields=self_type.extension_fields
if not isinstance(self_type, list)
else None,
loadingOptions=self_type.loadingOptions
if not isinstance(self_type, list)
else None,
extension_fields=(
self_type.extension_fields
if not isinstance(self_type, list)
else None
),
loadingOptions=(
self_type.loadingOptions
if not isinstance(self_type, list)
else None
),
)
)
outputs = yaml.comments.CommentedSeq()
Expand Down Expand Up @@ -818,10 +824,10 @@ def process_workflow_reqs_and_hints(
None,
replace_etool,
)
iwdr.listing[
index
] = "$(inputs._iwdr_listing_{}".format(
index
iwdr.listing[index] = (
"$(inputs._iwdr_listing_{}".format(
index
)
)
generated_iwdr_reqs.append(
(etool_id, index)
Expand Down Expand Up @@ -859,9 +865,9 @@ def process_workflow_reqs_and_hints(
None,
replace_etool,
)
iwdr.listing[
index
] = f"$(inputs._iwdr_listing_{index}"
iwdr.listing[index] = (
f"$(inputs._iwdr_listing_{index}"
)
generated_iwdr_reqs.append((etool_id, index))

elif entry.entryname:
Expand All @@ -885,9 +891,9 @@ def process_workflow_reqs_and_hints(
None,
replace_etool,
)
iwdr.listing[
index
] = f"$(inputs._iwdr_listing_{index}"
iwdr.listing[index] = (
f"$(inputs._iwdr_listing_{index}"
)
generated_iwdr_reqs.append((etool_id, index))
if generated_iwdr_reqs:
prop_reqs += (cwl.InitialWorkDirRequirement,)
Expand Down Expand Up @@ -1413,9 +1419,9 @@ def traverse_CommandLineTool(
inp.linkMerge = None
if replace_etool:
processes = [parent]
final_etool: Union[
cwl.CommandLineTool, cwl.ExpressionTool
] = etool_to_cltool(etool, find_expressionLib(processes))
final_etool: Union[cwl.CommandLineTool, cwl.ExpressionTool] = (
etool_to_cltool(etool, find_expressionLib(processes))
)
else:
final_etool = etool
etool_step = cwl.WorkflowStep(
Expand Down
56 changes: 31 additions & 25 deletions cwl_utils/cwl_v1_2_expression_refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,21 +353,27 @@ def generate_etool_from_expr(
cwl.WorkflowInputParameter(
id="self",
label=self_type.label if not isinstance(self_type, list) else None,
secondaryFiles=self_type.secondaryFiles
if not isinstance(self_type, list)
else None,
streamable=self_type.streamable
if not isinstance(self_type, list)
else None,
secondaryFiles=(
self_type.secondaryFiles
if not isinstance(self_type, list)
else None
),
streamable=(
self_type.streamable if not isinstance(self_type, list) else None
),
doc=self_type.doc if not isinstance(self_type, list) else None,
format=self_type.format if not isinstance(self_type, list) else None,
type_=new_type,
extension_fields=self_type.extension_fields
if not isinstance(self_type, list)
else None,
loadingOptions=self_type.loadingOptions
if not isinstance(self_type, list)
else None,
extension_fields=(
self_type.extension_fields
if not isinstance(self_type, list)
else None
),
loadingOptions=(
self_type.loadingOptions
if not isinstance(self_type, list)
else None
),
)
)
outputs = yaml.comments.CommentedSeq()
Expand Down Expand Up @@ -913,10 +919,10 @@ def process_workflow_reqs_and_hints(
None,
replace_etool,
)
iwdr.listing[
index
] = "$(inputs._iwdr_listing_{}".format(
index
iwdr.listing[index] = (
"$(inputs._iwdr_listing_{}".format(
index
)
)
generated_iwdr_reqs.append(
(etool_id, index)
Expand Down Expand Up @@ -954,9 +960,9 @@ def process_workflow_reqs_and_hints(
None,
replace_etool,
)
iwdr.listing[
index
] = f"$(inputs._iwdr_listing_{index}"
iwdr.listing[index] = (
f"$(inputs._iwdr_listing_{index}"
)
generated_iwdr_reqs.append((etool_id, index))

elif entry.entryname:
Expand All @@ -980,9 +986,9 @@ def process_workflow_reqs_and_hints(
None,
replace_etool,
)
iwdr.listing[
index
] = f"$(inputs._iwdr_listing_{index}"
iwdr.listing[index] = (
f"$(inputs._iwdr_listing_{index}"
)
generated_iwdr_reqs.append((etool_id, index))
if generated_iwdr_reqs:
prop_reqs += (cwl.InitialWorkDirRequirement,)
Expand Down Expand Up @@ -1508,9 +1514,9 @@ def traverse_CommandLineTool(
inp.linkMerge = None
if replace_etool:
processes = [parent]
final_etool: Union[
cwl.CommandLineTool, cwl.ExpressionTool
] = etool_to_cltool(etool, find_expressionLib(processes))
final_etool: Union[cwl.CommandLineTool, cwl.ExpressionTool] = (
etool_to_cltool(etool, find_expressionLib(processes))
)
else:
final_etool = etool
etool_step = cwl.WorkflowStep(
Expand Down
16 changes: 10 additions & 6 deletions cwl_utils/docker_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,22 @@ def run(args: argparse.Namespace) -> List[cwl.DockerRequirement]:
image_puller: ImagePuller = SingularityImagePuller(
req.dockerPull,
args.dir,
args.container_engine
if args.container_engine is not None
else "singularity",
(
args.container_engine
if args.container_engine is not None
else "singularity"
),
args.force_download,
)
else:
image_puller = DockerImagePuller(
req.dockerPull,
args.dir,
args.container_engine
if args.container_engine is not None
else "docker",
(
args.container_engine
if args.container_engine is not None
else "docker"
),
args.force_download,
)
image_puller.save_docker_image()
Expand Down
24 changes: 13 additions & 11 deletions cwl_utils/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,19 @@ def do_eval(
fullJS=fullJS,
jslib=jslib,
strip_whitespace=strip_whitespace,
escaping_behavior=1
if cwlVersion
in (
"v1.0",
"v1.1.0-dev1",
"v1.1",
"v1.2.0-dev1",
"v1.2.0-dev2",
"v1.2.0-dev3",
)
else 2,
escaping_behavior=(
1
if cwlVersion
in (
"v1.0",
"v1.1.0-dev1",
"v1.1",
"v1.2.0-dev1",
"v1.2.0-dev2",
"v1.2.0-dev3",
)
else 2
),
**kwargs,
)

Expand Down
14 changes: 8 additions & 6 deletions cwl_utils/expression_refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ def refactor(args: argparse.Namespace) -> int:
uri = Path(document).resolve().as_uri()
if version == "v1.0":
top = cwl_v1_0.load_document_by_yaml(result, uri)
traverse: Callable[
[Any, bool, bool, bool, bool], Tuple[Any, bool]
] = cwl_v1_0_expression_refactor.traverse
traverse: Callable[[Any, bool, bool, bool, bool], Tuple[Any, bool]] = (
cwl_v1_0_expression_refactor.traverse
)
save: saveCWL = cwl_v1_0.save
elif version == "v1.1":
top = cwl_v1_1.load_document_by_yaml(result, uri)
Expand Down Expand Up @@ -152,9 +152,11 @@ def refactor(args: argparse.Namespace) -> int:
if not isinstance(result, MutableSequence):
result_json = save(
result,
base_url=result.loadingOptions.fileuri
if result.loadingOptions.fileuri
else "",
base_url=(
result.loadingOptions.fileuri
if result.loadingOptions.fileuri
else ""
),
)
# ^^ Setting the base_url and keeping the default value
# for relative_uris=True means that the IDs in the generated
Expand Down
Loading

0 comments on commit e3f0704

Please sign in to comment.