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

Tests: Migrate db/test_transaction.yml to 'assert_type' tests #2209

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
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 typing import List

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


@atomic
def func1(x: int) -> List[int]: ...


x1: Callable[[int], List[int]] = func1
flaeppe marked this conversation as resolved.
Show resolved Hide resolved


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


x1 = func2


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


x2: Callable[[HttpRequest], HttpResponse] = view_func1


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


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

This file was deleted.

Loading