[3.2] Add durable argument to atomic (#586)

* [3.2] Add durable argument to atomic

* Adjust compatibility table for 3.2

* Update README.md

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Hannes Ljungberg
2021-04-13 12:17:30 +02:00
committed by GitHub
parent 3cca71a58f
commit e72cbb6eb5
3 changed files with 6 additions and 3 deletions

View File

@@ -42,7 +42,8 @@ We rely on different `django` and `mypy` versions:
| django-stubs | mypy version | django version | python version
| ------------ | ---- | ---- | ---- |
| 1.8.0 | 0.812 | 2.2.x \|\| 3.x | ^3.6
| 1.9.0-dev | 0.812 | 3.2.x | ^3.6
| 1.8.0 | 0.812 | 3.1.x | ^3.6
| 1.7.0 | 0.790 | 2.2.x \|\| 3.x | ^3.6
| 1.6.0 | 0.780 | 2.2.x \|\| 3.x | ^3.6
| 1.5.0 | 0.770 | 2.2.x \|\| 3.x | ^3.6

View File

@@ -26,7 +26,7 @@ _C = TypeVar("_C", bound=Callable) # Any callable
class Atomic:
using: Optional[str] = ...
savepoint: bool = ...
def __init__(self, using: Optional[str], savepoint: bool) -> None: ...
def __init__(self, using: Optional[str], savepoint: bool, durable: bool) -> None: ...
# When decorating, return the decorated function as-is, rather than clobbering it as ContextDecorator does.
def __call__(self, func: _C) -> _C: ...
def __enter__(self) -> None: ...
@@ -38,7 +38,7 @@ def atomic(using: _C) -> _C: ...
# Decorator or context-manager with parameters
@overload
def atomic(using: Optional[str] = ..., savepoint: bool = ...) -> Atomic: ...
def atomic(using: Optional[str] = ..., savepoint: bool = ..., durable: bool = ...) -> Atomic: ...
# Bare decorator
@overload

View File

@@ -7,6 +7,8 @@
pass
with transaction.atomic(using="mydb", savepoint=False):
pass
with transaction.atomic(using="mydb", savepoint=False, durable=True):
pass
- case: transaction_atomic_decorator
main: |