Skip to content

Commit 9c768e9

Browse files
committed
code: drop Python 3.6-3.7 support
1 parent 8075ae4 commit 9c768e9

Some content is hidden

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

44 files changed

+92
-1933
lines changed

.github/workflows/ci-tests.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,12 @@ jobs:
2828

2929
tox:
3030
name: Tox
31-
runs-on: ubuntu-20.04 # 22.04 doesn't support Python 3.6
31+
runs-on: ubuntu-22.04
3232
strategy:
3333
matrix:
3434
py-ver-major: [3]
35-
py-ver-minor: [6, 8, 9, 10, 11, 12]
35+
py-ver-minor: [8, 9, 10, 11, 12]
3636
step: [lint, unit, bandit, mypy]
37-
exclude:
38-
- py-ver-major: 3
39-
py-ver-minor: 6
40-
step: mypy
41-
- py-ver-major: 3
42-
py-ver-minor: 6
43-
step: lint
4437

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

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.6+ compatible code
3+
- Python 3.8+ 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: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ MODULE=cwltool
2525
# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
2626
# `[[` conditional expressions.
2727
PYSOURCES=$(wildcard ${MODULE}/**.py cwltool/cwlprov/*.py tests/*.py) setup.py
28-
DEVPKGS=diff_cover pylint pep257 pydocstyle 'tox<4' tox-pyenv \
28+
DEVPKGS=diff_cover pylint pep257 pydocstyle 'tox<4' tox-pyenv auto-walrus \
2929
isort wheel autoflake pyupgrade bandit -rlint-requirements.txt\
3030
-rtest-requirements.txt -rmypy-requirements.txt -rdocs/requirements.txt
3131
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pydocstyle sloccount \
@@ -191,16 +191,6 @@ mypy: $(PYSOURCES)
191191
fi # if minimally required ruamel.yaml version is 0.15.99 or greater, than the above can be removed
192192
MYPYPATH=$$MYPYPATH:mypy-stubs mypy $^
193193

194-
mypy_3.6: $(filter-out setup.py gittagger.py,$(PYSOURCES))
195-
if ! test -f $(shell python -c 'import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))')/py.typed ; \
196-
then \
197-
rm -Rf mypy-stubs/ruamel/yaml ; \
198-
ln -s $(shell python -c 'import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))') \
199-
mypy-stubs/ruamel/ ; \
200-
fi # if minimally required ruamel.yaml version is 0.15.99 or greater, than the above can be removed
201-
MYPYPATH=$$MYPYPATH:mypy-stubs mypy --python-version 3.6 $^
202-
203-
204194
mypyc: $(PYSOURCES)
205195
MYPYPATH=mypy-stubs CWLTOOL_USE_MYPYC=1 pip install --verbose -e . \
206196
&& pytest -rs -vv ${PYTEST_EXTRA}
@@ -210,7 +200,8 @@ shellcheck: FORCE
210200
cwltool-in-docker.sh
211201

212202
pyupgrade: $(PYSOURCES)
213-
pyupgrade --exit-zero-even-if-changed --py36-plus $^
203+
pyupgrade --exit-zero-even-if-changed --py38-plus $^
204+
auto-walrus $^
214205

215206
release-test: check-python3 FORCE
216207
git diff-index --quiet HEAD -- || ( echo You have uncommitted changes, please commit them and try again; false )

cwltool/checker.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Dict,
66
Iterator,
77
List,
8+
Literal,
89
MutableMapping,
910
MutableSequence,
1011
Optional,
@@ -16,7 +17,6 @@
1617
from schema_salad.exceptions import ValidationException
1718
from schema_salad.sourceline import SourceLine, bullets, strip_dup_lineno
1819
from schema_salad.utils import json_dumps
19-
from typing_extensions import Literal
2020

2121
from .errors import WorkflowException
2222
from .loghandler import _logger
@@ -288,7 +288,9 @@ def static_checker(
288288
)
289289
+ "\n"
290290
+ SourceLine(sink, "type").makeError(
291-
" with sink '%s' of type %s" % (shortname(sink["id"]), json_dumps(sink["type"]))
291+
" with sink '{}' of type {}".format(
292+
shortname(sink["id"]), json_dumps(sink["type"])
293+
)
292294
)
293295
)
294296
if extra_message is not None:
@@ -507,8 +509,7 @@ def get_step_id(field_id: str) -> str:
507509

508510

509511
def is_conditional_step(param_to_step: Dict[str, CWLObjectType], parm_id: str) -> bool:
510-
source_step = param_to_step.get(parm_id)
511-
if source_step is not None:
512+
if (source_step := param_to_step.get(parm_id)) is not None:
512513
if source_step.get("when") is not None:
513514
return True
514515
return False

cwltool/command_line_tool.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ def _initialworkdir(self, j: JobBase, builder: Builder) -> None:
693693
for i, t2 in enumerate(ls):
694694
if not isinstance(t2, Mapping):
695695
raise SourceLine(initialWorkdir, "listing", WorkflowException, debug).makeError(
696-
"Entry at index %s of listing is not a record, was %s" % (i, type(t2))
696+
f"Entry at index {i} of listing is not a record, was {type(t2)}"
697697
)
698698

699699
if "entry" not in t2:
@@ -715,7 +715,9 @@ def _initialworkdir(self, j: JobBase, builder: Builder) -> None:
715715

716716
if not isinstance(t2["entry"], Mapping):
717717
raise SourceLine(initialWorkdir, "listing", WorkflowException, debug).makeError(
718-
"Entry at index %s of listing is not a record, was %s" % (i, type(t2["entry"]))
718+
"Entry at index {} of listing is not a record, was {}".format(
719+
i, type(t2["entry"])
720+
)
719721
)
720722

721723
if t2["entry"].get("class") not in ("File", "Directory"):

cwltool/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
Dict,
1313
Iterable,
1414
List,
15+
Literal,
1516
Optional,
1617
TextIO,
1718
Tuple,
@@ -22,7 +23,6 @@
2223
from schema_salad.avro.schema import Names
2324
from schema_salad.ref_resolver import Loader
2425
from schema_salad.utils import FetcherCallableType
25-
from typing_extensions import Literal
2626

2727
from .mpi import MpiConfig
2828
from .pathmapper import PathMapper

cwltool/cwlprov/__init__.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import re
77
import uuid
88
from getpass import getuser
9-
from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Union
10-
11-
from typing_extensions import TypedDict
9+
from typing import IO, Any, Callable, Dict, List, Optional, Tuple, TypedDict, Union
1210

1311

1412
def _whoami() -> Tuple[str, str]:
@@ -112,24 +110,26 @@ def _valid_orcid(orcid: Optional[str]) -> str:
112110
"oa:motivatedBy": Dict[str, str],
113111
},
114112
)
115-
Aggregate = TypedDict(
116-
"Aggregate",
117-
{
118-
"uri": Optional[str],
119-
"bundledAs": Optional[Dict[str, Any]],
120-
"mediatype": Optional[str],
121-
"conformsTo": Optional[Union[str, List[str]]],
122-
"createdOn": Optional[str],
123-
"createdBy": Optional[Dict[str, str]],
124-
},
125-
total=False,
126-
)
113+
114+
115+
class Aggregate(TypedDict, total=False):
116+
"""RO Aggregate class."""
117+
118+
uri: Optional[str]
119+
bundledAs: Optional[Dict[str, Any]]
120+
mediatype: Optional[str]
121+
conformsTo: Optional[Union[str, List[str]]]
122+
createdOn: Optional[str]
123+
createdBy: Optional[Dict[str, str]]
124+
125+
127126
# Aggregate.bundledAs is actually type Aggregate, but cyclic definitions are not supported
128-
AuthoredBy = TypedDict(
129-
"AuthoredBy",
130-
{"orcid": Optional[str], "name": Optional[str], "uri": Optional[str]},
131-
total=False,
132-
)
127+
class AuthoredBy(TypedDict, total=False):
128+
"""RO AuthoredBy class."""
129+
130+
orcid: Optional[str]
131+
name: Optional[str]
132+
uri: Optional[str]
133133

134134

135135
def checksum_copy(

cwltool/cwlrdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def dot_with_parameters(g: Graph, stdout: Union[TextIO, StreamWriter]) -> None:
5151

5252
for step, run, _ in qres:
5353
stdout.write(
54-
'"%s" [label="%s"]\n' % (lastpart(step), f"{lastpart(step)} ({lastpart(run)})")
54+
'"{}" [label="{}"]\n'.format(lastpart(step), f"{lastpart(step)} ({lastpart(run)})")
5555
)
5656

5757
qres = cast(
@@ -170,7 +170,7 @@ def dot_without_parameters(g: Graph, stdout: Union[TextIO, StreamWriter]) -> Non
170170

171171
if str(runtype) != "https://w3id.org/cwl/cwl#Workflow":
172172
stdout.write(
173-
'"%s" [label="%s"]\n' % (dotname[step], urllib.parse.urldefrag(str(step))[1])
173+
f'"{dotname[step]}" [label="{urllib.parse.urldefrag(str(step))[1]}"]\n' # noqa: B907
174174
)
175175

176176
if currentwf is not None:

cwltool/docker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _get_docker_machine_mounts() -> List[str]:
4747
"-t",
4848
"vboxsf",
4949
],
50-
universal_newlines=True,
50+
text=True,
5151
).splitlines()
5252
]
5353
return __docker_machine_mounts

cwltool/docker_id.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ def check_output_and_strip(cmd: List[str]) -> Optional[str]:
3030
:return: Stripped string output of the command, or ``None`` if error
3131
"""
3232
try:
33-
result = subprocess.check_output( # nosec
34-
cmd, stderr=subprocess.STDOUT, universal_newlines=True
35-
)
33+
result = subprocess.check_output(cmd, stderr=subprocess.STDOUT, text=True) # nosec
3634
return result.strip()
3735
except (OSError, subprocess.CalledProcessError, TypeError, AttributeError):
3836
# OSError is raised if command doesn't exist

0 commit comments

Comments
 (0)