diff --git a/django-stubs/contrib/sitemaps/__init__.pyi b/django-stubs/contrib/sitemaps/__init__.pyi index c32af29f9..4973453a9 100644 --- a/django-stubs/contrib/sitemaps/__init__.pyi +++ b/django-stubs/contrib/sitemaps/__init__.pyi @@ -8,12 +8,6 @@ from django.core.paginator import Paginator from django.db.models.base import Model from django.db.models.query import QuerySet -PING_URL: str - -class SitemapNotFound(Exception): ... - -def ping_google(sitemap_url: str | None = ..., ping_url: str = ..., sitemap_uses_https: bool = ...) -> None: ... - _ItemT = TypeVar("_ItemT") class Sitemap(Generic[_ItemT]): diff --git a/django-stubs/contrib/sitemaps/management/__init__.pyi b/django-stubs/contrib/sitemaps/management/__init__.pyi deleted file mode 100644 index e69de29bb..000000000 diff --git a/django-stubs/contrib/sitemaps/management/commands/__init__.pyi b/django-stubs/contrib/sitemaps/management/commands/__init__.pyi deleted file mode 100644 index e69de29bb..000000000 diff --git a/django-stubs/contrib/sitemaps/management/commands/ping_google.pyi b/django-stubs/contrib/sitemaps/management/commands/ping_google.pyi deleted file mode 100644 index 8d75fb4d6..000000000 --- a/django-stubs/contrib/sitemaps/management/commands/ping_google.pyi +++ /dev/null @@ -1,3 +0,0 @@ -from django.core.management.base import BaseCommand - -class Command(BaseCommand): ... diff --git a/django-stubs/contrib/sites/requests.pyi b/django-stubs/contrib/sites/requests.pyi index 1532f4b29..0cb73d7ce 100644 --- a/django-stubs/contrib/sites/requests.pyi +++ b/django-stubs/contrib/sites/requests.pyi @@ -1,10 +1,11 @@ from typing import NoReturn +from django.db.models.base import ModelBase from django.http.request import HttpRequest class RequestSite: name: str domain: str def __init__(self, request: HttpRequest) -> None: ... - def save(self, force_insert: bool = ..., force_update: bool = ...) -> NoReturn: ... + def save(self, force_insert: bool | tuple[ModelBase, ...] = ..., force_update: bool = ...) -> NoReturn: ... def delete(self) -> NoReturn: ... diff --git a/django-stubs/contrib/staticfiles/checks.pyi b/django-stubs/contrib/staticfiles/checks.pyi index 5d4deba93..203471582 100644 --- a/django-stubs/contrib/staticfiles/checks.pyi +++ b/django-stubs/contrib/staticfiles/checks.pyi @@ -2,6 +2,9 @@ from collections.abc import Sequence from typing import Any from django.apps.config import AppConfig -from django.core.checks.messages import CheckMessage +from django.core.checks.messages import CheckMessage, Error + +E005: Error def check_finders(app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any) -> list[CheckMessage]: ... +def check_storages(app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any) -> list[CheckMessage]: ... diff --git a/django-stubs/contrib/staticfiles/finders.pyi b/django-stubs/contrib/staticfiles/finders.pyi index f6245a4b7..bac4b8a7e 100644 --- a/django-stubs/contrib/staticfiles/finders.pyi +++ b/django-stubs/contrib/staticfiles/finders.pyi @@ -17,7 +17,7 @@ class BaseFinder: class FileSystemFinder(BaseFinder): locations: list[tuple[str, str]] storages: dict[str, Any] - def __init__(self, app_names: Sequence[str] = ..., *args: Any, **kwargs: Any) -> None: ... + def __init__(self, app_names: Sequence[str] | None = ..., *args: Any, **kwargs: Any) -> None: ... def find_location(self, root: str, path: str, prefix: str | None = ...) -> str | None: ... @overload def find(self, path: str, all: Literal[False] = ...) -> str | None: ... diff --git a/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi b/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi index 4a84039e1..602a75c63 100644 --- a/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi +++ b/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi @@ -2,6 +2,7 @@ from typing import Any from django.core.files.storage import Storage from django.core.management.base import BaseCommand +from django.utils.functional import cached_property class Command(BaseCommand): copied_files: Any @@ -10,7 +11,7 @@ class Command(BaseCommand): post_processed_files: Any storage: Any def __init__(self, *args: Any, **kwargs: Any) -> None: ... - @property + @cached_property def local(self) -> bool: ... interactive: Any verbosity: Any @@ -21,6 +22,7 @@ class Command(BaseCommand): post_process: Any def set_options(self, **options: Any) -> None: ... def collect(self) -> dict[str, list[str]]: ... + def handle(self, **options: Any) -> str | None: ... def log(self, msg: str, level: int = ...) -> None: ... def is_local_storage(self) -> bool: ... def clear_dir(self, path: str) -> None: ... diff --git a/django-stubs/contrib/staticfiles/management/commands/findstatic.pyi b/django-stubs/contrib/staticfiles/management/commands/findstatic.pyi index be61bcbcf..19df69eaa 100644 --- a/django-stubs/contrib/staticfiles/management/commands/findstatic.pyi +++ b/django-stubs/contrib/staticfiles/management/commands/findstatic.pyi @@ -1,3 +1,6 @@ +from typing import Any + from django.core.management.base import LabelCommand -class Command(LabelCommand): ... +class Command(LabelCommand): + def handle_label(self, path: str, **options: Any) -> str | None: ... # type: ignore[override] diff --git a/django-stubs/contrib/staticfiles/storage.pyi b/django-stubs/contrib/staticfiles/storage.pyi index 1624f4f2b..2999c4a96 100644 --- a/django-stubs/contrib/staticfiles/storage.pyi +++ b/django-stubs/contrib/staticfiles/storage.pyi @@ -1,4 +1,5 @@ from collections.abc import Callable, Iterator +from re import Match from typing import Any from django.core.files.base import File @@ -23,10 +24,12 @@ class HashedFilesMixin: hashed_files: Any keep_intermediate_files: bool def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def file_hash(self, name: str, content: File = ...) -> str: ... + def file_hash(self, name: str, content: File | None = ...) -> str | None: ... def hashed_name(self, name: str, content: File | None = ..., filename: str | None = ...) -> str: ... def url(self, name: str, force: bool = ...) -> str: ... - def url_converter(self, name: str, hashed_files: dict[str, Any], template: str = ...) -> Callable: ... + def url_converter( + self, name: str, hashed_files: dict[str, Any], template: str | None = ... + ) -> Callable[[Match], str]: ... def post_process(self, paths: dict[str, Any], dry_run: bool = ..., **options: Any) -> _PostProcessT: ... def clean_name(self, name: str) -> str: ... def hash_key(self, name: str) -> str: ... @@ -40,7 +43,7 @@ class ManifestFilesMixin(HashedFilesMixin): manifest_storage: Storage | None hashed_files: dict[str, str] manifest_hash: str - def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def __init__(self, *args: Any, manifest_storage: Storage | None = ..., **kwargs: Any) -> None: ... def read_manifest(self) -> str: ... def load_manifest(self) -> dict[str, Any]: ... def save_manifest(self) -> None: ... diff --git a/django-stubs/db/models/base.pyi b/django-stubs/db/models/base.pyi index 344d7ae7a..54524fb75 100644 --- a/django-stubs/db/models/base.pyi +++ b/django-stubs/db/models/base.pyi @@ -71,14 +71,14 @@ class Model(metaclass=ModelBase): def get_constraints(self) -> list[tuple[type[Model], Sequence[BaseConstraint]]]: ... def save( self, - force_insert: bool = ..., + force_insert: bool | tuple[ModelBase, ...] = ..., force_update: bool = ..., using: str | None = ..., update_fields: Iterable[str] | None = ..., ) -> None: ... async def asave( self, - force_insert: bool = ..., + force_insert: bool | tuple[ModelBase, ...] = ..., force_update: bool = ..., using: str | None = ..., update_fields: Iterable[str] | None = ..., @@ -86,7 +86,7 @@ class Model(metaclass=ModelBase): def save_base( self, raw: bool = ..., - force_insert: bool = ..., + force_insert: bool | tuple[ModelBase, ...] = ..., force_update: bool = ..., using: str | None = ..., update_fields: Iterable[str] | None = ..., diff --git a/scripts/django_tests_settings.py b/scripts/django_tests_settings.py index c9eefbfd0..b005ec50a 100644 --- a/scripts/django_tests_settings.py +++ b/scripts/django_tests_settings.py @@ -9,3 +9,5 @@ "django.contrib.sessions", "django.contrib.sites", ] + +STATIC_URL = "static/" diff --git a/scripts/stubtest/allowlist.txt b/scripts/stubtest/allowlist.txt index 874c91f0d..ff300149e 100644 --- a/scripts/stubtest/allowlist.txt +++ b/scripts/stubtest/allowlist.txt @@ -12,8 +12,11 @@ django.conf.locale.* # We don't need migrations: django.contrib.admin.migrations.* django.contrib.auth.migrations.* -django.contrib.flatpages.migrations.* django.contrib.contenttypes.migrations.* +django.contrib.flatpages.migrations.* +django.contrib.redirects.migrations.* +django.contrib.sessions.migrations.* +django.contrib.sites.migrations.* # default_storage is actually an instance of DefaultStorage, but it proxies through to a Storage django.core.files.storage.default_storage @@ -195,6 +198,7 @@ django.contrib.gis.gdal.raster.source.GDALRaster.is_vsi_based django.contrib.postgres.expressions.ArraySubquery.output_field django.contrib.postgres.indexes.PostgresIndex.max_name_length django.contrib.sessions.backends.db.SessionStore.model +django.contrib.staticfiles.management.commands.collectstatic.Command.local django.core.files.File.size django.core.files.base.File.size django.core.files.storage.FileSystemStorage.base_location diff --git a/scripts/stubtest/allowlist_todo.txt b/scripts/stubtest/allowlist_todo.txt index 14ca19bb6..ce7fdc3a7 100644 --- a/scripts/stubtest/allowlist_todo.txt +++ b/scripts/stubtest/allowlist_todo.txt @@ -629,10 +629,7 @@ django.contrib.sites.models.Site.redirect_set django.contrib.sites.models.SiteManager.__slotnames__ django.contrib.staticfiles.finders.BaseStorageFinder.storage django.contrib.staticfiles.finders.DefaultStorageFinder.storage -django.contrib.staticfiles.finders.FileSystemFinder.__init__ -django.contrib.staticfiles.management.commands.collectstatic -django.contrib.staticfiles.management.commands.findstatic.Command.handle_label -django.contrib.staticfiles.storage +django.contrib.staticfiles.storage.staticfiles_storage django.core.cache.cache django.core.checks.registry.CheckRegistry.register django.core.files.locks.OVERLAPPED diff --git a/scripts/stubtest/allowlist_todo_django50.txt b/scripts/stubtest/allowlist_todo_django50.txt index 64c972b50..e1d9d6ed0 100644 --- a/scripts/stubtest/allowlist_todo_django50.txt +++ b/scripts/stubtest/allowlist_todo_django50.txt @@ -43,19 +43,6 @@ django.contrib.messages.storage.cookie.MessagePartSerializer django.contrib.messages.storage.cookie.bisect_keep_left django.contrib.messages.storage.cookie.bisect_keep_right django.contrib.messages.test -django.contrib.redirects.migrations.0001_initial -django.contrib.redirects.migrations.0002_alter_redirect_new_path_help_text -django.contrib.sessions.migrations.0001_initial -django.contrib.sitemaps.PING_URL -django.contrib.sitemaps.SitemapNotFound -django.contrib.sitemaps.management -django.contrib.sitemaps.management.commands -django.contrib.sitemaps.management.commands.ping_google -django.contrib.sitemaps.ping_google -django.contrib.sites.migrations.0001_initial -django.contrib.sites.migrations.0002_alter_domain_unique -django.contrib.staticfiles.checks.E005 -django.contrib.staticfiles.checks.check_storages django.db.backends.base.features.BaseDatabaseFeatures.delete_can_self_reference_subquery django.db.backends.base.features.BaseDatabaseFeatures.insert_test_table_with_defaults django.db.backends.base.features.BaseDatabaseFeatures.supports_default_keyword_in_bulk_insert diff --git a/tests/typecheck/test_import_all.yml b/tests/typecheck/test_import_all.yml index 0bb467146..5234ae7ad 100644 --- a/tests/typecheck/test_import_all.yml +++ b/tests/typecheck/test_import_all.yml @@ -290,9 +290,6 @@ import django.contrib.sessions.serializers import django.contrib.sitemaps import django.contrib.sitemaps.apps - import django.contrib.sitemaps.management - import django.contrib.sitemaps.management.commands - import django.contrib.sitemaps.management.commands.ping_google import django.contrib.sitemaps.views import django.contrib.sites import django.contrib.sites.admin