Skip to content

Commit 54c853e

Browse files
committed
Drop support for Python 3.9
1 parent 22bc7d8 commit 54c853e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+736
-752
lines changed

.github/workflows/ci-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
matrix:
3434
py-ver-major: [3]
35-
py-ver-minor: [9, 10, 11, 12, 13, 14]
35+
py-ver-minor: [10, 11, 12, 13, 14]
3636
step: [lint, unit, bandit, mypy]
3737

3838
env:

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Style guide:
22
- PEP-8 (as implemented by the `black` code formatting tool)
3-
- Python 3.8+ compatible code
3+
- Python 3.10+ compatible code
44
- PEP-484 type hints
55

66
The development is done using `git`, we encourage you to get familiar with it.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ shellcheck: FORCE
190190
cwltool-in-docker.sh
191191

192192
pyupgrade: $(PYSOURCES)
193-
pyupgrade --exit-zero-even-if-changed --py39-plus $^
193+
pyupgrade --exit-zero-even-if-changed --py310-plus $^
194194
auto-walrus $^
195195

196196
release-test: FORCE

README.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ executor
842842
::
843843

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

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

854854
()
855-
() -> Text
855+
() -> str
856856

857857
Return version string.
858858

@@ -879,7 +879,7 @@ resolver
879879
::
880880

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

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

@@ -890,23 +890,23 @@ construct_tool_object
890890
::
891891

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

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

897897
select_resources
898898
::
899899

900900
selectResources(request)
901-
(Dict[str, int], RuntimeContext) -> Dict[Text, int]
901+
(Dict[str, int], RuntimeContext) -> Dict[str, int]
902902

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

905905
make_fs_access
906906
::
907907

908908
make_fs_access(basedir)
909-
(Text) -> StdFsAccess
909+
(str) -> StdFsAccess
910910

911911
Return a file system access object.
912912

@@ -924,6 +924,6 @@ Workflow.make_workflow_step
924924
::
925925

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

929929
Create and return a workflow step object.

cwltool/argparser.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import argparse
44
import os
55
import urllib
6-
from collections.abc import MutableMapping, MutableSequence, Sequence
7-
from typing import Any, Callable, Optional, Union, cast
6+
from collections.abc import Callable, MutableMapping, MutableSequence, Sequence
7+
from typing import Any, cast
88

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

735-
objclass: Optional[str] = None
735+
objclass: str | None = None
736736

