Skip to content

Commit

Permalink
Drop Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Oct 15, 2024
1 parent 83def6a commit 05af6c1
Show file tree
Hide file tree
Showing 65 changed files with 541 additions and 778 deletions.
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: [8, 9, 10, 11, 12, 13]
py-ver-minor: [9, 10, 11, 12, 13]
step: [lint, unit, bandit, mypy]

env:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ MODULE=cwltool

# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
# `[[` conditional expressions.
PYSOURCES=$(wildcard ${MODULE}/**.py cwltool/cwlprov/*.py tests/*.py) setup.py
PYSOURCES=$(wildcard ${MODULE}/**.py cwltool/cwlprov/*.py tests/*.py tests/cwl-conformance/*.py) setup.py
DEVPKGS=diff_cover pylint pep257 pydocstyle 'tox<4' tox-pyenv auto-walrus \
isort wheel autoflake pyupgrade bandit -rlint-requirements.txt\
-rtest-requirements.txt -rmypy-requirements.txt -rdocs/requirements.txt
Expand Down Expand Up @@ -190,7 +190,7 @@ shellcheck: FORCE
cwltool-in-docker.sh

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

release-test: FORCE
Expand Down
33 changes: 11 additions & 22 deletions cwltool/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,8 @@
import argparse
import os
import urllib
from typing import (
Any,
Callable,
Dict,
List,
MutableMapping,
MutableSequence,
Optional,
Sequence,
Type,
Union,
cast,
)
from collections.abc import MutableMapping, MutableSequence, Sequence
from typing import Any, Callable, Optional, Union, cast

from .loghandler import _logger
from .process import Process, shortname
Expand Down Expand Up @@ -718,7 +707,7 @@ def arg_parser() -> argparse.ArgumentParser:
return parser


def get_default_args() -> Dict[str, Any]:
def get_default_args() -> dict[str, Any]:
"""Get default values of cwltool's command line options."""
ap = arg_parser()
args = ap.parse_args([])
Expand All @@ -732,7 +721,7 @@ class FSAction(argparse.Action):

def __init__(
self,
option_strings: List[str],
option_strings: list[str],
dest: str,
nargs: Any = None,
urljoin: Callable[[str, str], str] = urllib.parse.urljoin,
Expand Down Expand Up @@ -770,7 +759,7 @@ class FSAppendAction(argparse.Action):

def __init__(
self,
option_strings: List[str],
option_strings: list[str],
dest: str,
nargs: Any = None,
urljoin: Callable[[str, str], str] = urllib.parse.urljoin,
Expand Down Expand Up @@ -827,7 +816,7 @@ class AppendAction(argparse.Action):

def __init__(
self,
option_strings: List[str],
option_strings: list[str],
dest: str,
nargs: Any = None,
**kwargs: Any,
Expand Down Expand Up @@ -859,7 +848,7 @@ def add_argument(
toolparser: argparse.ArgumentParser,
name: str,
inptype: Any,
records: List[str],
records: list[str],
description: str = "",
default: Any = None,
input_required: bool = True,
Expand Down Expand Up @@ -888,9 +877,9 @@ def add_argument(
return None

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

if inptype == "File":
action = FileAction
Expand Down Expand Up @@ -962,8 +951,8 @@ def add_argument(
def generate_parser(
toolparser: argparse.ArgumentParser,
tool: Process,
namemap: Dict[str, str],
records: List[str],
namemap: dict[str, str],
records: list[str],
input_required: bool = True,
urljoin: Callable[[str, str], str] = urllib.parse.urljoin,
base_uri: str = "",
Expand Down
60 changes: 24 additions & 36 deletions cwltool/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,9 @@
import copy
import logging
import math
from collections.abc import MutableMapping, MutableSequence
from decimal import Decimal
from typing import (
IO,
TYPE_CHECKING,
Any,
Callable,
Dict,
List,
MutableMapping,
MutableSequence,
Optional,
Type,
Union,
cast,
)
from typing import IO, TYPE_CHECKING, Any, Callable, Optional, Union, cast

from cwl_utils import expression
from cwl_utils.file_formats import check_format
Expand Down Expand Up @@ -55,7 +43,7 @@
)
from .pathmapper import PathMapper

INPUT_OBJ_VOCAB: Dict[str, str] = {
INPUT_OBJ_VOCAB: dict[str, str] = {
"Any": "https://w3id.org/cwl/salad#Any",
"File": "https://w3id.org/cwl/cwl#File",
"Directory": "https://w3id.org/cwl/cwl#Directory",
Expand Down Expand Up @@ -107,16 +95,16 @@ class Builder(HasReqsHints):
def __init__(
self,
job: CWLObjectType,
files: List[CWLObjectType],
bindings: List[CWLObjectType],
files: list[CWLObjectType],
bindings: list[CWLObjectType],
schemaDefs: MutableMapping[str, CWLObjectType],
names: Names,
requirements: List[CWLObjectType],
hints: List[CWLObjectType],
resources: Dict[str, Union[int, float]],
requirements: list[CWLObjectType],
hints: list[CWLObjectType],
resources: dict[str, Union[int, float]],
mutation_manager: Optional[MutationManager],
formatgraph: Optional[Graph],
make_fs_access: Type[StdFsAccess],
make_fs_access: type[StdFsAccess],
fs_access: StdFsAccess,
job_script_provider: Optional[DependenciesConfiguration],
timeout: float,
Expand Down Expand Up @@ -172,19 +160,19 @@ def __init__(
self.find_default_container: Optional[Callable[[], str]] = None
self.container_engine = container_engine

def build_job_script(self, commands: List[str]) -> Optional[str]:
def build_job_script(self, commands: list[str]) -> Optional[str]:
if self.job_script_provider is not None:
return self.job_script_provider.build_job_script(self, commands)
return None

def bind_input(
self,
schema: CWLObjectType,
datum: Union[CWLObjectType, List[CWLObjectType]],
datum: Union[CWLObjectType, list[CWLObjectType]],
discover_secondaryFiles: bool,
lead_pos: Optional[Union[int, List[int]]] = None,
tail_pos: Optional[Union[str, List[int]]] = None,
) -> List[MutableMapping[str, Union[str, List[int]]]]:
lead_pos: Optional[Union[int, list[int]]] = None,
tail_pos: Optional[Union[str, list[int]]] = None,
) -> list[MutableMapping[str, Union[str, list[int]]]]:
"""
Bind an input object to the command line.
Expand All @@ -200,8 +188,8 @@ def bind_input(
if lead_pos is None:
lead_pos = []

bindings: List[MutableMapping[str, Union[str, List[int]]]] = []
binding: Union[MutableMapping[str, Union[str, List[int]]], CommentedMap] = {}
bindings: list[MutableMapping[str, Union[str, list[int]]]] = []
binding: Union[MutableMapping[str, Union[str, list[int]]], CommentedMap] = {}
value_from_expression = False
if "inputBinding" in schema and isinstance(schema["inputBinding"], MutableMapping):
binding = CommentedMap(schema["inputBinding"].items())
Expand Down Expand Up @@ -324,7 +312,7 @@ def bind_input(

if schema["type"] == "record":
datum = cast(CWLObjectType, datum)
for f in cast(List[CWLObjectType], schema["fields"]):
for f in cast(list[CWLObjectType], schema["fields"]):
name = cast(str, f["name"])
if name in datum and datum[name] is not None:
bindings.extend(
Expand Down Expand Up @@ -372,7 +360,7 @@ def _capture_files(f: CWLObjectType) -> CWLObjectType:
self.files.append(datum)

loadContents_sourceline: Union[
None, MutableMapping[str, Union[str, List[int]]], CWLObjectType
None, MutableMapping[str, Union[str, list[int]]], CWLObjectType
] = None
if binding and binding.get("loadContents"):
loadContents_sourceline = binding
Expand Down Expand Up @@ -513,7 +501,7 @@ def addsf(
if "format" in schema:
eval_format: Any = self.do_eval(schema["format"])
if isinstance(eval_format, str):
evaluated_format: Union[str, List[str]] = eval_format
evaluated_format: Union[str, list[str]] = eval_format
elif isinstance(eval_format, MutableSequence):
for index, entry in enumerate(eval_format):
message = None
Expand Down Expand Up @@ -541,7 +529,7 @@ def addsf(
raise SourceLine(
schema["format"], index, WorkflowException, debug
).makeError(message)
evaluated_format = cast(List[str], eval_format)
evaluated_format = cast(list[str], eval_format)
else:
raise SourceLine(schema, "format", WorkflowException, debug).makeError(
"An expression in the 'format' field must "
Expand Down Expand Up @@ -586,8 +574,8 @@ def addsf(
# Position to front of the sort key
if binding:
for bi in bindings:
bi["position"] = cast(List[int], binding["position"]) + cast(
List[int], bi["position"]
bi["position"] = cast(list[int], binding["position"]) + cast(
list[int], bi["position"]
)
bindings.append(binding)

Expand Down Expand Up @@ -618,7 +606,7 @@ def tostr(self, value: Union[MutableMapping[str, str], Any]) -> str:
else:
return str(value)

def generate_arg(self, binding: CWLObjectType) -> List[str]:
def generate_arg(self, binding: CWLObjectType) -> list[str]:
value = binding.get("datum")
debug = _logger.isEnabledFor(logging.DEBUG)
if "valueFrom" in binding:
Expand Down Expand Up @@ -648,7 +636,7 @@ def generate_arg(self, binding: CWLObjectType) -> List[str]:
argl = [itemSeparator.join([self.tostr(v) for v in value])]
elif binding.get("valueFrom"):
value = [self.tostr(v) for v in value]
return cast(List[str], ([prefix] if prefix else [])) + cast(List[str], value)
return cast(list[str], ([prefix] if prefix else [])) + cast(list[str], value)
elif prefix and value:
return [prefix]
else:
Expand Down
Loading

0 comments on commit 05af6c1

Please sign in to comment.