Skip to content

Commit 9ddd07b

Browse files
committed
freshen cwltool/mutation.py
1 parent 78db0a1 commit 9ddd07b

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

cwltool/mutation.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from collections import namedtuple
2-
from typing import Any, Dict
2+
from typing import Dict, cast
33

44
from .errors import WorkflowException
5+
from .utils import CWLObjectType
56

67
MutationState = namedtuple("MutationTracker", ["generation", "readers", "stepname"])
78

@@ -17,13 +18,12 @@ class MutationManager(object):
1718
1819
"""
1920

20-
def __init__(self): # type: () -> None
21+
def __init__(self) -> None:
2122
"""Initialize."""
2223
self.generations = {} # type: Dict[str, MutationState]
2324

24-
def register_reader(self, stepname, obj):
25-
# type: (str, Dict[str, Any]) -> None
26-
loc = obj["location"]
25+
def register_reader(self, stepname: str, obj: CWLObjectType) -> None:
26+
loc = cast(str, obj["location"])
2727
current = self.generations.get(loc, MutationState(0, [], ""))
2828
obj_generation = obj.get(_generation, 0)
2929

@@ -38,9 +38,8 @@ def register_reader(self, stepname, obj):
3838
current.readers.append(stepname)
3939
self.generations[loc] = current
4040

41-
def release_reader(self, stepname, obj):
42-
# type: (str, Dict[str, Any]) -> None
43-
loc = obj["location"]
41+
def release_reader(self, stepname: str, obj: CWLObjectType) -> None:
42+
loc = cast(str, obj["location"])
4443
current = self.generations.get(loc, MutationState(0, [], ""))
4544
obj_generation = obj.get(_generation, 0)
4645

@@ -54,9 +53,8 @@ def release_reader(self, stepname, obj):
5453

5554
self.generations[loc].readers.remove(stepname)
5655

57-
def register_mutation(self, stepname, obj):
58-
# type: (str, Dict[str, Any]) -> None
59-
loc = obj["location"]
56+
def register_mutation(self, stepname: str, obj: CWLObjectType) -> None:
57+
loc = cast(str, obj["location"])
6058
current = self.generations.get(loc, MutationState(0, [], ""))
6159
obj_generation = obj.get(_generation, 0)
6260

@@ -79,10 +77,10 @@ def register_mutation(self, stepname, obj):
7977
current.generation + 1, current.readers, stepname
8078
)
8179

82-
def set_generation(self, obj): # type: (Dict[str, str]) -> None
83-
loc = obj["location"]
80+
def set_generation(self, obj: CWLObjectType) -> None:
81+
loc = cast(str, obj["location"])
8482
current = self.generations.get(loc, MutationState(0, [], ""))
8583
obj[_generation] = current.generation
8684

87-
def unset_generation(self, obj): # type: (Dict[str, str]) -> None
85+
def unset_generation(self, obj: CWLObjectType) -> None:
8886
obj.pop(_generation, None)

0 commit comments

Comments
 (0)