You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the types, output = context.run("echo") returns possibly None, which makes sense for asynchronous tasks. For this example, the types are wrong, since never None could be returned. Can you please add an overload improving it?
The current type hints suggests that we should always guard against None as a return type, making the code much more verbose. I don't know enough about async to know to which extent this is avoidable, but adding guards every time we get a return object is very costly to readability and maintainability. Would love to know your take on this, @bitprophet.
I am prototyping some fixes for this, in tandem with #779 it feels like returning None some of the time (when disown=True) was a pre-type-hints bad idea - so I'm going to try just changing the behavior to return a Result even in that case, making the correct return value type hint simply Result.
Activity
MartinBernstorff commentedon Jun 27, 2023
I'd strongly support this suggestion!
Based on my testing, this was added in Invoke 2.1.2.
E.g. the type of this statement differs between:
The type of this is:
The current type hints suggests that we should always guard against
Noneas a return type, making the code much more verbose. I don't know enough about async to know to which extent this is avoidable, but adding guards every time we get a return object is very costly to readability and maintainability. Would love to know your take on this, @bitprophet.kuwv commentedon Jul 10, 2023
#956
bitprophet commentedon Jun 16, 2025
I am prototyping some fixes for this, in tandem with #779 it feels like returning None some of the time (when
disown=True) was a pre-type-hints bad idea - so I'm going to try just changing the behavior to return aResulteven in that case, making the correct return value type hint simplyResult.Runner.run now returns Result even if disown=True
Runner.run now returns Result even if disown=True
Runner.run now returns Result even if disown=True
Runner.run now returns Result even if disown=True
Runner.run now returns Result even if disown=True
Runner.run now returns Result even if disown=True
Runner.run now returns Result even if disown=True
Runner.run now returns Result even if disown=True
Runner.run now returns Result even if disown=True
Runner.run now returns Result even if disown=True
Runner.run now returns Result even if disown=True