-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Right now, AsyncExitStack.__aexit__ unconditionally returns a bool. However, this in contrast to ExitStack.__exit__, which returns the generic _ExitT_co with a bound of bool | None. Why is that? It looks like the actual implementations in contextlib are nearly identical, so I can't readily explain that decision.
Strictly speaking, I think bool is more correct for both, since the actual return value of both ExitStack and AsyncExitStack is a bool. But I suspect the type hints were structured this way to allow type checkers to determine whether the context manager swallows exceptions or not. That's explicitly the behavior of pyright (see here). If that's the case, why is there a difference between ExitStack and AsyncExitStack here? Is it intentional? Or just an oversight?