mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-18 01:45:59 +08:00
add BaseManager.create() typechecking
This commit is contained in:
@@ -11,7 +11,7 @@ CHANGE: int
|
||||
DELETION: int
|
||||
ACTION_FLAG_CHOICES: Any
|
||||
|
||||
class LogEntryManager(models.Manager):
|
||||
class LogEntryManager(models.Manager["LogEntry"]):
|
||||
def log_action(
|
||||
self,
|
||||
user_id: int,
|
||||
|
||||
@@ -16,7 +16,7 @@ class Permission(models.Model):
|
||||
content_type_id: int
|
||||
name: models.CharField = ...
|
||||
content_type: models.ForeignKey[ContentType] = ...
|
||||
codename: str = ...
|
||||
codename: models.CharField = ...
|
||||
def natural_key(self) -> Tuple[str, str, str]: ...
|
||||
|
||||
class GroupManager(models.Manager):
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.db import models
|
||||
|
||||
class Redirect(models.Model):
|
||||
id: None
|
||||
site_id: int
|
||||
site: Any = ...
|
||||
old_path: str = ...
|
||||
new_path: str = ...
|
||||
site: models.ForeignKey = ...
|
||||
old_path: models.CharField = ...
|
||||
new_path: models.CharField = ...
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
from typing import Any, Dict, Optional, Type, Union
|
||||
from typing import Dict, Optional, Type, Union
|
||||
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
from django.contrib.sessions.base_session import AbstractBaseSession
|
||||
from django.contrib.sessions.models import Session
|
||||
from django.core.signing import Serializer
|
||||
from django.db.models.base import Model
|
||||
|
||||
class SessionStore(SessionBase):
|
||||
accessed: bool
|
||||
serializer: Type[django.core.signing.JSONSerializer]
|
||||
serializer: Type[Serializer]
|
||||
def __init__(self, session_key: Optional[str] = ...) -> None: ...
|
||||
@classmethod
|
||||
def get_model_class(cls) -> Type[Session]: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, TypeVar, Union, ClassVar, Sequence
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, TypeVar, Union, ClassVar, Sequence, Generic
|
||||
|
||||
from django.db.models.manager import Manager
|
||||
|
||||
@@ -10,9 +10,9 @@ class Model(metaclass=ModelBase):
|
||||
class DoesNotExist(Exception): ...
|
||||
class Meta: ...
|
||||
_meta: Any
|
||||
_default_manager: Manager[Model]
|
||||
pk: Any = ...
|
||||
objects: Manager[Model]
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
def __init__(self: _Self, *args, **kwargs) -> None: ...
|
||||
def delete(self, using: Any = ..., keep_parents: bool = ...) -> Tuple[int, Dict[str, int]]: ...
|
||||
def full_clean(self, exclude: Optional[List[str]] = ..., validate_unique: bool = ...) -> None: ...
|
||||
def clean_fields(self, exclude: List[str] = ...) -> None: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import uuid
|
||||
from datetime import date, time, datetime, timedelta
|
||||
from typing import Any, Optional, Tuple, Iterable, Callable, Dict, Union, Type, TypeVar
|
||||
from typing import Any, Optional, Tuple, Iterable, Callable, Dict, Union, Type, TypeVar, Generic
|
||||
import decimal
|
||||
|
||||
from typing_extensions import Literal
|
||||
@@ -14,7 +14,7 @@ from django.forms import Widget, Field as FormField
|
||||
from .mixins import NOT_PROVIDED as NOT_PROVIDED
|
||||
|
||||
_Choice = Tuple[Any, Any]
|
||||
_ChoiceNamedGroup = Union[Tuple[str, Iterable[_Choice]], Tuple[str, Any]]
|
||||
_ChoiceNamedGroup = Tuple[str, Iterable[_Choice]]
|
||||
_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]
|
||||
|
||||
_ValidatorCallable = Callable[..., None]
|
||||
@@ -76,7 +76,7 @@ class SmallIntegerField(IntegerField): ...
|
||||
class BigIntegerField(IntegerField): ...
|
||||
|
||||
class FloatField(Field):
|
||||
def __set__(self, instance, value: Union[float, int, Combinable]) -> float: ...
|
||||
def __set__(self, instance, value: Union[float, int, str, Combinable]) -> float: ...
|
||||
def __get__(self, instance, owner) -> float: ...
|
||||
|
||||
class DecimalField(Field):
|
||||
@@ -102,7 +102,7 @@ class DecimalField(Field):
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
def __set__(self, instance, value: Union[str, Combinable]) -> decimal.Decimal: ...
|
||||
def __set__(self, instance, value: Union[str, float, decimal.Decimal, Combinable]) -> decimal.Decimal: ...
|
||||
def __get__(self, instance, owner) -> decimal.Decimal: ...
|
||||
|
||||
class AutoField(Field):
|
||||
@@ -167,15 +167,15 @@ class EmailField(CharField): ...
|
||||
class URLField(CharField): ...
|
||||
|
||||
class TextField(Field):
|
||||
def __set__(self, instance, value: str) -> None: ...
|
||||
def __set__(self, instance, value: Union[str, Combinable]) -> None: ...
|
||||
def __get__(self, instance, owner) -> str: ...
|
||||
|
||||
class BooleanField(Field):
|
||||
def __set__(self, instance, value: bool) -> None: ...
|
||||
def __set__(self, instance, value: Union[bool, Combinable]) -> None: ...
|
||||
def __get__(self, instance, owner) -> bool: ...
|
||||
|
||||
class NullBooleanField(Field):
|
||||
def __set__(self, instance, value: Optional[bool]) -> None: ...
|
||||
def __set__(self, instance, value: Optional[Union[bool, Combinable]]) -> None: ...
|
||||
def __get__(self, instance, owner) -> Optional[bool]: ...
|
||||
|
||||
class IPAddressField(Field):
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
from importlib.abc import SourceLoader
|
||||
from typing import Any, Callable, Dict, List, Optional, Type, Union
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Dict, List, MutableMapping, Optional, Type, Union
|
||||
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http.request import QueryDict
|
||||
from django.http.request import HttpRequest, QueryDict
|
||||
from django.http.response import Http404, HttpResponse
|
||||
from django.utils.safestring import SafeText
|
||||
|
||||
@@ -19,21 +18,21 @@ def cleanse_setting(key: Union[int, str], value: Any) -> Any: ...
|
||||
def get_safe_settings() -> Dict[str, Any]: ...
|
||||
def technical_500_response(request: Any, exc_type: Any, exc_value: Any, tb: Any, status_code: int = ...): ...
|
||||
def get_default_exception_reporter_filter() -> ExceptionReporterFilter: ...
|
||||
def get_exception_reporter_filter(request: Optional[WSGIRequest]) -> ExceptionReporterFilter: ...
|
||||
def get_exception_reporter_filter(request: Optional[HttpRequest]) -> ExceptionReporterFilter: ...
|
||||
|
||||
class ExceptionReporterFilter:
|
||||
def get_post_parameters(self, request: Any): ...
|
||||
def get_traceback_frame_variables(self, request: Any, tb_frame: Any): ...
|
||||
|
||||
class SafeExceptionReporterFilter(ExceptionReporterFilter):
|
||||
def is_active(self, request: Optional[WSGIRequest]) -> bool: ...
|
||||
def get_cleansed_multivaluedict(self, request: WSGIRequest, multivaluedict: QueryDict) -> QueryDict: ...
|
||||
def get_post_parameters(self, request: Optional[WSGIRequest]) -> Union[Dict[Any, Any], QueryDict]: ...
|
||||
def cleanse_special_types(self, request: Optional[WSGIRequest], value: Any) -> Any: ...
|
||||
def is_active(self, request: Optional[HttpRequest]) -> bool: ...
|
||||
def get_cleansed_multivaluedict(self, request: HttpRequest, multivaluedict: QueryDict) -> QueryDict: ...
|
||||
def get_post_parameters(self, request: Optional[HttpRequest]) -> MutableMapping[str, Any]: ...
|
||||
def cleanse_special_types(self, request: Optional[HttpRequest], value: Any) -> Any: ...
|
||||
def get_traceback_frame_variables(self, request: Any, tb_frame: Any): ...
|
||||
|
||||
class ExceptionReporter:
|
||||
request: Optional[WSGIRequest] = ...
|
||||
request: Optional[HttpRequest] = ...
|
||||
filter: ExceptionReporterFilter = ...
|
||||
exc_type: None = ...
|
||||
exc_value: Optional[str] = ...
|
||||
@@ -44,7 +43,7 @@ class ExceptionReporter:
|
||||
postmortem: None = ...
|
||||
def __init__(
|
||||
self,
|
||||
request: Optional[WSGIRequest],
|
||||
request: Optional[HttpRequest],
|
||||
exc_type: Optional[Type[BaseException]],
|
||||
exc_value: Optional[Union[str, BaseException]],
|
||||
tb: Optional[TracebackType],
|
||||
@@ -63,5 +62,5 @@ class ExceptionReporter:
|
||||
module_name: Optional[str] = None,
|
||||
): ...
|
||||
|
||||
def technical_404_response(request: WSGIRequest, exception: Http404) -> HttpResponse: ...
|
||||
def default_urlconf(request: WSGIRequest) -> HttpResponse: ...
|
||||
def technical_404_response(request: HttpRequest, exception: Http404) -> HttpResponse: ...
|
||||
def default_urlconf(request: HttpRequest) -> HttpResponse: ...
|
||||
|
||||
Reference in New Issue
Block a user