Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
matrix:
py-ver-major: [3]
py-ver-minor: [9, 10, 11, 12, 13, 14]
py-ver-minor: [10, 11, 12, 13, 14]
step: [lint, unit, bandit, mypy]

env:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Style guide:
- PEP-8 (as implemented by the `black` code formatting tool)
- Python 3.8+ compatible code
- Python 3.10+ compatible code
- PEP-484 type hints

The development is done using `git`, we encourage you to get familiar with it.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ shellcheck: FORCE
cwltool-in-docker.sh

pyupgrade: $(PYSOURCES)
pyupgrade --exit-zero-even-if-changed --py39-plus $^
pyupgrade --exit-zero-even-if-changed --py310-plus $^
auto-walrus $^

release-test: FORCE
Expand Down
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ executor
::

executor(tool, job_order_object, runtimeContext, logger)
(Process, Dict[Text, Any], RuntimeContext) -> Tuple[Dict[Text, Any], Text]
(Process, Dict[str, Any], RuntimeContext) -> Tuple[Dict[str, Any], str]

An implementation of the top-level workflow execution loop should
synchronously run a process object to completion and return the
Expand All @@ -852,7 +852,7 @@ versionfunc
::

()
() -> Text
() -> str

Return version string.

Expand All @@ -879,7 +879,7 @@ resolver
::

resolver(document_loader, document)
(Loader, Union[Text, dict[Text, Any]]) -> Text
(Loader, str | dict[str, Any]) -> str

Resolve a relative document identifier to an absolute one that can be fetched.

Expand All @@ -890,23 +890,23 @@ construct_tool_object
::

construct_tool_object(toolpath_object, loadingContext)
(MutableMapping[Text, Any], LoadingContext) -> Process
(MutableMapping[str, Any], LoadingContext) -> Process

Hook to construct a Process object (eg CommandLineTool) object from a document.

select_resources
::

selectResources(request)
(Dict[str, int], RuntimeContext) -> Dict[Text, int]
(Dict[str, int], RuntimeContext) -> Dict[str, int]

Take a resource request and turn it into a concrete resource assignment.

make_fs_access
::

make_fs_access(basedir)
(Text) -> StdFsAccess
(str) -> StdFsAccess

Return a file system access object.

Expand All @@ -924,6 +924,6 @@ Workflow.make_workflow_step
::

make_workflow_step(toolpath_object, pos, loadingContext, parentworkflowProv)
(Dict[Text, Any], int, LoadingContext, Optional[ProvenanceProfile]) -> WorkflowStep
(Dict[str, Any], int, LoadingContext, Optional[ProvenanceProfile]) -> WorkflowStep

Create and return a workflow step object.
120 changes: 58 additions & 62 deletions cwltool/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import argparse
import os
import urllib
from collections.abc import MutableMapping, MutableSequence, Sequence
from typing import Any, Callable, Optional, Union, cast
from collections.abc import Callable, MutableSequence, Sequence
from typing import Any, cast

import rich.markup
from rich_argparse import HelpPreviewAction, RichHelpFormatter
Expand Down Expand Up @@ -732,7 +732,7 @@ def get_default_args() -> dict[str, Any]:
class FSAction(argparse.Action):
"""Base action for our custom actions."""

objclass: Optional[str] = None
objclass: str | None = None

