Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django-stubs/db/transaction.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def set_rollback(rollback: bool, using: str | None = ...) -> None: ...
def mark_for_rollback_on_error(using: str | None = ...) -> Iterator[None]: ...
def on_commit(func: Callable[[], object], using: str | None = ..., robust: bool = ...) -> None: ...

_C = TypeVar("_C", bound=Callable) # Any callable
_C = TypeVar("_C", bound=Callable[..., Any]) # Any callable

# Don't inherit from ContextDecorator, so we can provide a more specific signature for __call__
class Atomic:
Expand Down
33 changes: 33 additions & 0 deletions tests/assert_type/db/test_transaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from collections.abc import Callable

from django.db.transaction import atomic, non_atomic_requests
from django.http import HttpRequest, HttpResponse
from typing_extensions import assert_type


@atomic
def func1(x: int, /) -> list[int]: ...


assert_type(func1, Callable[[int], list[int]])


@atomic(using="bla", savepoint=False)
def func2(x: int, /) -> list[int]: ...


assert_type(func2, Callable[[int], list[int]])


@non_atomic_requests
def view_func1(request: HttpRequest, /) -> HttpResponse: ...


assert_type(view_func1, Callable[[HttpRequest], HttpResponse])


@non_atomic_requests
def view_func2(request: HttpRequest, arg: str, /) -> HttpResponse: ...


assert_type(view_func2, Callable[[HttpRequest, str], HttpResponse])
29 changes: 0 additions & 29 deletions tests/typecheck/db/test_transaction.yml

This file was deleted.