mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-06 12:14:28 +08:00
A couple of small fixes (#81)
* Fix type of django.contrib.postgres.fields.JSONField(verbose_name) * Improve type for CursorWrapper.execute(params) Not perfect. Based on simple cases from http://initd.org/psycopg/docs/usage.html#adaptation-of-python-values-to-sql-types
This commit is contained in:
committed by
Maxim Kurnikov
parent
dd5b98faf0
commit
0e60b70ae4
@@ -15,7 +15,11 @@ class JSONField(CheckFieldDefaultMixin, Field):
|
||||
default_error_messages: Any = ...
|
||||
encoder: Any = ...
|
||||
def __init__(
|
||||
self, verbose_name: None = ..., name: None = ..., encoder: Optional[Type[JSONEncoder]] = ..., **kwargs: Any
|
||||
self,
|
||||
verbose_name: Optional[str] = ...,
|
||||
name: Optional[str] = ...,
|
||||
encoder: Optional[Type[JSONEncoder]] = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def db_type(self, connection: Any): ...
|
||||
def deconstruct(self) -> Tuple[None, str, List[Any], Dict[str, Union[Type[JSONEncoder], bool]]]: ...
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
from datetime import date, datetime, time
|
||||
from decimal import Decimal
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
|
||||
from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple, Union
|
||||
from uuid import UUID
|
||||
|
||||
logger: Any
|
||||
|
||||
# Python types that can be adapted to SQL.
|
||||
_SQLType = Union[None, bool, int, float, Decimal, str, bytes, datetime, UUID]
|
||||
|
||||
class CursorWrapper:
|
||||
cursor: Any = ...
|
||||
db: Any = ...
|
||||
@@ -15,10 +19,10 @@ class CursorWrapper:
|
||||
def __exit__(self, type: None, value: None, traceback: None) -> None: ...
|
||||
def callproc(self, procname: str, params: List[Any] = ..., kparams: Dict[str, int] = ...) -> Any: ...
|
||||
def execute(
|
||||
self, sql: str, params: Optional[Union[List[bool], List[datetime], List[float], Tuple]] = ...
|
||||
self, sql: str, params: Optional[Union[Sequence[_SQLType], Mapping[str, _SQLType]]] = ...
|
||||
) -> Optional[Any]: ...
|
||||
def executemany(
|
||||
self, sql: str, param_list: Union[Iterator[Any], List[Tuple[Union[int, str]]]]
|
||||
self, sql: str, param_list: Sequence[Optional[Union[Sequence[_SQLType], Mapping[str, _SQLType]]]]
|
||||
) -> Optional[Any]: ...
|
||||
|
||||
class CursorDebugWrapper(CursorWrapper):
|
||||
|
||||
Reference in New Issue
Block a user