Skip to content

Commit d0eaa1f

Browse files
committed
upgrade to mypy 0.971
1 parent 0576e19 commit d0eaa1f

File tree

9 files changed

+27
-19
lines changed

9 files changed

+27
-19
lines changed

cwl_utils/cwl_normalizer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ def run(args: argparse.Namespace) -> int:
8383
add_lc_filename(result, document)
8484
version = result.get("cwlVersion", None)
8585
if version in ("draft-3", "cwl:draft-3", "v1.0", "v1.1"):
86-
result = cwlupgrader.upgrade_document(
87-
result, False, False, args.dir, imports
88-
)
86+
result = cwlupgrader.upgrade_document(result, args.dir, imports=imports)
8987
else:
9088
_logger.error(
9189
"Sorry, %s in %s is not a supported CWL version by this tool.",

cwl_utils/graph_split.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import argparse
1212
import json
1313
import os
14-
from typing import Any, IO, MutableMapping, Set, Union, cast
14+
from typing import IO, Any, MutableMapping, Set, Union, cast
1515

1616
from cwlformat.formatter import stringify_dict
1717
from ruamel import yaml

cwl_utils/pack.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,25 @@
1818
import sys
1919
import urllib.parse
2020
import urllib.request
21-
from typing import Any, Dict, ItemsView, List, Optional, Tuple, cast
21+
from typing import (
22+
TYPE_CHECKING,
23+
Any,
24+
Dict,
25+
ItemsView,
26+
List,
27+
Optional,
28+
Tuple,
29+
Union,
30+
cast,
31+
)
2232

2333
from packaging import version
2434

2535
from cwl_utils import schemadef, utils
2636

37+
if TYPE_CHECKING:
38+
from _collections_abc import dict_items
39+
2740
logger = logging.getLogger(__name__)
2841

2942

@@ -167,7 +180,7 @@ def resolve_schemadefs(
167180

168181
def resolve_imports(cwl: Any, base_url: urllib.parse.ParseResult) -> Any:
169182
if isinstance(cwl, dict):
170-
itr = cwl.items()
183+
itr: Union["dict_items[Any, Any]", ItemsView[Any, Any]] = cwl.items()
171184
elif isinstance(cwl, list):
172185
itr = cast(ItemsView[Any, Any], [(n, v) for n, v in enumerate(cwl)])
173186
else:

cwl_utils/sandboxjs.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@ def __init__(
9797
self.have_node_slim: bool = have_node_slim
9898
self.minimum_node_version_str: str = minimum_node_version_str
9999
self.process_finished_str: str = process_finished_str
100-
self.processes_to_kill = (
101-
collections.deque()
102-
) # type: Deque[subprocess.Popen[str]]
100+
self.processes_to_kill: Deque[subprocess.Popen[str]] = collections.deque()
103101

104102
def __del__(self) -> None:
105-
kill_processes(self.processes_to_kill)
103+
try:
104+
kill_processes(self.processes_to_kill)
105+
except TypeError:
106+
pass
106107

107108
def check_js_threshold_version(self, working_alias: str) -> bool:
108109
"""

cwl_utils/utils.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ def _is_github_symbolic_link(base_url: urllib.parse.ParseResult, contents: str)
5151

5252
def bytes2str_in_dicts(
5353
inp: Union[MutableMapping[str, Any], MutableSequence[Any], Any],
54-
):
55-
# type: (...) -> Union[str, MutableSequence[Any], MutableMapping[str, Any]]
54+
) -> Union[str, MutableSequence[Any], MutableMapping[str, Any]]:
5655
"""
5756
Convert any present byte string to unicode string, inplace.
5857
@@ -79,9 +78,7 @@ def bytes2str_in_dicts(
7978
return inp
8079

8180

82-
def kill_processes(
83-
processes_to_kill, # type: Deque[subprocess.Popen[str]]
84-
) -> None:
81+
def kill_processes(processes_to_kill: Deque[subprocess.Popen[str]]) -> None:
8582
while processes_to_kill:
8683
process = processes_to_kill.popleft()
8784
if isinstance(process.args, MutableSequence):

mypy-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mypy==0.910
1+
mypy==0.971
22
typing_extensions
33
types-requests
44
types-setuptools>==57.4.0

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cwl-upgrader >= 1.2
1+
cwl-upgrader >= 1.2.3
22
packaging
33
requests
44
schema-salad >= 8.2, < 9

tests/load_cwl_by_path.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# SPDX-License-Identifier: Apache-2.0
33
from pathlib import Path
44

5-
65
from cwl_utils.parser import load_document_by_uri, save
76

87
# File Input - This is the only thing you will need to adjust or take in as an input to your function:

tests/test_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_latest_parser() -> None:
7373
uri = Path(TEST_v1_2_CWL).as_uri()
7474
with open(TEST_v1_2_CWL) as cwl_h:
7575
yaml_obj12 = yaml.main.round_trip_load(cwl_h, preserve_quotes=True)
76-
latest_cwl_obj = latest.load_document_by_yaml(yaml_obj12, uri) # type: ignore
76+
latest_cwl_obj = latest.load_document_by_yaml(yaml_obj12, uri)
7777
assert latest_cwl_obj.cwlVersion == "v1.2"
7878

7979

0 commit comments

Comments
 (0)