737737
def __init__(
738738
self,
@@ -754,8 +754,8 @@ def __call__(
754754
self,
755755
parser: argparse.ArgumentParser,
756756
namespace: argparse.Namespace,
757-
values: Union[str, Sequence[Any], None],
758-
option_string: Optional[str] = None,
757+
values: str | Sequence[Any] | None,
758+
option_string: str | None = None,
759759
) -> None:
760760
setattr(
761761
namespace,
@@ -770,7 +770,7 @@ def __call__(
770770
class FSAppendAction(argparse.Action):
771771
"""Appending version of the base action for our custom actions."""
772772

773-
objclass: Optional[str] = None
773+
objclass: str | None = None
774774

775775
def __init__(
776776
self,
@@ -792,8 +792,8 @@ def __call__(
792792
self,
793793
parser: argparse.ArgumentParser,
794794
namespace: argparse.Namespace,
795-
values: Union[str, Sequence[Any], None],
796-
option_string: Optional[str] = None,
795+
values: str | Sequence[Any] | None,
796+
option_string: str | None = None,
797797
) -> None:
798798
g = getattr(namespace, self.dest)
799799
if not g:
@@ -808,19 +808,19 @@ def __call__(
808808

809809

810810
class FileAction(FSAction):
811-
objclass: Optional[str] = "File"
811+
objclass: str | None = "File"
812812

813813

814814
class DirectoryAction(FSAction):
815-
objclass: Optional[str] = "Directory"
815+
objclass: str | None = "Directory"
816816

817817

818818
class FileAppendAction(FSAppendAction):
819-
objclass: Optional[str] = "File"
819+
objclass: str | None = "File"
820820

821821

822822
class DirectoryAppendAction(FSAppendAction):
823-
objclass: Optional[str] = "Directory"
823+
objclass: str | None = "Directory"
824824

825825

826826
class AppendAction(argparse.Action):
@@ -844,8 +844,8 @@ def __call__(
844844
self,
845845
parser: argparse.ArgumentParser,
846846
namespace: argparse.Namespace,
847-
values: Union[str, Sequence[Any], None],
848-
option_string: Optional[str] = None,
847+
values: str | Sequence[Any] | None,
848+
option_string: str | None = None,
849849
) -> None:
850850
g = getattr(namespace, self.dest, None)
851851
if g is None:
@@ -893,8 +893,8 @@ def add_argument(
893893
return None
894894

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

900900
if inptype == "File":

cwltool/builder.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import copy
44
import logging
55
import math
6-
from collections.abc import MutableMapping, MutableSequence
6+
from collections.abc import Callable, MutableMapping, MutableSequence
77
from decimal import Decimal
8-
from typing import IO, TYPE_CHECKING, Any, Callable, Optional, Union, cast
8+
from typing import IO, TYPE_CHECKING, Any, Optional, cast
99

1010
from cwl_utils import expression
1111
from cwl_utils.file_formats import check_format
@@ -101,9 +101,9 @@ def __init__(
101101
names: Names,
102102
requirements: list[CWLObjectType],
103103
hints: list[CWLObjectType],
104-
resources: dict[str, Union[int, float]],
105-
mutation_manager: Optional[MutationManager],
106-
formatgraph: Optional[Graph],
104+
resources: dict[str, int | float],
105+
mutation_manager: MutationManager | None,
106+
formatgraph: Graph | None,
107107
make_fs_access: type[StdFsAccess],
108108
fs_access: StdFsAccess,
109109
job_script_provider: Optional["DependenciesConfiguration"],
@@ -157,10 +157,10 @@ def __init__(
157157

158158
self.pathmapper: Optional["PathMapper"] = None
159159
self.prov_obj: Optional["ProvenanceProfile"] = None
160-
self.find_default_container: Optional[Callable[[], str]] = None
160+
self.find_default_container: Callable[[], str] | None = None
161161
self.container_engine = container_engine
162162

163-
def build_job_script(self, commands: list[str]) -> Optional[str]:
163+
def build_job_script(self, commands: list[str]) -> str | None:
164164
"""Use the job_script_provider to turn the commands into a job script."""
165165
if self.job_script_provider is not None:
166166
return self.job_script_provider.build_job_script(self, commands)
@@ -169,11 +169,11 @@ def build_job_script(self, commands: list[str]) -> Optional[str]:
169169
def bind_input(
170170
self,
171171
schema: CWLObjectType,
172-
datum: Union[CWLObjectType, list[CWLObjectType]],
172+
datum: CWLObjectType | list[CWLObjectType],
173173
discover_secondaryFiles: bool,
174-
lead_pos: Optional[Union[int, list[int]]] = None,
175-
tail_pos: Optional[Union[str, list[int]]] = None,
176-
) -> list[MutableMapping[str, Union[str, list[int]]]]:
174+
lead_pos: int | list[int] | None = None,
175+
tail_pos: str | list[int] | None = None,
176+
) -> list[MutableMapping[str, str | list[int]]]:
177177
"""
178178
Bind an input object to the command line.
179179
@@ -189,8 +189,8 @@ def bind_input(
189189
if lead_pos is None:
190190
lead_pos = []
191191

192-
bindings: list[MutableMapping[str, Union[str, list[int]]]] = []
193-
binding: Union[MutableMapping[str, Union[str, list[int]]], CommentedMap] = {}
192+
bindings: list[MutableMapping[str, str | list[int]]] = []
193+
binding: MutableMapping[str, str | list[int]] | CommentedMap = {}
194194
value_from_expression = False
195195
if "inputBinding" in schema and isinstance(schema["inputBinding"], MutableMapping):
196196
binding = CommentedMap(schema["inputBinding"].items())
@@ -226,7 +226,7 @@ def bind_input(
226226
if isinstance(schema["type"], MutableSequence):
227227
bound_input = False
228228
for t in schema["type"]:
229-
avsc: Optional[Schema] = None
229+
avsc: Schema | None = None
230230
if isinstance(t, str) and self.names.has_name(t, None):
231231
avsc = self.names.get_name(t, None)
232232
elif (
@@ -360,9 +360,9 @@ def _capture_files(f: CWLObjectType) -> CWLObjectType:
360360
datum = cast(CWLObjectType, datum)
361361
self.files.append(datum)
362362

363-
loadContents_sourceline: Union[
364-
None, MutableMapping[str, Union[str, list[int]]], CWLObjectType
365-
] = None
363+
loadContents_sourceline: (
364+
None | MutableMapping[str, str | list[int]] | CWLObjectType
365+
) = None
366366
if binding and binding.get("loadContents"):
367367
loadContents_sourceline = binding
368368
elif schema.get("loadContents"):
@@ -502,7 +502,7 @@ def addsf(
502502
if "format" in schema:
503503
eval_format: Any = self.do_eval(schema["format"])
504504
if isinstance(eval_format, str):
505-
evaluated_format: Union[str, list[str]] = eval_format
505+
evaluated_format: str | list[str] = eval_format
506506
elif isinstance(eval_format, MutableSequence):
507507
for index, entry in enumerate(eval_format):
508508
message = None
@@ -582,7 +582,7 @@ def addsf(
582582

583583
return bindings
584584

585-
def tostr(self, value: Union[MutableMapping[str, str], Any]) -> str:
585+
def tostr(self, value: MutableMapping[str, str] | Any) -> str:
586586
"""
587587
Represent an input parameter as a string.
588588
@@ -668,11 +668,11 @@ def generate_arg(self, binding: CWLObjectType) -> list[str]:
668668

669669
def do_eval(
670670
self,
671-
ex: Optional[CWLOutputType],
672-
context: Optional[Any] = None,
671+
ex: CWLOutputType | None,
672+
context: Any | None = None,
673673
recursive: bool = False,
674674
strip_whitespace: bool = True,
675-
) -> Optional[CWLOutputType]:
675+
) -> CWLOutputType | None:
676676
if recursive:
677677
if isinstance(ex, MutableMapping):
678678
return {k: self.do_eval(v, context, recursive) for k, v in ex.items()}

cwltool/checker.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def _get_type(tp: Any) -> Any:
2323
def check_types(
2424
srctype: SinkType,
2525
sinktype: SinkType,
26-
linkMerge: Optional[str],
27-
valueFrom: Optional[str],
28-
) -> Union[Literal["pass"], Literal["warning"], Literal["exception"]]:
26+
linkMerge: str | None,
27+
valueFrom: str | None,
28+
) -> Literal["pass"] | Literal["warning"] | Literal["exception"]:
2929
"""
3030
Check if the source and sink types are correct.
3131
@@ -60,7 +60,7 @@ def merge_flatten_type(src: SinkType) -> CWLOutputType:
6060
return {"items": src, "type": "array"}
6161

6262

63-
def can_assign_src_to_sink(src: SinkType, sink: Optional[SinkType], strict: bool = False) -> bool:
63+
def can_assign_src_to_sink(src: SinkType, sink: SinkType | None, strict: bool = False) -> bool:
6464
"""
6565
Check for identical type specifications, ignoring extra keys like inputBinding.
6666
@@ -322,14 +322,14 @@ class _SrcSink(NamedTuple):
322322

323323
src: CWLObjectType
324324
sink: CWLObjectType
325-
linkMerge: Optional[str]
326-
message: Optional[str]
325+
linkMerge: str | None
326+
message: str | None
327327

328328

329329
def _check_all_types(
330330
src_dict: dict[str, CWLObjectType],
331331
sinks: MutableSequence[CWLObjectType],
332-
sourceField: Union[Literal["source"], Literal["outputSource"]],
332+
sourceField: Literal["source"] | Literal["outputSource"],
333333
param_to_step: dict[str, CWLObjectType],
334334
) -> dict[str, list[_SrcSink]]:
335335
"""
@@ -350,7 +350,7 @@ def _check_all_types(
350350
extra_message = "pickValue is: %s" % pickValue
351351

352352
if isinstance(sink[sourceField], MutableSequence):
353-
linkMerge: Optional[str] = cast(
353+
linkMerge: str | None = cast(
354354
Optional[str],
355355
sink.get(
356356
"linkMerge",
@@ -518,7 +518,7 @@ def is_conditional_step(param_to_step: dict[str, CWLObjectType], parm_id: str) -
518518

519519
def is_all_output_method_loop_step(param_to_step: dict[str, CWLObjectType], parm_id: str) -> bool:
520520
"""Check if a step contains a `loop` directive with `all_iterations` outputMethod."""
521-
source_step: Optional[MutableMapping[str, Any]] = param_to_step.get(parm_id)
521+
source_step: MutableMapping[str, Any] | None = param_to_step.get(parm_id)
522522
if source_step is not None:
523523
if (
524524
source_step.get("loop") is not None

0 commit comments

Comments
 (0)