Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions django-stubs/apps/config.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class AppConfig:
@classmethod
def create(cls, entry: str) -> AppConfig: ...
def get_model(self, model_name: str, require_ready: bool = ...) -> type[Model]: ...
def get_models(
self, include_auto_created: bool = ..., include_swapped: bool = ...
) -> Iterator[type[Model]]: ...
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> Iterator[type[Model]]: ...
def import_models(self) -> None: ...
def ready(self) -> None: ...
16 changes: 4 additions & 12 deletions django-stubs/apps/registry.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@ class Apps:
_pending_operations: dict[tuple[str, str], list[Any]]
models_ready: bool = ...
ready: bool = ...
def __init__(
self, installed_apps: Iterable[AppConfig | str] | None = ...
) -> None: ...
def __init__(self, installed_apps: Iterable[AppConfig | str] | None = ...) -> None: ...
def populate(self, installed_apps: Iterable[AppConfig | str] = ...) -> None: ...
def check_apps_ready(self) -> None: ...
def check_models_ready(self) -> None: ...
def get_app_configs(self) -> Iterable[AppConfig]: ...
def get_app_config(self, app_label: str) -> AppConfig: ...
# it's not possible to support it in plugin properly now
def get_models(
self, include_auto_created: bool = ..., include_swapped: bool = ...
) -> list[type[Model]]: ...
def get_model(
self, app_label: str, model_name: str | None = ..., require_ready: bool = ...
) -> type[Model]: ...
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> list[type[Model]]: ...
def get_model(self, app_label: str, model_name: str | None = ..., require_ready: bool = ...) -> type[Model]: ...
def register_model(self, app_label: str, model: type[Model]) -> None: ...
def is_installed(self, app_name: str) -> bool: ...
def get_containing_app_config(self, object_name: str) -> AppConfig | None: ...
Expand All @@ -41,9 +35,7 @@ class Apps:
def set_installed_apps(self, installed: Iterable[str]) -> None: ...
def unset_installed_apps(self) -> None: ...
def clear_cache(self) -> None: ...
def lazy_model_operation(
self, function: Callable[..., Any], *model_keys: Any
) -> None: ...
def lazy_model_operation(self, function: Callable[..., Any], *model_keys: Any) -> None: ...
def do_pending_operations(self, model: type[Model]) -> None: ...

apps: Apps
66 changes: 33 additions & 33 deletions django-stubs/conf/global_settings.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -333,43 +333,43 @@ MIDDLEWARE: list[str] = ...
############

# Cache to store session data if using the cache session backend.
SESSION_CACHE_ALIAS = "default"
SESSION_CACHE_ALIAS: str = "default"
# Cookie name. This can be whatever you want.
SESSION_COOKIE_NAME = "sessionid"
SESSION_COOKIE_NAME: str = "sessionid"
# Age of cookie, in seconds (default: 2 weeks).
SESSION_COOKIE_AGE = ...
SESSION_COOKIE_AGE: int = ...
# A string like "example.com", or None for standard domain cookie.
SESSION_COOKIE_DOMAIN: str | None = ...
# Whether the session cookie should be secure (https:// only).
SESSION_COOKIE_SECURE = False
SESSION_COOKIE_SECURE: bool = False
# The path of the session cookie.
SESSION_COOKIE_PATH = "/"
SESSION_COOKIE_PATH: str = "/"
# Whether to use the non-RFC standard httpOnly flag (IE, FF3+, others)
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_HTTPONLY: bool = True
# Whether to set the flag restricting cookie leaks on cross-site requests.
# This can be 'Lax', 'Strict', or None to disable the flag.
SESSION_COOKIE_SAMESITE: str | None = ...
# Whether to save the session data on every request.
SESSION_SAVE_EVERY_REQUEST = False
SESSION_SAVE_EVERY_REQUEST: bool = False
# Whether a user's session cookie expires when the Web browser is closed.
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_EXPIRE_AT_BROWSER_CLOSE: bool = False
# The module to store session data
SESSION_ENGINE = "django.contrib.sessions.backends.db"
SESSION_ENGINE: str = "django.contrib.sessions.backends.db"
# Directory to store session files if using the file session module. If None,
# the backend will use a sensible default.
SESSION_FILE_PATH: str | None = ...
# class to serialize session data
SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
SESSION_SERIALIZER: str = "django.contrib.sessions.serializers.JSONSerializer"

#########
# CACHE #
#########

# The cache backends to use.
CACHES: dict[str, dict[str, Any]] = ...
CACHE_MIDDLEWARE_KEY_PREFIX = ""
CACHE_MIDDLEWARE_SECONDS = 600
CACHE_MIDDLEWARE_ALIAS = "default"
CACHE_MIDDLEWARE_KEY_PREFIX: str = ""
CACHE_MIDDLEWARE_SECONDS: int = 600
CACHE_MIDDLEWARE_ALIAS: str = "default"

