mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-03-01 12:56:52 +08:00
updated package setup (#485)
* updated package setup * updated to use python 3.9 * fixed test runner * fixed typecheck tests * fixed discrepencies * added override to runner * updated travis * updated pre-commit hooks * updated dep
This commit is contained in:
committed by
GitHub
parent
a3624dec36
commit
44151c485d
26
tests/typecheck/db/models/test_init.yml
Normal file
26
tests/typecheck/db/models/test_init.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
- case: field_to_many_and_to_one_attrs_bool_or_none_in_field_base_class
|
||||
main: |
|
||||
from django.db.models import Field
|
||||
|
||||
field: Field
|
||||
my_bool: bool
|
||||
|
||||
my_bool = field.one_to_many
|
||||
my_bool = field.one_to_one
|
||||
my_bool = field.many_to_many
|
||||
my_bool = field.many_to_one
|
||||
|
||||
# Narrowing the types should give us bool
|
||||
assert field.one_to_many is not None
|
||||
my_bool = field.one_to_many
|
||||
assert field.one_to_one is not None
|
||||
my_bool = field.one_to_one
|
||||
assert field.many_to_many is not None
|
||||
my_bool = field.many_to_many
|
||||
assert field.many_to_one is not None
|
||||
my_bool = field.many_to_one
|
||||
out: |
|
||||
main:6: error: Incompatible types in assignment (expression has type "Optional[bool]", variable has type "bool")
|
||||
main:7: error: Incompatible types in assignment (expression has type "Optional[bool]", variable has type "bool")
|
||||
main:8: error: Incompatible types in assignment (expression has type "Optional[bool]", variable has type "bool")
|
||||
main:9: error: Incompatible types in assignment (expression has type "Optional[bool]", variable has type "bool")
|
||||
28
tests/typecheck/db/test_transaction.yml
Normal file
28
tests/typecheck/db/test_transaction.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
- case: atomic_bare
|
||||
main: |
|
||||
from django.db.transaction import atomic
|
||||
@atomic
|
||||
def func(x: int) -> list: ...
|
||||
reveal_type(func) # N: Revealed type is 'def (x: builtins.int) -> builtins.list[Any]'
|
||||
- case: atomic_args
|
||||
main: |
|
||||
from django.db.transaction import atomic
|
||||
@atomic(using='bla', savepoint=False)
|
||||
def func(x: int) -> list: ...
|
||||
reveal_type(func) # N: Revealed type is 'def (x: builtins.int) -> builtins.list[Any]'
|
||||
- case: non_atomic_requests_bare
|
||||
main: |
|
||||
from django.db.transaction import non_atomic_requests
|
||||
@non_atomic_requests
|
||||
def view_func(request): ...
|
||||
reveal_type(view_func) # N: Revealed type is 'def (request: Any) -> Any'
|
||||
|
||||
- case: non_atomic_requests_args
|
||||
main: |
|
||||
from django.http.request import HttpRequest
|
||||
from django.http.response import HttpResponse
|
||||
from django.db.transaction import non_atomic_requests
|
||||
@non_atomic_requests
|
||||
def view_func(request: HttpRequest, arg: str) -> HttpResponse: ...
|
||||
reveal_type(view_func) # N: Revealed type is 'def (request: django.http.request.HttpRequest, arg: builtins.str) -> django.http.response.HttpResponse'
|
||||
|
||||
Reference in New Issue
Block a user