AbstractContextManager.__enter__ not properly annotated #13950
Labels
reason: inexpressable
Closed, because this can't be expressed within the current type system
stubs: false negative
Type checkers do not report an error, but should
Per the Python docs,
AbstractContextManager
provides a default__enter__
implementation which just returnsself
. But this does not appear to be properly type annotated (usingSelf
):Running this with
mypy
, only the second case properly reveals the type asB2
. The first one just saysAny
.At runtime, the behavior of both is identical.
I have recreated this on both Python 3.12 and Python 3.13.
The text was updated successfully, but these errors were encountered: