I'm pretty sure this has to be dead code
Review Request #1960 - Created March 20, 2015 and submitted
|benjyw, ity, stuhood|
Note first, in passing, that
isinstance(type(action), type)is a tautology. But, that aside, what this code seems to be trying to do is check whether the
actionis either a class representing a subclass of Task or a function of either zero or one arguments. In the latter case it wants to make a new subclass of Task that invokes the function when executed. However, the function wrapping code can't possibly work unless I'm deeply missing something: In the
FuncTaskthe args parameter containing the positional arguments to
__init__has to be either empty or contain one argument. However TaskBase in task.py defines an
__init__that takes two positional arguments.
So any attempt to construct an instance of
FuncTaskwould fail: if passed zero or one arguments, the call to
super(FuncTask, self).__init__(...)will fail because the super constructer needs two positional arguments and if called with more than one arguments it will raise an
It's possible that the code was meant to refer to the args in the enclosing scope but, unless I'm very confused about Python, it does not so this code must never be used so might as well be deleted.
Oh good find, I'd completely forgotten about this code.
This is some very old code that did once work but was forgotten when we reworked the Task lifecycle. The idea was to allow very simple tasks to be written as functions. But this is a minor convenience at best, and it wouldn't play nicely with the current Task lifecycle, nor with the options system. And, as you say, it's broken now. Removing it seems like the right thing to do, unless jsirois has objections.
One thing though: Please put a link to the travis CI run in the "Testing done" box.
Revision 2 (+17 -30)