Peter Roelants
06/09/2021, 7:14 PMerror: Signature of "run" incompatible with supertype "Task"
For example for following Task:
class RestTaskTest(prefect.Task):
def run(self, string_val: str, int_val: int) -> TaskTestResult:
return TaskTestResult(string_val=string_val, int_val=int_val)
This makes sense since the definition of Task.run
is def run(self) -> None:
.
Is there any way to make mypy work together with overriding of Task.run in custom tasks? Or is the only option to ignore these with # type: ignore
?Peter Roelants
06/09/2021, 7:14 PMKevin Kho
Any
?Peter Roelants
06/09/2021, 7:32 PMAny
.
However, I don't think its only the Any. I tried changing that in prefect, and the error is still there. There are also the Task method arguments that are overwritten self
is overwritten by self, string_val: str, int_val: int
in the previous example. And I don't know how to correctly type this myself.Zach Schumacher
06/09/2021, 7:42 PMZach Schumacher
06/09/2021, 7:42 PMfrom prefect.utilities.tasks import defaults_from_attrs
Zach Schumacher
06/09/2021, 7:43 PMPeter Roelants
06/10/2021, 7:49 AM@defaults_from_attrs()
on top of the overridden run()
method works. Thanks!