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
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?
Activity
bradleyharden commentedon Jul 8, 2025
Whoops, it looks like this has already been fixed in #13888. I forgot to check if my typeshed was up to date. Sorry