##################
# AUTHENTICATION #
Expand All @@ -379,14 +379,14 @@ AUTH_USER_MODEL: str = ...

AUTHENTICATION_BACKENDS: Sequence[str] = ...

LOGIN_URL = "/accounts/login/"
LOGIN_URL: str = "/accounts/login/"

LOGIN_REDIRECT_URL: str = ...

LOGOUT_REDIRECT_URL: str | None = ...

# The number of days a password reset link is valid for
PASSWORD_RESET_TIMEOUT_DAYS = 3
PASSWORD_RESET_TIMEOUT_DAYS: int = 3

# the first hasher in this list is the preferred algorithm. any
# password using different algorithms will be converted automatically
Expand All @@ -399,27 +399,27 @@ AUTH_PASSWORD_VALIDATORS: list[dict[str, str]] = ...
# SIGNING #
###########

SIGNING_BACKEND = "django.core.signing.TimestampSigner"
SIGNING_BACKEND: str = "django.core.signing.TimestampSigner"

########
# CSRF #
########

# Dotted path to callable to be used as view when a request is
# rejected by the CSRF middleware.
CSRF_FAILURE_VIEW = "django.views.csrf.csrf_failure"
CSRF_FAILURE_VIEW: str = "django.views.csrf.csrf_failure"

# Settings for CSRF cookie.
CSRF_COOKIE_NAME = "csrftoken"
CSRF_COOKIE_AGE = ...
CSRF_COOKIE_NAME: str = "csrftoken"
CSRF_COOKIE_AGE: int = ...
CSRF_COOKIE_DOMAIN: TypeAlias = None
CSRF_COOKIE_PATH = "/"
CSRF_COOKIE_SECURE = False
CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_PATH: str = "/"
CSRF_COOKIE_SECURE: bool = False
CSRF_COOKIE_HTTPONLY: bool = False
CSRF_COOKIE_SAMESITE: str | None = ...
CSRF_HEADER_NAME = "HTTP_X_CSRFTOKEN"
CSRF_HEADER_NAME: str = "HTTP_X_CSRFTOKEN"
CSRF_TRUSTED_ORIGINS: list[str] = ...
CSRF_USE_SESSIONS = False
CSRF_USE_SESSIONS: bool = False

############
# MESSAGES #
Expand All @@ -436,21 +436,21 @@ MESSAGE_STORAGE = ...
###########

# The callable to use to configure logging
LOGGING_CONFIG = "logging.config.dictConfig"
LOGGING_CONFIG: str = "logging.config.dictConfig"

# Custom logging configuration.
LOGGING: dict[str, Any] = ...

# Default exception reporter filter class used in case none has been
# specifically assigned to the HttpRequest instance.
DEFAULT_EXCEPTION_REPORTER_FILTER = "django.views.debug.SafeExceptionReporterFilter"
DEFAULT_EXCEPTION_REPORTER_FILTER: str = "django.views.debug.SafeExceptionReporterFilter"

###########
# TESTING #
###########

# The name of the class to use to run the test suite
TEST_RUNNER = "django.test.runner.DiscoverRunner"
TEST_RUNNER: str = "django.test.runner.DiscoverRunner"

