Replies: 1 comment
-
There's not really any way to make this covariant, since that would not be safe. Using a type var will work, but you will need to add a separate overload for it: I'm using PEP695 notation for brevity @overload
async def isolate[T](
coroutine: Awaitable[T],
*,
catch: type[BaseException] = Exception,
caught: MutableSequence[BaseException] | None = None
) -> T | Literal[NORETURN]: ...
@overload
async def isolate[T, ExceptionT: BaseException](
coroutine: Awaitable[T],
*,
catch: type[ExceptionT],
caught: MutableSequence[ExceptionT]
) -> T | Literal[NORETURN]: ... Making use of PEP696 and setting a default for |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Consider the following code:
I would like to change the typing in such a way that the
caught
has the (covariant) type ofMutableSequence[catch]
.The usage that errors for now:
I have tried to use typevars, but that only lead to different error:
Any hints greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions