Skip to content

Commit a8113b1

Browse files
committed
Drop support for Python 3.8
miscellaneous formatting & pyupgrade
1 parent e4b0d02 commit a8113b1

File tree

15 files changed

+131
-166
lines changed

15 files changed

+131
-166
lines changed

.github/workflows/ci-tests.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ jobs:
2222
matrix:
2323
# The README.rst file mentions the versions tested, please update it as well
2424
py-ver-major: [3]
25-
py-ver-minor: [8, 9, 10, 11, 12, 13]
25+
py-ver-minor: [9, 10, 11, 12, 13]
2626
step: [lint, unit, mypy, bandit]
27-
exclude:
28-
- step: mypy
29-
py-ver-minor: 8
3027

3128
env:
3229
py-semver: ${{ format('{0}.{1}', matrix.py-ver-major, matrix.py-ver-minor) }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ mypy: $(PYSOURCES)
168168
MYPYPATH=$$MYPYPATH:mypy-stubs mypy $^
169169

170170
pyupgrade: $(filter-out schema_salad/metaschema.py,$(PYSOURCES))
171-
pyupgrade --exit-zero-even-if-changed --py38-plus $^
171+
pyupgrade --exit-zero-even-if-changed --py39-plus $^
172172
auto-walrus $^
173173

174174
release-test: FORCE

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This is a testing tool for checking the output of Tools and Workflows described
3232
with the Common Workflow Language. Among other uses, it is used to run the CWL
3333
conformance tests.
3434

35-
This is written and tested for Python 3.8, 3.9, 3.10, 3.11, 3.12, and 3.13.
35+
This is written and tested for Python 3.9, 3.10, 3.11, 3.12, and 3.13.
3636

3737
.. contents:: Table of Contents
3838
:local:

cwltest/compare.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import hashlib
44
import json
5-
from typing import Any, Callable, Dict, Optional, Set
5+
from typing import Any, Callable, Optional
6+
67
import cwltest.stdfsaccess
78

89
fs_access = cwltest.stdfsaccess.StdFsAccess("")
@@ -26,7 +27,7 @@ def format(
2627

2728

2829
def _check_keys(
29-
keys: Set[str], expected: Dict[str, Any], actual: Dict[str, Any], skip_details: bool
30+
keys: set[str], expected: dict[str, Any], actual: dict[str, Any], skip_details: bool
3031
) -> None:
3132
for k in keys:
3233
try:
@@ -37,7 +38,7 @@ def _check_keys(
3738
) from e
3839

3940

40-
def _compare_contents(expected: Dict[str, Any], actual: Dict[str, Any]) -> None:
41+
def _compare_contents(expected: dict[str, Any], actual: dict[str, Any]) -> None:
4142
with open(actual["path"]) as f:
4243
actual_contents = f.read()
4344
if (expected_contents := expected["contents"]) != actual_contents:
@@ -52,7 +53,7 @@ def _compare_contents(expected: Dict[str, Any], actual: Dict[str, Any]) -> None:
5253

5354

5455
def _compare_dict(
55-
expected: Dict[str, Any], actual: Dict[str, Any], skip_details: bool
56+
expected: dict[str, Any], actual: dict[str, Any], skip_details: bool
5657
) -> None:
5758
for c in expected:
5859
try:
@@ -68,7 +69,7 @@ def _compare_dict(
6869

6970

7071
def _compare_directory(
71-
expected: Dict[str, Any], actual: Dict[str, Any], skip_details: bool
72+
expected: dict[str, Any], actual: dict[str, Any], skip_details: bool
7273
) -> None:
7374
if actual.get("class") != "Directory":
7475
raise CompareFail.format(
@@ -97,7 +98,7 @@ def _compare_directory(
9798

9899

99100
def _compare_file(
100-
expected: Dict[str, Any], actual: Dict[str, Any], skip_details: bool
101+
expected: dict[str, Any], actual: dict[str, Any], skip_details: bool
101102
) -> None:
102103
_compare_location(expected, actual, skip_details)
103104
if "contents" in expected:
@@ -117,7 +118,7 @@ def _compare_file(
117118

118119

119120
def _compare_location(
120-
expected: Dict[str, Any], actual: Dict[str, Any], skip_details: bool
121+
expected: dict[str, Any], actual: dict[str, Any], skip_details: bool
121122
) -> None:
122123
if "path" in expected:
123124
expected_comp = "path"
@@ -160,7 +161,7 @@ def _compare_location(
160161
)
161162

162163

163-
def _compare_checksum(expected: Dict[str, Any], actual: Dict[str, Any]) -> None:
164+
def _compare_checksum(expected: dict[str, Any], actual: dict[str, Any]) -> None:
164165
if "path" in actual:
165166
path = actual["path"]
166167
else:
@@ -195,7 +196,7 @@ def _compare_checksum(expected: Dict[str, Any], actual: Dict[str, Any]) -> None:
195196
)
196197

197198

198-
def _compare_size(expected: Dict[str, Any], actual: Dict[str, Any]) -> None:
199+
def _compare_size(expected: dict[str, Any], actual: dict[str, Any]) -> None:
199200
if "path" in actual:
200201
path = actual["path"]
201202
else:

cwltest/hooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""Hooks for pytest-cwl users."""
22

3-
from typing import Any, Dict, Optional, Tuple
3+
from typing import Any, Optional
44

55
from cwltest import utils
66

77

88
def pytest_cwl_execute_test( # type: ignore[empty-body]
99
config: utils.CWLTestConfig, processfile: str, jobfile: Optional[str]
10-
) -> Tuple[int, Optional[Dict[str, Any]]]:
10+
) -> tuple[int, Optional[dict[str, Any]]]:
1111
"""
1212
Execute CWL test using a Python function instead of a command line runner.
1313

cwltest/main.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
import sys
77
from collections import Counter, defaultdict
88
from concurrent.futures import ThreadPoolExecutor
9-
from typing import Dict, List, Optional, Set, cast
9+
from typing import Optional, cast
1010

1111
import junit_xml
1212
import schema_salad.avro
1313
import schema_salad.ref_resolver
1414
import schema_salad.schema
15+
from schema_salad.exceptions import ValidationException
16+
17+
from cwltest import logger, utils
1518
from cwltest.argparser import arg_parser
1619
from cwltest.utils import (
1720
CWLTestConfig,
1821
CWLTestReport,
1922
TestResult,
2023
load_optional_fsaccess_plugin,
2124
)
22-
from schema_salad.exceptions import ValidationException
23-
24-
from cwltest import logger, utils
2525

2626
if sys.stderr.isatty():
2727
PREFIX = "\r"
@@ -33,7 +33,7 @@
3333

3434
def _run_test(
3535
args: argparse.Namespace,
36-
test: Dict[str, str],
36+
test: dict[str, str],
3737
test_number: int,
3838
total_tests: int,
3939
) -> TestResult:
@@ -78,8 +78,8 @@ def _run_test(
7878
return utils.run_test_plain(config, test, test_number)
7979

8080

81-
def _expand_number_range(nr: str) -> List[int]:
82-
result: List[int] = []
81+
def _expand_number_range(nr: str) -> list[int]:
82+
result: list[int] = []
8383
for s in nr.split(","):
8484
sp = s.split("-")
8585
if len(sp) == 2:
@@ -123,8 +123,8 @@ def main() -> int:
123123

124124
load_optional_fsaccess_plugin()
125125

126-
ntotal: Dict[str, int] = Counter()
127-
npassed: Dict[str, List[CWLTestReport]] = defaultdict(list)
126+
ntotal: dict[str, int] = Counter()
127+
npassed: dict[str, list[CWLTestReport]] = defaultdict(list)
128128

129129
if args.only_tools:
130130
alltests = tests
@@ -161,7 +161,7 @@ def main() -> int:
161161
logger.warning("The `id` field is missing.")
162162

163163
if args.show_tags:
164-
alltags: Set[str] = set()
164+
alltags: set[str] = set()
165165
for t in tests:
166166
ts = t.get("tags", [])
167167
alltags |= set(ts)

cwltest/plugin.py

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,16 @@
55
import os
66
import time
77
import traceback
8+
from collections.abc import Iterator
89
from io import StringIO
910
from pathlib import Path
10-
from typing import (
11-
TYPE_CHECKING,
12-
Any,
13-
Dict,
14-
Iterator,
15-
List,
16-
Optional,
17-
Protocol,
18-
Set,
19-
Tuple,
20-
Union,
21-
cast,
22-
)
11+
from typing import TYPE_CHECKING, Any, Optional, Protocol, Union, cast
2312
from urllib.parse import urljoin
2413

2514
import pytest
26-
from cwltest.compare import CompareFail, compare
2715

2816
from cwltest import REQUIRED, UNSUPPORTED_FEATURE, logger, utils
17+
from cwltest.compare import CompareFail, compare
2918

3019
if TYPE_CHECKING:
3120
from _pytest._code.code import ExceptionInfo, TracebackStyle
@@ -42,12 +31,12 @@ class TestRunner(Protocol):
4231

4332
def __call__(
4433
self, config: utils.CWLTestConfig, processfile: str, jobfile: Optional[str]
45-
) -> List[Optional[Dict[str, Any]]]:
34+
) -> list[Optional[dict[str, Any]]]:
4635
"""Type signature for pytest_cwl_execute_test hook results."""
4736
...
4837

4938

50-
def _get_comma_separated_option(config: "Config", name: str) -> List[str]:
39+
def _get_comma_separated_option(config: "Config", name: str) -> list[str]:
5140
options = config.getoption(name)
5241
if options is None:
5342
return []
@@ -58,7 +47,7 @@ def _get_comma_separated_option(config: "Config", name: str) -> List[str]:
5847

5948

6049
def _run_test_hook_or_plain(
61-
test: Dict[str, str],
50+
test: dict[str, str],
6251
config: utils.CWLTestConfig,
6352
hook: "HookCaller",
6453
) -> utils.TestResult:
@@ -76,7 +65,7 @@ def _run_test_hook_or_plain(
7665
hook_out = hook(config=config, processfile=processfile, jobfile=jobfile)
7766
if not hook_out:
7867
return utils.run_test_plain(config, test)
79-
returncode, out = cast(Tuple[int, Optional[Dict[str, Any]]], hook_out[0])
68+
returncode, out = cast(tuple[int, Optional[dict[str, Any]]], hook_out[0])
8069
duration = time.time() - start_time
8170
outstr = json.dumps(out) if out is not None else "{}"
8271
if returncode == UNSUPPORTED_FEATURE:
@@ -164,7 +153,7 @@ def __init__(
164153
self,
165154
name: str,
166155
parent: Optional["Node"],
167-
spec: Dict[str, Any],
156+
spec: dict[str, Any],
168157
) -> None:
169158
"""Initialize this CWLItem."""
170159
super().__init__(name, parent)
@@ -198,7 +187,7 @@ def runtest(self) -> None:
198187
hook,
199188
)
200189
cwl_results = self.config.cwl_results # type: ignore[attr-defined]
201-
cast(List[Tuple[Dict[str, Any], utils.TestResult]], cwl_results).append(
190+
cast(list[tuple[dict[str, Any], utils.TestResult]], cwl_results).append(
202191
(self.spec, result)
203192
)
204193
if result.return_code != 0:
@@ -238,7 +227,7 @@ def repr_failure(
238227
)
239228
)
240229

241-
def reportinfo(self) -> Tuple[Union["os.PathLike[str]", str], Optional[int], str]:
230+
def reportinfo(self) -> tuple[Union["os.PathLike[str]", str], Optional[int], str]:
242231
"""Status report."""
243232
return self.path, 0, "cwl test: %s" % self.name
244233

@@ -258,10 +247,10 @@ def _add_global_properties(self) -> None:
258247

259248
def collect(self) -> Iterator[CWLItem]:
260249
"""Load the cwltest file and yield parsed entries."""
261-
include: Set[str] = set(_get_comma_separated_option(self.config, "cwl_include"))
262-
exclude: Set[str] = set(_get_comma_separated_option(self.config, "cwl_exclude"))
263-
tags: Set[str] = set(_get_comma_separated_option(self.config, "cwl_tags"))
264-
exclude_tags: Set[str] = set(
250+
include: set[str] = set(_get_comma_separated_option(self.config, "cwl_include"))
251+
exclude: set[str] = set(_get_comma_separated_option(self.config, "cwl_exclude"))
252+
tags: set[str] = set(_get_comma_separated_option(self.config, "cwl_tags"))
253+
exclude_tags: set[str] = set(
265254
_get_comma_separated_option(self.config, "cwl_exclude_tags")
266255
)
267256
tests, _ = utils.load_and_validate_tests(str(self.path))
@@ -302,7 +291,7 @@ def collect(self) -> Iterator[CWLItem]:
302291
yield item
303292

304293

305-
__OPTIONS: List[Tuple[str, Dict[str, Any]]] = [
294+
__OPTIONS: list[tuple[str, dict[str, Any]]] = [
306295
(
307296
"--cwl-runner",
308297
{
@@ -400,14 +389,14 @@ def pytest_collect_file(
400389

401390
def pytest_configure(config: "PytestConfig") -> None:
402391
"""Store the raw tests and the test results."""
403-
cwl_results: List[Tuple[Dict[str, Any], utils.TestResult]] = []
392+
cwl_results: list[tuple[dict[str, Any], utils.TestResult]] = []
404393
config.cwl_results = cwl_results # type: ignore[attr-defined]
405394

406395

407396
def pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None:
408397
"""Generate badges."""
409398
cwl_results = cast(
410-
List[Tuple[Dict[str, Any], utils.TestResult]],
399+
list[tuple[dict[str, Any], utils.TestResult]],
411400
getattr(session.config, "cwl_results", None),
412401
)
413402
if not cwl_results:

0 commit comments

Comments
 (0)