# Apps that don't need to be serialized at test database creation time
# (only apps with migrations are to start with)
Expand Down Expand Up @@ -497,11 +497,11 @@ SILENCED_SYSTEM_CHECKS: list[str] = ...
#######################
# SECURITY MIDDLEWARE #
#######################
SECURE_BROWSER_XSS_FILTER = False
SECURE_CONTENT_TYPE_NOSNIFF = False
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
SECURE_HSTS_PRELOAD = False
SECURE_HSTS_SECONDS = 0
SECURE_BROWSER_XSS_FILTER: bool = False
SECURE_CONTENT_TYPE_NOSNIFF: bool = False
SECURE_HSTS_INCLUDE_SUBDOMAINS: bool = False
SECURE_HSTS_PRELOAD: bool = False
SECURE_HSTS_SECONDS: int = 0
SECURE_REDIRECT_EXEMPT: list[str] = ...
SECURE_SSL_HOST: TypeAlias = None
SECURE_SSL_REDIRECT = False
SECURE_SSL_REDIRECT: bool = False
4 changes: 1 addition & 3 deletions django-stubs/conf/urls/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ def url(
name: str = ...,
) -> URLPattern: ...
@overload
def url(
regex: str, view: IncludedURLConf, kwargs: dict[str, Any] = ..., name: str = ...
) -> URLResolver: ...
def url(regex: str, view: IncludedURLConf, kwargs: dict[str, Any] = ..., name: str = ...) -> URLResolver: ...
@overload
def url(
regex: str,
Expand Down
4 changes: 1 addition & 3 deletions django-stubs/conf/urls/i18n.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ from typing import Any

from django.urls.resolvers import URLPattern

def i18n_patterns(
*urls: Any, prefix_default_language: bool = ...
) -> list[list[URLPattern]]: ...
def i18n_patterns(*urls: Any, prefix_default_language: bool = ...) -> list[list[URLPattern]]: ...
def is_language_prefix_patterns_used(urlconf: str) -> tuple[bool, bool]: ...

urlpatterns: list[Callable[..., Any]]
4 changes: 1 addition & 3 deletions django-stubs/conf/urls/static.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ from typing import Any

from django.urls.resolvers import URLPattern

def static(
prefix: str, view: Callable[..., Any] = ..., **kwargs: Any
) -> list[URLPattern]: ...
def static(prefix: str, view: Callable[..., Any] = ..., **kwargs: Any) -> list[URLPattern]: ...
12 changes: 3 additions & 9 deletions django-stubs/contrib/admin/checks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@ from django.core.checks.messages import CheckMessage, Error

_CheckError: TypeAlias = str | Error

def check_admin_app(
app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any
) -> list[_CheckError]: ...
def check_admin_app(app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any) -> list[_CheckError]: ...
def check_dependencies(**kwargs: Any) -> list[_CheckError]: ...

class BaseModelAdminChecks:
def check(
self, admin_obj: BaseModelAdmin[Any], **kwargs: Any
) -> list[CheckMessage]: ...
def check(self, admin_obj: BaseModelAdmin[Any], **kwargs: Any) -> list[CheckMessage]: ...

class ModelAdminChecks(BaseModelAdminChecks): ...
class InlineModelAdminChecks(BaseModelAdminChecks): ...

def must_be(type: Any, option: Any, obj: Any, id: Any) -> Any: ...
def must_inherit_from(parent: Any, option: Any, obj: Any, id: Any) -> Any: ...
def refer_to_missing_field(
field: Any, option: Any, model: Any, obj: Any, id: Any
) -> Any: ...
def refer_to_missing_field(field: Any, option: Any, model: Any, obj: Any, id: Any) -> Any: ...
5 changes: 1 addition & 4 deletions django-stubs/contrib/admin/decorators.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ _M = TypeVar("_M", bound=Model)
_T = TypeVar("_T", bound=object)

def action(
function: (
Callable[[ModelAdmin[_M], HttpRequest, QuerySet[_M]], HttpResponse | None]
| None
) = ...,
function: (Callable[[ModelAdmin[_M], HttpRequest, QuerySet[_M]], HttpResponse | None] | None) = ...,
*,
permissions: Sequence[str] | None = ...,
description: str | None = ...,
Expand Down
4 changes: 1 addition & 3 deletions django-stubs/contrib/admin/filters.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class ListFilter:
) -> None: ...
def has_output(self) -> bool: ...
def choices(self, changelist: Any) -> Iterator[dict[str, Any]] | None: ...
def queryset(
self, request: Any, queryset: QuerySet[Any]
) -> QuerySet[Any] | None: ...
def queryset(self, request: Any, queryset: QuerySet[Any]) -> QuerySet[Any] | None: ...
def expected_parameters(self) -> list[str] | None: ...

class SimpleListFilter(ListFilter):
Expand Down
4 changes: 1 addition & 3 deletions django-stubs/contrib/admin/helpers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ class AdminReadonlyField:
is_checkbox: bool = ...
is_readonly: bool = ...
empty_value_display: Any = ...
def __init__(
self, form: Any, field: Any, is_first: Any, model_admin: Any | None = ...
) -> None: ...
def __init__(self, form: Any, field: Any, is_first: Any, model_admin: Any | None = ...) -> None: ...
def label_tag(self) -> SafeText: ...
def contents(self) -> SafeText: ...

Expand Down
7 changes: 3 additions & 4 deletions django-stubs/contrib/admin/models.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from collections.abc import Iterable
from typing import Any, ClassVar, TypeAlias, TypeVar
from typing import Any, ClassVar, TypeVar

from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils import timezone as timezone
from typing_extensions import Self

ADDITION: int
Expand Down Expand Up @@ -38,8 +37,8 @@ class LogEntryManager(models.Manager[_LogEntryT]):

class LogEntry(models.Model):
action_time = models.DateTimeField()
user: TypeAlias = models.ForeignKey[User]
content_type: TypeAlias = models.ForeignKey[ContentType]
user = models.ForeignKey[User](User, on_delete=models.CASCADE)
content_type = models.ForeignKey[ContentType](ContentType, on_delete=models.SET_NULL, null=True, blank=True)
object_id = models.TextField(blank=True, null=True)
object_repr = models.CharField()
action_flag = models.PositiveSmallIntegerField()
Expand Down
Loading