create explicit methods for ambiguously typed Task
kwargs
#17388
Labels
development
Tech debt, refactors, CI, tests, and other related work.
enhancement
An improvement of an existing feature
Describe the current behavior
Problem
There are many ways to use the task decorator, whether on functions or instance methods, which today we try to handle all this with overloads.
In particular, using keyword arguments like
return_state
andwait_for
in task calls makes proper type checking (nearly, if not) impossible. These kwargs modify the return type of a task (e.g., changing fromR
toState[R]
whenreturn_state=True
), which breaks static type checking inmypy
andpyright
. This creates frustrating developer experiences and makes it difficult to rely on type checkers for preventing bugs.Describe the proposed behavior
Create explicit methods on
Task
objects that clearly indicate their return type, e.g.call_and_return_state
submit_and_return_state
__call__
submit
Example Use
Additional context
We'll want to re-use some interface so we don't have to maintain even more methods in different places
related to #17379
The text was updated successfully, but these errors were encountered: