Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transaction.atomic is incompatible with ExitStack().enter_context #410

Closed
flaeppe opened this issue Jun 26, 2020 · 1 comment
Closed

transaction.atomic is incompatible with ExitStack().enter_context #410

flaeppe opened this issue Jun 26, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@flaeppe
Copy link
Member

flaeppe commented Jun 26, 2020

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.0
  • django version: 3.0.7
  • mypy version: 0.770
  • django-stubs version: 1.5.0
@flaeppe flaeppe added the bug Something isn't working label Jun 26, 2020
@flaeppe
Copy link
Member Author

flaeppe commented Apr 10, 2022

Closed via #909

@flaeppe flaeppe closed this as completed Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant