diff options
Diffstat (limited to 'SCons/Taskmaster')
-rw-r--r-- | SCons/Taskmaster/Job.py | 42 | ||||
-rw-r--r-- | SCons/Taskmaster/JobTests.py | 76 | ||||
-rw-r--r-- | SCons/Taskmaster/TaskmasterTests.py | 90 | ||||
-rw-r--r-- | SCons/Taskmaster/__init__.py | 46 |
4 files changed, 127 insertions, 127 deletions
diff --git a/SCons/Taskmaster/Job.py b/SCons/Taskmaster/Job.py index a63b5291b..572464ba6 100644 --- a/SCons/Taskmaster/Job.py +++ b/SCons/Taskmaster/Job.py @@ -55,10 +55,10 @@ default_stack_size = 256 interrupt_msg = 'Build interrupted.' class InterruptState: - def __init__(self): + def __init__(self) -> None: self.interrupted = False - def set(self): + def set(self) -> None: self.interrupted = True def __call__(self): @@ -70,7 +70,7 @@ class Jobs: methods for starting, stopping, and waiting on all N jobs. """ - def __init__(self, num, taskmaster): + def __init__(self, num, taskmaster) -> None: """ Create 'num' jobs using the given taskmaster. @@ -109,7 +109,7 @@ class Jobs: self.job = Serial(taskmaster) self.num_jobs = 1 - def run(self, postfunc=lambda: None): + def run(self, postfunc=lambda: None) -> None: """Run the jobs. postfunc() will be invoked after the jobs has run. It will be @@ -129,7 +129,7 @@ class Jobs: """Returns whether the jobs were interrupted by a signal.""" return self.job.interrupted() - def _setup_sig_handler(self): + def _setup_sig_handler(self) -> None: """Setup an interrupt handler so that SCons can shutdown cleanly in various conditions: @@ -150,7 +150,7 @@ class Jobs: SCons forks before executing another process. In that case, we want the child to exit immediately. """ - def handler(signum, stack, self=self, parentpid=os.getpid()): + def handler(signum, stack, self=self, parentpid=os.getpid()) -> None: if os.getpid() == parentpid: self.job.taskmaster.stop() self.job.interrupted.set() @@ -169,7 +169,7 @@ class Jobs: "Will not be able to reinstate and so will return to default handler." SCons.Warnings.warn(SCons.Warnings.SConsWarning, msg) - def _reset_sig_handler(self): + def _reset_sig_handler(self) -> None: """Restore the signal handlers to their previous state (before the call to _setup_sig_handler().""" sigint_to_use = self.old_sigint if self.old_sigint is not None else signal.SIG_DFL @@ -191,7 +191,7 @@ class Serial: This class is not thread safe. """ - def __init__(self, taskmaster): + def __init__(self, taskmaster) -> None: """Create a new serial job given a taskmaster. The taskmaster's next_task() method should return the next task @@ -253,7 +253,7 @@ else: dequeues the task, executes it, and posts a tuple including the task and a boolean indicating whether the task executed successfully. """ - def __init__(self, requestQueue, resultsQueue, interrupted): + def __init__(self, requestQueue, resultsQueue, interrupted) -> None: super().__init__() self.daemon = True self.requestQueue = requestQueue @@ -287,7 +287,7 @@ else: class ThreadPool: """This class is responsible for spawning and managing worker threads.""" - def __init__(self, num, stack_size, interrupted): + def __init__(self, num, stack_size, interrupted) -> None: """Create the request and reply queues, and 'num' worker threads. One must specify the stack size of the worker threads. The @@ -318,7 +318,7 @@ else: if 'prev_size' in locals(): threading.stack_size(prev_size) - def put(self, task): + def put(self, task) -> None: """Put task into request queue.""" self.requestQueue.put(task) @@ -326,10 +326,10 @@ else: """Remove and return a result tuple from the results queue.""" return self.resultsQueue.get() - def preparation_failed(self, task): + def preparation_failed(self, task) -> None: self.resultsQueue.put((task, False)) - def cleanup(self): + def cleanup(self) -> None: """ Shuts down the thread pool, giving each worker thread a chance to shut down gracefully. @@ -365,7 +365,7 @@ else: This class is thread safe. """ - def __init__(self, taskmaster, num, stack_size): + def __init__(self, taskmaster, num, stack_size) -> None: """Create a new parallel job given a taskmaster. The taskmaster's next_task() method should return the next @@ -459,16 +459,16 @@ else: COMPLETED = 3 class Worker(threading.Thread): - def __init__(self, owner): + def __init__(self, owner) -> None: super().__init__() self.daemon = True self.owner = owner self.start() - def run(self): + def run(self) -> None: self.owner._work() - def __init__(self, taskmaster, num, stack_size): + def __init__(self, taskmaster, num, stack_size) -> None: self.taskmaster = taskmaster self.num_workers = num self.stack_size = stack_size @@ -507,21 +507,21 @@ else: jl.addHandler(self.taskmaster.trace.log_handler) return jl - def trace_message(self, message): + def trace_message(self, message) -> None: # This grabs the name of the function which calls trace_message() method_name = sys._getframe(1).f_code.co_name + "():" thread_id=threading.get_ident() self.trace.debug('%s.%s [Thread:%s] %s' % (type(self).__name__, method_name, thread_id, message)) # print('%-15s %s' % (method_name, message)) - def start(self): + def start(self) -> None: self._start_workers() for worker in self.workers: worker.join() self.workers = [] self.taskmaster.cleanup() - def _start_workers(self): + def _start_workers(self) -> None: prev_size = self._adjust_stack_size() for _ in range(self.num_workers): self.workers.append(NewParallel.Worker(self)) @@ -544,7 +544,7 @@ else: return None - def _restore_stack_size(self, prev_size): + def _restore_stack_size(self, prev_size) -> None: if prev_size is not None: threading.stack_size(prev_size) diff --git a/SCons/Taskmaster/JobTests.py b/SCons/Taskmaster/JobTests.py index 9e7b08024..3faa97d53 100644 --- a/SCons/Taskmaster/JobTests.py +++ b/SCons/Taskmaster/JobTests.py @@ -63,37 +63,37 @@ num_tasks = num_jobs*5 class DummyLock: """fake lock class to use if threads are not supported""" - def acquire(self): + def acquire(self) -> None: pass - def release(self): + def release(self) -> None: pass class NoThreadsException(Exception): """raised by the ParallelTestCase if threads are not supported""" - def __str__(self): + def __str__(self) -> str: return "the interpreter doesn't support threads" class Task: """A dummy task class for testing purposes.""" - def __init__(self, i, taskmaster): + def __init__(self, i, taskmaster) -> None: self.i = i self.taskmaster = taskmaster self.was_executed = 0 self.was_prepared = 0 - def prepare(self): + def prepare(self) -> None: self.was_prepared = 1 - def _do_something(self): + def _do_something(self) -> None: pass - def needs_execute(self): + def needs_execute(self) -> bool: return True - def execute(self): + def execute(self) -> None: self.taskmaster.test_case.assertTrue(self.was_prepared, "the task wasn't prepared") @@ -119,7 +119,7 @@ class Task: self.taskmaster.end_list.append(self.i) self.taskmaster.guard.release() - def executed(self): + def executed(self) -> None: self.taskmaster.num_executed = self.taskmaster.num_executed + 1 self.taskmaster.test_case.assertTrue(self.was_prepared, @@ -129,20 +129,20 @@ class Task: self.taskmaster.test_case.assertTrue(isinstance(self, Task), "the task wasn't really a Task instance") - def failed(self): + def failed(self) -> None: self.taskmaster.num_failed = self.taskmaster.num_failed + 1 self.taskmaster.stop = 1 self.taskmaster.test_case.assertTrue(self.was_prepared, "the task wasn't prepared") - def postprocess(self): + def postprocess(self) -> None: self.taskmaster.num_postprocessed = self.taskmaster.num_postprocessed + 1 - def exception_set(self): + def exception_set(self) -> None: pass class RandomTask(Task): - def _do_something(self): + def _do_something(self) -> None: # do something that will take some random amount of time: for i in range(random.randrange(0, 100 + num_sines, 1)): x = math.sin(i) @@ -151,20 +151,20 @@ class RandomTask(Task): class ExceptionTask: """A dummy task class for testing purposes.""" - def __init__(self, i, taskmaster): + def __init__(self, i, taskmaster) -> None: self.taskmaster = taskmaster self.was_prepared = 0 - def prepare(self): + def prepare(self) -> None: self.was_prepared = 1 - def needs_execute(self): + def needs_execute(self) -> bool: return True def execute(self): raise Exception - def executed(self): + def executed(self) -> None: self.taskmaster.num_executed = self.taskmaster.num_executed + 1 self.taskmaster.test_case.assertTrue(self.was_prepared, @@ -174,22 +174,22 @@ class ExceptionTask: self.taskmaster.test_case.assertTrue(self.__class__ is Task, "the task wasn't really a Task instance") - def failed(self): + def failed(self) -> None: self.taskmaster.num_failed = self.taskmaster.num_failed + 1 self.taskmaster.stop = 1 self.taskmaster.test_case.assertTrue(self.was_prepared, "the task wasn't prepared") - def postprocess(self): + def postprocess(self) -> None: self.taskmaster.num_postprocessed = self.taskmaster.num_postprocessed + 1 - def exception_set(self): + def exception_set(self) -> None: self.taskmaster.exception_set() class Taskmaster: """A dummy taskmaster class for testing the job classes.""" - def __init__(self, n, test_case, Task): + def __init__(self, n, test_case, Task) -> None: """n is the number of dummy tasks to perform.""" self.test_case = test_case @@ -232,14 +232,14 @@ class Taskmaster: def all_tasks_are_postprocessed(self): return self.num_postprocessed == self.num_tasks - def tasks_were_serial(self): + def tasks_were_serial(self) -> bool: """analyze the task order to see if they were serial""" return not self.found_parallel - def exception_set(self): + def exception_set(self) -> None: pass - def cleanup(self): + def cleanup(self) -> None: pass @@ -292,7 +292,7 @@ class ParallelTestCase(JobTestCase): # tasks complete and get their notifications on the resultsQueue. class SleepTask(Task): - def _do_something(self): + def _do_something(self) -> None: time.sleep(0.01) global SaveThreadPool @@ -329,7 +329,7 @@ class ParallelTestCase(JobTestCase): SCons.Taskmaster.Job.ThreadPool = SaveThreadPool class SerialTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """test a serial job""" taskmaster = Taskmaster(num_tasks, self, RandomTask) @@ -350,7 +350,7 @@ class SerialTestCase(unittest.TestCase): class NoParallelTestCase(JobTestCase): - def runTest(self): + def runTest(self) -> None: """test handling lack of parallel support""" def NoParallel(tm, num, stack_size): raise NameError @@ -377,7 +377,7 @@ class NoParallelTestCase(JobTestCase): class SerialExceptionTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """test a serial job with tasks that raise exceptions""" taskmaster = Taskmaster(num_tasks, self, ExceptionTask) @@ -396,7 +396,7 @@ class SerialExceptionTestCase(unittest.TestCase): class ParallelExceptionTestCase(JobTestCase): - def runTest(self): + def runTest(self) -> None: """test parallel jobs with tasks that raise exceptions""" taskmaster = Taskmaster(num_tasks, self, ExceptionTask) @@ -421,23 +421,23 @@ import SCons.Node import time class DummyNodeInfo: - def update(self, obj): + def update(self, obj) -> None: pass class testnode (SCons.Node.Node): - def __init__(self): + def __init__(self) -> None: super().__init__() self.expect_to_be = SCons.Node.executed self.ninfo = DummyNodeInfo() class goodnode (testnode): - def __init__(self): + def __init__(self) -> None: super().__init__() self.expect_to_be = SCons.Node.up_to_date self.ninfo = DummyNodeInfo() class slowgoodnode (goodnode): - def prepare(self): + def prepare(self) -> None: # Delay to allow scheduled Jobs to run while the dispatcher # sleeps. Keep this short because it affects the time taken # by this test. @@ -445,7 +445,7 @@ class slowgoodnode (goodnode): goodnode.prepare(self) class badnode (goodnode): - def __init__(self): + def __init__(self) -> None: super().__init__() self.expect_to_be = SCons.Node.failed def build(self, **kw): @@ -467,7 +467,7 @@ class badpreparenode (badnode): class _SConsTaskTest(JobTestCase): - def _test_seq(self, num_jobs): + def _test_seq(self, num_jobs) -> None: for node_seq in [ [goodnode], [badnode], @@ -484,7 +484,7 @@ class _SConsTaskTest(JobTestCase): self._do_test(num_jobs, node_seq) - def _do_test(self, num_jobs, node_seq): + def _do_test(self, num_jobs, node_seq) -> None: testnodes = [] for tnum in range(num_tasks): @@ -549,13 +549,13 @@ class _SConsTaskTest(JobTestCase): class SerialTaskTest(_SConsTaskTest): - def runTest(self): + def runTest(self) -> None: """test serial jobs with actual Taskmaster and Task""" self._test_seq(1) class ParallelTaskTest(_SConsTaskTest): - def runTest(self): + def runTest(self) -> None: """test parallel jobs with actual Taskmaster and Task""" self._test_seq(num_jobs) diff --git a/SCons/Taskmaster/TaskmasterTests.py b/SCons/Taskmaster/TaskmasterTests.py index 95150fd98..32959fb0a 100644 --- a/SCons/Taskmaster/TaskmasterTests.py +++ b/SCons/Taskmaster/TaskmasterTests.py @@ -39,7 +39,7 @@ scan_called = 0 class Node: - def __init__(self, name, kids=[], scans=[]): + def __init__(self, name, kids=[], scans=[]) -> None: self.name = name self.kids = kids self.scans = scans @@ -72,7 +72,7 @@ class Node: def disambiguate(self): return self - def push_to_cache(self): + def push_to_cache(self) -> None: pass def retrieve_from_cache(self): @@ -81,18 +81,18 @@ class Node: cache_text.append(self.name + " retrieved") return self.cached - def make_ready(self): + def make_ready(self) -> None: pass - def prepare(self): + def prepare(self) -> None: self.prepared = 1 self.get_binfo() - def build(self): + def build(self) -> None: global built_text built_text = self.name + " built" - def remove(self): + def remove(self) -> None: pass # The following four methods new_binfo(), del_binfo(), @@ -104,7 +104,7 @@ class Node: binfo = "binfo" return binfo - def del_binfo(self): + def del_binfo(self) -> None: """Delete the build info from this node.""" try: delattr(self, 'binfo') @@ -123,13 +123,13 @@ class Node: return binfo - def clear(self): + def clear(self) -> None: # The del_binfo() call here isn't necessary for normal execution, # but is for interactive mode, where we might rebuild the same # target and need to start from scratch. self.del_binfo() - def built(self): + def built(self) -> None: global built_text if not self.cached: built_text = built_text + " really" @@ -141,10 +141,10 @@ class Node: self.clear() - def release_target_info(self): + def release_target_info(self) -> None: pass - def has_builder(self): + def has_builder(self) -> bool: return self.builder is not None def is_derived(self): @@ -153,7 +153,7 @@ class Node: def alter_targets(self): return self.alttargets, None - def visited(self): + def visited(self) -> None: global visited_nodes visited_nodes.append(self.name) @@ -163,7 +163,7 @@ class Node: self.scanned = 1 return self.kids - def scan(self): + def scan(self) -> None: global scan_called scan_called = scan_called + 1 self.kids = self.kids + self.scans @@ -172,7 +172,7 @@ class Node: def scanner_key(self): return self.name - def add_to_waiting_parents(self, node): + def add_to_waiting_parents(self, node) -> int: wp = self.waiting_parents if node in wp: return 0 @@ -182,44 +182,44 @@ class Node: def get_state(self): return self.state - def set_state(self, state): + def set_state(self, state) -> None: self.state = state - def set_bsig(self, bsig): + def set_bsig(self, bsig) -> None: self.bsig = bsig - def set_csig(self, csig): + def set_csig(self, csig) -> None: self.csig = csig - def store_csig(self): + def store_csig(self) -> None: pass - def store_bsig(self): + def store_bsig(self) -> None: pass - def is_pseudo_derived(self): + def is_pseudo_derived(self) -> None: pass def is_up_to_date(self): return self._current_val - def depends_on(self, nodes): + def depends_on(self, nodes) -> int: for node in nodes: if node in self.kids: return 1 return 0 - def __str__(self): + def __str__(self) -> str: return self.name - def postprocess(self): + def postprocess(self) -> None: self.postprocessed = 1 self.waiting_parents = set() def get_executor(self): if not hasattr(self, 'executor'): class Executor: - def prepare(self): + def prepare(self) -> None: pass def get_action_targets(self): @@ -261,7 +261,7 @@ class MyException(Exception): class TaskmasterTestCase(unittest.TestCase): - def test_next_task(self): + def test_next_task(self) -> None: """Test fetching the next task """ global built_text @@ -307,7 +307,7 @@ class TaskmasterTestCase(unittest.TestCase): top_node = n3 class MyTask(SCons.Taskmaster.AlwaysTask): - def execute(self): + def execute(self) -> None: global built_text if self.targets[0].get_state() == SCons.Node.up_to_date: if self.top: @@ -550,14 +550,14 @@ class TaskmasterTestCase(unittest.TestCase): s = n2.get_state() assert s == SCons.Node.executed, s - def test_make_ready_out_of_date(self): + def test_make_ready_out_of_date(self) -> None: """Test the Task.make_ready() method's list of out-of-date Nodes """ ood = [] def TaskGen(tm, targets, top, node, ood=ood): class MyTask(SCons.Taskmaster.AlwaysTask): - def make_ready(self): + def make_ready(self) -> None: SCons.Taskmaster.Task.make_ready(self) self.ood.extend(self.out_of_date) @@ -597,7 +597,7 @@ class TaskmasterTestCase(unittest.TestCase): t = tm.next_task() assert ood == [a5], ood - def test_make_ready_exception(self): + def test_make_ready_exception(self) -> None: """Test handling exceptions from Task.make_ready() """ @@ -612,7 +612,7 @@ class TaskmasterTestCase(unittest.TestCase): assert exc_type == MyException, repr(exc_type) assert str(exc_value) == "from make_ready()", exc_value - def test_needs_execute(self): + def test_needs_execute(self) -> None: """Test that we can't instantiate a Task subclass without needs_execute We should be getting: @@ -627,7 +627,7 @@ class TaskmasterTestCase(unittest.TestCase): with self.assertRaises(TypeError): _ = tm.next_task() - def test_make_ready_all(self): + def test_make_ready_all(self) -> None: """Test the make_ready_all() method""" class MyTask(SCons.Taskmaster.AlwaysTask): @@ -688,7 +688,7 @@ class TaskmasterTestCase(unittest.TestCase): t = tm.next_task() assert t is None - def test_children_errors(self): + def test_children_errors(self) -> None: """Test errors when fetching the children of a node. """ @@ -697,7 +697,7 @@ class TaskmasterTestCase(unittest.TestCase): raise SCons.Errors.StopError("stop!") class ExitNode(Node): - def children(self): + def children(self) -> None: sys.exit(77) n1 = StopNode("n1") @@ -715,7 +715,7 @@ class TaskmasterTestCase(unittest.TestCase): assert exc_value.node == n2, exc_value.node assert exc_value.status == 77, exc_value.status - def test_cycle_detection(self): + def test_cycle_detection(self) -> None: """Test detecting dependency cycles """ n1 = Node("n1") @@ -731,7 +731,7 @@ class TaskmasterTestCase(unittest.TestCase): else: assert 'Did not catch expected UserError' - def test_next_top_level_candidate(self): + def test_next_top_level_candidate(self) -> None: """Test the next_top_level_candidate() method """ n1 = Node("n1") @@ -745,7 +745,7 @@ class TaskmasterTestCase(unittest.TestCase): assert t.targets == [n3], list(map(str, t.targets)) assert t.top == 1, t.top - def test_stop(self): + def test_stop(self) -> None: """Test the stop() method Both default and overridden in a subclass. @@ -769,7 +769,7 @@ class TaskmasterTestCase(unittest.TestCase): assert tm.next_task() is None class MyTM(SCons.Taskmaster.Taskmaster): - def stop(self): + def stop(self) -> None: global built_text built_text = "MyTM.stop()" SCons.Taskmaster.Taskmaster.stop(self) @@ -787,7 +787,7 @@ class TaskmasterTestCase(unittest.TestCase): assert built_text == "MyTM.stop()" assert tm.next_task() is None - def test_executed(self): + def test_executed(self) -> None: """Test when a task has been executed """ global built_text @@ -945,7 +945,7 @@ class TaskmasterTestCase(unittest.TestCase): else: raise AssertionError("did not catch expected exception") - def test_execute(self): + def test_execute(self) -> None: """Test executing a task """ global built_text @@ -1043,7 +1043,7 @@ class TaskmasterTestCase(unittest.TestCase): assert built_text is None, built_text assert cache_text == ["n7 retrieved", "n8 retrieved"], cache_text - def test_cached_execute(self): + def test_cached_execute(self) -> None: """Test executing a task with cached targets """ # In issue #2720 Alexei Klimkin detected that the previous @@ -1087,7 +1087,7 @@ class TaskmasterTestCase(unittest.TestCase): has_binfo = hasattr(n1, 'binfo') assert has_binfo, has_binfo - def test_cached_execute_target_unlink_fails(self): + def test_cached_execute_target_unlink_fails(self) -> None: """Test executing a task with cached targets where unlinking one of the targets fail """ global cache_text @@ -1114,7 +1114,7 @@ class TaskmasterTestCase(unittest.TestCase): _save_warn = SCons.Warnings.warn issued_warnings = [] - def fake_warnings_warn(clz, message): + def fake_warnings_warn(clz, message) -> None: nonlocal issued_warnings issued_warnings.append((clz, message)) SCons.Warnings.warn = fake_warnings_warn @@ -1136,7 +1136,7 @@ class TaskmasterTestCase(unittest.TestCase): self.assertEqual(cache_text, ["n1 retrieved"], msg=cache_text) - def test_exception(self): + def test_exception(self) -> None: """Test generic Taskmaster exception handling """ @@ -1221,7 +1221,7 @@ class TaskmasterTestCase(unittest.TestCase): else: assert 0, "did not catch expected exception" - def test_postprocess(self): + def test_postprocess(self) -> None: """Test postprocessing targets to give them a chance to clean up """ n1 = Node("n1") @@ -1247,7 +1247,7 @@ class TaskmasterTestCase(unittest.TestCase): assert n2.postprocessed assert n3.postprocessed - def test_trace(self): + def test_trace(self) -> None: """Test Taskmaster tracing """ import io diff --git a/SCons/Taskmaster/__init__.py b/SCons/Taskmaster/__init__.py index 7ab864eee..7965ca818 100644 --- a/SCons/Taskmaster/__init__.py +++ b/SCons/Taskmaster/__init__.py @@ -81,7 +81,7 @@ class Stats: the Taskmaster records its decision each time it processes the Node. (Ideally, that's just once per Node.) """ - def __init__(self): + def __init__(self) -> None: """ Instantiates a Taskmaster.Stats object, initializing all appropriate counters to zero. @@ -106,7 +106,7 @@ fmt = "%(considered)3d "\ "%(build)3d " -def dump_stats(): +def dump_stats() -> None: for n in sorted(StatsNodes, key=lambda a: str(a)): print((fmt % n.attributes.stats.__dict__) + str(n)) @@ -132,19 +132,19 @@ class Task(ABC): LOGGER = None - def __init__(self, tm, targets, top, node): + def __init__(self, tm, targets, top, node) -> None: self.tm = tm self.targets = targets self.top = top self.node = node self.exc_clear() - def trace_message(self, node, description='node'): + def trace_message(self, node, description: str='node') -> None: # This grabs the name of the function which calls trace_message() method_name=sys._getframe(1).f_code.co_name+"():" Task.LOGGER.debug('%-15s %s %s' % (method_name, description, self.tm.tm_trace_node(node))) - def display(self, message): + def display(self, message) -> None: """ Hook to allow the calling interface to display a message. @@ -157,7 +157,7 @@ class Task(ABC): """ pass - def prepare(self): + def prepare(self) -> None: """ Called just before the task is executed. @@ -260,7 +260,7 @@ class Task(ABC): buildError.exc_info = sys.exc_info() raise buildError - def executed_without_callbacks(self): + def executed_without_callbacks(self) -> None: """ Called when the task has been successfully executed and the Taskmaster instance doesn't want to call @@ -276,7 +276,7 @@ class Task(ABC): side_effect.set_state(NODE_NO_STATE) t.set_state(NODE_EXECUTED) - def executed_with_callbacks(self): + def executed_with_callbacks(self) -> None: """ Called when the task has been successfully executed and the Taskmaster instance wants to call the Node's callback @@ -311,7 +311,7 @@ class Task(ABC): executed = executed_with_callbacks - def failed(self): + def failed(self) -> None: """ Default action when a task fails: stop the build. @@ -321,7 +321,7 @@ class Task(ABC): """ self.fail_stop() - def fail_stop(self): + def fail_stop(self) -> None: """ Explicit stop-the-build failure. @@ -349,7 +349,7 @@ class Task(ABC): self.targets = [self.tm.current_top] self.top = 1 - def fail_continue(self): + def fail_continue(self) -> None: """ Explicit continue-the-build failure. @@ -366,7 +366,7 @@ class Task(ABC): self.tm.will_not_build(self.targets, lambda n: n.set_state(NODE_FAILED)) - def make_ready_all(self): + def make_ready_all(self) -> None: """ Marks all targets in a task ready for execution. @@ -431,7 +431,7 @@ class Task(ABC): make_ready = make_ready_current - def postprocess(self): + def postprocess(self) -> None: """ Post-processes a task after it's been executed. @@ -511,7 +511,7 @@ class Task(ABC): """ return self.exception - def exc_clear(self): + def exc_clear(self) -> None: """ Clears any recorded exception. @@ -521,7 +521,7 @@ class Task(ABC): self.exception = (None, None, None) self.exception_raise = self._no_exception_to_raise - def exception_set(self, exception=None): + def exception_set(self, exception=None) -> None: """ Records an exception to be raised at the appropriate time. @@ -533,7 +533,7 @@ class Task(ABC): self.exception = exception self.exception_raise = self._exception_raise - def _no_exception_to_raise(self): + def _no_exception_to_raise(self) -> None: pass def _exception_raise(self): @@ -563,7 +563,7 @@ class Task(ABC): class AlwaysTask(Task): - def needs_execute(self): + def needs_execute(self) -> bool: """ Always returns True (indicating this Task should always be executed). @@ -606,7 +606,7 @@ class Taskmaster: The Taskmaster for walking the dependency DAG. """ - def __init__(self, targets=[], tasker=None, order=None, trace=None): + def __init__(self, targets=[], tasker=None, order=None, trace=None) -> None: self.original_top = targets self.top_targets_left = targets[:] self.top_targets_left.reverse() @@ -623,7 +623,7 @@ class Taskmaster: self.trace = False self.configure_trace(trace) - def configure_trace(self, trace=None): + def configure_trace(self, trace=None) -> None: """ This handles the command line option --taskmastertrace= It can be: @@ -726,7 +726,7 @@ class Taskmaster: self.will_not_build(candidates) return None - def _validate_pending_children(self): + def _validate_pending_children(self) -> None: """ Validate the content of the pending_children set. Assert if an internal error is found. @@ -803,7 +803,7 @@ class Taskmaster: for p in n.waiting_parents: assert p.ref_count > 0, (str(n), str(p), p.ref_count) - def tm_trace_node(self, node): + def tm_trace_node(self, node) -> str: return('<%-10s %-3s %s>' % (StateString[node.get_state()], node.ref_count, repr(str(node)))) @@ -1047,7 +1047,7 @@ class Taskmaster: return task - def will_not_build(self, nodes, node_func=lambda n: None): + def will_not_build(self, nodes, node_func=lambda n: None) -> None: """ Perform clean-up about nodes that will never be built. Invokes a user defined function on all of these nodes (including all @@ -1092,7 +1092,7 @@ class Taskmaster: # allow us to use in-place updates self.pending_children = pending_children - def stop(self): + def stop(self) -> None: """ Stops the current build completely. """ |