Closed
Description
Bug report
django.db.transaction.atomic
is incompatible with contextlib.ExitStack().enter_context
What's wrong
Repro case:
from contextlib import ExitStack
from django.db import transaction
with ExitStack() as stack:
stack.enter_context(transaction.atomic())
Causes:
error: Argument 1 to "enter_context" of "ExitStack" has incompatible type "Atomic"; expected "ContextManager[<nothing>]" [arg-type]
How is that should be
transaction.atomic()
should be accepted as a valid argument to stack.enter_context
as it declares the expected __enter__
and __exit__
methods.
System information
- OS:
python
version: 3.8.0django
version: 3.0.7mypy
version: 0.770django-stubs
version: 1.5.0