def __init__(
self,
Expand All @@ -754,8 +754,8 @@ def __call__(
self,
parser: argparse.ArgumentParser,
namespace: argparse.Namespace,
values: Union[str, Sequence[Any], None],
option_string: Optional[str] = None,
values: str | Sequence[Any] | None,
option_string: str | None = None,
) -> None:
setattr(
namespace,
Expand All @@ -770,7 +770,7 @@ def __call__(
class FSAppendAction(argparse.Action):
"""Appending version of the base action for our custom actions."""

objclass: Optional[str] = None
objclass: str | None = None

def __init__(
self,
Expand All @@ -792,8 +792,8 @@ def __call__(
self,
parser: argparse.ArgumentParser,
namespace: argparse.Namespace,
values: Union[str, Sequence[Any], None],
option_string: Optional[str] = None,
values: str | Sequence[Any] | None,
option_string: str | None = None,
) -> None:
g = getattr(namespace, self.dest)
if not g:
Expand All @@ -808,19 +808,19 @@ def __call__(


class FileAction(FSAction):
objclass: Optional[str] = "File"
objclass: str | None = "File"


class DirectoryAction(FSAction):
objclass: Optional[str] = "Directory"
objclass: str | None = "Directory"


class FileAppendAction(FSAppendAction):
objclass: Optional[str] = "File"
objclass: str | None = "File"


class DirectoryAppendAction(FSAppendAction):
objclass: Optional[str] = "Directory"
objclass: str | None = "Directory"


class AppendAction(argparse.Action):
Expand All @@ -844,8 +844,8 @@ def __call__(
self,
parser: argparse.ArgumentParser,
namespace: argparse.Namespace,
values: Union[str, Sequence[Any], None],
option_string: Optional[str] = None,
values: str | Sequence[Any] | None,
option_string: str | None = None,
) -> None:
g = getattr(namespace, self.dest, None)
if g is None:
Expand Down Expand Up @@ -893,59 +893,55 @@ def add_argument(
return None

ahelp = description.replace("%", "%%")
action: Optional[Union[type[argparse.Action], str]] = None
atype: Optional[Any] = None
action: type[argparse.Action] | str | None = None
atype: Any | None = None
typekw: dict[str, Any] = {}

if inptype == "File":
action = FileAction
elif inptype == "Directory":
action = DirectoryAction
elif isinstance(inptype, MutableMapping) and inptype["type"] == "array":
if inptype["items"] == "File":
match inptype:
case "File":
action = FileAction
case "Directory":
action = DirectoryAction
case {"type": "array", "items": "File"}:
action = FileAppendAction
elif inptype["items"] == "Directory":
case {"type": "array", "items": "Directory"}:
action = DirectoryAppendAction
else:
case {"type": "array", "items": str(items)}:
action = AppendAction
items = inptype["items"]
if items == "int" or items == "long":
atype = int
elif items == "double" or items == "float":
atype = float
elif isinstance(inptype, MutableMapping) and inptype["type"] == "enum":
atype = str
elif isinstance(inptype, MutableMapping) and inptype["type"] == "record":
records.append(name)
for field in inptype["fields"]:
fieldname = name + "." + shortname(field["name"])
fieldtype = field["type"]
fielddescription = field.get("doc", "")
add_argument(
toolparser,
fieldname,
fieldtype,
records,
fielddescription,
default=default.get(shortname(field["name"]), None) if default else None,
input_required=required,
)
return
elif inptype == "string":
atype = str
elif inptype == "int":
atype = int
elif inptype == "long":
atype = int
elif inptype == "double":
atype = float
elif inptype == "float":
atype = float
elif inptype == "boolean":
action = "store_true"
else:
_logger.debug("Can't make command line argument from %s", inptype)
return None
match items:
case "int" | "long":
atype = int
case "double" | "float":
atype = float
case {"type": "enum"}:
atype = str
case {"type": "record", "fields": list(fields)}:
records.append(name)
for field in fields:
fieldname = name + "." + shortname(field["name"])
fieldtype = field["type"]
fielddescription = field.get("doc", "")
add_argument(
toolparser,
fieldname,
fieldtype,
records,
fielddescription,
default=default.get(shortname(field["name"]), None) if default else None,
input_required=required,
)
return
case "string":
atype = str
case "int" | "long":
atype = int
case "double" | "float":
atype = float
case "boolean":
action = "store_true"
case _:
_logger.debug("Can't make command line argument from %s", inptype)
return None

if action in (FileAction, DirectoryAction, FileAppendAction, DirectoryAppendAction):
typekw["urljoin"] = urljoin
Expand Down
Loading
Loading