From 5d9fc3dadfa458fa7e7da41c4b81ddc3b99a3725 Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sat, 12 Nov 2022 16:28:31 +0100 Subject: [PATCH 01/13] only allow redirect_chain attribute in response when client sets the follow flag Signed-off-by: Oleg Hoefling --- django-stubs/test/client.pyi | 114 ++++++++++++++++++++++----- tests/typecheck/test/test_client.yml | 4 +- 2 files changed, 99 insertions(+), 19 deletions(-) diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index 4d11de6af..36607da63 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -10,6 +10,7 @@ from typing import ( Iterable, Iterator, List, + Literal, NoReturn, Optional, Pattern, @@ -17,6 +18,7 @@ from typing import ( Type, TypeVar, Union, + overload, ) from django.contrib.auth.base_user import AbstractBaseUser @@ -129,6 +131,8 @@ class _MonkeyPatchedWSGIResponse(_WSGIResponse): context: ContextList | Dict[str, Any] content: bytes resolver_match: ResolverMatch + +class _MonkeyPatchedWSGIResponseRedirect(_MonkeyPatchedWSGIResponse): redirect_chain: List[Tuple[str, int]] class _MonkeyPatchedASGIResponse(_ASGIResponse): @@ -159,36 +163,110 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]): ) -> None: ... # Silence type warnings, since this class overrides arguments and return types in an unsafe manner. def request(self, **request: Any) -> _MonkeyPatchedWSGIResponse: ... - def get( # type: ignore - self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any + @overload # type: ignore + def get( + self, path: str, data: Any = ..., follow: Literal[False] = ..., secure: bool = ..., **extra: Any ) -> _MonkeyPatchedWSGIResponse: ... - def post( # type: ignore - self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any + @overload + def get( + self, path: str, data: Any = ..., follow: Literal[True] = ..., secure: bool = ..., **extra: Any + ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload # type: ignore + def post( + self, + path: str, + data: Any = ..., + content_type: str = ..., + follow: Literal[False] = ..., + secure: bool = ..., + **extra: Any ) -> _MonkeyPatchedWSGIResponse: ... - def head( # type: ignore - self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any + @overload + def post( + self, + path: str, + data: Any = ..., + content_type: str = ..., + follow: Literal[True] = ..., + secure: bool = ..., + **extra: Any + ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload # type: ignore + def head( + self, path: str, data: Any = ..., follow: Literal[False] = ..., secure: bool = ..., **extra: Any ) -> _MonkeyPatchedWSGIResponse: ... - def trace( # type: ignore - self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any + @overload + def head( + self, path: str, data: Any = ..., follow: Literal[True] = ..., secure: bool = ..., **extra: Any + ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload # type: ignore + def trace( + self, path: str, data: Any = ..., follow: Literal[False] = ..., secure: bool = ..., **extra: Any ) -> _MonkeyPatchedWSGIResponse: ... - def options( # type: ignore + @overload + def trace( + self, path: str, data: Any = ..., follow: Literal[True] = ..., secure: bool = ..., **extra: Any + ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload # type: ignore + def put( self, path: str, - data: Union[Dict[str, str], str] = ..., + data: Any = ..., content_type: str = ..., - follow: bool = ..., + follow: Literal[False] = ..., secure: bool = ..., **extra: Any ) -> _MonkeyPatchedWSGIResponse: ... - def put( # type: ignore - self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any - ) -> _MonkeyPatchedWSGIResponse: ... - def patch( # type: ignore - self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any + @overload + def put( + self, + path: str, + data: Any = ..., + content_type: str = ..., + follow: Literal[True] = ..., + secure: bool = ..., + **extra: Any + ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload # type: ignore + def patch( + self, + path: str, + data: Any = ..., + content_type: str = ..., + follow: Literal[False] = ..., + secure: bool = ..., + **extra: Any ) -> _MonkeyPatchedWSGIResponse: ... - def delete( # type: ignore - self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any + @overload + def patch( + self, + path: str, + data: Any = ..., + content_type: str = ..., + follow: Literal[True] = ..., + secure: bool = ..., + **extra: Any + ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload # type: ignore + def delete( + self, + path: str, + data: Any = ..., + content_type: str = ..., + follow: Literal[False] = ..., + secure: bool = ..., + **extra: Any ) -> _MonkeyPatchedWSGIResponse: ... + @overload + def delete( + self, + path: str, + data: Any = ..., + content_type: str = ..., + follow: Literal[True] = ..., + secure: bool = ..., + **extra: Any + ) -> _MonkeyPatchedWSGIResponseRedirect: ... class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGIResponse]]): handler: AsyncClientHandler diff --git a/tests/typecheck/test/test_client.yml b/tests/typecheck/test/test_client.yml index b8c060a70..37178cbf7 100644 --- a/tests/typecheck/test/test_client.yml +++ b/tests/typecheck/test/test_client.yml @@ -9,8 +9,10 @@ reveal_type(response.client) # N: Revealed type is "django.test.client.Client" reveal_type(response.context) # N: Revealed type is "Union[django.test.utils.ContextList, builtins.dict[builtins.str, Any]]" reveal_type(response.content) # N: Revealed type is "builtins.bytes" - reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]" + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" response.json() + redirected_response = client.get('foo', follow=True) + reveal_type(redirected_response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]" - case: async_client_methods main: | from django.test.client import AsyncClient From bde7358724887b45b60211d2a252576105c19aeb Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sat, 12 Nov 2022 16:47:54 +0100 Subject: [PATCH 02/13] compat for py3.7 Signed-off-by: Oleg Hoefling --- django-stubs/test/client.pyi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index 36607da63..e7dea7027 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -1,3 +1,4 @@ +import sys from io import BytesIO from json import JSONEncoder from types import TracebackType @@ -33,6 +34,11 @@ from django.template.base import Template from django.test.utils import ContextList from django.urls import ResolverMatch +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + BOUNDARY: str = ... MULTIPART_CONTENT: str = ... CONTENT_TYPE_RE: Pattern = ... From 44b79990c782e92fbd3b30b016671dd15641c1a4 Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sat, 12 Nov 2022 17:00:19 +0100 Subject: [PATCH 03/13] compat for py3.7, fixed Signed-off-by: Oleg Hoefling --- django-stubs/test/client.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index e7dea7027..59c86dabd 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -11,7 +11,6 @@ from typing import ( Iterable, Iterator, List, - Literal, NoReturn, Optional, Pattern, From 1efa5dace20ddaa399bdcedcf4565365bca4a0af Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sat, 12 Nov 2022 17:39:47 +0100 Subject: [PATCH 04/13] address review comments, extract follow flag checks in a separate test case Signed-off-by: Oleg Hoefling --- django-stubs/test/client.pyi | 35 ++++++++++--- tests/typecheck/test/test_client.yml | 76 ++++++++++++++++++++++++++-- 2 files changed, 102 insertions(+), 9 deletions(-) diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index 59c86dabd..b6bd8a577 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -1,4 +1,3 @@ -import sys from io import BytesIO from json import JSONEncoder from types import TracebackType @@ -32,11 +31,7 @@ from django.http.response import HttpResponseBase from django.template.base import Template from django.test.utils import ContextList from django.urls import ResolverMatch - -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal +from typing_extensions import Literal BOUNDARY: str = ... MULTIPART_CONTENT: str = ... @@ -176,6 +171,10 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]): def get( self, path: str, data: Any = ..., follow: Literal[True] = ..., secure: bool = ..., **extra: Any ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload + def get( + self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any + ) -> _MonkeyPatchedWSGIResponse: ... @overload # type: ignore def post( self, @@ -196,6 +195,10 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]): secure: bool = ..., **extra: Any ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload + def post( + self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any + ) -> _MonkeyPatchedWSGIResponse: ... @overload # type: ignore def head( self, path: str, data: Any = ..., follow: Literal[False] = ..., secure: bool = ..., **extra: Any @@ -204,6 +207,10 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]): def head( self, path: str, data: Any = ..., follow: Literal[True] = ..., secure: bool = ..., **extra: Any ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload + def head( + self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any + ) -> _MonkeyPatchedWSGIResponse: ... @overload # type: ignore def trace( self, path: str, data: Any = ..., follow: Literal[False] = ..., secure: bool = ..., **extra: Any @@ -212,6 +219,10 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]): def trace( self, path: str, data: Any = ..., follow: Literal[True] = ..., secure: bool = ..., **extra: Any ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload + def trace( + self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any + ) -> _MonkeyPatchedWSGIResponse: ... @overload # type: ignore def put( self, @@ -232,6 +243,10 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]): secure: bool = ..., **extra: Any ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload + def put( + self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any + ) -> _MonkeyPatchedWSGIResponse: ... @overload # type: ignore def patch( self, @@ -252,6 +267,10 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]): secure: bool = ..., **extra: Any ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload + def patch( + self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any + ) -> _MonkeyPatchedWSGIResponse: ... @overload # type: ignore def delete( self, @@ -272,6 +291,10 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]): secure: bool = ..., **extra: Any ) -> _MonkeyPatchedWSGIResponseRedirect: ... + @overload + def delete( + self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any + ) -> _MonkeyPatchedWSGIResponse: ... class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGIResponse]]): handler: AsyncClientHandler diff --git a/tests/typecheck/test/test_client.yml b/tests/typecheck/test/test_client.yml index 37178cbf7..93cfb8881 100644 --- a/tests/typecheck/test/test_client.yml +++ b/tests/typecheck/test/test_client.yml @@ -9,10 +9,7 @@ reveal_type(response.client) # N: Revealed type is "django.test.client.Client" reveal_type(response.context) # N: Revealed type is "Union[django.test.utils.ContextList, builtins.dict[builtins.str, Any]]" reveal_type(response.content) # N: Revealed type is "builtins.bytes" - response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" response.json() - redirected_response = client.get('foo', follow=True) - reveal_type(redirected_response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]" - case: async_client_methods main: | from django.test.client import AsyncClient @@ -37,3 +34,76 @@ async_factory = AsyncRequestFactory() async_request = async_factory.get('foo') reveal_type(async_request) # N: Revealed type is "django.core.handlers.asgi.ASGIRequest" +- case: client_follow_flag + main: | + from django.test.client import Client + client = Client() + response = client.get('foo') + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.get('foo', follow=False) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.get('foo', follow=True) + reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]" + x: bool + response = client.get('foo', follow=x) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + + response = client.post('foo') + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.post('foo', follow=False) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.post('foo', follow=True) + reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]" + x: bool + response = client.post('foo', follow=x) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + + response = client.head('foo') + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.head('foo', follow=False) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.head('foo', follow=True) + reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]" + x: bool + response = client.head('foo', follow=x) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + + response = client.trace('foo') + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.trace('foo', follow=False) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.trace('foo', follow=True) + reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]" + x: bool + response = client.trace('foo', follow=x) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + + response = client.put('foo') + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.put('foo', follow=False) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.put('foo', follow=True) + reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]" + x: bool + response = client.put('foo', follow=x) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + + response = client.patch('foo') + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.patch('foo', follow=False) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.patch('foo', follow=True) + reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]" + x: bool + response = client.patch('foo', follow=x) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + + response = client.delete('foo') + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.delete('foo', follow=False) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" + response = client.delete('foo', follow=True) + reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]" + x: bool + response = client.delete('foo', follow=x) + response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain" From d5157ac748179e1f3c9d99bdb82c506f4316c386 Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sat, 12 Nov 2022 17:17:35 +0100 Subject: [PATCH 05/13] configure flake8-pyi plugin in pre-commit Signed-off-by: Oleg Hoefling --- .pre-commit-config.yaml | 4 ++++ setup.cfg | 1 + 2 files changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 82da0d316..517e92f48 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,6 +33,10 @@ repos: rev: 5.0.4 hooks: - id: flake8 + additional_dependencies: + - flake8-pyi + types: [] + files: ^.*.pyi?$ ci: autofix_commit_msg: '[pre-commit.ci] auto fixes from pre-commit.com hooks' diff --git a/setup.cfg b/setup.cfg index 15228ddf0..dc551d268 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,6 +4,7 @@ extend-ignore = E203 extend-select = F401, Y max_line_length = 120 per-file-ignores = + *.pyi: B, E301, E302, E305, E501, E701, E704, W503 *__init__.pyi: F401 base_user.pyi: Y003 models.pyi: Y003 From cc78575ceb7116bbaf2bfe617ff16a5e6a504225 Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sat, 12 Nov 2022 18:18:28 +0100 Subject: [PATCH 06/13] use pep 604 union types where possible Signed-off-by: Oleg Hoefling --- django-stubs/apps/config.pyi | 10 +- django-stubs/apps/registry.pyi | 12 +- django-stubs/conf/__init__.pyi | 2 +- django-stubs/conf/global_settings.pyi | 44 +-- django-stubs/conf/urls/__init__.pyi | 22 +- django-stubs/contrib/admin/actions.pyi | 4 +- django-stubs/contrib/admin/checks.pyi | 4 +- django-stubs/contrib/admin/decorators.pyi | 20 +- django-stubs/contrib/admin/filters.pyi | 10 +- django-stubs/contrib/admin/helpers.pyi | 60 +-- django-stubs/contrib/admin/models.pyi | 6 +- django-stubs/contrib/admin/options.pyi | 142 ++++--- django-stubs/contrib/admin/sites.pyi | 50 ++- .../contrib/admin/templatetags/admin_list.pyi | 18 +- .../contrib/admin/templatetags/admin_urls.pyi | 8 +- .../contrib/admin/templatetags/log.pyi | 4 +- django-stubs/contrib/admin/utils.pyi | 38 +- .../contrib/admin/views/autocomplete.pyi | 4 +- .../contrib/admin/views/decorators.pyi | 8 +- django-stubs/contrib/admin/views/main.pyi | 30 +- django-stubs/contrib/admin/widgets.pyi | 52 +-- django-stubs/contrib/admindocs/middleware.pyi | 4 +- django-stubs/contrib/admindocs/utils.pyi | 8 +- django-stubs/contrib/admindocs/views.pyi | 8 +- django-stubs/contrib/auth/__init__.pyi | 8 +- django-stubs/contrib/auth/backends.pyi | 30 +- django-stubs/contrib/auth/base_user.pyi | 10 +- django-stubs/contrib/auth/checks.pyi | 6 +- django-stubs/contrib/auth/decorators.pyi | 12 +- django-stubs/contrib/auth/forms.pyi | 24 +- django-stubs/contrib/auth/hashers.pyi | 18 +- django-stubs/contrib/auth/middleware.pyi | 4 +- django-stubs/contrib/auth/mixins.pyi | 4 +- django-stubs/contrib/auth/models.pyi | 34 +- .../contrib/auth/password_validation.pyi | 20 +- django-stubs/contrib/auth/tokens.pyi | 6 +- django-stubs/contrib/auth/views.pyi | 12 +- django-stubs/contrib/contenttypes/checks.pyi | 6 +- django-stubs/contrib/contenttypes/fields.pyi | 34 +- django-stubs/contrib/contenttypes/forms.pyi | 24 +- django-stubs/contrib/contenttypes/models.pyi | 6 +- django-stubs/contrib/contenttypes/views.pyi | 6 +- .../flatpages/templatetags/flatpages.pyi | 4 +- django-stubs/contrib/gis/admin/options.pyi | 8 +- .../gis/db/backends/mysql/operations.pyi | 4 +- .../gis/db/backends/postgis/operations.pyi | 8 +- .../contrib/gis/db/backends/utils.pyi | 4 +- .../contrib/gis/db/models/aggregates.pyi | 8 +- django-stubs/contrib/gis/db/models/fields.pyi | 42 +- .../contrib/gis/db/models/functions.pyi | 8 +- django-stubs/contrib/gis/db/models/proxy.pyi | 6 +- django-stubs/contrib/gis/forms/fields.pyi | 4 +- django-stubs/contrib/gis/forms/widgets.pyi | 6 +- django-stubs/contrib/gis/gdal/geometries.pyi | 4 +- .../contrib/gis/gdal/prototypes/errcheck.pyi | 4 +- .../gis/gdal/prototypes/generation.pyi | 12 +- django-stubs/contrib/gis/gdal/raster/band.pyi | 10 +- .../contrib/gis/gdal/raster/source.pyi | 6 +- django-stubs/contrib/gis/gdal/srs.pyi | 4 +- django-stubs/contrib/gis/geoip2/base.pyi | 4 +- django-stubs/contrib/gis/geos/geometry.pyi | 4 +- django-stubs/contrib/gis/geos/libgeos.pyi | 9 +- .../contrib/gis/geos/mutable_list.pyi | 4 +- django-stubs/contrib/gis/geos/point.pyi | 4 +- .../contrib/gis/geos/prototypes/io.pyi | 6 +- django-stubs/contrib/gis/measure.pyi | 4 +- django-stubs/contrib/gis/sitemaps/kml.pyi | 4 +- django-stubs/contrib/gis/sitemaps/views.pyi | 6 +- .../contrib/gis/utils/layermapping.pyi | 8 +- django-stubs/contrib/gis/utils/srs.pyi | 8 +- django-stubs/contrib/gis/views.pyi | 4 +- .../humanize/templatetags/humanize.pyi | 12 +- django-stubs/contrib/messages/api.pyi | 22 +- .../contrib/messages/context_processors.pyi | 4 +- .../contrib/messages/storage/__init__.pyi | 2 +- .../contrib/messages/storage/base.pyi | 8 +- .../contrib/messages/storage/session.pyi | 4 +- django-stubs/contrib/postgres/constraints.pyi | 18 +- .../contrib/postgres/fields/array.pyi | 30 +- .../contrib/postgres/fields/ranges.pyi | 4 +- django-stubs/contrib/postgres/forms/array.pyi | 14 +- .../contrib/postgres/forms/hstore.pyi | 4 +- .../contrib/postgres/forms/ranges.pyi | 12 +- django-stubs/contrib/postgres/indexes.pyi | 94 ++--- django-stubs/contrib/postgres/search.pyi | 50 +-- django-stubs/contrib/postgres/validators.pyi | 6 +- .../contrib/sessions/backends/base.pyi | 20 +- .../contrib/sessions/backends/cache.pyi | 4 +- .../contrib/sessions/backends/cached_db.pyi | 4 +- django-stubs/contrib/sessions/backends/db.pyi | 4 +- .../contrib/sessions/backends/file.pyi | 4 +- .../contrib/sessions/base_session.pyi | 4 +- django-stubs/contrib/sitemaps/__init__.pyi | 32 +- django-stubs/contrib/sitemaps/views.pyi | 8 +- django-stubs/contrib/sites/managers.pyi | 4 +- django-stubs/contrib/sites/models.pyi | 4 +- django-stubs/contrib/sites/shortcuts.pyi | 4 +- django-stubs/contrib/staticfiles/checks.pyi | 4 +- django-stubs/contrib/staticfiles/finders.pyi | 28 +- django-stubs/contrib/staticfiles/storage.pyi | 8 +- django-stubs/contrib/staticfiles/urls.pyi | 4 +- django-stubs/contrib/staticfiles/utils.pyi | 8 +- django-stubs/contrib/syndication/views.pyi | 10 +- django-stubs/core/cache/backends/base.pyi | 78 ++-- .../core/cache/backends/memcached.pyi | 8 +- django-stubs/core/cache/utils.pyi | 4 +- django-stubs/core/checks/async_checks.pyi | 4 +- django-stubs/core/checks/caches.pyi | 12 +- django-stubs/core/checks/database.pyi | 4 +- django-stubs/core/checks/messages.pyi | 20 +- django-stubs/core/checks/model_checks.pyi | 8 +- django-stubs/core/checks/registry.pyi | 12 +- django-stubs/core/checks/security/base.pyi | 28 +- django-stubs/core/checks/security/csrf.pyi | 6 +- .../core/checks/security/sessions.pyi | 6 +- django-stubs/core/checks/templates.pyi | 6 +- django-stubs/core/checks/translation.pyi | 12 +- django-stubs/core/checks/urls.pyi | 8 +- django-stubs/core/exceptions.pyi | 14 +- django-stubs/core/files/base.pyi | 30 +- django-stubs/core/files/images.pyi | 6 +- django-stubs/core/files/storage.pyi | 22 +- django-stubs/core/files/uploadedfile.pyi | 48 +-- django-stubs/core/files/uploadhandler.pyi | 54 +-- django-stubs/core/files/utils.pyi | 4 +- django-stubs/core/handlers/asgi.pyi | 22 +- django-stubs/core/handlers/base.pyi | 12 +- django-stubs/core/handlers/exception.pyi | 6 +- django-stubs/core/handlers/wsgi.pyi | 6 +- django-stubs/core/mail/__init__.pyi | 28 +- django-stubs/core/mail/backends/base.pyi | 10 +- django-stubs/core/mail/backends/smtp.pyi | 9 +- django-stubs/core/mail/message.pyi | 60 +-- django-stubs/core/management/__init__.pyi | 10 +- django-stubs/core/management/base.pyi | 42 +- .../management/commands/compilemessages.pyi | 2 +- .../core/management/commands/loaddata.pyi | 6 +- .../core/management/commands/makemessages.pyi | 4 +- .../core/management/commands/migrate.pyi | 4 +- .../management/commands/showmigrations.pyi | 6 +- .../core/management/commands/sqlmigrate.pyi | 4 +- django-stubs/core/management/templates.pyi | 6 +- django-stubs/core/management/utils.pyi | 12 +- django-stubs/core/paginator.pyi | 14 +- django-stubs/core/serializers/__init__.pyi | 8 +- django-stubs/core/serializers/base.pyi | 40 +- django-stubs/core/serializers/json.pyi | 4 +- django-stubs/core/serializers/jsonl.pyi | 4 +- django-stubs/core/serializers/pyyaml.pyi | 4 +- .../core/serializers/xml_serializer.pyi | 4 +- django-stubs/core/signing.pyi | 20 +- django-stubs/core/validators.pyi | 50 +-- django-stubs/db/backends/base/base.pyi | 14 +- django-stubs/db/backends/base/client.pyi | 6 +- django-stubs/db/backends/base/creation.pyi | 10 +- django-stubs/db/backends/base/features.pyi | 14 +- .../db/backends/base/introspection.pyi | 18 +- django-stubs/db/backends/base/operations.pyi | 62 +-- django-stubs/db/backends/base/schema.pyi | 18 +- django-stubs/db/backends/mysql/base.pyi | 8 +- django-stubs/db/backends/mysql/client.pyi | 4 +- django-stubs/db/backends/mysql/operations.pyi | 18 +- django-stubs/db/backends/oracle/base.pyi | 12 +- django-stubs/db/backends/oracle/functions.pyi | 6 +- .../db/backends/oracle/operations.pyi | 18 +- .../db/backends/postgresql/client.pyi | 4 +- django-stubs/db/backends/sqlite3/creation.pyi | 3 +- .../db/backends/sqlite3/introspection.pyi | 4 +- django-stubs/db/backends/utils.pyi | 61 ++- django-stubs/db/migrations/autodetector.pyi | 20 +- django-stubs/db/migrations/exceptions.pyi | 6 +- django-stubs/db/migrations/executor.pyi | 20 +- django-stubs/db/migrations/graph.pyi | 20 +- django-stubs/db/migrations/loader.pyi | 12 +- django-stubs/db/migrations/migration.pyi | 4 +- .../db/migrations/operations/base.pyi | 6 +- .../db/migrations/operations/fields.pyi | 4 +- .../db/migrations/operations/models.pyi | 28 +- .../db/migrations/operations/special.pyi | 10 +- .../db/migrations/operations/utils.pyi | 12 +- django-stubs/db/migrations/optimizer.pyi | 6 +- django-stubs/db/migrations/questioner.pyi | 10 +- django-stubs/db/migrations/serializer.pyi | 4 +- django-stubs/db/migrations/state.pyi | 14 +- django-stubs/db/models/aggregates.pyi | 4 +- django-stubs/db/models/base.pyi | 26 +- django-stubs/db/models/constraints.pyi | 28 +- django-stubs/db/models/deletion.pyi | 26 +- django-stubs/db/models/expressions.pyi | 94 +++-- django-stubs/db/models/fields/__init__.pyi | 314 ++++++++------- django-stubs/db/models/fields/files.pyi | 50 ++- django-stubs/db/models/fields/json.pyi | 16 +- django-stubs/db/models/fields/mixins.pyi | 6 +- django-stubs/db/models/fields/related.pyi | 134 +++---- .../db/models/fields/related_descriptors.pyi | 20 +- .../db/models/fields/related_lookups.pyi | 4 +- .../db/models/fields/reverse_related.pyi | 62 +-- .../db/models/functions/comparison.pyi | 4 +- django-stubs/db/models/functions/datetime.pyi | 6 +- django-stubs/db/models/functions/text.pyi | 24 +- django-stubs/db/models/functions/window.pyi | 8 +- django-stubs/db/models/indexes.pyi | 24 +- django-stubs/db/models/lookups.pyi | 14 +- django-stubs/db/models/manager.pyi | 92 +++-- django-stubs/db/models/options.pyi | 60 +-- django-stubs/db/models/query.pyi | 104 +++-- django-stubs/db/models/query_utils.pyi | 35 +- django-stubs/db/models/signals.pyi | 18 +- django-stubs/db/models/sql/compiler.pyi | 52 +-- django-stubs/db/models/sql/datastructures.pyi | 20 +- django-stubs/db/models/sql/query.pyi | 92 +++-- django-stubs/db/models/sql/subqueries.pyi | 10 +- django-stubs/db/models/sql/where.pyi | 18 +- django-stubs/db/models/utils.pyi | 4 +- django-stubs/db/transaction.pyi | 42 +- django-stubs/db/utils.pyi | 10 +- django-stubs/dispatch/dispatcher.pyi | 12 +- django-stubs/forms/boundfield.pyi | 20 +- django-stubs/forms/fields.pyi | 358 +++++++++--------- django-stubs/forms/forms.pyi | 36 +- django-stubs/forms/formsets.pyi | 34 +- django-stubs/forms/models.pyi | 208 +++++----- django-stubs/forms/renderers.pyi | 6 +- django-stubs/forms/utils.pyi | 8 +- django-stubs/forms/widgets.pyi | 110 +++--- django-stubs/http/multipartparser.pyi | 16 +- django-stubs/http/request.pyi | 98 ++--- django-stubs/http/response.pyi | 42 +- django-stubs/middleware/cache.pyi | 12 +- django-stubs/middleware/common.pyi | 4 +- django-stubs/middleware/csrf.pyi | 6 +- django-stubs/middleware/security.pyi | 6 +- django-stubs/shortcuts.pyi | 26 +- django-stubs/template/backends/base.pyi | 8 +- django-stubs/template/backends/django.pyi | 4 +- django-stubs/template/backends/dummy.pyi | 6 +- django-stubs/template/backends/jinja2.pyi | 6 +- django-stubs/template/base.pyi | 92 ++--- django-stubs/template/context.pyi | 60 ++- django-stubs/template/context_processors.pyi | 6 +- django-stubs/template/defaultfilters.pyi | 48 +-- django-stubs/template/defaulttags.pyi | 68 ++-- django-stubs/template/engine.pyi | 18 +- django-stubs/template/exceptions.pyi | 12 +- django-stubs/template/library.pyi | 63 ++- django-stubs/template/loader.pyi | 14 +- django-stubs/template/loader_tags.pyi | 16 +- django-stubs/template/loaders/base.pyi | 4 +- django-stubs/template/loaders/cached.pyi | 4 +- django-stubs/template/loaders/filesystem.pyi | 8 +- django-stubs/template/response.pyi | 38 +- django-stubs/template/smartif.pyi | 16 +- django-stubs/templatetags/cache.pyi | 6 +- django-stubs/templatetags/i18n.pyi | 26 +- django-stubs/templatetags/static.pyi | 10 +- django-stubs/templatetags/tz.pyi | 8 +- django-stubs/test/client.pyi | 33 +- django-stubs/test/html.pyi | 14 +- django-stubs/test/runner.pyi | 38 +- django-stubs/test/testcases.pyi | 84 ++-- django-stubs/test/utils.pyi | 56 ++- django-stubs/urls/__init__.pyi | 4 +- django-stubs/urls/base.pyi | 20 +- django-stubs/urls/conf.pyi | 12 +- django-stubs/urls/converters.pyi | 6 +- django-stubs/urls/resolvers.pyi | 60 +-- django-stubs/urls/utils.pyi | 4 +- django-stubs/utils/_os.pyi | 5 +- django-stubs/utils/archive.pyi | 8 +- django-stubs/utils/autoreload.pyi | 6 +- django-stubs/utils/baseconv.pyi | 4 +- django-stubs/utils/cache.pyi | 24 +- django-stubs/utils/connection.pyi | 8 +- django-stubs/utils/crypto.pyi | 16 +- django-stubs/utils/datastructures.pyi | 28 +- django-stubs/utils/dateformat.pyi | 22 +- django-stubs/utils/dateparse.pyi | 10 +- django-stubs/utils/datetime_safe.pyi | 5 +- django-stubs/utils/deconstruct.pyi | 4 +- django-stubs/utils/decorators.pyi | 6 +- django-stubs/utils/deprecation.pyi | 2 +- django-stubs/utils/encoding.pyi | 4 +- django-stubs/utils/feedgenerator.pyi | 52 +-- django-stubs/utils/formats.pyi | 32 +- django-stubs/utils/functional.pyi | 16 +- django-stubs/utils/html.pyi | 4 +- django-stubs/utils/http.pyi | 14 +- django-stubs/utils/inspect.pyi | 4 +- django-stubs/utils/jslex.pyi | 6 +- django-stubs/utils/log.pyi | 22 +- django-stubs/utils/numberformat.pyi | 10 +- django-stubs/utils/regex_helper.pyi | 12 +- django-stubs/utils/termcolors.pyi | 6 +- django-stubs/utils/text.pyi | 12 +- django-stubs/utils/timesince.pyi | 10 +- django-stubs/utils/timezone.pyi | 30 +- django-stubs/utils/translation/__init__.pyi | 22 +- django-stubs/utils/translation/reloader.pyi | 4 +- django-stubs/utils/translation/trans_real.pyi | 16 +- django-stubs/utils/tree.pyi | 6 +- django-stubs/utils/version.pyi | 10 +- django-stubs/utils/xmlutils.pyi | 6 +- django-stubs/views/debug.pyi | 44 +-- django-stubs/views/decorators/cache.pyi | 6 +- django-stubs/views/decorators/http.pyi | 4 +- django-stubs/views/defaults.pyi | 4 +- django-stubs/views/generic/base.pyi | 14 +- django-stubs/views/generic/dates.pyi | 36 +- django-stubs/views/generic/detail.pyi | 12 +- django-stubs/views/generic/edit.pyi | 16 +- django-stubs/views/generic/list.pyi | 16 +- django-stubs/views/i18n.pyi | 8 +- django-stubs/views/static.pyi | 6 +- 313 files changed, 3169 insertions(+), 3462 deletions(-) diff --git a/django-stubs/apps/config.pyi b/django-stubs/apps/config.pyi index bc23d0f16..ba477f4a0 100644 --- a/django-stubs/apps/config.pyi +++ b/django-stubs/apps/config.pyi @@ -1,5 +1,5 @@ import types -from typing import Dict, Iterator, Optional, Type +from typing import Dict, Iterator, Type from django.apps.registry import Apps from django.db.models.base import Model @@ -9,14 +9,14 @@ MODELS_MODULE_NAME: str class AppConfig: name: str = ... - module: Optional[types.ModuleType] = ... - apps: Optional[Apps] = ... + module: types.ModuleType | None = ... + apps: Apps | None = ... label: str = ... verbose_name: _StrOrPromise = ... path: str = ... - models_module: Optional[str] = ... + models_module: str | None = ... models: Dict[str, Type[Model]] = ... - def __init__(self, app_name: str, app_module: Optional[types.ModuleType]) -> None: ... + def __init__(self, app_name: str, app_module: types.ModuleType | None) -> None: ... @classmethod def create(cls, entry: str) -> AppConfig: ... def get_model(self, model_name: str, require_ready: bool = ...) -> Type[Model]: ... diff --git a/django-stubs/apps/registry.pyi b/django-stubs/apps/registry.pyi index 9cf5ed1bc..468a679b4 100644 --- a/django-stubs/apps/registry.pyi +++ b/django-stubs/apps/registry.pyi @@ -1,5 +1,5 @@ import threading -from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union +from typing import Any, Callable, Dict, Iterable, List, Tuple, Type from django.db.models.base import Model @@ -15,20 +15,20 @@ class Apps: _pending_operations: Dict[Tuple[str, str], List] models_ready: bool = ... ready: bool = ... - def __init__(self, installed_apps: Optional[Iterable[Union[AppConfig, str]]] = ...) -> None: ... - def populate(self, installed_apps: Iterable[Union[AppConfig, str]] = ...) -> 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: Optional[str] = ..., require_ready: bool = ...) -> Type[Any]: ... + def get_model(self, app_label: str, model_name: str | None = ..., require_ready: bool = ...) -> Type[Any]: ... 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) -> Optional[AppConfig]: ... + def get_containing_app_config(self, object_name: str) -> AppConfig | None: ... def get_registered_model(self, app_label: str, model_name: str) -> Type[Model]: ... - def get_swappable_settings_name(self, to_string: str) -> Optional[str]: ... + def get_swappable_settings_name(self, to_string: str) -> str | None: ... def set_available_apps(self, available: Iterable[str]) -> None: ... def unset_available_apps(self) -> None: ... def set_installed_apps(self, installed: Iterable[str]) -> None: ... diff --git a/django-stubs/conf/__init__.pyi b/django-stubs/conf/__init__.pyi index 83ec3275b..c48da17f3 100644 --- a/django-stubs/conf/__init__.pyi +++ b/django-stubs/conf/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.utils.functional import LazyObject diff --git a/django-stubs/conf/global_settings.pyi b/django-stubs/conf/global_settings.pyi index 24014e8bd..9f71ba6cb 100644 --- a/django-stubs/conf/global_settings.pyi +++ b/django-stubs/conf/global_settings.pyi @@ -5,7 +5,7 @@ by the DJANGO_SETTINGS_MODULE environment variable. # This is defined here as a do-nothing function because we can't import # django.utils.translation -- that module depends on the settings. -from typing import Any, Dict, List, Optional, Pattern, Protocol, Sequence, Tuple, Union +from typing import Any, Dict, List, Pattern, Protocol, Sequence, Tuple from typing_extensions import Literal @@ -58,11 +58,11 @@ LOCALE_PATHS: List[str] = ... # Settings for language cookie LANGUAGE_COOKIE_NAME: str = ... -LANGUAGE_COOKIE_AGE: Optional[int] = ... -LANGUAGE_COOKIE_DOMAIN: Optional[str] = ... +LANGUAGE_COOKIE_AGE: int | None = ... +LANGUAGE_COOKIE_DOMAIN: str | None = ... LANGUAGE_COOKIE_PATH: str = ... LANGUAGE_COOKIE_HTTPONLY: bool = ... -LANGUAGE_COOKIE_SAMESITE: Optional[Literal["Lax", "Strict", "None", False]] = ... +LANGUAGE_COOKIE_SAMESITE: Literal["Lax", "Strict", "None", False] | None = ... # If you set this to True, Django will format dates, numbers and calendars # according to user current locale. @@ -85,9 +85,9 @@ DATABASES: Dict[str, Dict[str, Any]] = ... # Classes used to implement DB routing behavior. class Router(Protocol): - def allow_migrate(self, db: str, app_label: str, **hints: Any) -> Optional[bool]: ... + def allow_migrate(self, db: str, app_label: str, **hints: Any) -> bool | None: ... -DATABASE_ROUTERS: List[Union[str, Router]] = ... +DATABASE_ROUTERS: List[str | Router] = ... # The email backend to use. For possible shortcuts see django.core.mail. # The default is to use the SMTP backend. @@ -109,9 +109,9 @@ EMAIL_HOST_USER: str = ... EMAIL_HOST_PASSWORD: str = ... EMAIL_USE_TLS: bool = ... EMAIL_USE_SSL: bool = ... -EMAIL_SSL_CERTFILE: Optional[str] = ... -EMAIL_SSL_KEYFILE: Optional[str] = ... -EMAIL_TIMEOUT: Optional[int] = ... +EMAIL_SSL_CERTFILE: str | None = ... +EMAIL_SSL_KEYFILE: str | None = ... +EMAIL_TIMEOUT: int | None = ... # List of strings representing installed apps. INSTALLED_APPS: List[str] = ... @@ -136,7 +136,7 @@ APPEND_SLASH: bool = ... PREPEND_WWW: bool = ... # Override the server-derived value of SCRIPT_NAME -FORCE_SCRIPT_NAME: Optional[str] = ... +FORCE_SCRIPT_NAME: str | None = ... # List of compiled regular expression objects representing User-Agent strings # that are not allowed to visit any page, systemwide. Use this for bad @@ -182,11 +182,11 @@ MEDIA_URL: str = ... # Absolute path to the directory static files should be collected to. # Example: "/var/www/example.com/static/" -STATIC_ROOT: Optional[str] = ... +STATIC_ROOT: str | None = ... # URL that handles the static files served from STATIC_ROOT. # Example: "http://example.com/static/", "http://static.example.com/" -STATIC_URL: Optional[str] = ... +STATIC_URL: str | None = ... # List of upload handler classes to be applied in order. FILE_UPLOAD_HANDLERS: List[str] = ... @@ -206,7 +206,7 @@ DATA_UPLOAD_MAX_NUMBER_FIELDS: int = ... # Directory in which upload streamed files will be temporarily saved. A value of # `None` will make Django use the operating system's default temporary directory # (i.e. "/tmp" on *nix systems). -FILE_UPLOAD_TEMP_DIR: Optional[str] = ... +FILE_UPLOAD_TEMP_DIR: str | None = ... # The numeric mode to set newly-uploaded files to. The value should be a mode # you'd pass directly to os.chmod; see https://docs.python.org/library/os.html#files-and-directories. @@ -215,13 +215,13 @@ FILE_UPLOAD_PERMISSIONS: int = ... # The numeric mode to assign to newly-created directories, when uploading files. # The value should be a mode as you'd pass to os.chmod; # see https://docs.python.org/library/os.html#files-and-directories. -FILE_UPLOAD_DIRECTORY_PERMISSIONS: Optional[int] = ... +FILE_UPLOAD_DIRECTORY_PERMISSIONS: int | None = ... # Python module path where user will place custom format definition. # The directory where this setting is pointing should contain subdirectories # named as the locales, containing a formats.py file # (i.e. "myproject.locale" for myproject/locale/en/formats.py etc. use) -FORMAT_MODULE_PATH: Optional[str] = ... +FORMAT_MODULE_PATH: str | None = ... # Default formatting for date objects. See all available format strings here: # https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date @@ -305,7 +305,7 @@ USE_X_FORWARDED_PORT: bool = ... # 'django.core.wsgi.get_wsgi_application' is used, thus preserving the same # behavior as previous versions of Django. Otherwise this should point to an # actual WSGI application object. -WSGI_APPLICATION: Optional[str] = ... +WSGI_APPLICATION: str | None = ... # If your Django app is behind a proxy that sets a header to specify secure # connections, AND that proxy ensures that user-submitted headers with the @@ -314,7 +314,7 @@ WSGI_APPLICATION: Optional[str] = ... # that header/value, request.is_secure() will return True. # WARNING! Only set this if you fully understand what you're doing. Otherwise, # you may be opening yourself up to a security risk. -SECURE_PROXY_SSL_HEADER: Optional[Tuple[str, str]] = ... +SECURE_PROXY_SSL_HEADER: Tuple[str, str] | None = ... ############## # MIDDLEWARE # @@ -336,7 +336,7 @@ SESSION_COOKIE_NAME: str = ... # Age of cookie, in seconds (default: 2 weeks). SESSION_COOKIE_AGE: int = ... # A string like "example.com", or None for standard domain cookie. -SESSION_COOKIE_DOMAIN: Optional[str] = ... +SESSION_COOKIE_DOMAIN: str | None = ... # Whether the session cookie should be secure (https:// only). SESSION_COOKIE_SECURE: bool = ... # The path of the session cookie. @@ -354,7 +354,7 @@ SESSION_EXPIRE_AT_BROWSER_CLOSE: bool = ... SESSION_ENGINE: str = ... # Directory to store session files if using the file session module. If None, # the backend will use a sensible default. -SESSION_FILE_PATH: Optional[str] = ... +SESSION_FILE_PATH: str | None = ... # class to serialize session data SESSION_SERIALIZER: str = ... @@ -380,7 +380,7 @@ LOGIN_URL: str = ... LOGIN_REDIRECT_URL: str = ... -LOGOUT_REDIRECT_URL: Optional[str] = ... +LOGOUT_REDIRECT_URL: str | None = ... # The number of days a password reset link is valid for PASSWORD_RESET_TIMEOUT_DAYS: int = ... @@ -409,7 +409,7 @@ CSRF_FAILURE_VIEW: str = ... # Settings for CSRF cookie. CSRF_COOKIE_NAME: str = ... CSRF_COOKIE_AGE: int = ... -CSRF_COOKIE_DOMAIN: Optional[str] = ... +CSRF_COOKIE_DOMAIN: str | None = ... CSRF_COOKIE_PATH: str = ... CSRF_COOKIE_SECURE: bool = ... CSRF_COOKIE_HTTPONLY: bool = ... @@ -500,5 +500,5 @@ SECURE_HSTS_INCLUDE_SUBDOMAINS: bool = ... SECURE_HSTS_PRELOAD: bool = ... SECURE_HSTS_SECONDS: int = ... SECURE_REDIRECT_EXEMPT: List[str] = ... -SECURE_SSL_HOST: Optional[str] = ... +SECURE_SSL_HOST: str | None = ... SECURE_SSL_REDIRECT: bool = ... diff --git a/django-stubs/conf/urls/__init__.pyi b/django-stubs/conf/urls/__init__.pyi index 865a3a33f..6d58d9a41 100644 --- a/django-stubs/conf/urls/__init__.pyi +++ b/django-stubs/conf/urls/__init__.pyi @@ -1,30 +1,30 @@ # Stubs for django.conf.urls (Python 3.5) -from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Union, overload +from typing import Any, Callable, Dict, Sequence, Tuple, overload from django.http.response import HttpResponse, HttpResponseBase from django.urls import URLPattern, URLResolver from django.urls import include as include -handler400: Union[str, Callable[..., HttpResponse]] = ... -handler403: Union[str, Callable[..., HttpResponse]] = ... -handler404: Union[str, Callable[..., HttpResponse]] = ... -handler500: Union[str, Callable[..., HttpResponse]] = ... +handler400: str | Callable[..., HttpResponse] = ... +handler403: str | Callable[..., HttpResponse] = ... +handler404: str | Callable[..., HttpResponse] = ... +handler500: str | Callable[..., HttpResponse] = ... -IncludedURLConf = Tuple[Sequence[Union[URLResolver, URLPattern]], Optional[str], Optional[str]] +IncludedURLConf = Tuple[Sequence[URLResolver | URLPattern], str | None, str | None] # Deprecated @overload def url( - regex: str, view: Callable[..., HttpResponseBase], kwargs: Optional[Dict[str, Any]] = ..., name: Optional[str] = ... + regex: str, view: Callable[..., HttpResponseBase], kwargs: Dict[str, Any] | None = ..., name: str | None = ... ) -> URLPattern: ... @overload def url( - regex: str, view: IncludedURLConf, kwargs: Optional[Dict[str, Any]] = ..., name: Optional[str] = ... + regex: str, view: IncludedURLConf, kwargs: Dict[str, Any] | None = ..., name: str | None = ... ) -> URLResolver: ... @overload def url( regex: str, - view: Sequence[Union[URLResolver, str]], - kwargs: Optional[Dict[str, Any]] = ..., - name: Optional[str] = ..., + view: Sequence[URLResolver | str], + kwargs: Dict[str, Any] | None = ..., + name: str | None = ..., ) -> URLResolver: ... diff --git a/django-stubs/contrib/admin/actions.pyi b/django-stubs/contrib/admin/actions.pyi index 137095079..767fc7100 100644 --- a/django-stubs/contrib/admin/actions.pyi +++ b/django-stubs/contrib/admin/actions.pyi @@ -1,8 +1,6 @@ -from typing import Optional - from django.contrib.admin.options import ModelAdmin from django.db.models.query import QuerySet from django.http.request import HttpRequest from django.template.response import TemplateResponse -def delete_selected(modeladmin: ModelAdmin, request: HttpRequest, queryset: QuerySet) -> Optional[TemplateResponse]: ... +def delete_selected(modeladmin: ModelAdmin, request: HttpRequest, queryset: QuerySet) -> TemplateResponse | None: ... diff --git a/django-stubs/contrib/admin/checks.pyi b/django-stubs/contrib/admin/checks.pyi index c44ff93cd..2500aa411 100644 --- a/django-stubs/contrib/admin/checks.pyi +++ b/django-stubs/contrib/admin/checks.pyi @@ -1,10 +1,10 @@ -from typing import Any, List, Optional, Sequence +from typing import Any, List, Sequence from django.apps.config import AppConfig from django.contrib.admin.options import BaseModelAdmin from django.core.checks.messages import CheckMessage, Error -def check_admin_app(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> List[CheckMessage]: ... +def check_admin_app(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> List[CheckMessage]: ... def check_dependencies(**kwargs: Any) -> List[CheckMessage]: ... class BaseModelAdminChecks: diff --git a/django-stubs/contrib/admin/decorators.pyi b/django-stubs/contrib/admin/decorators.pyi index 86f694dbd..f01e3bb97 100644 --- a/django-stubs/contrib/admin/decorators.pyi +++ b/django-stubs/contrib/admin/decorators.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Optional, Sequence, Type, TypeVar, Union +from typing import Any, Callable, Sequence, Type, TypeVar from django.contrib.admin import ModelAdmin from django.contrib.admin.sites import AdminSite @@ -10,17 +10,17 @@ from django.http import HttpRequest _ModelT = TypeVar("_ModelT", bound=Model) def action( - function: Optional[Callable[[ModelAdmin, HttpRequest, QuerySet], None]] = ..., + function: Callable[[ModelAdmin, HttpRequest, QuerySet], None] | None = ..., *, - permissions: Optional[Sequence[str]] = ..., - description: Optional[str] = ..., + permissions: Sequence[str] | None = ..., + description: str | None = ..., ) -> Callable: ... def display( - function: Optional[Callable[[_ModelT], Any]] = ..., + function: Callable[[_ModelT], Any] | None = ..., *, - boolean: Optional[bool] = ..., - ordering: Optional[Union[str, Combinable, BaseExpression]] = ..., - description: Optional[str] = ..., - empty_value: Optional[str] = ..., + boolean: bool | None = ..., + ordering: str | Combinable | BaseExpression | None = ..., + description: str | None = ..., + empty_value: str | None = ..., ) -> Callable: ... -def register(*models: Type[Model], site: Optional[AdminSite] = ...) -> Callable: ... +def register(*models: Type[Model], site: AdminSite | None = ...) -> Callable: ... diff --git a/django-stubs/contrib/admin/filters.pyi b/django-stubs/contrib/admin/filters.pyi index e3a22c513..54456c129 100644 --- a/django-stubs/contrib/admin/filters.pyi +++ b/django-stubs/contrib/admin/filters.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Type +from typing import Any, Callable, Dict, Iterable, Iterator, List, Tuple, Type from django.contrib.admin.options import ModelAdmin from django.db.models.base import Model @@ -16,14 +16,14 @@ class ListFilter: ) -> None: ... def has_output(self) -> bool: ... def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... - def queryset(self, request: HttpRequest, queryset: QuerySet) -> Optional[QuerySet]: ... - def expected_parameters(self) -> Optional[List[str]]: ... + def queryset(self, request: HttpRequest, queryset: QuerySet) -> QuerySet | None: ... + def expected_parameters(self) -> List[str] | None: ... class SimpleListFilter(ListFilter): parameter_name: str = ... lookup_choices: Any = ... - def value(self) -> Optional[str]: ... - def lookups(self, request: HttpRequest, model_admin: ModelAdmin) -> Optional[Iterable[Tuple[Any, str]]]: ... + def value(self) -> str | None: ... + def lookups(self, request: HttpRequest, model_admin: ModelAdmin) -> Iterable[Tuple[Any, str]] | None: ... def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... class FieldListFilter(ListFilter): diff --git a/django-stubs/contrib/admin/helpers.pyi b/django-stubs/contrib/admin/helpers.pyi index 19b2f3730..64c007d22 100644 --- a/django-stubs/contrib/admin/helpers.pyi +++ b/django-stubs/contrib/admin/helpers.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Tuple, Union +from typing import Any, Callable, Dict, Iterable, Iterator, List, Mapping, Sequence, Tuple from django import forms from django.contrib.admin.options import ModelAdmin @@ -26,7 +26,7 @@ class _PrepopulatedDict(TypedDict): class AdminForm: prepopulated_fields: List[_PrepopulatedDict] - model_admin: Optional[ModelAdmin] = ... + model_admin: ModelAdmin | None = ... readonly_fields: Sequence[str] = ... form: ModelForm fieldsets: List[Tuple[Any, Dict[str, List[str]]]] @@ -35,8 +35,8 @@ class AdminForm: form: ModelForm, fieldsets: List[Tuple[Any, Dict[str, List[str]]]], prepopulated_fields: Mapping[str, Iterable[str]], - readonly_fields: Optional[Sequence[str]] = ..., - model_admin: Optional[ModelAdmin] = ..., + readonly_fields: Sequence[str] | None = ..., + model_admin: ModelAdmin | None = ..., ) -> None: ... def __iter__(self) -> Iterator[Fieldset]: ... @property @@ -49,18 +49,18 @@ class AdminForm: class Fieldset: form: ModelForm = ... classes: str = ... - description: Optional[str] = ... - model_admin: Optional[ModelAdmin] = ... + description: str | None = ... + model_admin: ModelAdmin | None = ... readonly_fields: Sequence[str] = ... def __init__( self, form: ModelForm, - name: Optional[Any] = ..., + name: Any | None = ..., readonly_fields: Sequence[str] = ..., fields: Sequence[str] = ..., classes: Iterable[str] = ..., - description: Optional[str] = ..., - model_admin: Optional[ModelAdmin] = ..., + description: str | None = ..., + model_admin: ModelAdmin | None = ..., ) -> None: ... @property def media(self) -> Media: ... @@ -70,16 +70,16 @@ class Fieldline: form: ModelForm = ... fields: Sequence[str] = ... has_visible_field: bool = ... - model_admin: Optional[ModelAdmin] = ... + model_admin: ModelAdmin | None = ... readonly_fields: Sequence[str] = ... def __init__( self, form: ModelForm, - field: Union[str, Sequence[str]], - readonly_fields: Optional[Sequence[str]] = ..., - model_admin: Optional[ModelAdmin] = ..., + field: str | Sequence[str], + readonly_fields: Sequence[str] | None = ..., + model_admin: ModelAdmin | None = ..., ) -> None: ... - def __iter__(self) -> Iterator[Union[AdminField, AdminReadonlyField]]: ... + def __iter__(self) -> Iterator[AdminField | AdminReadonlyField]: ... def errors(self) -> SafeString: ... class AdminField: @@ -95,12 +95,12 @@ class _FieldDictT(TypedDict): name: str label: str help_text: str - field: Union[Callable[[Model], Any], str] + field: Callable[[Model], Any] | str class AdminReadonlyField: field: _FieldDictT = ... form: ModelForm = ... - model_admin: Optional[ModelAdmin] = ... + model_admin: ModelAdmin | None = ... is_first: bool = ... is_checkbox: bool = ... is_readonly: bool = ... @@ -108,9 +108,9 @@ class AdminReadonlyField: def __init__( self, form: ModelForm, - field: Union[Callable[[Model], Any], str], + field: Callable[[Model], Any] | str, is_first: bool, - model_admin: Optional[ModelAdmin] = ..., + model_admin: ModelAdmin | None = ..., ) -> None: ... def label_tag(self) -> SafeString: ... def contents(self) -> SafeString: ... @@ -119,7 +119,7 @@ class InlineAdminFormSet: opts: Any = ... formset: Any = ... fieldsets: Any = ... - model_admin: Optional[ModelAdmin] = ... + model_admin: ModelAdmin | None = ... readonly_fields: Sequence[str] = ... prepopulated_fields: Dict[str, Any] = ... classes: str = ... @@ -132,16 +132,16 @@ class InlineAdminFormSet: inline: Any, formset: Any, fieldsets: Any, - prepopulated_fields: Optional[Dict[str, Any]] = ..., - readonly_fields: Optional[Sequence[str]] = ..., - model_admin: Optional[ModelAdmin] = ..., + prepopulated_fields: Dict[str, Any] | None = ..., + readonly_fields: Sequence[str] | None = ..., + model_admin: ModelAdmin | None = ..., has_add_permission: bool = ..., has_change_permission: bool = ..., has_delete_permission: bool = ..., has_view_permission: bool = ..., ) -> None: ... def __iter__(self) -> Iterator[InlineAdminForm]: ... - def fields(self) -> Iterator[Dict[str, Union[Dict[str, bool], bool, Widget, str]]]: ... + def fields(self) -> Iterator[Dict[str, Dict[str, bool] | bool | Widget | str]]: ... def inline_formset_data(self) -> str: ... @property def forms(self) -> List[BaseForm]: ... @@ -152,22 +152,22 @@ class InlineAdminFormSet: class InlineAdminForm(AdminForm): formset: Any = ... - original: Optional[bool] = ... + original: bool | None = ... show_url: bool = ... - absolute_url: Optional[str] = ... + absolute_url: str | None = ... def __init__( self, formset: Any, form: ModelForm, fieldsets: Any, prepopulated_fields: Any, - original: Optional[bool], - readonly_fields: Optional[Sequence[str]] = ..., - model_admin: Optional[ModelAdmin] = ..., - view_on_site_url: Optional[str] = ..., + original: bool | None, + readonly_fields: Sequence[str] | None = ..., + model_admin: ModelAdmin | None = ..., + view_on_site_url: str | None = ..., ) -> None: ... def __iter__(self) -> Iterator[InlineFieldset]: ... - def needs_explicit_pk_field(self) -> Union[bool, AutoField]: ... + def needs_explicit_pk_field(self) -> bool | AutoField: ... def pk_field(self) -> AdminField: ... def fk_field(self) -> AdminField: ... def deletion_field(self) -> AdminField: ... diff --git a/django-stubs/contrib/admin/models.pyi b/django-stubs/contrib/admin/models.pyi index 73b079b53..6c1a20cee 100644 --- a/django-stubs/contrib/admin/models.pyi +++ b/django-stubs/contrib/admin/models.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Union +from typing import Any from uuid import UUID from django.contrib.contenttypes.models import ContentType @@ -15,7 +15,7 @@ class LogEntryManager(models.Manager["LogEntry"]): self, user_id: int, content_type_id: int, - object_id: Union[int, str, UUID], + object_id: int | str | UUID, object_repr: str, action_flag: int, change_message: Any = ..., @@ -35,4 +35,4 @@ class LogEntry(models.Model): def is_deletion(self) -> bool: ... def get_change_message(self) -> str: ... def get_edited_object(self) -> Model: ... - def get_admin_url(self) -> Optional[str]: ... + def get_admin_url(self) -> str | None: ... diff --git a/django-stubs/contrib/admin/options.pyi b/django-stubs/contrib/admin/options.pyi index 25221429c..548e67876 100644 --- a/django-stubs/contrib/admin/options.pyi +++ b/django-stubs/contrib/admin/options.pyi @@ -58,7 +58,7 @@ VERTICAL: Literal[2] = ... _Direction = Union[Literal[1], Literal[2]] -def get_content_type_for_model(obj: Union[Type[Model], Model]) -> ContentType: ... +def get_content_type_for_model(obj: Type[Model] | Model) -> ContentType: ... def get_ul_class(radio_style: int) -> str: ... class IncorrectLookupParameters(Exception): ... @@ -94,8 +94,8 @@ _ModelT = TypeVar("_ModelT", bound=Model) class BaseModelAdmin(Generic[_ModelT]): autocomplete_fields: Sequence[str] = ... raw_id_fields: Sequence[str] = ... - fields: Optional[_FieldGroups] = ... - exclude: Optional[Sequence[str]] = ... + fields: _FieldGroups | None = ... + exclude: Sequence[str] | None = ... fieldsets: Optional[_FieldsetSpec] = ... form: Type[forms.ModelForm[_ModelT]] = ... filter_vertical: Sequence[str] = ... @@ -104,9 +104,9 @@ class BaseModelAdmin(Generic[_ModelT]): prepopulated_fields: Dict[str, Sequence[str]] = ... formfield_overrides: Mapping[Type[Field], Mapping[str, Any]] = ... readonly_fields: Sequence[str] = ... - ordering: Optional[Sequence[str]] = ... - sortable_by: Optional[_ListOrTuple[str]] = ... - view_on_site: Union[bool, Callable[[_ModelT], str]] = ... + ordering: Sequence[str] | None = ... + sortable_by: _ListOrTuple[str] | None = ... + view_on_site: bool | Callable[[_ModelT], str] = ... show_full_result_count: bool = ... checks_class: Any = ... model: Type[_ModelT] @@ -114,66 +114,62 @@ class BaseModelAdmin(Generic[_ModelT]): admin_site: AdminSite def __init__(self) -> None: ... def check(self, **kwargs: Any) -> List[CheckMessage]: ... - def formfield_for_dbfield(self, db_field: Field, request: HttpRequest, **kwargs: Any) -> Optional[FormField]: ... + def formfield_for_dbfield(self, db_field: Field, request: HttpRequest, **kwargs: Any) -> FormField | None: ... def formfield_for_choice_field(self, db_field: Field, request: HttpRequest, **kwargs: Any) -> TypedChoiceField: ... - def get_field_queryset( - self, db: Optional[str], db_field: RelatedField, request: HttpRequest - ) -> Optional[QuerySet]: ... + def get_field_queryset(self, db: str | None, db_field: RelatedField, request: HttpRequest) -> QuerySet | None: ... def formfield_for_foreignkey( self, db_field: ForeignKey, request: HttpRequest, **kwargs: Any ) -> ModelChoiceField: ... def formfield_for_manytomany( self, db_field: ManyToManyField, request: HttpRequest, **kwargs: Any - ) -> Optional[ModelMultipleChoiceField]: ... + ) -> ModelMultipleChoiceField | None: ... def get_autocomplete_fields(self, request: HttpRequest) -> Sequence[str]: ... - def get_view_on_site_url(self, obj: Optional[_ModelT] = ...) -> Optional[str]: ... + def get_view_on_site_url(self, obj: _ModelT | None = ...) -> str | None: ... def get_empty_value_display(self) -> SafeString: ... - def get_exclude(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Optional[Sequence[str]]: ... - def get_fields(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> _FieldGroups: ... - def get_fieldsets(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> _FieldsetSpec: ... - def get_inlines(self, request: HttpRequest, obj: Optional[_ModelT]) -> List[Type[InlineModelAdmin]]: ... + def get_exclude(self, request: HttpRequest, obj: _ModelT | None = ...) -> Sequence[str] | None: ... + def get_fields(self, request: HttpRequest, obj: _ModelT | None = ...) -> _FieldGroups: ... + def get_fieldsets(self, request: HttpRequest, obj: _ModelT | None = ...) -> _FieldsetSpec: ... + def get_inlines(self, request: HttpRequest, obj: _ModelT | None) -> List[Type[InlineModelAdmin]]: ... def get_ordering(self, request: HttpRequest) -> Sequence[str]: ... - def get_readonly_fields(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Sequence[str]: ... - def get_prepopulated_fields( - self, request: HttpRequest, obj: Optional[_ModelT] = ... - ) -> Dict[str, Sequence[str]]: ... + def get_readonly_fields(self, request: HttpRequest, obj: _ModelT | None = ...) -> Sequence[str]: ... + def get_prepopulated_fields(self, request: HttpRequest, obj: _ModelT | None = ...) -> Dict[str, Sequence[str]]: ... def get_queryset(self, request: HttpRequest) -> QuerySet[_ModelT]: ... def get_sortable_by(self, request: HttpRequest) -> Sequence[str]: ... def lookup_allowed(self, lookup: str, value: str) -> bool: ... def to_field_allowed(self, request: HttpRequest, to_field: str) -> bool: ... def has_add_permission(self, request: HttpRequest) -> bool: ... - def has_change_permission(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> bool: ... - def has_delete_permission(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> bool: ... - def has_view_permission(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> bool: ... - def has_view_or_change_permission(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> bool: ... + def has_change_permission(self, request: HttpRequest, obj: _ModelT | None = ...) -> bool: ... + def has_delete_permission(self, request: HttpRequest, obj: _ModelT | None = ...) -> bool: ... + def has_view_permission(self, request: HttpRequest, obj: _ModelT | None = ...) -> bool: ... + def has_view_or_change_permission(self, request: HttpRequest, obj: _ModelT | None = ...) -> bool: ... def has_module_permission(self, request: HttpRequest) -> bool: ... -_DisplayT = _ListOrTuple[Union[str, Callable[[_ModelT], str]]] +_DisplayT = _ListOrTuple[str | Callable[[_ModelT], str]] class ModelAdmin(BaseModelAdmin[_ModelT]): list_display: _DisplayT = ... - list_display_links: Optional[_DisplayT] = ... + list_display_links: _DisplayT | None = ... list_filter: _ListOrTuple[_ListFilterT] = ... - list_select_related: Union[bool, Sequence[str]] = ... + list_select_related: bool | Sequence[str] = ... list_per_page: int = ... list_max_show_all: int = ... list_editable: Sequence[str] = ... search_fields: Sequence[str] = ... - date_hierarchy: Optional[str] = ... + date_hierarchy: str | None = ... save_as: bool = ... save_as_continue: bool = ... save_on_top: bool = ... paginator: Type = ... preserve_filters: bool = ... inlines: Sequence[Type[InlineModelAdmin]] = ... - add_form_template: Optional[_TemplateForResponseT] = ... - change_form_template: Optional[_TemplateForResponseT] = ... - change_list_template: Optional[_TemplateForResponseT] = ... - delete_confirmation_template: Optional[_TemplateForResponseT] = ... - delete_selected_confirmation_template: Optional[_TemplateForResponseT] = ... - object_history_template: Optional[_TemplateForResponseT] = ... - popup_response_template: Optional[_TemplateForResponseT] = ... - actions: Optional[Sequence[Union[Callable[[ModelAdmin, HttpRequest, QuerySet], None], str]]] = ... + add_form_template: _TemplateForResponseT | None = ... + change_form_template: _TemplateForResponseT | None = ... + change_list_template: _TemplateForResponseT | None = ... + delete_confirmation_template: _TemplateForResponseT | None = ... + delete_selected_confirmation_template: _TemplateForResponseT | None = ... + object_history_template: _TemplateForResponseT | None = ... + popup_response_template: _TemplateForResponseT | None = ... + actions: Sequence[Callable[[ModelAdmin, HttpRequest, QuerySet], None] | str] | None = ... action_form: Any = ... actions_on_top: bool = ... actions_on_bottom: bool = ... @@ -182,7 +178,7 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): opts: Options[_ModelT] = ... admin_site: AdminSite = ... def __init__(self, model: Type[_ModelT], admin_site: AdminSite) -> None: ... - def get_inline_instances(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> List[InlineModelAdmin]: ... + def get_inline_instances(self, request: HttpRequest, obj: _ModelT | None = ...) -> List[InlineModelAdmin]: ... def get_urls(self) -> List[URLPattern]: ... @property def urls(self) -> List[URLPattern]: ... @@ -190,18 +186,16 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): def media(self) -> Media: ... def get_model_perms(self, request: HttpRequest) -> Dict[str, bool]: ... def get_form( - self, request: HttpRequest, obj: Optional[_ModelT] = ..., change: bool = ..., **kwargs: Any + self, request: HttpRequest, obj: _ModelT | None = ..., change: bool = ..., **kwargs: Any ) -> Type[forms.ModelForm[_ModelT]]: ... def get_changelist(self, request: HttpRequest, **kwargs: Any) -> Type[ChangeList]: ... def get_changelist_instance(self, request: HttpRequest) -> ChangeList: ... - def get_object( - self, request: HttpRequest, object_id: str, from_field: Optional[str] = ... - ) -> Optional[_ModelT]: ... + def get_object(self, request: HttpRequest, object_id: str, from_field: str | None = ...) -> _ModelT | None: ... def get_changelist_form(self, request: HttpRequest, **kwargs: Any) -> Type[ModelForm[_ModelT]]: ... def get_changelist_formset( self, request: HttpRequest, **kwargs: Any ) -> Type[BaseModelFormSet[_ModelT, ModelForm[_ModelT]]]: ... - def get_formsets_with_inlines(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Iterator[Any]: ... + def get_formsets_with_inlines(self, request: HttpRequest, obj: _ModelT | None = ...) -> Iterator[Any]: ... def get_paginator( self, request: HttpRequest, @@ -214,15 +208,15 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): def log_change(self, request: HttpRequest, object: _ModelT, message: Any) -> LogEntry: ... def log_deletion(self, request: HttpRequest, object: _ModelT, object_repr: str) -> LogEntry: ... def action_checkbox(self, obj: _ModelT) -> SafeString: ... - def get_actions(self, request: HttpRequest) -> Dict[str, Optional[Tuple[Callable[..., str], str, str]]]: ... + def get_actions(self, request: HttpRequest) -> Dict[str, Tuple[Callable[..., str], str, str] | None]: ... def get_action_choices( self, request: HttpRequest, default_choices: List[Tuple[str, str]] = ... ) -> List[Tuple[str, str]]: ... - def get_action(self, action: Union[Callable, str]) -> Optional[Tuple[Callable[..., str], str, str]]: ... + def get_action(self, action: Callable | str) -> Tuple[Callable[..., str], str, str] | None: ... def get_list_display(self, request: HttpRequest) -> _DisplayT: ... def get_list_display_links(self, request: HttpRequest, list_display: _DisplayT) -> _DisplayT: ... def get_list_filter(self, request: HttpRequest) -> Sequence[_ListFilterT]: ... - def get_list_select_related(self, request: HttpRequest) -> Union[bool, Sequence[str]]: ... + def get_list_select_related(self, request: HttpRequest) -> bool | Sequence[str]: ... def get_search_fields(self, request: HttpRequest) -> Sequence[str]: ... def get_search_results( self, request: HttpRequest, queryset: QuerySet, search_term: str @@ -237,7 +231,7 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): self, request: HttpRequest, message: str, - level: Union[int, str] = ..., + level: int | str = ..., extra_tags: str = ..., fail_silently: bool = ..., ) -> None: ... @@ -254,44 +248,42 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): add: bool = ..., change: bool = ..., form_url: str = ..., - obj: Optional[_ModelT] = ..., - ) -> HttpResponse: ... - def response_add( - self, request: HttpRequest, obj: _ModelT, post_url_continue: Optional[str] = ... + obj: _ModelT | None = ..., ) -> HttpResponse: ... + def response_add(self, request: HttpRequest, obj: _ModelT, post_url_continue: str | None = ...) -> HttpResponse: ... def response_change(self, request: HttpRequest, obj: _ModelT) -> HttpResponse: ... def response_post_save_add(self, request: HttpRequest, obj: _ModelT) -> HttpResponseRedirect: ... def response_post_save_change(self, request: HttpRequest, obj: _ModelT) -> HttpResponseRedirect: ... # Probably FileResponse cannot come from ModelAdmin views - def response_action(self, request: HttpRequest, queryset: QuerySet) -> Optional[HttpResponse]: ... + def response_action(self, request: HttpRequest, queryset: QuerySet) -> HttpResponse | None: ... def response_delete(self, request: HttpRequest, obj_display: str, obj_id: int) -> HttpResponse: ... def render_delete_form(self, request: HttpRequest, context: Dict[str, Any]) -> HttpResponse: ... def get_inline_formsets( - self, request: HttpRequest, formsets: List[Any], inline_instances: List[Any], obj: Optional[_ModelT] = ... + self, request: HttpRequest, formsets: List[Any], inline_instances: List[Any], obj: _ModelT | None = ... ) -> List[Any]: ... - def get_changeform_initial_data(self, request: HttpRequest) -> Dict[str, Union[str, List[str]]]: ... + def get_changeform_initial_data(self, request: HttpRequest) -> Dict[str, str | List[str]]: ... def changeform_view( self, request: HttpRequest, - object_id: Optional[str] = ..., + object_id: str | None = ..., form_url: str = ..., - extra_context: Optional[Dict[str, Any]] = ..., + extra_context: Dict[str, Any] | None = ..., ) -> HttpResponse: ... def add_view( - self, request: HttpRequest, form_url: str = ..., extra_context: Optional[Dict[str, Any]] = ... + self, request: HttpRequest, form_url: str = ..., extra_context: Dict[str, Any] | None = ... ) -> HttpResponse: ... def change_view( - self, request: HttpRequest, object_id: str, form_url: str = ..., extra_context: Optional[Dict[str, Any]] = ... + self, request: HttpRequest, object_id: str, form_url: str = ..., extra_context: Dict[str, Any] | None = ... ) -> HttpResponse: ... - def changelist_view(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ... + def changelist_view(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> HttpResponse: ... def get_deleted_objects( - self, objs: Union[Sequence[_ModelT], QuerySet[_ModelT]], request: HttpRequest + self, objs: Sequence[_ModelT] | QuerySet[_ModelT], request: HttpRequest ) -> Tuple[List[Model], Dict[str, int], Set[str], List[str]]: ... def delete_view( - self, request: HttpRequest, object_id: str, extra_context: Optional[Dict[str, Any]] = ... + self, request: HttpRequest, object_id: str, extra_context: Dict[str, Any] | None = ... ) -> HttpResponse: ... def history_view( - self, request: HttpRequest, object_id: str, extra_context: Optional[Dict[str, Any]] = ... + self, request: HttpRequest, object_id: str, extra_context: Dict[str, Any] | None = ... ) -> HttpResponse: ... _ChildModelT = TypeVar("_ChildModelT", bound=Model) @@ -299,17 +291,17 @@ _ParentModelT = TypeVar("_ParentModelT", bound=Model) class InlineModelAdmin(Generic[_ChildModelT, _ParentModelT], BaseModelAdmin[_ChildModelT]): model: Type[_ChildModelT] = ... - fk_name: Optional[str] = ... + fk_name: str | None = ... formset: Type[BaseInlineFormSet[_ChildModelT, _ParentModelT, forms.ModelForm[_ChildModelT]]] = ... extra: int = ... - min_num: Optional[int] = ... - max_num: Optional[int] = ... + min_num: int | None = ... + max_num: int | None = ... template: str = ... - verbose_name: Optional[_StrOrPromise] = ... - verbose_name_plural: Optional[_StrOrPromise] = ... + verbose_name: _StrOrPromise | None = ... + verbose_name_plural: _StrOrPromise | None = ... can_delete: bool = ... show_change_link: bool = ... - classes: Optional[Sequence[str]] = ... + classes: Sequence[str] | None = ... admin_site: AdminSite = ... parent_model: Type[_ParentModelT] = ... opts: Options[_ChildModelT] = ... @@ -317,17 +309,17 @@ class InlineModelAdmin(Generic[_ChildModelT, _ParentModelT], BaseModelAdmin[_Chi def __init__(self, parent_model: Type[_ParentModelT], admin_site: AdminSite) -> None: ... @property def media(self) -> Media: ... - def get_extra(self, request: HttpRequest, obj: Optional[_ParentModelT] = ..., **kwargs: Any) -> int: ... - def get_min_num(self, request: HttpRequest, obj: Optional[_ParentModelT] = ..., **kwargs: Any) -> Optional[int]: ... - def get_max_num(self, request: HttpRequest, obj: Optional[_ParentModelT] = ..., **kwargs: Any) -> Optional[int]: ... + def get_extra(self, request: HttpRequest, obj: _ParentModelT | None = ..., **kwargs: Any) -> int: ... + def get_min_num(self, request: HttpRequest, obj: _ParentModelT | None = ..., **kwargs: Any) -> int | None: ... + def get_max_num(self, request: HttpRequest, obj: _ParentModelT | None = ..., **kwargs: Any) -> int | None: ... def get_formset( - self, request: HttpRequest, obj: Optional[_ParentModelT] = ..., **kwargs: Any + self, request: HttpRequest, obj: _ParentModelT | None = ..., **kwargs: Any ) -> Type[BaseInlineFormSet[_ChildModelT, _ParentModelT, forms.ModelForm[_ChildModelT]]]: ... def get_queryset(self, request: HttpRequest) -> QuerySet[_ChildModelT]: ... - def has_add_permission(self, request: HttpRequest, obj: Optional[_ParentModelT]) -> bool: ... # type: ignore - def has_change_permission(self, request: HttpRequest, obj: Optional[_ParentModelT] = ...) -> bool: ... # type: ignore - def has_delete_permission(self, request: HttpRequest, obj: Optional[_ParentModelT] = ...) -> bool: ... # type: ignore - def has_view_permission(self, request: HttpRequest, obj: Optional[_ParentModelT] = ...) -> bool: ... # type: ignore + def has_add_permission(self, request: HttpRequest, obj: _ParentModelT | None) -> bool: ... # type: ignore + def has_change_permission(self, request: HttpRequest, obj: _ParentModelT | None = ...) -> bool: ... # type: ignore + def has_delete_permission(self, request: HttpRequest, obj: _ParentModelT | None = ...) -> bool: ... # type: ignore + def has_view_permission(self, request: HttpRequest, obj: _ParentModelT | None = ...) -> bool: ... # type: ignore class StackedInline(InlineModelAdmin[_ChildModelT, _ParentModelT]): template: str = ... diff --git a/django-stubs/contrib/admin/sites.pyi b/django-stubs/contrib/admin/sites.pyi index e5f7688f8..3bd23ea28 100644 --- a/django-stubs/contrib/admin/sites.pyi +++ b/django-stubs/contrib/admin/sites.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union +from typing import Any, Callable, Dict, Iterable, List, Tuple, Type from django.apps.config import AppConfig from django.contrib.admin.options import ModelAdmin @@ -22,7 +22,7 @@ else: all_sites: MutableSet[AdminSite] -_ActionCallback = Callable[[ModelAdmin, HttpRequest, QuerySet], Optional[TemplateResponse]] +_ActionCallback = Callable[[ModelAdmin, HttpRequest, QuerySet], TemplateResponse | None] class AlreadyRegistered(Exception): ... class NotRegistered(Exception): ... @@ -32,13 +32,13 @@ class AdminSite: site_header: str = ... index_title: str = ... site_url: str = ... - login_form: Optional[Type[AuthenticationForm]] = ... - index_template: Optional[str] = ... - app_index_template: Optional[str] = ... - login_template: Optional[str] = ... - logout_template: Optional[str] = ... - password_change_template: Optional[str] = ... - password_change_done_template: Optional[str] = ... + login_form: Type[AuthenticationForm] | None = ... + index_template: str | None = ... + app_index_template: str | None = ... + login_template: str | None = ... + logout_template: str | None = ... + password_change_template: str | None = ... + password_change_done_template: str | None = ... name: str = ... enable_nav_sidebar: bool = ... empty_value_display: str = ... @@ -48,40 +48,38 @@ class AdminSite: _global_actions: Dict[str, _ActionCallback] _actions: Dict[str, _ActionCallback] def __init__(self, name: str = ...) -> None: ... - def check(self, app_configs: Optional[Iterable[AppConfig]]) -> List[CheckMessage]: ... + def check(self, app_configs: Iterable[AppConfig] | None) -> List[CheckMessage]: ... def register( self, - model_or_iterable: Union[Type[Model], Iterable[Type[Model]]], - admin_class: Optional[Type[ModelAdmin]] = ..., + model_or_iterable: Type[Model] | Iterable[Type[Model]], + admin_class: Type[ModelAdmin] | None = ..., **options: Any ) -> None: ... - def unregister(self, model_or_iterable: Union[Type[Model], Iterable[Type[Model]]]) -> None: ... + def unregister(self, model_or_iterable: Type[Model] | Iterable[Type[Model]]) -> None: ... def is_registered(self, model: Type[Model]) -> bool: ... - def add_action(self, action: _ActionCallback, name: Optional[str] = ...) -> None: ... + def add_action(self, action: _ActionCallback, name: str | None = ...) -> None: ... def disable_action(self, name: str) -> None: ... def get_action(self, name: str) -> Callable: ... @property def actions(self) -> Iterable[Tuple[str, _ActionCallback]]: ... def has_permission(self, request: HttpRequest) -> bool: ... def admin_view(self, view: Callable, cacheable: bool = ...) -> Callable: ... - def get_urls(self) -> List[Union[URLResolver, URLPattern]]: ... + def get_urls(self) -> List[URLResolver | URLPattern]: ... @property - def urls(self) -> Tuple[List[Union[URLResolver, URLPattern]], str, str]: ... + def urls(self) -> Tuple[List[URLResolver | URLPattern], str, str]: ... def each_context(self, request: HttpRequest) -> Dict[str, Any]: ... - def password_change( - self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ... - ) -> TemplateResponse: ... + def password_change(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> TemplateResponse: ... def password_change_done( - self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ... + self, request: HttpRequest, extra_context: Dict[str, Any] | None = ... ) -> TemplateResponse: ... - def i18n_javascript(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ... - def logout(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ... - def login(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ... - def _build_app_dict(self, request: HttpRequest, label: Optional[_StrOrPromise] = ...) -> Dict[str, Any]: ... + def i18n_javascript(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> HttpResponse: ... + def logout(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> TemplateResponse: ... + def login(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> HttpResponse: ... + def _build_app_dict(self, request: HttpRequest, label: _StrOrPromise | None = ...) -> Dict[str, Any]: ... def get_app_list(self, request: HttpRequest) -> List[Any]: ... - def index(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ... + def index(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> TemplateResponse: ... def app_index( - self, request: HttpRequest, app_label: str, extra_context: Optional[Dict[str, Any]] = ... + self, request: HttpRequest, app_label: str, extra_context: Dict[str, Any] | None = ... ) -> TemplateResponse: ... def autocomplete_view(self, request: HttpRequest) -> HttpResponse: ... def catch_all_view(self, request: HttpRequest, url: str) -> HttpResponse: ... diff --git a/django-stubs/contrib/admin/templatetags/admin_list.pyi b/django-stubs/contrib/admin/templatetags/admin_list.pyi index 723939b3e..bc290008a 100644 --- a/django-stubs/contrib/admin/templatetags/admin_list.pyi +++ b/django-stubs/contrib/admin/templatetags/admin_list.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, Iterator, List, Optional, Union +from typing import Any, Dict, Iterable, Iterator, List from django.contrib.admin.filters import FieldListFilter from django.contrib.admin.templatetags.base import InclusionAdminNode @@ -18,24 +18,22 @@ DOT: str def paginator_number(cl: ChangeList, i: int) -> SafeString: ... def pagination(cl: ChangeList) -> Dict[str, Any]: ... def pagination_tag(parser: Parser, token: Token) -> InclusionAdminNode: ... -def result_headers(cl: ChangeList) -> Iterator[Dict[str, Optional[Union[int, str]]]]: ... -def items_for_result(cl: ChangeList, result: Model, form: Optional[ModelForm]) -> Iterator[SafeString]: ... +def result_headers(cl: ChangeList) -> Iterator[Dict[str, int | str | None]]: ... +def items_for_result(cl: ChangeList, result: Model, form: ModelForm | None) -> Iterator[SafeString]: ... class ResultList(list): - form: Optional[ModelForm] = ... - def __init__(self, form: Optional[ModelForm], *items: Any) -> None: ... + form: ModelForm | None = ... + def __init__(self, form: ModelForm | None, *items: Any) -> None: ... def results(cl: ChangeList) -> Iterator[ResultList]: ... def result_hidden_fields(cl: ChangeList) -> Iterator[BoundField]: ... def result_list( cl: ChangeList, -) -> Dict[ - str, Union[List[Dict[str, Optional[Union[int, str]]]], List[ResultList], List[BoundField], ChangeList, int] -]: ... +) -> Dict[str, List[Dict[str, int | str | None]] | List[ResultList] | List[BoundField] | ChangeList | int]: ... def result_list_tag(parser: Parser, token: Token) -> InclusionAdminNode: ... -def date_hierarchy(cl: ChangeList) -> Optional[Dict[str, Any]]: ... +def date_hierarchy(cl: ChangeList) -> Dict[str, Any] | None: ... def date_hierarchy_tag(parser: Parser, token: Token) -> InclusionAdminNode: ... -def search_form(cl: ChangeList) -> Dict[str, Union[bool, ChangeList, str]]: ... +def search_form(cl: ChangeList) -> Dict[str, bool | ChangeList | str]: ... def search_form_tag(parser: Parser, token: Token) -> InclusionAdminNode: ... def admin_list_filter(cl: ChangeList, spec: FieldListFilter) -> SafeString: ... def admin_actions(context: RequestContext) -> RequestContext: ... diff --git a/django-stubs/contrib/admin/templatetags/admin_urls.pyi b/django-stubs/contrib/admin/templatetags/admin_urls.pyi index 245ae3455..ab3081d49 100644 --- a/django-stubs/contrib/admin/templatetags/admin_urls.pyi +++ b/django-stubs/contrib/admin/templatetags/admin_urls.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Union +from typing import Any, Dict from uuid import UUID from django.db.models.options import Options @@ -8,10 +8,10 @@ from django.utils.safestring import SafeString register: Any def admin_urlname(value: Options, arg: SafeString) -> str: ... -def admin_urlquote(value: Union[int, str, UUID]) -> Union[int, str, UUID]: ... +def admin_urlquote(value: int | str | UUID) -> int | str | UUID: ... def add_preserved_filters( - context: Union[Dict[str, Union[Options, str]], RequestContext], + context: Dict[str, Options | str] | RequestContext, url: str, popup: bool = ..., - to_field: Optional[str] = ..., + to_field: str | None = ..., ) -> str: ... diff --git a/django-stubs/contrib/admin/templatetags/log.pyi b/django-stubs/contrib/admin/templatetags/log.pyi index 9dd4ee46a..5978f1a12 100644 --- a/django-stubs/contrib/admin/templatetags/log.pyi +++ b/django-stubs/contrib/admin/templatetags/log.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django import template from django.template.base import Parser, Token @@ -10,7 +10,7 @@ class AdminLogNode(template.Node): limit: str user: str varname: str - def __init__(self, limit: str, varname: str, user: Optional[str]) -> None: ... + def __init__(self, limit: str, varname: str, user: str | None) -> None: ... def render(self, context: Context) -> str: ... def get_admin_log(parser: Parser, token: Token) -> AdminLogNode: ... diff --git a/django-stubs/contrib/admin/utils.pyi b/django-stubs/contrib/admin/utils.pyi index f93a2747f..2f5f6d7d9 100644 --- a/django-stubs/contrib/admin/utils.pyi +++ b/django-stubs/contrib/admin/utils.pyi @@ -1,5 +1,5 @@ import datetime -from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Type, Union, overload +from typing import Any, Callable, Dict, Iterable, List, Sequence, Set, Tuple, Type, overload from uuid import UUID from django.contrib.admin.options import BaseModelAdmin @@ -19,13 +19,13 @@ from typing_extensions import Literal, TypedDict class FieldIsAForeignKeyColumnName(Exception): ... def lookup_needs_distinct(opts: Options, lookup_path: str) -> bool: ... -def prepare_lookup_value(key: str, value: Union[datetime.datetime, str]) -> Union[bool, datetime.datetime, str]: ... -def quote(s: Union[int, str, UUID]) -> str: ... +def prepare_lookup_value(key: str, value: datetime.datetime | str) -> bool | datetime.datetime | str: ... +def quote(s: int | str | UUID) -> str: ... def unquote(s: str) -> str: ... -def flatten(fields: Any) -> List[Union[Callable, str]]: ... -def flatten_fieldsets(fieldsets: Any) -> List[Union[Callable, str]]: ... +def flatten(fields: Any) -> List[Callable | str]: ... +def flatten_fieldsets(fieldsets: Any) -> List[Callable | str]: ... def get_deleted_objects( - objs: Union[Sequence[Optional[Model]], QuerySet[Model]], request: HttpRequest, admin_site: AdminSite + objs: Sequence[Model | None] | QuerySet[Model], request: HttpRequest, admin_site: AdminSite ) -> Tuple[List[Model], Dict[str, int], Set[str], List[str]]: ... class NestedObjects(Collector): @@ -38,7 +38,7 @@ class NestedObjects(Collector): protected: Any = ... model_objs: Any = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def add_edge(self, source: Optional[Model], target: Model) -> None: ... + def add_edge(self, source: Model | None, target: Model) -> None: ... def related_objects( self, related_model: Type[Model], related_fields: Iterable[Field], objs: _IndexableCollection[Model] ) -> QuerySet[Model]: ... @@ -49,26 +49,26 @@ class _ModelFormatDict(TypedDict): verbose_name: str verbose_name_plural: str -def model_format_dict(obj: Union[Model, Type[Model], QuerySet, Options[Model]]) -> _ModelFormatDict: ... -def model_ngettext(obj: Union[Options, QuerySet], n: Optional[int] = ...) -> str: ... +def model_format_dict(obj: Model | Type[Model] | QuerySet | Options[Model]) -> _ModelFormatDict: ... +def model_ngettext(obj: Options | QuerySet, n: int | None = ...) -> str: ... def lookup_field( - name: Union[Callable, str], obj: Model, model_admin: Optional[BaseModelAdmin] = ... -) -> Tuple[Optional[Field], Optional[str], Any]: ... + name: Callable | str, obj: Model, model_admin: BaseModelAdmin | None = ... +) -> Tuple[Field | None, str | None, Any]: ... @overload def label_for_field( # type: ignore - name: Union[Callable, str], + name: Callable | str, model: Type[Model], - model_admin: Optional[BaseModelAdmin] = ..., + model_admin: BaseModelAdmin | None = ..., return_attr: Literal[True] = ..., - form: Optional[BaseForm] = ..., -) -> Tuple[str, Union[Callable, str, None]]: ... + form: BaseForm | None = ..., +) -> Tuple[str, Callable | str | None]: ... @overload def label_for_field( - name: Union[Callable, str], + name: Callable | str, model: Type[Model], - model_admin: Optional[BaseModelAdmin] = ..., + model_admin: BaseModelAdmin | None = ..., return_attr: Literal[False] = ..., - form: Optional[BaseForm] = ..., + form: BaseForm | None = ..., ) -> str: ... def help_text_for_field(name: str, model: Type[Model]) -> str: ... def display_for_field(value: Any, field: Field, empty_value_display: str) -> str: ... @@ -76,7 +76,7 @@ def display_for_value(value: Any, empty_value_display: str, boolean: bool = ...) class NotRelationField(Exception): ... -def get_model_from_relation(field: Union[Field, reverse_related.ForeignObjectRel]) -> Type[Model]: ... +def get_model_from_relation(field: Field | reverse_related.ForeignObjectRel) -> Type[Model]: ... def reverse_field_path(model: Type[Model], path: str) -> Tuple[Type[Model], str]: ... def get_fields_from_path(model: Type[Model], path: str) -> List[Field]: ... def construct_change_message( diff --git a/django-stubs/contrib/admin/views/autocomplete.pyi b/django-stubs/contrib/admin/views/autocomplete.pyi index 06a13ba89..102b838ee 100644 --- a/django-stubs/contrib/admin/views/autocomplete.pyi +++ b/django-stubs/contrib/admin/views/autocomplete.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.contrib.admin.options import ModelAdmin from django.db.models import Model @@ -8,4 +8,4 @@ from django.views.generic.list import BaseListView class AutocompleteJsonView(BaseListView): model_admin: ModelAdmin = ... term: Any = ... - def has_perm(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ... + def has_perm(self, request: HttpRequest, obj: Model | None = ...) -> bool: ... diff --git a/django-stubs/contrib/admin/views/decorators.pyi b/django-stubs/contrib/admin/views/decorators.pyi index 55bbeb329..95eb3e352 100644 --- a/django-stubs/contrib/admin/views/decorators.pyi +++ b/django-stubs/contrib/admin/views/decorators.pyi @@ -1,12 +1,10 @@ -from typing import Callable, Optional, TypeVar, overload +from typing import Callable, TypeVar, overload _C = TypeVar("_C", bound=Callable) @overload -def staff_member_required( - view_func: _C = ..., redirect_field_name: Optional[str] = ..., login_url: str = ... -) -> _C: ... +def staff_member_required(view_func: _C = ..., redirect_field_name: str | None = ..., login_url: str = ...) -> _C: ... @overload def staff_member_required( - view_func: None = ..., redirect_field_name: Optional[str] = ..., login_url: str = ... + view_func: None = ..., redirect_field_name: str | None = ..., login_url: str = ... ) -> Callable: ... diff --git a/django-stubs/contrib/admin/views/main.pyi b/django-stubs/contrib/admin/views/main.pyi index 3d2d7eee1..a93b31537 100644 --- a/django-stubs/contrib/admin/views/main.pyi +++ b/django-stubs/contrib/admin/views/main.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Type, Union +from typing import Any, Callable, Dict, Iterable, List, Sequence, Tuple, Type from django.contrib.admin.filters import ListFilter from django.contrib.admin.options import IS_POPUP_VAR as IS_POPUP_VAR # noqa: F401 @@ -30,12 +30,12 @@ class ChangeList: list_filter: Sequence[_ListFilterT] = ... date_hierarchy: Any = ... search_fields: Sequence[str] = ... - list_select_related: Union[bool, Sequence[str]] = ... + list_select_related: bool | Sequence[str] = ... list_per_page: int = ... list_max_show_all: int = ... model_admin: ModelAdmin = ... preserved_filters: str = ... - sortable_by: Optional[Sequence[str]] = ... + sortable_by: Sequence[str] | None = ... page_num: int = ... show_all: bool = ... is_popup: bool = ... @@ -46,7 +46,7 @@ class ChangeList: queryset: Any = ... title: str = ... pk_attname: str = ... - formset: Optional[BaseFormSet] + formset: BaseFormSet | None def __init__( self, request: HttpRequest, @@ -54,33 +54,29 @@ class ChangeList: list_display: _DisplayT, list_display_links: _DisplayT, list_filter: Sequence[_ListFilterT], - date_hierarchy: Optional[str], + date_hierarchy: str | None, search_fields: Sequence[str], - list_select_related: Union[bool, Sequence[str]], + list_select_related: bool | Sequence[str], list_per_page: int, list_max_show_all: int, list_editable: Sequence[str], model_admin: ModelAdmin, - sortable_by: Optional[Sequence[str]], + sortable_by: Sequence[str] | None, ) -> None: ... - def get_filters_params(self, params: Optional[Dict[str, Any]] = ...) -> Dict[str, Any]: ... - def get_filters( - self, request: HttpRequest - ) -> Tuple[List[ListFilter], bool, Dict[str, Union[bool, str]], bool, bool]: ... - def get_query_string( - self, new_params: Optional[Dict[str, Any]] = ..., remove: Optional[Iterable[str]] = ... - ) -> str: ... + def get_filters_params(self, params: Dict[str, Any] | None = ...) -> Dict[str, Any]: ... + def get_filters(self, request: HttpRequest) -> Tuple[List[ListFilter], bool, Dict[str, bool | str], bool, bool]: ... + def get_query_string(self, new_params: Dict[str, Any] | None = ..., remove: Iterable[str] | None = ...) -> str: ... result_count: int = ... show_full_result_count: bool = ... show_admin_actions: bool = ... - full_result_count: Optional[int] = ... + full_result_count: int | None = ... result_list: Any = ... can_show_all: bool = ... multi_page: bool = ... paginator: Any = ... def get_results(self, request: HttpRequest) -> None: ... - def get_ordering_field(self, field_name: Union[Callable, str]) -> Optional[Union[Expression, str]]: ... - def get_ordering(self, request: HttpRequest, queryset: QuerySet) -> List[Union[Expression, str]]: ... + def get_ordering_field(self, field_name: Callable | str) -> Expression | str | None: ... + def get_ordering(self, request: HttpRequest, queryset: QuerySet) -> List[Expression | str]: ... def get_ordering_field_columns(self) -> Dict[int, Literal["desc", "asc"]]: ... def get_queryset(self, request: HttpRequest) -> QuerySet: ... filter_specs: List[ListFilter] diff --git a/django-stubs/contrib/admin/widgets.pyi b/django-stubs/contrib/admin/widgets.pyi index 45f044d62..1cd346359 100644 --- a/django-stubs/contrib/admin/widgets.pyi +++ b/django-stubs/contrib/admin/widgets.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union +from typing import Any, Dict, Iterable, List, Mapping, Sequence, Tuple from django import forms from django.contrib.admin.sites import AdminSite @@ -16,20 +16,20 @@ class FilteredSelectMultiple(forms.SelectMultiple): self, verbose_name: _StrOrPromise, is_stacked: bool, - attrs: Optional[_OptAttrs] = ..., + attrs: _OptAttrs | None = ..., choices: _FieldChoices = ..., ) -> None: ... class AdminDateWidget(forms.DateInput): - def __init__(self, attrs: Optional[_OptAttrs] = ..., format: Optional[str] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ..., format: str | None = ...) -> None: ... class AdminTimeWidget(forms.TimeInput): - def __init__(self, attrs: Optional[_OptAttrs] = ..., format: Optional[str] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ..., format: str | None = ...) -> None: ... class AdminSplitDateTime(forms.SplitDateTimeWidget): template_name: str - def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... + def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... class AdminRadioSelect(forms.RadioSelect): ... class AdminFileWidget(forms.ClearableFileInput): ... @@ -39,21 +39,21 @@ def url_params_from_lookup_dict(lookups: Any) -> Dict[str, str]: ... class ForeignKeyRawIdWidget(forms.TextInput): rel: ManyToOneRel = ... admin_site: AdminSite = ... - db: Optional[str] = ... + db: str | None = ... def __init__( - self, rel: ManyToOneRel, admin_site: AdminSite, attrs: Optional[_OptAttrs] = ..., using: Optional[str] = ... + self, rel: ManyToOneRel, admin_site: AdminSite, attrs: _OptAttrs | None = ..., using: str | None = ... ) -> None: ... def base_url_parameters(self) -> Dict[str, str]: ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... def url_parameters(self) -> Dict[str, str]: ... def label_and_url_for_value(self, value: Any) -> Tuple[str, str]: ... class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): rel: ManyToManyRel = ... # type: ignore - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... def url_parameters(self) -> Dict[str, str]: ... def label_and_url_for_value(self, value: Any) -> Tuple[str, str]: ... - def format_value(self, value: Any) -> Optional[str]: ... + def format_value(self, value: Any) -> str | None: ... def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Iterable[File]], name: str) -> Any: ... class RelatedFieldWidgetWrapper(forms.Widget): @@ -71,7 +71,7 @@ class RelatedFieldWidgetWrapper(forms.Widget): widget: forms.ChoiceWidget, rel: ManyToOneRel, admin_site: AdminSite, - can_add_related: Optional[bool] = ..., + can_add_related: bool | None = ..., can_change_related: bool = ..., can_delete_related: bool = ..., can_view_related: bool = ..., @@ -81,7 +81,7 @@ class RelatedFieldWidgetWrapper(forms.Widget): @property def is_hidden(self) -> bool: ... def get_related_url(self, info: Tuple[str, str], action: str, *args: Any) -> str: ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Iterable[File]], name: str) -> Any: ... def value_omitted_from_data( self, data: Mapping[str, Any], files: Mapping[str, Iterable[File]], name: str @@ -89,28 +89,28 @@ class RelatedFieldWidgetWrapper(forms.Widget): def id_for_label(self, id_: str) -> str: ... class AdminTextareaWidget(forms.Textarea): - def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... class AdminTextInputWidget(forms.TextInput): - def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... class AdminEmailInputWidget(forms.EmailInput): - def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... class AdminURLFieldWidget(forms.URLInput): template_name: str - def __init__(self, attrs: Optional[_OptAttrs] = ..., validator_class: Any = ...) -> None: ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... + def __init__(self, attrs: _OptAttrs | None = ..., validator_class: Any = ...) -> None: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... class AdminIntegerFieldWidget(forms.NumberInput): - def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... class_name: str = ... class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): class_name: str = ... class AdminUUIDInputWidget(forms.TextInput): - def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... SELECT2_TRANSLATIONS: Dict[str, str] = ... @@ -118,25 +118,25 @@ class AutocompleteMixin: url_name: str = ... field: Any = ... admin_site: AdminSite = ... - db: Optional[str] = ... + db: str | None = ... choices: Any = ... attrs: _OptAttrs = ... def __init__( self, field: Any, admin_site: AdminSite, - attrs: Optional[_OptAttrs] = ..., + attrs: _OptAttrs | None = ..., choices: Any = ..., - using: Optional[str] = ..., + using: str | None = ..., ) -> None: ... def get_url(self) -> str: ... @property def media(self) -> Media: ... - def build_attrs(self, base_attrs: _OptAttrs, extra_attrs: Optional[_OptAttrs] = ...) -> Dict[str, Any]: ... + def build_attrs(self, base_attrs: _OptAttrs, extra_attrs: _OptAttrs | None = ...) -> Dict[str, Any]: ... # typo in source: `attr` instead of `attrs` def optgroups( - self, name: str, value: Sequence[str], attr: Optional[_OptAttrs] = ... - ) -> List[Tuple[Optional[str], List[Dict[str, Any]], Optional[int]]]: ... + self, name: str, value: Sequence[str], attr: _OptAttrs | None = ... + ) -> List[Tuple[str | None, List[Dict[str, Any]], int | None]]: ... class AutocompleteSelect(AutocompleteMixin, forms.Select): ... # type: ignore class AutocompleteSelectMultiple(AutocompleteMixin, forms.SelectMultiple): ... # type: ignore diff --git a/django-stubs/contrib/admindocs/middleware.pyi b/django-stubs/contrib/admindocs/middleware.pyi index 5f2c5928e..117e564ca 100644 --- a/django-stubs/contrib/admindocs/middleware.pyi +++ b/django-stubs/contrib/admindocs/middleware.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Optional, Tuple +from typing import Any, Callable, Dict, Tuple from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponseBase @@ -11,4 +11,4 @@ class XViewMiddleware(MiddlewareMixin): view_func: Callable[..., HttpResponseBase], view_args: Tuple, view_kwargs: Dict[Any, Any], - ) -> Optional[HttpResponse]: ... + ) -> HttpResponse | None: ... diff --git a/django-stubs/contrib/admindocs/utils.pyi b/django-stubs/contrib/admindocs/utils.pyi index 63cec51c1..055be3fcc 100644 --- a/django-stubs/contrib/admindocs/utils.pyi +++ b/django-stubs/contrib/admindocs/utils.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, Optional, Tuple +from typing import Any, Callable, Dict, List, Tuple from django.utils.safestring import SafeString @@ -6,7 +6,7 @@ docutils_is_available: bool def get_view_name(view_func: Callable) -> str: ... def parse_docstring(docstring: str) -> Tuple[str, str, Dict[str, str]]: ... -def parse_rst(text: str, default_reference_context: Any, thing_being_parsed: Optional[Any] = ...) -> SafeString: ... +def parse_rst(text: str, default_reference_context: Any, thing_being_parsed: Any | None = ...) -> SafeString: ... ROLES: Dict[str, str] @@ -17,8 +17,8 @@ def default_reference_role( text: str, lineno: Any, inliner: Any, - options: Optional[Any] = ..., - content: Optional[Any] = ..., + options: Any | None = ..., + content: Any | None = ..., ) -> Tuple[List[Any], List[Any]]: ... named_group_matcher: Any diff --git a/django-stubs/contrib/admindocs/views.pyi b/django-stubs/contrib/admindocs/views.pyi index 98be0dafa..cf03083ae 100644 --- a/django-stubs/contrib/admindocs/views.pyi +++ b/django-stubs/contrib/admindocs/views.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Iterable, List, Optional, Pattern, Tuple, Union +from typing import Any, Callable, Iterable, List, Pattern, Tuple from django.db.models.fields import Field from django.urls import _AnyURL @@ -17,8 +17,8 @@ class ModelDetailView(BaseAdminDocsView): ... class TemplateDetailView(BaseAdminDocsView): ... def get_return_data_type(func_name: Any) -> str: ... -def get_readable_field_data_type(field: Union[Field, str]) -> str: ... +def get_readable_field_data_type(field: Field | str) -> str: ... def extract_views_from_urlpatterns( - urlpatterns: Iterable[_AnyURL], base: str = ..., namespace: Optional[str] = ... -) -> List[Tuple[Callable, Pattern[str], Optional[str], Optional[str]]]: ... + urlpatterns: Iterable[_AnyURL], base: str = ..., namespace: str | None = ... +) -> List[Tuple[Callable, Pattern[str], str | None, str | None]]: ... def simplify_regex(pattern: str) -> str: ... diff --git a/django-stubs/contrib/auth/__init__.pyi b/django-stubs/contrib/auth/__init__.pyi index 5c728b354..27a4e6915 100644 --- a/django-stubs/contrib/auth/__init__.pyi +++ b/django-stubs/contrib/auth/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Type, Union +from typing import Any, List, Type from django.contrib.auth.backends import ModelBackend from django.contrib.auth.base_user import AbstractBaseUser @@ -18,13 +18,13 @@ REDIRECT_FIELD_NAME: str def load_backend(path: str) -> ModelBackend: ... def get_backends() -> List[ModelBackend]: ... -def authenticate(request: Optional[HttpRequest] = ..., **credentials: Any) -> Optional[AbstractBaseUser]: ... +def authenticate(request: HttpRequest | None = ..., **credentials: Any) -> AbstractBaseUser | None: ... def login( - request: HttpRequest, user: Optional[AbstractBaseUser], backend: Optional[Union[Type[ModelBackend], str]] = ... + request: HttpRequest, user: AbstractBaseUser | None, backend: Type[ModelBackend] | str | None = ... ) -> None: ... def logout(request: HttpRequest) -> None: ... def get_user_model() -> Type[AbstractBaseUser]: ... -def get_user(request: Union[HttpRequest, Client]) -> Union[AbstractBaseUser, AnonymousUser]: ... +def get_user(request: HttpRequest | Client) -> AbstractBaseUser | AnonymousUser: ... def get_permission_codename(action: str, opts: Options) -> str: ... def update_session_auth_hash(request: HttpRequest, user: AbstractBaseUser) -> None: ... diff --git a/django-stubs/contrib/auth/backends.pyi b/django-stubs/contrib/auth/backends.pyi index 6c9cb06ab..6fe293f30 100644 --- a/django-stubs/contrib/auth/backends.pyi +++ b/django-stubs/contrib/auth/backends.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Set, TypeVar, Union +from typing import Any, Set, TypeVar from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import AnonymousUser, Permission @@ -6,34 +6,30 @@ from django.db.models import QuerySet from django.db.models.base import Model from django.http.request import HttpRequest -_AnyUser = Union[AbstractBaseUser, AnonymousUser] +_AnyUser = AbstractBaseUser | AnonymousUser UserModel: Any class BaseBackend: - def authenticate(self, request: Optional[HttpRequest], **kwargs: Any) -> Optional[AbstractBaseUser]: ... - def get_user(self, user_id: int) -> Optional[AbstractBaseUser]: ... - def get_user_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ... - def get_group_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ... - def get_all_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ... - def has_perm(self, user_obj: _AnyUser, perm: str, obj: Optional[Model] = ...) -> bool: ... + def authenticate(self, request: HttpRequest | None, **kwargs: Any) -> AbstractBaseUser | None: ... + def get_user(self, user_id: int) -> AbstractBaseUser | None: ... + def get_user_permissions(self, user_obj: _AnyUser, obj: Model | None = ...) -> Set[str]: ... + def get_group_permissions(self, user_obj: _AnyUser, obj: Model | None = ...) -> Set[str]: ... + def get_all_permissions(self, user_obj: _AnyUser, obj: Model | None = ...) -> Set[str]: ... + def has_perm(self, user_obj: _AnyUser, perm: str, obj: Model | None = ...) -> bool: ... class ModelBackend(BaseBackend): def authenticate( - self, - request: Optional[HttpRequest], - username: Optional[str] = ..., - password: Optional[str] = ..., - **kwargs: Any - ) -> Optional[AbstractBaseUser]: ... + self, request: HttpRequest | None, username: str | None = ..., password: str | None = ..., **kwargs: Any + ) -> AbstractBaseUser | None: ... def has_module_perms(self, user_obj: _AnyUser, app_label: str) -> bool: ... - def user_can_authenticate(self, user: Optional[_AnyUser]) -> bool: ... + def user_can_authenticate(self, user: _AnyUser | None) -> bool: ... def with_perm( self, - perm: Union[str, Permission], + perm: str | Permission, is_active: bool = ..., include_superusers: bool = ..., - obj: Optional[Model] = ..., + obj: Model | None = ..., ) -> QuerySet[AbstractBaseUser]: ... class AllowAllUsersModelBackend(ModelBackend): ... diff --git a/django-stubs/contrib/auth/base_user.pyi b/django-stubs/contrib/auth/base_user.pyi index 960108dae..4f2209634 100644 --- a/django-stubs/contrib/auth/base_user.pyi +++ b/django-stubs/contrib/auth/base_user.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Tuple, TypeVar, Union, overload +from typing import Any, List, Tuple, TypeVar, overload from django.db import models from django.db.models.base import Model @@ -10,23 +10,23 @@ _T = TypeVar("_T", bound=Model) class BaseUserManager(models.Manager[_T]): @classmethod - def normalize_email(cls, email: Optional[str]) -> str: ... + def normalize_email(cls, email: str | None) -> str: ... def make_random_password(self, length: int = ..., allowed_chars: str = ...) -> str: ... - def get_by_natural_key(self, username: Optional[str]) -> _T: ... + def get_by_natural_key(self, username: str | None) -> _T: ... class AbstractBaseUser(models.Model): REQUIRED_FIELDS: List[str] = ... password = models.CharField(max_length=128) last_login = models.DateTimeField(blank=True, null=True) - is_active: Union[bool, BooleanField[Union[bool, Combinable], bool]] = ... + is_active: bool | BooleanField[bool | Combinable, bool] = ... def get_username(self) -> str: ... def natural_key(self) -> Tuple[str]: ... @property def is_anonymous(self) -> Literal[False]: ... @property def is_authenticated(self) -> Literal[True]: ... - def set_password(self, raw_password: Optional[str]) -> None: ... + def set_password(self, raw_password: str | None) -> None: ... def check_password(self, raw_password: str) -> bool: ... def set_unusable_password(self) -> None: ... def has_usable_password(self) -> bool: ... diff --git a/django-stubs/contrib/auth/checks.pyi b/django-stubs/contrib/auth/checks.pyi index 677f1b136..fc954593c 100644 --- a/django-stubs/contrib/auth/checks.pyi +++ b/django-stubs/contrib/auth/checks.pyi @@ -1,9 +1,9 @@ -from typing import Any, Optional, Sequence +from typing import Any, Sequence from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage -def check_user_model(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> Sequence[CheckMessage]: ... +def check_user_model(app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any) -> Sequence[CheckMessage]: ... def check_models_permissions( - app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any + app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any ) -> Sequence[CheckMessage]: ... diff --git a/django-stubs/contrib/auth/decorators.pyi b/django-stubs/contrib/auth/decorators.pyi index fd5b0320b..094c7bd32 100644 --- a/django-stubs/contrib/auth/decorators.pyi +++ b/django-stubs/contrib/auth/decorators.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Iterable, Optional, TypeVar, Union, overload +from typing import Callable, Iterable, TypeVar, overload from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME # noqa: F401 from django.contrib.auth.models import AbstractBaseUser, AnonymousUser @@ -7,16 +7,16 @@ from django.http.response import HttpResponseBase _VIEW = TypeVar("_VIEW", bound=Callable[..., HttpResponseBase]) def user_passes_test( - test_func: Callable[[Union[AbstractBaseUser, AnonymousUser]], bool], - login_url: Optional[str] = ..., + test_func: Callable[[AbstractBaseUser | AnonymousUser], bool], + login_url: str | None = ..., redirect_field_name: str = ..., ) -> Callable[[_VIEW], _VIEW]: ... # There are two ways of calling @login_required: @with(arguments) and @bare @overload -def login_required(redirect_field_name: str = ..., login_url: Optional[str] = ...) -> Callable[[_VIEW], _VIEW]: ... +def login_required(redirect_field_name: str = ..., login_url: str | None = ...) -> Callable[[_VIEW], _VIEW]: ... @overload -def login_required(function: _VIEW, redirect_field_name: str = ..., login_url: Optional[str] = ...) -> _VIEW: ... +def login_required(function: _VIEW, redirect_field_name: str = ..., login_url: str | None = ...) -> _VIEW: ... def permission_required( - perm: Union[Iterable[str], str], login_url: Optional[str] = ..., raise_exception: bool = ... + perm: Iterable[str] | str, login_url: str | None = ..., raise_exception: bool = ... ) -> Callable[[_VIEW], _VIEW]: ... diff --git a/django-stubs/contrib/auth/forms.pyi b/django-stubs/contrib/auth/forms.pyi index 232dc6dcc..a7b780824 100644 --- a/django-stubs/contrib/auth/forms.pyi +++ b/django-stubs/contrib/auth/forms.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, List, Optional, Type, TypeVar, Union +from typing import Any, Dict, Iterable, List, Type, TypeVar from django import forms from django.contrib.auth.base_user import AbstractBaseUser @@ -16,14 +16,14 @@ _User = TypeVar("_User", bound=AbstractBaseUser) class ReadOnlyPasswordHashWidget(forms.Widget): template_name: str = ... read_only: bool = ... - def get_context(self, name: str, value: Any, attrs: Optional[Dict[str, Any]]) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: Dict[str, Any] | None) -> Dict[str, Any]: ... class ReadOnlyPasswordHashField(forms.Field): widget: _ClassLevelWidgetT = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... class UsernameField(forms.CharField): - def to_python(self, value: Optional[Any]) -> Optional[Any]: ... + def to_python(self, value: Any | None) -> Any | None: ... def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... class UserCreationForm(forms.ModelForm[_User]): @@ -42,10 +42,10 @@ class AuthenticationForm(forms.Form): username: forms.Field = ... password: forms.Field = ... error_messages: _ErrorMessagesT = ... - request: Optional[HttpRequest] = ... + request: HttpRequest | None = ... user_cache: Any = ... username_field: models.Field = ... - def __init__(self, request: Optional[HttpRequest] = ..., *args: Any, **kwargs: Any) -> None: ... + def __init__(self, request: HttpRequest | None = ..., *args: Any, **kwargs: Any) -> None: ... def confirm_login_allowed(self, user: AbstractBaseUser) -> None: ... def get_user(self) -> AbstractBaseUser: ... def get_invalid_login_error(self) -> ValidationError: ... @@ -58,22 +58,22 @@ class PasswordResetForm(forms.Form): subject_template_name: str, email_template_name: str, context: Dict[str, Any], - from_email: Optional[str], + from_email: str | None, to_email: str, - html_email_template_name: Optional[str] = ..., + html_email_template_name: str | None = ..., ) -> None: ... def get_users(self, email: str) -> Iterable[AbstractBaseUser]: ... def save( self, - domain_override: Optional[str] = ..., + domain_override: str | None = ..., subject_template_name: str = ..., email_template_name: str = ..., use_https: bool = ..., token_generator: PasswordResetTokenGenerator = ..., - from_email: Optional[str] = ..., - request: Optional[HttpRequest] = ..., - html_email_template_name: Optional[str] = ..., - extra_email_context: Optional[Dict[str, str]] = ..., + from_email: str | None = ..., + request: HttpRequest | None = ..., + html_email_template_name: str | None = ..., + extra_email_context: Dict[str, str] | None = ..., ) -> None: ... class SetPasswordForm(forms.Form): diff --git a/django-stubs/contrib/auth/hashers.pyi b/django-stubs/contrib/auth/hashers.pyi index 3557342ae..f0d1b2fbb 100644 --- a/django-stubs/contrib/auth/hashers.pyi +++ b/django-stubs/contrib/auth/hashers.pyi @@ -1,25 +1,21 @@ -from typing import Any, Callable, Dict, List, Optional, Tuple, Union +from typing import Any, Callable, Dict, List, Tuple UNUSABLE_PASSWORD_PREFIX: str UNUSABLE_PASSWORD_SUFFIX_LENGTH: int -def is_password_usable(encoded: Optional[str]) -> bool: ... -def check_password( - password: Optional[str], encoded: str, setter: Optional[Callable] = ..., preferred: str = ... -) -> bool: ... -def make_password( - password: Optional[str], salt: Optional[str] = ..., hasher: Union[str, BasePasswordHasher] = ... -) -> str: ... +def is_password_usable(encoded: str | None) -> bool: ... +def check_password(password: str | None, encoded: str, setter: Callable | None = ..., preferred: str = ...) -> bool: ... +def make_password(password: str | None, salt: str | None = ..., hasher: str | BasePasswordHasher = ...) -> str: ... def get_hashers() -> List[BasePasswordHasher]: ... def get_hashers_by_algorithm() -> Dict[str, BasePasswordHasher]: ... def reset_hashers(**kwargs: Any) -> None: ... -def get_hasher(algorithm: Union[str, BasePasswordHasher] = ...) -> BasePasswordHasher: ... +def get_hasher(algorithm: str | BasePasswordHasher = ...) -> BasePasswordHasher: ... def identify_hasher(encoded: str) -> BasePasswordHasher: ... def mask_hash(hash: str, show: int = ..., char: str = ...) -> str: ... class BasePasswordHasher: algorithm: str = ... - library: Union[str, Tuple[str, str]] = ... + library: str | Tuple[str, str] = ... rounds: int = ... time_cost: int = ... memory_cost: int = ... @@ -34,7 +30,7 @@ class BasePasswordHasher: def harden_runtime(self, password: str, encoded: str) -> None: ... class PBKDF2PasswordHasher(BasePasswordHasher): - def encode(self, password: str, salt: str, iterations: Optional[int] = ...) -> str: ... + def encode(self, password: str, salt: str, iterations: int | None = ...) -> str: ... class PBKDF2SHA1PasswordHasher(PBKDF2PasswordHasher): ... class Argon2PasswordHasher(BasePasswordHasher): ... diff --git a/django-stubs/contrib/auth/middleware.pyi b/django-stubs/contrib/auth/middleware.pyi index 4a2e591d8..52cc8ae35 100644 --- a/django-stubs/contrib/auth/middleware.pyi +++ b/django-stubs/contrib/auth/middleware.pyi @@ -1,11 +1,9 @@ -from typing import Union - from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import AnonymousUser from django.http.request import HttpRequest from django.utils.deprecation import MiddlewareMixin -def get_user(request: HttpRequest) -> Union[AnonymousUser, AbstractBaseUser]: ... +def get_user(request: HttpRequest) -> AnonymousUser | AbstractBaseUser: ... class AuthenticationMiddleware(MiddlewareMixin): def process_request(self, request: HttpRequest) -> None: ... diff --git a/django-stubs/contrib/auth/mixins.pyi b/django-stubs/contrib/auth/mixins.pyi index 60f7c1441..d8fc25f9d 100644 --- a/django-stubs/contrib/auth/mixins.pyi +++ b/django-stubs/contrib/auth/mixins.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Optional, Sequence +from typing import Any, Callable, Sequence from django import http from django.http.response import HttpResponseBase, HttpResponseRedirect @@ -24,6 +24,6 @@ class PermissionRequiredMixin(AccessMixin): def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ... class UserPassesTestMixin(AccessMixin): - def test_func(self) -> Optional[bool]: ... + def test_func(self) -> bool | None: ... def get_test_func(self) -> Callable: ... def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ... diff --git a/django-stubs/contrib/auth/models.pyi b/django-stubs/contrib/auth/models.pyi index 0ddfb6d8c..4c47c21bc 100644 --- a/django-stubs/contrib/auth/models.pyi +++ b/django-stubs/contrib/auth/models.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Optional, Set, Tuple, Type, TypeVar, Union +from typing import Any, Iterable, Set, Tuple, Type, TypeVar from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser from django.contrib.auth.base_user import BaseUserManager as BaseUserManager @@ -10,7 +10,7 @@ from django.db.models.base import Model from django.db.models.manager import EmptyManager from typing_extensions import Literal -_AnyUser = Union[Model, "AnonymousUser"] +_AnyUser = Model | "AnonymousUser" def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ... @@ -40,29 +40,29 @@ _T = TypeVar("_T", bound=Model) class UserManager(BaseUserManager[_T]): def create_user( - self, username: str, email: Optional[str] = ..., password: Optional[str] = ..., **extra_fields: Any + self, username: str, email: str | None = ..., password: str | None = ..., **extra_fields: Any ) -> _T: ... def create_superuser( - self, username: str, email: Optional[str] = ..., password: Optional[str] = ..., **extra_fields: Any + self, username: str, email: str | None = ..., password: str | None = ..., **extra_fields: Any ) -> _T: ... def with_perm( self, - perm: Union[str, Permission], + perm: str | Permission, is_active: bool = ..., include_superusers: bool = ..., - backend: Optional[str] = ..., - obj: Optional[Model] = ..., + backend: str | None = ..., + obj: Model | None = ..., ) -> QuerySet[_T]: ... class PermissionsMixin(models.Model): is_superuser = models.BooleanField() groups = models.ManyToManyField(Group) user_permissions = models.ManyToManyField(Permission) - def get_user_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ... - def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ... - def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ... - def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ... - def has_perms(self, perm_list: Iterable[str], obj: Optional[_AnyUser] = ...) -> bool: ... + def get_user_permissions(self, obj: _AnyUser | None = ...) -> Set[str]: ... + def get_group_permissions(self, obj: _AnyUser | None = ...) -> Set[str]: ... + def get_all_permissions(self, obj: _AnyUser | None = ...) -> Set[str]: ... + def has_perm(self, perm: str, obj: _AnyUser | None = ...) -> bool: ... + def has_perms(self, perm_list: Iterable[str], obj: _AnyUser | None = ...) -> bool: ... def has_module_perms(self, app_label: str) -> bool: ... class AbstractUser(AbstractBaseUser, PermissionsMixin): @@ -99,11 +99,11 @@ class AnonymousUser: def groups(self) -> EmptyManager[Group]: ... @property def user_permissions(self) -> EmptyManager[Permission]: ... - def get_user_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ... - def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[Any]: ... - def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ... - def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ... - def has_perms(self, perm_list: Iterable[str], obj: Optional[_AnyUser] = ...) -> bool: ... + def get_user_permissions(self, obj: _AnyUser | None = ...) -> Set[str]: ... + def get_group_permissions(self, obj: _AnyUser | None = ...) -> Set[Any]: ... + def get_all_permissions(self, obj: _AnyUser | None = ...) -> Set[str]: ... + def has_perm(self, perm: str, obj: _AnyUser | None = ...) -> bool: ... + def has_perms(self, perm_list: Iterable[str], obj: _AnyUser | None = ...) -> bool: ... def has_module_perms(self, module: str) -> bool: ... @property def is_anonymous(self) -> Literal[True]: ... diff --git a/django-stubs/contrib/auth/password_validation.pyi b/django-stubs/contrib/auth/password_validation.pyi index f719f8801..63ced0844 100644 --- a/django-stubs/contrib/auth/password_validation.pyi +++ b/django-stubs/contrib/auth/password_validation.pyi @@ -1,30 +1,30 @@ from pathlib import Path, PosixPath -from typing import Any, List, Mapping, Optional, Protocol, Sequence, Set, Union +from typing import Any, List, Mapping, Protocol, Sequence, Set from django.db.models.base import Model _UserModel = Model class PasswordValidator(Protocol): - def validate(self, __password: str, __user: Optional[_UserModel] = ...) -> None: ... + def validate(self, __password: str, __user: _UserModel | None = ...) -> None: ... def get_help_text(self) -> str: ... def get_default_password_validators() -> List[PasswordValidator]: ... def get_password_validators(validator_config: Sequence[Mapping[str, Any]]) -> List[PasswordValidator]: ... def validate_password( - password: str, user: Optional[_UserModel] = ..., password_validators: Optional[Sequence[PasswordValidator]] = ... + password: str, user: _UserModel | None = ..., password_validators: Sequence[PasswordValidator] | None = ... ) -> None: ... def password_changed( - password: str, user: Optional[_UserModel] = ..., password_validators: Optional[Sequence[PasswordValidator]] = ... + password: str, user: _UserModel | None = ..., password_validators: Sequence[PasswordValidator] | None = ... ) -> None: ... -def password_validators_help_texts(password_validators: Optional[Sequence[PasswordValidator]] = ...) -> List[str]: ... +def password_validators_help_texts(password_validators: Sequence[PasswordValidator] | None = ...) -> List[str]: ... password_validators_help_text_html: Any class MinimumLengthValidator: min_length: int = ... def __init__(self, min_length: int = ...) -> None: ... - def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ... + def validate(self, password: str, user: _UserModel | None = ...) -> None: ... def get_help_text(self) -> str: ... class UserAttributeSimilarityValidator: @@ -32,16 +32,16 @@ class UserAttributeSimilarityValidator: user_attributes: Sequence[str] = ... max_similarity: float = ... def __init__(self, user_attributes: Sequence[str] = ..., max_similarity: float = ...) -> None: ... - def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ... + def validate(self, password: str, user: _UserModel | None = ...) -> None: ... def get_help_text(self) -> str: ... class CommonPasswordValidator: DEFAULT_PASSWORD_LIST_PATH: Path = ... passwords: Set[str] = ... - def __init__(self, password_list_path: Union[Path, PosixPath, str] = ...) -> None: ... - def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ... + def __init__(self, password_list_path: Path | PosixPath | str = ...) -> None: ... + def validate(self, password: str, user: _UserModel | None = ...) -> None: ... def get_help_text(self) -> str: ... class NumericPasswordValidator: - def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ... + def validate(self, password: str, user: _UserModel | None = ...) -> None: ... def get_help_text(self) -> str: ... diff --git a/django-stubs/contrib/auth/tokens.pyi b/django-stubs/contrib/auth/tokens.pyi index 3ce0e7cb7..fe4939ecc 100644 --- a/django-stubs/contrib/auth/tokens.pyi +++ b/django-stubs/contrib/auth/tokens.pyi @@ -1,5 +1,5 @@ from datetime import date, datetime -from typing import Any, Optional, Union +from typing import Any from django.contrib.auth.base_user import AbstractBaseUser @@ -8,10 +8,10 @@ class PasswordResetTokenGenerator: secret: Any = ... algorithm: str = ... def make_token(self, user: AbstractBaseUser) -> str: ... - def check_token(self, user: Optional[AbstractBaseUser], token: Optional[str]) -> bool: ... + def check_token(self, user: AbstractBaseUser | None, token: str | None) -> bool: ... def _make_token_with_timestamp(self, user: AbstractBaseUser, timestamp: int, legacy: bool = ...) -> str: ... def _make_hash_value(self, user: AbstractBaseUser, timestamp: int) -> str: ... - def _num_seconds(self, dt: Union[datetime, date]) -> int: ... + def _num_seconds(self, dt: datetime | date) -> int: ... def _now(self) -> datetime: ... default_token_generator: Any diff --git a/django-stubs/contrib/auth/views.pyi b/django-stubs/contrib/auth/views.pyi index f1ada8239..a25b484ad 100644 --- a/django-stubs/contrib/auth/views.pyi +++ b/django-stubs/contrib/auth/views.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Set +from typing import Any, Dict, Set from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.forms import AuthenticationForm @@ -21,16 +21,16 @@ class LoginView(SuccessURLAllowedHostsMixin, FormView[AuthenticationForm]): def get_redirect_url(self) -> str: ... class LogoutView(SuccessURLAllowedHostsMixin, TemplateView): - next_page: Optional[str] = ... + next_page: str | None = ... redirect_field_name: str = ... extra_context: Any = ... def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... - def get_next_page(self) -> Optional[str]: ... + def get_next_page(self) -> str | None: ... -def logout_then_login(request: HttpRequest, login_url: Optional[str] = ...) -> HttpResponseRedirect: ... +def logout_then_login(request: HttpRequest, login_url: str | None = ...) -> HttpResponseRedirect: ... def redirect_to_login( - next: str, login_url: Optional[str] = ..., redirect_field_name: Optional[str] = ... + next: str, login_url: str | None = ..., redirect_field_name: str | None = ... ) -> HttpResponseRedirect: ... class PasswordContextMixin: @@ -60,7 +60,7 @@ class PasswordResetConfirmView(PasswordContextMixin, FormView): token_generator: Any = ... validlink: bool = ... user: Any = ... - def get_user(self, uidb64: str) -> Optional[AbstractBaseUser]: ... + def get_user(self, uidb64: str) -> AbstractBaseUser | None: ... class PasswordResetCompleteView(PasswordContextMixin, TemplateView): title: Any = ... diff --git a/django-stubs/contrib/contenttypes/checks.pyi b/django-stubs/contrib/contenttypes/checks.pyi index fd62dbd0c..983bbb607 100644 --- a/django-stubs/contrib/contenttypes/checks.pyi +++ b/django-stubs/contrib/contenttypes/checks.pyi @@ -1,11 +1,11 @@ -from typing import Any, Optional, Sequence +from typing import Any, Sequence from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage def check_generic_foreign_keys( - app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any + app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any ) -> Sequence[CheckMessage]: ... def check_model_name_lengths( - app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any + app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any ) -> Sequence[CheckMessage]: ... diff --git a/django-stubs/contrib/contenttypes/fields.pyi b/django-stubs/contrib/contenttypes/fields.pyi index b3617f39b..a99835a1c 100644 --- a/django-stubs/contrib/contenttypes/fields.pyi +++ b/django-stubs/contrib/contenttypes/fields.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union +from typing import Any, Callable, Dict, List, Tuple, Type from django.contrib.contenttypes.models import ContentType from django.core.checks.messages import CheckMessage @@ -15,7 +15,7 @@ from django.db.models.sql.where import WhereNode class GenericForeignKey(FieldCacheMixin): # django-stubs implementation only fields - _pyi_private_set_type: Union[Any, Combinable] + _pyi_private_set_type: Any | Combinable _pyi_private_get_type: Any # attributes auto_created: bool = ... @@ -38,28 +38,28 @@ class GenericForeignKey(FieldCacheMixin): name: Any = ... model: Any = ... def contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ... - def get_filter_kwargs_for_object(self, obj: Model) -> Dict[str, Optional[ContentType]]: ... + def get_filter_kwargs_for_object(self, obj: Model) -> Dict[str, ContentType | None]: ... def get_forward_related_filter(self, obj: Model) -> Dict[str, int]: ... def check(self, **kwargs: Any) -> List[CheckMessage]: ... def get_cache_name(self) -> str: ... def get_content_type( - self, obj: Optional[Model] = ..., id: Optional[int] = ..., using: Optional[str] = ... + self, obj: Model | None = ..., id: int | None = ..., using: str | None = ... ) -> ContentType: ... def get_prefetch_queryset( - self, instances: Union[List[Model], QuerySet], queryset: Optional[QuerySet] = ... + self, instances: List[Model] | QuerySet, queryset: QuerySet | None = ... ) -> Tuple[List[Model], Callable, Callable, bool, str, bool]: ... - def __get__(self, instance: Optional[Model], cls: Optional[Type[Model]] = ...) -> Optional[Any]: ... - def __set__(self, instance: Model, value: Optional[Any]) -> None: ... + def __get__(self, instance: Model | None, cls: Type[Model] | None = ...) -> Any | None: ... + def __set__(self, instance: Model, value: Any | None) -> None: ... class GenericRel(ForeignObjectRel): field: GenericRelation def __init__( self, field: GenericRelation, - to: Union[Type[Model], str], - related_name: Optional[str] = ..., - related_query_name: Optional[str] = ..., - limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ..., + to: Type[Model] | str, + related_name: str | None = ..., + related_query_name: str | None = ..., + limit_choices_to: Dict[str, Any] | Callable[[], Any] | None = ..., ) -> None: ... class GenericRelation(ForeignObject): @@ -71,20 +71,20 @@ class GenericRelation(ForeignObject): to_fields: Any = ... def __init__( self, - to: Union[Type[Model], str], + to: Type[Model] | str, object_id_field: str = ..., content_type_field: str = ..., for_concrete_model: bool = ..., - related_query_name: Optional[str] = ..., - limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ..., + related_query_name: str | None = ..., + limit_choices_to: Dict[str, Any] | Callable[[], Any] | None = ..., **kwargs: Any ) -> None: ... def resolve_related_fields(self) -> List[Tuple[Field, Field]]: ... - def get_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ... - def get_reverse_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ... + def get_path_info(self, filtered_relation: FilteredRelation | None = ...) -> List[PathInfo]: ... + def get_reverse_path_info(self, filtered_relation: FilteredRelation | None = ...) -> List[PathInfo]: ... def get_content_type(self) -> ContentType: ... def get_extra_restriction( - self, where_class: Type[WhereNode], alias: Optional[str], remote_alias: str + self, where_class: Type[WhereNode], alias: str | None, remote_alias: str ) -> WhereNode: ... def bulk_related_objects(self, objs: List[Model], using: str = ...) -> QuerySet: ... diff --git a/django-stubs/contrib/contenttypes/forms.pyi b/django-stubs/contrib/contenttypes/forms.pyi index ff879852e..ffe20b4f9 100644 --- a/django-stubs/contrib/contenttypes/forms.pyi +++ b/django-stubs/contrib/contenttypes/forms.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Type, TypeVar +from typing import Any, Type, TypeVar from django.db.models import Model from django.forms.models import BaseModelFormSet, ModelForm @@ -12,12 +12,12 @@ class BaseGenericInlineFormSet(BaseModelFormSet[_M, _ModelFormT]): save_as_new: Any = ... def __init__( self, - data: Optional[Any] = ..., - files: Optional[Any] = ..., - instance: Optional[Any] = ..., + data: Any | None = ..., + files: Any | None = ..., + instance: Any | None = ..., save_as_new: bool = ..., - prefix: Optional[Any] = ..., - queryset: Optional[Any] = ..., + prefix: Any | None = ..., + queryset: Any | None = ..., **kwargs: Any ) -> None: ... def initial_form_count(self) -> int: ... @@ -31,17 +31,17 @@ def generic_inlineformset_factory( formset: Any = ..., ct_field: str = ..., fk_field: str = ..., - fields: Optional[Any] = ..., - exclude: Optional[Any] = ..., + fields: Any | None = ..., + exclude: Any | None = ..., extra: int = ..., can_order: bool = ..., can_delete: bool = ..., - max_num: Optional[Any] = ..., - formfield_callback: Optional[Any] = ..., + max_num: Any | None = ..., + formfield_callback: Any | None = ..., validate_max: bool = ..., for_concrete_model: bool = ..., - min_num: Optional[Any] = ..., + min_num: Any | None = ..., validate_min: bool = ..., - absolute_max: Optional[int] = ..., + absolute_max: int | None = ..., can_delete_extra: bool = ..., ) -> Type[BaseGenericInlineFormSet[_M, _ModelFormT]]: ... diff --git a/django-stubs/contrib/contenttypes/models.pyi b/django-stubs/contrib/contenttypes/models.pyi index e9f5e7cbf..1daecc677 100644 --- a/django-stubs/contrib/contenttypes/models.pyi +++ b/django-stubs/contrib/contenttypes/models.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Tuple, Type, Union +from typing import Any, Dict, Tuple, Type from django.db import models from django.db.models.base import Model @@ -6,7 +6,7 @@ from django.db.models.query import QuerySet class ContentTypeManager(models.Manager["ContentType"]): def get_by_natural_key(self, app_label: str, model: str) -> ContentType: ... - def get_for_model(self, model: Union[Type[Model], Model], for_concrete_model: bool = ...) -> ContentType: ... + def get_for_model(self, model: Type[Model] | Model, for_concrete_model: bool = ...) -> ContentType: ... def get_for_models(self, *models: Any, for_concrete_models: bool = ...) -> Dict[Type[Model], ContentType]: ... def get_for_id(self, id: int) -> ContentType: ... def clear_cache(self) -> None: ... @@ -18,7 +18,7 @@ class ContentType(models.Model): objects: ContentTypeManager = ... @property def name(self) -> str: ... - def model_class(self) -> Optional[Type[Model]]: ... + def model_class(self) -> Type[Model] | None: ... def get_object_for_this_type(self, **kwargs: Any) -> Model: ... def get_all_objects_for_this_type(self, **kwargs: Any) -> QuerySet: ... def natural_key(self) -> Tuple[str, str]: ... diff --git a/django-stubs/contrib/contenttypes/views.pyi b/django-stubs/contrib/contenttypes/views.pyi index 05f704120..0897864fe 100644 --- a/django-stubs/contrib/contenttypes/views.pyi +++ b/django-stubs/contrib/contenttypes/views.pyi @@ -1,8 +1,4 @@ -from typing import Union - from django.http.request import HttpRequest from django.http.response import HttpResponseRedirect -def shortcut( - request: HttpRequest, content_type_id: Union[int, str], object_id: Union[int, str] -) -> HttpResponseRedirect: ... +def shortcut(request: HttpRequest, content_type_id: int | str, object_id: int | str) -> HttpResponseRedirect: ... diff --git a/django-stubs/contrib/flatpages/templatetags/flatpages.pyi b/django-stubs/contrib/flatpages/templatetags/flatpages.pyi index e9be47e88..89951ea0a 100644 --- a/django-stubs/contrib/flatpages/templatetags/flatpages.pyi +++ b/django-stubs/contrib/flatpages/templatetags/flatpages.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django import template from django.template.base import Parser, Token @@ -10,7 +10,7 @@ class FlatpageNode(template.Node): context_name: str = ... starts_with: None = ... user: None = ... - def __init__(self, context_name: str, starts_with: Optional[str] = ..., user: Optional[str] = ...) -> None: ... + def __init__(self, context_name: str, starts_with: str | None = ..., user: str | None = ...) -> None: ... def render(self, context: Context) -> str: ... def get_flatpages(parser: Parser, token: Token) -> FlatpageNode: ... diff --git a/django-stubs/contrib/gis/admin/options.pyi b/django-stubs/contrib/gis/admin/options.pyi index 113ca6eee..1e5200ffe 100644 --- a/django-stubs/contrib/gis/admin/options.pyi +++ b/django-stubs/contrib/gis/admin/options.pyi @@ -1,4 +1,4 @@ -from typing import Any, Union +from typing import Any from django.contrib.admin import ModelAdmin as ModelAdmin @@ -14,9 +14,9 @@ class GeoModelAdmin(ModelAdmin): num_zoom: int = ... max_zoom: bool = ... min_zoom: bool = ... - units: Union[str, bool] = ... - max_resolution: Union[str, bool] = ... - max_extent: Union[str, bool] = ... + units: str | bool = ... + max_resolution: str | bool = ... + max_extent: str | bool = ... modifiable: bool = ... mouse_position: bool = ... scale_text: bool = ... diff --git a/django-stubs/contrib/gis/db/backends/mysql/operations.pyi b/django-stubs/contrib/gis/db/backends/mysql/operations.pyi index 94a3365b6..890fbe06d 100644 --- a/django-stubs/contrib/gis/db/backends/mysql/operations.pyi +++ b/django-stubs/contrib/gis/db/backends/mysql/operations.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, Optional, Set, Type +from typing import Any, Callable, Dict, List, Set, Type from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations as BaseSpatialOperations from django.contrib.gis.db.backends.utils import SpatialOperator @@ -24,4 +24,4 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations): def unsupported_functions(self) -> Set[str]: ... # type: ignore def geo_db_type(self, f: Any) -> Any: ... def get_distance(self, f: Any, value: Any, lookup_type: Any) -> List[Any]: ... - def get_geometry_converter(self, expression: Any) -> Callable[[Any, Any, Any], Optional[GEOSGeometryBase]]: ... + def get_geometry_converter(self, expression: Any) -> Callable[[Any, Any, Any], GEOSGeometryBase | None]: ... diff --git a/django-stubs/contrib/gis/db/backends/postgis/operations.pyi b/django-stubs/contrib/gis/db/backends/postgis/operations.pyi index 6f6e1f943..021995aa6 100644 --- a/django-stubs/contrib/gis/db/backends/postgis/operations.pyi +++ b/django-stubs/contrib/gis/db/backends/postgis/operations.pyi @@ -1,4 +1,4 @@ -from typing import Any, Union +from typing import Any from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations from django.contrib.gis.db.backends.utils import SpatialOperator @@ -10,10 +10,8 @@ BILATERAL: Literal["bilateral"] class PostGISOperator(SpatialOperator): geography: Any = ... - raster: Union[bool, Literal["bilateral"]] = ... - def __init__( - self, geography: bool = ..., raster: Union[bool, Literal["bilateral"]] = ..., **kwargs: Any - ) -> None: ... + raster: bool | Literal["bilateral"] = ... + def __init__(self, geography: bool = ..., raster: bool | Literal["bilateral"] = ..., **kwargs: Any) -> None: ... def check_raster(self, lookup: Any, template_params: Any) -> Any: ... class ST_Polygon(Func): diff --git a/django-stubs/contrib/gis/db/backends/utils.pyi b/django-stubs/contrib/gis/db/backends/utils.pyi index e7024bbcc..a3d2ed3dd 100644 --- a/django-stubs/contrib/gis/db/backends/utils.pyi +++ b/django-stubs/contrib/gis/db/backends/utils.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.db.models.sql.compiler import _AsSqlType @@ -6,7 +6,7 @@ class SpatialOperator: sql_template: Any = ... op: Any = ... func: Any = ... - def __init__(self, op: Optional[Any] = ..., func: Optional[Any] = ...) -> None: ... + def __init__(self, op: Any | None = ..., func: Any | None = ...) -> None: ... @property def default_template(self) -> Any: ... def as_sql(self, connection: Any, lookup: Any, template_params: Any, sql_params: Any) -> _AsSqlType: ... diff --git a/django-stubs/contrib/gis/db/models/aggregates.pyi b/django-stubs/contrib/gis/db/models/aggregates.pyi index 09f37b3b9..ea178930e 100644 --- a/django-stubs/contrib/gis/db/models/aggregates.pyi +++ b/django-stubs/contrib/gis/db/models/aggregates.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.db.models import Aggregate from django.db.models.sql.compiler import _AsSqlType @@ -9,14 +9,14 @@ class GeoAggregate(Aggregate): @property def output_field(self) -> Any: ... def as_sql( - self, compiler: Any, connection: Any, function: Optional[Any] = ..., **extra_context: Any + self, compiler: Any, connection: Any, function: Any | None = ..., **extra_context: Any ) -> _AsSqlType: ... def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... def resolve_expression( self, - query: Optional[Any] = ..., + query: Any | None = ..., allow_joins: bool = ..., - reuse: Optional[Any] = ..., + reuse: Any | None = ..., summarize: bool = ..., for_save: bool = ..., ) -> Any: ... diff --git a/django-stubs/contrib/gis/db/models/fields.pyi b/django-stubs/contrib/gis/db/models/fields.pyi index 8fe251d33..284156de1 100644 --- a/django-stubs/contrib/gis/db/models/fields.pyi +++ b/django-stubs/contrib/gis/db/models/fields.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, NamedTuple, Optional, Tuple, TypeVar, Union +from typing import Any, Iterable, NamedTuple, Tuple, TypeVar from django.core.validators import _ValidatorCallable from django.db.models.fields import Field, _ErrorMessagesT, _FieldChoices @@ -20,13 +20,13 @@ def get_srid_info(srid: int, connection: Any) -> SRIDCacheEntry: ... class BaseSpatialField(Field[_ST, _GT]): def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., + verbose_name: _StrOrPromise | None = ..., srid: int = ..., spatial_index: bool = ..., *, - name: Optional[str] = ..., + name: str | None = ..., primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., @@ -35,15 +35,15 @@ class BaseSpatialField(Field[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[_ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... def deconstruct(self) -> Any: ... def db_type(self, connection: Any) -> Any: ... @@ -66,7 +66,7 @@ class GeometryField(BaseSpatialField): geography: Any = ... def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., + verbose_name: _StrOrPromise | None = ..., dim: int = ..., geography: bool = ..., *, @@ -74,9 +74,9 @@ class GeometryField(BaseSpatialField): tolerance: float = ..., srid: int = ..., spatial_index: bool = ..., - name: Optional[str] = ..., + name: str | None = ..., primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., @@ -85,15 +85,15 @@ class GeometryField(BaseSpatialField): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[_ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... def deconstruct(self) -> Any: ... def formfield(self, **kwargs: Any) -> Any: ... # type: ignore[override] diff --git a/django-stubs/contrib/gis/db/models/functions.pyi b/django-stubs/contrib/gis/db/models/functions.pyi index a9506e52b..806417f63 100644 --- a/django-stubs/contrib/gis/db/models/functions.pyi +++ b/django-stubs/contrib/gis/db/models/functions.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.db.models import Func from django.db.models import Transform as StandardTransform @@ -13,7 +13,7 @@ class GeoFuncMixin: @property def geo_field(self) -> Any: ... def as_sql( - self, compiler: Any, connection: Any, function: Optional[Any] = ..., **extra_context: Any + self, compiler: Any, connection: Any, function: Any | None = ..., **extra_context: Any ) -> _AsSqlType: ... def resolve_expression(self, *args: Any, **kwargs: Any) -> Any: ... @@ -89,7 +89,7 @@ class DistanceResultMixin: class Distance(DistanceResultMixin, OracleToleranceMixin, GeoFunc): geom_param_pos: Any = ... spheroid: Any = ... - def __init__(self, expr1: Any, expr2: Any, spheroid: Optional[Any] = ..., **extra: Any) -> None: ... + def __init__(self, expr1: Any, expr2: Any, spheroid: Any | None = ..., **extra: Any) -> None: ... def as_postgresql(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... @@ -101,7 +101,7 @@ class ForcePolygonCW(GeomOutputGeoFunc): class GeoHash(GeoFunc): output_field: Any = ... - def __init__(self, expression: Any, precision: Optional[Any] = ..., **extra: Any) -> None: ... + def __init__(self, expression: Any, precision: Any | None = ..., **extra: Any) -> None: ... def as_mysql(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class GeometryDistance(GeoFunc): diff --git a/django-stubs/contrib/gis/db/models/proxy.pyi b/django-stubs/contrib/gis/db/models/proxy.pyi index 8971b8d28..50271f9bd 100644 --- a/django-stubs/contrib/gis/db/models/proxy.pyi +++ b/django-stubs/contrib/gis/db/models/proxy.pyi @@ -1,8 +1,8 @@ -from typing import Any, Optional +from typing import Any from django.db.models.query_utils import DeferredAttribute class SpatialProxy(DeferredAttribute): - def __init__(self, klass: Any, field: Any, load_func: Optional[Any] = ...) -> None: ... - def __get__(self, instance: Any, cls: Optional[Any] = ...) -> Any: ... + def __init__(self, klass: Any, field: Any, load_func: Any | None = ...) -> None: ... + def __get__(self, instance: Any, cls: Any | None = ...) -> Any: ... def __set__(self, instance: Any, value: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/forms/fields.pyi b/django-stubs/contrib/gis/forms/fields.pyi index 273fe65ba..ff7a9e21a 100644 --- a/django-stubs/contrib/gis/forms/fields.pyi +++ b/django-stubs/contrib/gis/forms/fields.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django import forms @@ -7,7 +7,7 @@ class GeometryField(forms.Field): geom_type: str = ... default_error_messages: Any = ... srid: Any = ... - def __init__(self, *, srid: Optional[Any] = ..., geom_type: Optional[Any] = ..., **kwargs: Any) -> None: ... + def __init__(self, *, srid: Any | None = ..., geom_type: Any | None = ..., **kwargs: Any) -> None: ... def to_python(self, value: Any) -> Any: ... def clean(self, value: Any) -> Any: ... def has_changed(self, initial: Any, data: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/forms/widgets.pyi b/django-stubs/contrib/gis/forms/widgets.pyi index 7c09685ad..703d60990 100644 --- a/django-stubs/contrib/gis/forms/widgets.pyi +++ b/django-stubs/contrib/gis/forms/widgets.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing import Any, Optional +from typing import Any from django.forms.widgets import Widget as Widget @@ -14,7 +14,7 @@ class BaseGeometryWidget(Widget): supports_3d: bool = ... template_name: str = ... attrs: Any = ... - def __init__(self, attrs: Optional[Any] = ...) -> None: ... + def __init__(self, attrs: Any | None = ...) -> None: ... def serialize(self, value: Any) -> Any: ... def deserialize(self, value: Any) -> Any: ... def get_context(self, name: Any, value: Any, attrs: Any) -> Any: ... @@ -34,4 +34,4 @@ class OSMWidget(OpenLayersWidget): default_lon: int = ... default_lat: int = ... default_zoom: int = ... - def __init__(self, attrs: Optional[Any] = ...) -> None: ... + def __init__(self, attrs: Any | None = ...) -> None: ... diff --git a/django-stubs/contrib/gis/gdal/geometries.pyi b/django-stubs/contrib/gis/gdal/geometries.pyi index 66fe9d2ac..585a7e5e7 100644 --- a/django-stubs/contrib/gis/gdal/geometries.pyi +++ b/django-stubs/contrib/gis/gdal/geometries.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.contrib.gis.gdal.base import GDALBase as GDALBase @@ -6,7 +6,7 @@ class OGRGeometry(GDALBase): destructor: Any = ... ptr: Any = ... srs: Any = ... - def __init__(self, geom_input: Any, srs: Optional[Any] = ...) -> None: ... + def __init__(self, geom_input: Any, srs: Any | None = ...) -> None: ... @classmethod def from_bbox(cls, bbox: Any) -> Any: ... @staticmethod diff --git a/django-stubs/contrib/gis/gdal/prototypes/errcheck.pyi b/django-stubs/contrib/gis/gdal/prototypes/errcheck.pyi index f00d5132d..2264790bc 100644 --- a/django-stubs/contrib/gis/gdal/prototypes/errcheck.pyi +++ b/django-stubs/contrib/gis/gdal/prototypes/errcheck.pyi @@ -1,8 +1,8 @@ -from typing import Any, Optional +from typing import Any def arg_byref(args: Any, offset: int = ...) -> Any: ... def ptr_byref(args: Any, offset: int = ...) -> Any: ... -def check_const_string(result: Any, func: Any, cargs: Any, offset: Optional[Any] = ..., cpl: bool = ...) -> Any: ... +def check_const_string(result: Any, func: Any, cargs: Any, offset: Any | None = ..., cpl: bool = ...) -> Any: ... def check_string(result: Any, func: Any, cargs: Any, offset: int = ..., str_result: bool = ...) -> Any: ... def check_envelope(result: Any, func: Any, cargs: Any, offset: int = ...) -> Any: ... def check_geom(result: Any, func: Any, cargs: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/gdal/prototypes/generation.pyi b/django-stubs/contrib/gis/gdal/prototypes/generation.pyi index b55af370d..55f9070af 100644 --- a/django-stubs/contrib/gis/gdal/prototypes/generation.pyi +++ b/django-stubs/contrib/gis/gdal/prototypes/generation.pyi @@ -1,19 +1,19 @@ from ctypes import c_char_p -from typing import Any, Optional +from typing import Any class gdal_char_p(c_char_p): ... -def bool_output(func: Any, argtypes: Any, errcheck: Optional[Any] = ...) -> Any: ... +def bool_output(func: Any, argtypes: Any, errcheck: Any | None = ...) -> Any: ... def double_output(func: Any, argtypes: Any, errcheck: bool = ..., strarg: bool = ..., cpl: bool = ...) -> Any: ... -def geom_output(func: Any, argtypes: Any, offset: Optional[Any] = ...) -> Any: ... -def int_output(func: Any, argtypes: Any, errcheck: Optional[Any] = ...) -> Any: ... +def geom_output(func: Any, argtypes: Any, offset: Any | None = ...) -> Any: ... +def int_output(func: Any, argtypes: Any, errcheck: Any | None = ...) -> Any: ... def int64_output(func: Any, argtypes: Any) -> Any: ... def srs_output(func: Any, argtypes: Any) -> Any: ... def const_string_output( - func: Any, argtypes: Any, offset: Optional[Any] = ..., decoding: Optional[Any] = ..., cpl: bool = ... + func: Any, argtypes: Any, offset: Any | None = ..., decoding: Any | None = ..., cpl: bool = ... ) -> Any: ... def string_output( - func: Any, argtypes: Any, offset: int = ..., str_result: bool = ..., decoding: Optional[Any] = ... + func: Any, argtypes: Any, offset: int = ..., str_result: bool = ..., decoding: Any | None = ... ) -> Any: ... def void_output(func: Any, argtypes: Any, errcheck: bool = ..., cpl: bool = ...) -> Any: ... def voidptr_output(func: Any, argtypes: Any, errcheck: bool = ...) -> Any: ... diff --git a/django-stubs/contrib/gis/gdal/raster/band.pyi b/django-stubs/contrib/gis/gdal/raster/band.pyi index ec9e471ff..50869cf37 100644 --- a/django-stubs/contrib/gis/gdal/raster/band.pyi +++ b/django-stubs/contrib/gis/gdal/raster/band.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterator, Optional +from typing import Any, Iterator from django.contrib.gis.gdal.raster.base import GDALRasterBase as GDALRasterBase @@ -30,10 +30,10 @@ class GDALBand(GDALRasterBase): def color_interp(self, as_string: bool = ...) -> Any: ... def data( self, - data: Optional[Any] = ..., - offset: Optional[Any] = ..., - size: Optional[Any] = ..., - shape: Optional[Any] = ..., + data: Any | None = ..., + offset: Any | None = ..., + size: Any | None = ..., + shape: Any | None = ..., as_memoryview: bool = ..., ) -> Any: ... diff --git a/django-stubs/contrib/gis/gdal/raster/source.pyi b/django-stubs/contrib/gis/gdal/raster/source.pyi index c2dbbf5e7..781d66160 100644 --- a/django-stubs/contrib/gis/gdal/raster/source.pyi +++ b/django-stubs/contrib/gis/gdal/raster/source.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.contrib.gis.gdal.raster.base import GDALRasterBase as GDALRasterBase @@ -56,8 +56,8 @@ class GDALRaster(GDALRasterBase): def transform( self, srs: Any, - driver: Optional[Any] = ..., - name: Optional[Any] = ..., + driver: Any | None = ..., + name: Any | None = ..., resampling: str = ..., max_error: float = ..., ) -> Any: ... diff --git a/django-stubs/contrib/gis/gdal/srs.pyi b/django-stubs/contrib/gis/gdal/srs.pyi index 32b90be87..a584f9e36 100644 --- a/django-stubs/contrib/gis/gdal/srs.pyi +++ b/django-stubs/contrib/gis/gdal/srs.pyi @@ -1,5 +1,5 @@ from enum import IntEnum -from typing import Any, Optional +from typing import Any from django.contrib.gis.gdal.base import GDALBase as GDALBase @@ -11,7 +11,7 @@ class SpatialReference(GDALBase): destructor: Any = ... axis_order: Any = ... ptr: Any = ... - def __init__(self, srs_input: str = ..., srs_type: str = ..., axis_order: Optional[Any] = ...) -> None: ... + def __init__(self, srs_input: str = ..., srs_type: str = ..., axis_order: Any | None = ...) -> None: ... def __getitem__(self, target: Any) -> Any: ... def attr_value(self, target: Any, index: int = ...) -> Any: ... def auth_name(self, target: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/geoip2/base.pyi b/django-stubs/contrib/gis/geoip2/base.pyi index f0690f970..ae9faea5a 100644 --- a/django-stubs/contrib/gis/geoip2/base.pyi +++ b/django-stubs/contrib/gis/geoip2/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any GEOIP_SETTINGS: Any @@ -12,7 +12,7 @@ class GeoIP2: MODE_MEMORY: int = ... cache_options: Any = ... def __init__( - self, path: Optional[Any] = ..., cache: int = ..., country: Optional[Any] = ..., city: Optional[Any] = ... + self, path: Any | None = ..., cache: int = ..., country: Any | None = ..., city: Any | None = ... ) -> None: ... def __del__(self) -> None: ... def city(self, query: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/geos/geometry.pyi b/django-stubs/contrib/gis/geos/geometry.pyi index 05d2d3a9a..4f4370a95 100644 --- a/django-stubs/contrib/gis/geos/geometry.pyi +++ b/django-stubs/contrib/gis/geos/geometry.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, TypeVar +from typing import Any, TypeVar from django.contrib.gis.geometry import hex_regex as hex_regex # noqa: F401 from django.contrib.gis.geometry import json_regex as json_regex @@ -137,4 +137,4 @@ class LinearGeometryMixin: class GEOSGeometry(GEOSGeometryBase, ListMixin): srid: Any = ... - def __init__(self, geo_input: Any, srid: Optional[Any] = ...) -> None: ... + def __init__(self, geo_input: Any, srid: Any | None = ...) -> None: ... diff --git a/django-stubs/contrib/gis/geos/libgeos.pyi b/django-stubs/contrib/gis/geos/libgeos.pyi index 857cd9f83..4e72a74d8 100644 --- a/django-stubs/contrib/gis/geos/libgeos.pyi +++ b/django-stubs/contrib/gis/geos/libgeos.pyi @@ -1,6 +1,6 @@ from ctypes import Structure from logging import Logger -from typing import Any, Optional +from typing import Any logger: Logger @@ -31,12 +31,7 @@ class GEOSFuncFactory: errcheck: Any = ... func_name: Any = ... def __init__( - self, - func_name: Any, - *, - restype: Optional[Any] = ..., - errcheck: Optional[Any] = ..., - argtypes: Optional[Any] = ... + self, func_name: Any, *, restype: Any | None = ..., errcheck: Any | None = ..., argtypes: Any | None = ... ) -> None: ... def __call__(self, *args: Any) -> Any: ... @property diff --git a/django-stubs/contrib/gis/geos/mutable_list.pyi b/django-stubs/contrib/gis/geos/mutable_list.pyi index dbb8b9a82..709a24bbf 100644 --- a/django-stubs/contrib/gis/geos/mutable_list.pyi +++ b/django-stubs/contrib/gis/geos/mutable_list.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class ListMixin: def __init__(self, *args: Any, **kwargs: Any) -> None: ... @@ -21,4 +21,4 @@ class ListMixin: def pop(self, index: int = ...) -> Any: ... def remove(self, val: Any) -> None: ... def reverse(self) -> None: ... - def sort(self, key: Optional[Any] = ..., reverse: bool = ...) -> None: ... + def sort(self, key: Any | None = ..., reverse: bool = ...) -> None: ... diff --git a/django-stubs/contrib/gis/geos/point.pyi b/django-stubs/contrib/gis/geos/point.pyi index bed91bdb1..9821686c1 100644 --- a/django-stubs/contrib/gis/geos/point.pyi +++ b/django-stubs/contrib/gis/geos/point.pyi @@ -1,11 +1,11 @@ -from typing import Any, Iterator, Optional +from typing import Any, Iterator from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry class Point(GEOSGeometry): has_cs: bool = ... def __init__( - self, x: Optional[Any] = ..., y: Optional[Any] = ..., z: Optional[Any] = ..., srid: Optional[Any] = ... + self, x: Any | None = ..., y: Any | None = ..., z: Any | None = ..., srid: Any | None = ... ) -> None: ... def __iter__(self) -> Iterator[Any]: ... def __len__(self) -> int: ... diff --git a/django-stubs/contrib/gis/geos/prototypes/io.pyi b/django-stubs/contrib/gis/geos/prototypes/io.pyi index 451da5b2d..5fc105fbf 100644 --- a/django-stubs/contrib/gis/geos/prototypes/io.pyi +++ b/django-stubs/contrib/gis/geos/prototypes/io.pyi @@ -1,6 +1,6 @@ import threading from ctypes import Structure -from typing import Any, Optional +from typing import Any from django.contrib.gis.geos.base import GEOSBase as GEOSBase from django.contrib.gis.geos.libgeos import GEOSFuncFactory as GEOSFuncFactory @@ -76,7 +76,7 @@ class _WKBReader(IOBase): class WKTWriter(IOBase): ptr_type: Any = ... destructor: Any = ... - def __init__(self, dim: int = ..., trim: bool = ..., precision: Optional[Any] = ...) -> None: ... + def __init__(self, dim: int = ..., trim: bool = ..., precision: Any | None = ...) -> None: ... def write(self, geom: Any) -> Any: ... @property def outdim(self) -> Any: ... @@ -118,7 +118,7 @@ class ThreadLocalIO(threading.local): thread_context: Any def wkt_r() -> Any: ... -def wkt_w(dim: int = ..., trim: bool = ..., precision: Optional[Any] = ...) -> Any: ... +def wkt_w(dim: int = ..., trim: bool = ..., precision: Any | None = ...) -> Any: ... def wkb_r() -> Any: ... def wkb_w(dim: int = ...) -> Any: ... def ewkb_w(dim: int = ...) -> Any: ... diff --git a/django-stubs/contrib/gis/measure.pyi b/django-stubs/contrib/gis/measure.pyi index d518c829f..e5b2bf202 100644 --- a/django-stubs/contrib/gis/measure.pyi +++ b/django-stubs/contrib/gis/measure.pyi @@ -1,11 +1,11 @@ -from typing import Any, Optional +from typing import Any class MeasureBase: STANDARD_UNIT: Any = ... ALIAS: Any = ... UNITS: Any = ... LALIAS: Any = ... - def __init__(self, default_unit: Optional[Any] = ..., **kwargs: Any) -> None: ... + def __init__(self, default_unit: Any | None = ..., **kwargs: Any) -> None: ... standard: Any = ... def __getattr__(self, name: Any) -> Any: ... def __eq__(self, other: Any) -> bool: ... diff --git a/django-stubs/contrib/gis/sitemaps/kml.pyi b/django-stubs/contrib/gis/sitemaps/kml.pyi index 81ee0c69e..f2ece2388 100644 --- a/django-stubs/contrib/gis/sitemaps/kml.pyi +++ b/django-stubs/contrib/gis/sitemaps/kml.pyi @@ -1,11 +1,11 @@ -from typing import Any, Optional +from typing import Any from django.contrib.sitemaps import Sitemap as Sitemap class KMLSitemap(Sitemap): geo_format: str = ... locations: Any = ... - def __init__(self, locations: Optional[Any] = ...) -> None: ... + def __init__(self, locations: Any | None = ...) -> None: ... def items(self) -> Any: ... def location(self, obj: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/sitemaps/views.pyi b/django-stubs/contrib/gis/sitemaps/views.pyi index 4774a699d..efc64d88f 100644 --- a/django-stubs/contrib/gis/sitemaps/views.pyi +++ b/django-stubs/contrib/gis/sitemaps/views.pyi @@ -1,15 +1,13 @@ -from typing import Optional - from django.http import HttpRequest, HttpResponse def kml( request: HttpRequest, label: str, model: str, - field_name: Optional[str] = ..., + field_name: str | None = ..., compress: bool = ..., using: str = ..., ) -> HttpResponse: ... def kmz( - request: HttpRequest, label: str, model: str, field_name: Optional[str] = ..., using: str = ... + request: HttpRequest, label: str, model: str, field_name: str | None = ..., using: str = ... ) -> HttpResponse: ... diff --git a/django-stubs/contrib/gis/utils/layermapping.pyi b/django-stubs/contrib/gis/utils/layermapping.pyi index dcb9ad6e3..7fad74512 100644 --- a/django-stubs/contrib/gis/utils/layermapping.pyi +++ b/django-stubs/contrib/gis/utils/layermapping.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class LayerMapError(Exception): ... class InvalidString(LayerMapError): ... @@ -28,12 +28,12 @@ class LayerMapping: data: Any, mapping: Any, layer: int = ..., - source_srs: Optional[Any] = ..., + source_srs: Any | None = ..., encoding: str = ..., transaction_mode: str = ..., transform: bool = ..., - unique: Optional[Any] = ..., - using: Optional[Any] = ..., + unique: Any | None = ..., + using: Any | None = ..., ) -> None: ... def check_fid_range(self, fid_range: Any) -> Any: ... geom_field: str = ... diff --git a/django-stubs/contrib/gis/utils/srs.pyi b/django-stubs/contrib/gis/utils/srs.pyi index 89644bf6e..bf6472f78 100644 --- a/django-stubs/contrib/gis/utils/srs.pyi +++ b/django-stubs/contrib/gis/utils/srs.pyi @@ -1,9 +1,9 @@ -from typing import Any, Optional +from typing import Any def add_srs_entry( srs: Any, auth_name: str = ..., - auth_srid: Optional[Any] = ..., - ref_sys_name: Optional[Any] = ..., - database: Optional[Any] = ..., + auth_srid: Any | None = ..., + ref_sys_name: Any | None = ..., + database: Any | None = ..., ) -> None: ... diff --git a/django-stubs/contrib/gis/views.pyi b/django-stubs/contrib/gis/views.pyi index d9ddea8a1..f069f5ec1 100644 --- a/django-stubs/contrib/gis/views.pyi +++ b/django-stubs/contrib/gis/views.pyi @@ -1,6 +1,6 @@ -from typing import Dict, Optional, Type +from typing import Dict, Type from django.contrib.gis.feeds import Feed from django.http import HttpRequest, HttpResponse -def feed(request: HttpRequest, url: str, feed_dict: Optional[Dict[str, Type[Feed]]] = ...) -> HttpResponse: ... +def feed(request: HttpRequest, url: str, feed_dict: Dict[str, Type[Feed]] | None = ...) -> HttpResponse: ... diff --git a/django-stubs/contrib/humanize/templatetags/humanize.pyi b/django-stubs/contrib/humanize/templatetags/humanize.pyi index 92752fe8d..0b06c7c6a 100644 --- a/django-stubs/contrib/humanize/templatetags/humanize.pyi +++ b/django-stubs/contrib/humanize/templatetags/humanize.pyi @@ -1,19 +1,19 @@ from datetime import date from datetime import datetime as datetime -from typing import Any, Callable, Dict, Optional, SupportsInt, Tuple, Type, Union +from typing import Any, Callable, Dict, SupportsInt, Tuple, Type from django import template register: template.Library -def ordinal(value: Optional[Union[str, SupportsInt]]) -> Optional[str]: ... -def intcomma(value: Optional[Union[str, SupportsInt]], use_l10n: bool = ...) -> str: ... +def ordinal(value: str | SupportsInt | None) -> str | None: ... +def intcomma(value: str | SupportsInt | None, use_l10n: bool = ...) -> str: ... intword_converters: Tuple[Tuple[int, Callable]] -def intword(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ... -def apnumber(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ... -def naturalday(value: Optional[Union[date, str]], arg: Optional[str] = ...) -> Optional[str]: ... +def intword(value: str | SupportsInt | None) -> int | str | None: ... +def apnumber(value: str | SupportsInt | None) -> int | str | None: ... +def naturalday(value: date | str | None, arg: str | None = ...) -> str | None: ... def naturaltime(value: datetime) -> str: ... class NaturalTimeFormatter: diff --git a/django-stubs/contrib/messages/api.pyi b/django-stubs/contrib/messages/api.pyi index 7ad6d5973..fabad0c0d 100644 --- a/django-stubs/contrib/messages/api.pyi +++ b/django-stubs/contrib/messages/api.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Union +from typing import Any, List from django.contrib.messages.storage.base import BaseStorage from django.http.request import HttpRequest @@ -6,21 +6,17 @@ from django.http.request import HttpRequest class MessageFailure(Exception): ... def add_message( - request: Optional[HttpRequest], + request: HttpRequest | None, level: int, message: str, extra_tags: str = ..., - fail_silently: Union[bool, str] = ..., + fail_silently: bool | str = ..., ) -> None: ... -def get_messages(request: HttpRequest) -> Union[List[Any], BaseStorage]: ... +def get_messages(request: HttpRequest) -> List[Any] | BaseStorage: ... def get_level(request: HttpRequest) -> int: ... def set_level(request: HttpRequest, level: int) -> bool: ... -def debug(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ... -def info(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ... -def success( - request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ... -) -> None: ... -def warning( - request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ... -) -> None: ... -def error(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ... +def debug(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: bool | str = ...) -> None: ... +def info(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: bool | str = ...) -> None: ... +def success(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: bool | str = ...) -> None: ... +def warning(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: bool | str = ...) -> None: ... +def error(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: bool | str = ...) -> None: ... diff --git a/django-stubs/contrib/messages/context_processors.pyi b/django-stubs/contrib/messages/context_processors.pyi index 86528482b..a899f718c 100644 --- a/django-stubs/contrib/messages/context_processors.pyi +++ b/django-stubs/contrib/messages/context_processors.pyi @@ -1,6 +1,6 @@ -from typing import Any, Dict, List, Union +from typing import Any, Dict, List from django.contrib.messages.storage.base import BaseStorage from django.http.request import HttpRequest -def messages(request: HttpRequest) -> Dict[str, Union[Dict[str, int], List[Any], BaseStorage]]: ... +def messages(request: HttpRequest) -> Dict[str, Dict[str, int] | List[Any] | BaseStorage]: ... diff --git a/django-stubs/contrib/messages/storage/__init__.pyi b/django-stubs/contrib/messages/storage/__init__.pyi index a98ba21b4..4c8874558 100644 --- a/django-stubs/contrib/messages/storage/__init__.pyi +++ b/django-stubs/contrib/messages/storage/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.contrib.messages.storage.base import BaseStorage from django.http.request import HttpRequest diff --git a/django-stubs/contrib/messages/storage/base.pyi b/django-stubs/contrib/messages/storage/base.pyi index 01ccca8bf..9ffad6065 100644 --- a/django-stubs/contrib/messages/storage/base.pyi +++ b/django-stubs/contrib/messages/storage/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterator, List, Optional +from typing import Any, Iterator, List from django.http.request import HttpRequest from django.http.response import HttpResponseBase @@ -9,7 +9,7 @@ class Message: level: int = ... message: str = ... extra_tags: str = ... - def __init__(self, level: int, message: str, extra_tags: Optional[str] = ...) -> None: ... + def __init__(self, level: int, message: str, extra_tags: str | None = ...) -> None: ... @property def tags(self) -> str: ... @property @@ -23,6 +23,6 @@ class BaseStorage: def __len__(self) -> int: ... def __iter__(self) -> Iterator[Message]: ... def __contains__(self, item: Any) -> bool: ... - def update(self, response: HttpResponseBase) -> Optional[List[Message]]: ... - def add(self, level: int, message: str, extra_tags: Optional[str] = ...) -> None: ... + def update(self, response: HttpResponseBase) -> List[Message] | None: ... + def add(self, level: int, message: str, extra_tags: str | None = ...) -> None: ... level: Any = ... diff --git a/django-stubs/contrib/messages/storage/session.pyi b/django-stubs/contrib/messages/storage/session.pyi index 8ba628194..5f0179fe8 100644 --- a/django-stubs/contrib/messages/storage/session.pyi +++ b/django-stubs/contrib/messages/storage/session.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Sequence, Union +from typing import Any, List, Sequence from django.contrib.messages.storage.base import BaseStorage from django.http.request import HttpRequest @@ -7,4 +7,4 @@ class SessionStorage(BaseStorage): session_key: str = ... def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ... def serialize_messages(self, messages: Sequence[Any]) -> str: ... - def deserialize_messages(self, data: Optional[Union[List[Any], str]]) -> Optional[List[Any]]: ... + def deserialize_messages(self, data: List[Any] | str | None) -> List[Any] | None: ... diff --git a/django-stubs/contrib/postgres/constraints.pyi b/django-stubs/contrib/postgres/constraints.pyi index d9177e4c9..563af8b53 100644 --- a/django-stubs/contrib/postgres/constraints.pyi +++ b/django-stubs/contrib/postgres/constraints.pyi @@ -1,4 +1,4 @@ -from typing import List, Optional, Sequence, Tuple, Union +from typing import List, Sequence, Tuple from django.db.models import Deferrable from django.db.models.constraints import BaseConstraint @@ -6,17 +6,17 @@ from django.db.models.expressions import Combinable from django.db.models.query_utils import Q class ExclusionConstraint(BaseConstraint): - expressions: Sequence[Tuple[Union[str, Combinable], str]] + expressions: Sequence[Tuple[str | Combinable, str]] index_type: str - condition: Optional[Q] + condition: Q | None def __init__( self, *, name: str, - expressions: Sequence[Tuple[Union[str, Combinable], str]], - index_type: Optional[str] = ..., - condition: Optional[Q] = ..., - deferrable: Optional[Deferrable] = ..., - include: Union[List[str], Tuple[str], None] = ..., - opclasses: Union[List[str], Tuple[str]] = ..., + expressions: Sequence[Tuple[str | Combinable, str]], + index_type: str | None = ..., + condition: Q | None = ..., + deferrable: Deferrable | None = ..., + include: List[str] | Tuple[str] | None = ..., + opclasses: List[str] | Tuple[str] = ..., ) -> None: ... diff --git a/django-stubs/contrib/postgres/fields/array.pyi b/django-stubs/contrib/postgres/fields/array.pyi index 2171c838a..06d64d9f2 100644 --- a/django-stubs/contrib/postgres/fields/array.pyi +++ b/django-stubs/contrib/postgres/fields/array.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, Optional, Sequence, Type, TypeVar, Union +from typing import Any, Iterable, List, Sequence, Type, TypeVar from django.core.validators import _ValidatorCallable from django.db.models import Field, Transform @@ -13,24 +13,24 @@ _ST = TypeVar("_ST") _GT = TypeVar("_GT") class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]): - _pyi_private_set_type: Union[Sequence[Any], Combinable] + _pyi_private_set_type: Sequence[Any] | Combinable _pyi_private_get_type: List[Any] empty_strings_allowed: bool = ... default_error_messages: _ErrorMessagesT = ... base_field: Field = ... - size: Optional[int] = ... + size: int | None = ... default_validators: Sequence[_ValidatorCallable] = ... from_db_value: Any = ... def __init__( self, base_field: Field, - size: Optional[int] = ..., + size: int | None = ..., *, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., @@ -39,16 +39,16 @@ class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[_ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... @property def description(self) -> str: ... # type: ignore - def get_transform(self, name: Any) -> Optional[Type[Transform]]: ... + def get_transform(self, name: Any) -> Type[Transform] | None: ... diff --git a/django-stubs/contrib/postgres/fields/ranges.pyi b/django-stubs/contrib/postgres/fields/ranges.pyi index dea70e526..86d0e6890 100644 --- a/django-stubs/contrib/postgres/fields/ranges.pyi +++ b/django-stubs/contrib/postgres/fields/ranges.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Type +from typing import Any, Dict, Type from django.db import models from django.db.models.lookups import PostgresOperatorLookup @@ -26,7 +26,7 @@ class RangeField(models.Field): empty_strings_allowed: bool = ... base_field: models.Field = ... range_type: Type[Range] = ... - def get_prep_value(self, value: Any) -> Optional[Any]: ... + def get_prep_value(self, value: Any) -> Any | None: ... def to_python(self, value: Any) -> Any: ... class IntegerRangeField(RangeField): diff --git a/django-stubs/contrib/postgres/forms/array.pyi b/django-stubs/contrib/postgres/forms/array.pyi index f3c859040..7a2122aaa 100644 --- a/django-stubs/contrib/postgres/forms/array.pyi +++ b/django-stubs/contrib/postgres/forms/array.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Sequence, Type, Union +from typing import Any, Dict, Sequence, Type from django import forms as forms from django.contrib.postgres.validators import ArrayMaxLengthValidator as ArrayMaxLengthValidator @@ -15,15 +15,15 @@ class SimpleArrayField(forms.CharField): default_error_messages: _ErrorMessagesT = ... base_field: forms.Field delimiter: str - min_length: Optional[int] - max_length: Optional[int] + min_length: int | None + max_length: int | None def __init__( self, base_field: forms.Field, *, delimiter: str = ..., - max_length: Optional[int] = ..., - min_length: Optional[int] = ..., + max_length: int | None = ..., + min_length: int | None = ..., **kwargs: Any ) -> None: ... def clean(self, value: Any) -> Sequence[Any]: ... @@ -37,13 +37,13 @@ class SplitArrayWidget(forms.Widget): template_name: str widget: _ClassLevelWidgetT size: int - def __init__(self, widget: Union[forms.Widget, Type[forms.Widget]], size: int, **kwargs: Any) -> None: ... + def __init__(self, widget: forms.Widget | Type[forms.Widget], size: int, **kwargs: Any) -> None: ... @property def is_hidden(self) -> bool: ... def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... def id_for_label(self, id_: str) -> str: ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs] = ...) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None = ...) -> Dict[str, Any]: ... @property def media(self) -> Media: ... # type: ignore @property diff --git a/django-stubs/contrib/postgres/forms/hstore.pyi b/django-stubs/contrib/postgres/forms/hstore.pyi index 8b5099e5e..5041186dc 100644 --- a/django-stubs/contrib/postgres/forms/hstore.pyi +++ b/django-stubs/contrib/postgres/forms/hstore.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Type, Union +from typing import Any, Dict, Type from django import forms from django.db.models.fields import _ErrorMessagesT @@ -8,5 +8,5 @@ class HStoreField(forms.CharField): widget: _ClassLevelWidgetT default_error_messages: _ErrorMessagesT = ... def prepare_value(self, value: Any) -> Any: ... - def to_python(self, value: Any) -> Dict[str, Optional[str]]: ... # type: ignore + def to_python(self, value: Any) -> Dict[str, str | None]: ... # type: ignore def has_changed(self, initial: Any, data: Any) -> bool: ... diff --git a/django-stubs/contrib/postgres/forms/ranges.pyi b/django-stubs/contrib/postgres/forms/ranges.pyi index dcf944f2d..75f089e87 100644 --- a/django-stubs/contrib/postgres/forms/ranges.pyi +++ b/django-stubs/contrib/postgres/forms/ranges.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Tuple, Type, Union +from typing import Any, Tuple, Type from django import forms from django.db.models.fields import _ErrorMessagesT @@ -6,13 +6,11 @@ from django.forms.widgets import MultiWidget, _OptAttrs from psycopg2.extras import Range class RangeWidget(MultiWidget): - def __init__( - self, base_widget: Union[forms.Widget, Type[forms.Widget]], attrs: Optional[_OptAttrs] = ... - ) -> None: ... - def decompress(self, value: Any) -> Tuple[Optional[Any], Optional[Any]]: ... + def __init__(self, base_widget: forms.Widget | Type[forms.Widget], attrs: _OptAttrs | None = ...) -> None: ... + def decompress(self, value: Any) -> Tuple[Any | None, Any | None]: ... class HiddenRangeWidget(RangeWidget): - def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... class BaseRangeField(forms.MultiValueField): default_error_messages: _ErrorMessagesT @@ -21,7 +19,7 @@ class BaseRangeField(forms.MultiValueField): hidden_widget: Type[forms.Widget] def __init__(self, **kwargs: Any) -> None: ... def prepare_value(self, value: Any) -> Any: ... - def compress(self, values: Tuple[Optional[Any], Optional[Any]]) -> Optional[Range]: ... + def compress(self, values: Tuple[Any | None, Any | None]) -> Range | None: ... class IntegerRangeField(BaseRangeField): default_error_messages: _ErrorMessagesT diff --git a/django-stubs/contrib/postgres/indexes.pyi b/django-stubs/contrib/postgres/indexes.pyi index 3ea3c84ca..73f6371ce 100644 --- a/django-stubs/contrib/postgres/indexes.pyi +++ b/django-stubs/contrib/postgres/indexes.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Sequence, Tuple, Type, Union +from typing import Any, List, Sequence, Tuple, Type from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.backends.ddl_references import Statement @@ -19,101 +19,101 @@ class PostgresIndex(Index): class BloomIndex(PostgresIndex): def __init__( self, - *expressions: Union[BaseExpression, Combinable, str], - length: Optional[int] = ..., + *expressions: BaseExpression | Combinable | str, + length: int | None = ..., columns: _ListOrTuple[int] = ..., fields: Sequence[str] = ..., - name: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + name: str | None = ..., + db_tablespace: str | None = ..., opclasses: Sequence[str] = ..., - condition: Optional[Q] = ..., - include: Optional[Sequence[str]] = ..., + condition: Q | None = ..., + include: Sequence[str] | None = ..., ) -> None: ... class BrinIndex(PostgresIndex): def __init__( self, - *expressions: Union[BaseExpression, Combinable, str], - autosummarize: Optional[bool] = ..., - pages_per_range: Optional[int] = ..., + *expressions: BaseExpression | Combinable | str, + autosummarize: bool | None = ..., + pages_per_range: int | None = ..., fields: Sequence[str] = ..., - name: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + name: str | None = ..., + db_tablespace: str | None = ..., opclasses: Sequence[str] = ..., - condition: Optional[Q] = ..., - include: Optional[Sequence[str]] = ..., + condition: Q | None = ..., + include: Sequence[str] | None = ..., ) -> None: ... class BTreeIndex(PostgresIndex): def __init__( self, - *expressions: Union[BaseExpression, Combinable, str], - fillfactor: Optional[int] = ..., + *expressions: BaseExpression | Combinable | str, + fillfactor: int | None = ..., fields: Sequence[str] = ..., - name: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + name: str | None = ..., + db_tablespace: str | None = ..., opclasses: Sequence[str] = ..., - condition: Optional[Q] = ..., - include: Optional[Sequence[str]] = ..., + condition: Q | None = ..., + include: Sequence[str] | None = ..., ) -> None: ... class GinIndex(PostgresIndex): def __init__( self, - *expressions: Union[BaseExpression, Combinable, str], - fastupdate: Optional[bool] = ..., - gin_pending_list_limit: Optional[int] = ..., + *expressions: BaseExpression | Combinable | str, + fastupdate: bool | None = ..., + gin_pending_list_limit: int | None = ..., fields: Sequence[str] = ..., - name: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + name: str | None = ..., + db_tablespace: str | None = ..., opclasses: Sequence[str] = ..., - condition: Optional[Q] = ..., - include: Optional[Sequence[str]] = ..., + condition: Q | None = ..., + include: Sequence[str] | None = ..., ) -> None: ... class GistIndex(PostgresIndex): def __init__( self, - *expressions: Union[BaseExpression, Combinable, str], - buffering: Optional[bool] = ..., - fillfactor: Optional[int] = ..., + *expressions: BaseExpression | Combinable | str, + buffering: bool | None = ..., + fillfactor: int | None = ..., fields: Sequence[str] = ..., - name: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + name: str | None = ..., + db_tablespace: str | None = ..., opclasses: Sequence[str] = ..., - condition: Optional[Q] = ..., - include: Optional[Sequence[str]] = ..., + condition: Q | None = ..., + include: Sequence[str] | None = ..., ) -> None: ... class HashIndex(PostgresIndex): def __init__( self, - *expressions: Union[BaseExpression, Combinable, str], - fillfactor: Optional[int] = ..., + *expressions: BaseExpression | Combinable | str, + fillfactor: int | None = ..., fields: Sequence[str] = ..., - name: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + name: str | None = ..., + db_tablespace: str | None = ..., opclasses: Sequence[str] = ..., - condition: Optional[Q] = ..., - include: Optional[Sequence[str]] = ..., + condition: Q | None = ..., + include: Sequence[str] | None = ..., ) -> None: ... class SpGistIndex(PostgresIndex): def __init__( self, - *expressions: Union[BaseExpression, Combinable, str], - fillfactor: Optional[int] = ..., + *expressions: BaseExpression | Combinable | str, + fillfactor: int | None = ..., fields: Sequence[str] = ..., - name: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + name: str | None = ..., + db_tablespace: str | None = ..., opclasses: Sequence[str] = ..., - condition: Optional[Q] = ..., - include: Optional[Sequence[str]] = ..., + condition: Q | None = ..., + include: Sequence[str] | None = ..., ) -> None: ... class OpClass(Func): def __init__( self, - expression: Union[BaseExpression, Combinable, str], + expression: BaseExpression | Combinable | str, name: str, ) -> None: ... diff --git a/django-stubs/contrib/postgres/search.pyi b/django-stubs/contrib/postgres/search.pyi index 0b8b228b7..47ba6e5bc 100644 --- a/django-stubs/contrib/postgres/search.pyi +++ b/django-stubs/contrib/postgres/search.pyi @@ -1,31 +1,31 @@ -from typing import Any, Dict, Optional, TypeVar, Union +from typing import Any, Dict, TypeVar from django.db.models import Expression, Field from django.db.models.expressions import Combinable, CombinedExpression, Func, Value from django.db.models.lookups import Lookup -_Expression = Union[str, Combinable, "SearchQueryCombinable"] +_Expression = str | Combinable | "SearchQueryCombinable" class SearchVectorExact(Lookup): ... class SearchVectorField(Field): ... class SearchQueryField(Field): ... class SearchConfig(Expression): - config: Optional[_Expression] = ... + config: _Expression | None = ... def __init__(self, config: _Expression) -> None: ... @classmethod - def from_parameter(cls, config: Optional[_Expression]) -> SearchConfig: ... + def from_parameter(cls, config: _Expression | None) -> SearchConfig: ... class SearchVectorCombinable: ADD: str = ... class SearchVector(SearchVectorCombinable, Func): - config: Optional[_Expression] = ... + config: _Expression | None = ... function: str = ... arg_joiner: str = ... output_field: Field def __init__( - self, *expressions: _Expression, config: Optional[_Expression] = ..., weight: Optional[Any] = ... + self, *expressions: _Expression, config: _Expression | None = ..., weight: Any | None = ... ) -> None: ... class CombinedSearchVector(SearchVectorCombinable, CombinedExpression): @@ -34,8 +34,8 @@ class CombinedSearchVector(SearchVectorCombinable, CombinedExpression): lhs: Combinable, connector: str, rhs: Combinable, - config: Optional[_Expression], - output_field: Optional[Field] = None, + config: _Expression | None, + output_field: Field | None = None, ) -> None: ... _T = TypeVar("_T", bound="SearchQueryCombinable") @@ -53,9 +53,9 @@ class SearchQuery(SearchQueryCombinable, Func): # type: ignore def __init__( self, value: _Expression, - output_field: Optional[Field] = ..., + output_field: Field | None = ..., *, - config: Optional[_Expression] = ..., + config: _Expression | None = ..., invert: bool = ..., search_type: str = ..., ) -> None: ... @@ -67,17 +67,17 @@ class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression): # type: i lhs: Combinable, connector: str, rhs: Combinable, - config: Optional[_Expression], - output_field: Optional[Field] = None, + config: _Expression | None, + output_field: Field | None = None, ) -> None: ... class SearchRank(Func): def __init__( self, - vector: Union[SearchVector, _Expression], - query: Union[SearchQuery, _Expression], - weights: Optional[Any] = ..., - normalization: Optional[Any] = ..., + vector: SearchVector | _Expression, + query: SearchQuery | _Expression, + weights: Any | None = ..., + normalization: Any | None = ..., cover_density: bool = ..., ) -> None: ... @@ -90,15 +90,15 @@ class SearchHeadline(Func): expression: _Expression, query: _Expression, *, - config: Optional[_Expression] = ..., - start_sel: Optional[Any] = ..., - stop_sel: Optional[Any] = ..., - max_words: Optional[int] = ..., - min_words: Optional[int] = ..., - short_word: Optional[str] = ..., - highlight_all: Optional[bool] = ..., - max_fragments: Optional[int] = ..., - fragment_delimiter: Optional[str] = ..., + config: _Expression | None = ..., + start_sel: Any | None = ..., + stop_sel: Any | None = ..., + max_words: int | None = ..., + min_words: int | None = ..., + short_word: str | None = ..., + highlight_all: bool | None = ..., + max_fragments: int | None = ..., + fragment_delimiter: str | None = ..., ) -> None: ... class TrigramBase(Func): diff --git a/django-stubs/contrib/postgres/validators.pyi b/django-stubs/contrib/postgres/validators.pyi index 00ad4ff7f..24c2b0fe6 100644 --- a/django-stubs/contrib/postgres/validators.pyi +++ b/django-stubs/contrib/postgres/validators.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, Mapping, Optional +from typing import Any, Dict, Iterable, Mapping from django.core.validators import MaxLengthValidator, MaxValueValidator, MinLengthValidator, MinValueValidator @@ -8,9 +8,7 @@ class ArrayMinLengthValidator(MinLengthValidator): ... class KeysValidator: messages: Dict[str, str] = ... strict: bool = ... - def __init__( - self, keys: Iterable[str], strict: bool = ..., messages: Optional[Mapping[str, str]] = ... - ) -> None: ... + def __init__(self, keys: Iterable[str], strict: bool = ..., messages: Mapping[str, str] | None = ...) -> None: ... def __call__(self, value: Any) -> None: ... class RangeMaxValueValidator(MaxValueValidator): ... diff --git a/django-stubs/contrib/sessions/backends/base.pyi b/django-stubs/contrib/sessions/backends/base.pyi index bce66e9a6..ad711da13 100644 --- a/django-stubs/contrib/sessions/backends/base.pyi +++ b/django-stubs/contrib/sessions/backends/base.pyi @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Dict, Optional, Union +from typing import Any, Dict VALID_KEY_CHARS: Any @@ -12,36 +12,36 @@ class SessionBase(Dict[str, Any]): accessed: bool = ... modified: bool = ... serializer: Any = ... - def __init__(self, session_key: Optional[str] = ...) -> None: ... + def __init__(self, session_key: str | None = ...) -> None: ... def set_test_cookie(self) -> None: ... def test_cookie_worked(self) -> bool: ... def delete_test_cookie(self) -> None: ... def encode(self, session_dict: Dict[str, Any]) -> str: ... - def decode(self, session_data: Union[bytes, str]) -> Dict[str, Any]: ... + def decode(self, session_data: bytes | str) -> Dict[str, Any]: ... def has_key(self, key: Any) -> Any: ... def keys(self) -> Any: ... def values(self) -> Any: ... def items(self) -> Any: ... def clear(self) -> None: ... def is_empty(self) -> bool: ... - def _get_session_key(self) -> Optional[str]: ... - def _set_session_key(self, value: Optional[str]) -> None: ... + def _get_session_key(self) -> str | None: ... + def _set_session_key(self, value: str | None) -> None: ... @property - def session_key(self) -> Optional[str]: ... + def session_key(self) -> str | None: ... @property - def _session_key(self) -> Optional[str]: ... + def _session_key(self) -> str | None: ... @_session_key.setter - def _session_key(self, value: Optional[str]) -> None: ... + def _session_key(self, value: str | None) -> None: ... def get_expiry_age(self, **kwargs: Any) -> int: ... def get_expiry_date(self, **kwargs: Any) -> datetime: ... - def set_expiry(self, value: Optional[Union[datetime, int]]) -> None: ... + def set_expiry(self, value: datetime | int | None) -> None: ... def get_expire_at_browser_close(self) -> bool: ... def flush(self) -> None: ... def cycle_key(self) -> None: ... def exists(self, session_key: str) -> bool: ... def create(self) -> None: ... def save(self, must_create: bool = ...) -> None: ... - def delete(self, session_key: Optional[str] = ...) -> None: ... + def delete(self, session_key: str | None = ...) -> None: ... def load(self) -> Dict[str, Any]: ... @classmethod def clear_expired(cls) -> None: ... diff --git a/django-stubs/contrib/sessions/backends/cache.pyi b/django-stubs/contrib/sessions/backends/cache.pyi index 865393b11..59d440f05 100644 --- a/django-stubs/contrib/sessions/backends/cache.pyi +++ b/django-stubs/contrib/sessions/backends/cache.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.contrib.sessions.backends.base import SessionBase @@ -6,6 +6,6 @@ KEY_PREFIX: str class SessionStore(SessionBase): cache_key_prefix: Any = ... - def __init__(self, session_key: Optional[str] = ...) -> None: ... + def __init__(self, session_key: str | None = ...) -> None: ... @property def cache_key(self) -> str: ... diff --git a/django-stubs/contrib/sessions/backends/cached_db.pyi b/django-stubs/contrib/sessions/backends/cached_db.pyi index b49ef9067..9b48dc1fd 100644 --- a/django-stubs/contrib/sessions/backends/cached_db.pyi +++ b/django-stubs/contrib/sessions/backends/cached_db.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.contrib.sessions.backends.db import SessionStore as DBStore @@ -6,6 +6,6 @@ KEY_PREFIX: str class SessionStore(DBStore): cache_key_prefix: Any = ... - def __init__(self, session_key: Optional[str] = ...) -> None: ... + def __init__(self, session_key: str | None = ...) -> None: ... @property def cache_key(self) -> str: ... diff --git a/django-stubs/contrib/sessions/backends/db.pyi b/django-stubs/contrib/sessions/backends/db.pyi index b93f3cbcc..01763bce4 100644 --- a/django-stubs/contrib/sessions/backends/db.pyi +++ b/django-stubs/contrib/sessions/backends/db.pyi @@ -1,4 +1,4 @@ -from typing import Dict, Optional, Type +from typing import Dict, Type from django.contrib.sessions.backends.base import SessionBase from django.contrib.sessions.base_session import AbstractBaseSession @@ -6,7 +6,7 @@ from django.contrib.sessions.models import Session from django.db.models.base import Model class SessionStore(SessionBase): - def __init__(self, session_key: Optional[str] = ...) -> None: ... + def __init__(self, session_key: str | None = ...) -> None: ... @classmethod def get_model_class(cls) -> Type[Session]: ... @property diff --git a/django-stubs/contrib/sessions/backends/file.pyi b/django-stubs/contrib/sessions/backends/file.pyi index 96e20463a..84af0d3ec 100644 --- a/django-stubs/contrib/sessions/backends/file.pyi +++ b/django-stubs/contrib/sessions/backends/file.pyi @@ -1,9 +1,7 @@ -from typing import Optional - from django.contrib.sessions.backends.base import SessionBase class SessionStore(SessionBase): storage_path: str = ... file_prefix: str = ... - def __init__(self, session_key: Optional[str] = ...) -> None: ... + def __init__(self, session_key: str | None = ...) -> None: ... def clean(self) -> None: ... diff --git a/django-stubs/contrib/sessions/base_session.pyi b/django-stubs/contrib/sessions/base_session.pyi index 9e337fb7f..aedebe638 100644 --- a/django-stubs/contrib/sessions/base_session.pyi +++ b/django-stubs/contrib/sessions/base_session.pyi @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Dict, Optional, Type, TypeVar +from typing import Any, Dict, Type, TypeVar from django.contrib.sessions.backends.base import SessionBase from django.db import models @@ -16,5 +16,5 @@ class AbstractBaseSession(models.Model): session_key: str objects: Any = ... @classmethod - def get_session_store_class(cls) -> Optional[Type[SessionBase]]: ... + def get_session_store_class(cls) -> Type[SessionBase] | None: ... def get_decoded(self) -> Dict[str, Any]: ... diff --git a/django-stubs/contrib/sitemaps/__init__.pyi b/django-stubs/contrib/sitemaps/__init__.pyi index fe59b4a14..eb2e5ba2b 100644 --- a/django-stubs/contrib/sitemaps/__init__.pyi +++ b/django-stubs/contrib/sitemaps/__init__.pyi @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Dict, Generic, Iterable, List, Mapping, Optional, Sequence, TypeVar, Union +from typing import Any, Dict, Generic, Iterable, List, Mapping, Sequence, TypeVar from django.contrib.sites.models import Site from django.contrib.sites.requests import RequestSite @@ -11,15 +11,15 @@ PING_URL: str class SitemapNotFound(Exception): ... -def ping_google(sitemap_url: Optional[str] = ..., ping_url: str = ..., sitemap_uses_https: bool = ...) -> None: ... +def ping_google(sitemap_url: str | None = ..., ping_url: str = ..., sitemap_uses_https: bool = ...) -> None: ... _ItemT = TypeVar("_ItemT") class Sitemap(Generic[_ItemT]): limit: int = ... - protocol: Optional[str] = ... + protocol: str | None = ... i18n: bool = ... - languages: Optional[Sequence[str]] = ... + languages: Sequence[str] | None = ... alternates: bool = ... x_default: bool = ... def items(self) -> Iterable[_ItemT]: ... @@ -27,25 +27,25 @@ class Sitemap(Generic[_ItemT]): @property def paginator(self) -> Paginator: ... def get_urls( - self, page: Union[int, str] = ..., site: Optional[Union[Site, RequestSite]] = ..., protocol: Optional[str] = ... + self, page: int | str = ..., site: Site | RequestSite | None = ..., protocol: str | None = ... ) -> List[Dict[str, Any]]: ... - def get_latest_lastmod(self) -> Optional[datetime]: ... + def get_latest_lastmod(self) -> datetime | None: ... _ModelT = TypeVar("_ModelT", bound=Model) class GenericSitemap(Sitemap[_ModelT]): - priority: Optional[float] = ... - changefreq: Optional[str] = ... + priority: float | None = ... + changefreq: str | None = ... queryset: QuerySet[_ModelT] = ... - date_field: Optional[str] = ... - protocol: Optional[str] = ... + date_field: str | None = ... + protocol: str | None = ... def __init__( self, - info_dict: Mapping[str, Union[datetime, QuerySet[_ModelT], str]], - priority: Optional[float] = ..., - changefreq: Optional[str] = ..., - protocol: Optional[str] = ..., + info_dict: Mapping[str, datetime | QuerySet[_ModelT] | str], + priority: float | None = ..., + changefreq: str | None = ..., + protocol: str | None = ..., ) -> None: ... def items(self) -> QuerySet[_ModelT]: ... - def lastmod(self, item: _ModelT) -> Optional[datetime]: ... - def get_latest_lastmod(self) -> Optional[datetime]: ... + def lastmod(self, item: _ModelT) -> datetime | None: ... + def get_latest_lastmod(self) -> datetime | None: ... diff --git a/django-stubs/contrib/sitemaps/views.pyi b/django-stubs/contrib/sitemaps/views.pyi index 41deb9fdf..3891589a7 100644 --- a/django-stubs/contrib/sitemaps/views.pyi +++ b/django-stubs/contrib/sitemaps/views.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Dict, Optional, Type, TypeVar, Union +from typing import Callable, Dict, Type, TypeVar from django.contrib.sitemaps import GenericSitemap, Sitemap from django.http.request import HttpRequest @@ -9,15 +9,15 @@ _C = TypeVar("_C", bound=Callable) def x_robots_tag(func: _C) -> _C: ... def index( request: HttpRequest, - sitemaps: Dict[str, Union[Type[Sitemap], Sitemap]], + sitemaps: Dict[str, Type[Sitemap] | Sitemap], template_name: str = ..., content_type: str = ..., sitemap_url_name: str = ..., ) -> TemplateResponse: ... def sitemap( request: HttpRequest, - sitemaps: Dict[str, Union[Type[Sitemap], Sitemap]], - section: Optional[str] = ..., + sitemaps: Dict[str, Type[Sitemap] | Sitemap], + section: str | None = ..., template_name: str = ..., content_type: str = ..., ) -> TemplateResponse: ... diff --git a/django-stubs/contrib/sites/managers.pyi b/django-stubs/contrib/sites/managers.pyi index 5b3b78f51..f629ef4a2 100644 --- a/django-stubs/contrib/sites/managers.pyi +++ b/django-stubs/contrib/sites/managers.pyi @@ -1,4 +1,4 @@ -from typing import Optional, TypeVar +from typing import TypeVar from django.contrib.sites.models import Site from django.db import models @@ -6,4 +6,4 @@ from django.db import models _T = TypeVar("_T", bound=Site) class CurrentSiteManager(models.Manager[_T]): - def __init__(self, field_name: Optional[str] = ...) -> None: ... + def __init__(self, field_name: str | None = ...) -> None: ... diff --git a/django-stubs/contrib/sites/models.pyi b/django-stubs/contrib/sites/models.pyi index 099ab2629..68400d47c 100644 --- a/django-stubs/contrib/sites/models.pyi +++ b/django-stubs/contrib/sites/models.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Tuple, Type +from typing import Any, Tuple, Type from django.db import models from django.http.request import HttpRequest @@ -6,7 +6,7 @@ from django.http.request import HttpRequest SITE_CACHE: Any class SiteManager(models.Manager["Site"]): - def get_current(self, request: Optional[HttpRequest] = ...) -> Site: ... + def get_current(self, request: HttpRequest | None = ...) -> Site: ... def clear_cache(self) -> None: ... def get_by_natural_key(self, domain: str) -> Site: ... diff --git a/django-stubs/contrib/sites/shortcuts.pyi b/django-stubs/contrib/sites/shortcuts.pyi index 6938e6f9a..44f8d0205 100644 --- a/django-stubs/contrib/sites/shortcuts.pyi +++ b/django-stubs/contrib/sites/shortcuts.pyi @@ -1,7 +1,5 @@ -from typing import Optional, Union - from django.contrib.sites.models import Site from django.contrib.sites.requests import RequestSite from django.http.request import HttpRequest -def get_current_site(request: Optional[HttpRequest]) -> Union[Site, RequestSite]: ... +def get_current_site(request: HttpRequest | None) -> Site | RequestSite: ... diff --git a/django-stubs/contrib/staticfiles/checks.pyi b/django-stubs/contrib/staticfiles/checks.pyi index fb1ba2543..159aa0ea6 100644 --- a/django-stubs/contrib/staticfiles/checks.pyi +++ b/django-stubs/contrib/staticfiles/checks.pyi @@ -1,6 +1,6 @@ -from typing import Any, List, Optional, Sequence +from typing import Any, List, Sequence from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage -def check_finders(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ... +def check_finders(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 25aef2172..edeedd397 100644 --- a/django-stubs/contrib/staticfiles/finders.pyi +++ b/django-stubs/contrib/staticfiles/finders.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, Iterator, List, Optional, Sequence, Tuple, Type, overload +from typing import Any, Dict, Iterable, Iterator, List, Sequence, Tuple, Type, overload from django.core.checks.messages import CheckMessage from django.core.files.storage import FileSystemStorage, Storage @@ -9,50 +9,50 @@ searched_locations: Any class BaseFinder: def check(self, **kwargs: Any) -> List[CheckMessage]: ... @overload - def find(self, path: str, all: Literal[False] = ...) -> Optional[str]: ... + def find(self, path: str, all: Literal[False] = ...) -> str | None: ... @overload def find(self, path: str, all: Literal[True]) -> List[str]: ... - def list(self, ignore_patterns: Optional[Iterable[str]]) -> Iterable[Any]: ... + def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... 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 find_location(self, root: str, path: str, prefix: Optional[str] = ...) -> Optional[str]: ... + def find_location(self, root: str, path: str, prefix: str | None = ...) -> str | None: ... @overload - def find(self, path: str, all: Literal[False] = ...) -> Optional[str]: ... + def find(self, path: str, all: Literal[False] = ...) -> str | None: ... @overload def find(self, path: str, all: Literal[True]) -> List[str]: ... - def list(self, ignore_patterns: Optional[Iterable[str]]) -> Iterable[Any]: ... + def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... class AppDirectoriesFinder(BaseFinder): storage_class: Type[FileSystemStorage] = ... source_dir: str = ... apps: List[str] = ... storages: Dict[str, FileSystemStorage] = ... - def __init__(self, app_names: Optional[Iterable[str]] = ..., *args: Any, **kwargs: Any) -> None: ... - def find_in_app(self, app: str, path: str) -> Optional[str]: ... + def __init__(self, app_names: Iterable[str] | None = ..., *args: Any, **kwargs: Any) -> None: ... + def find_in_app(self, app: str, path: str) -> str | None: ... @overload - def find(self, path: str, all: Literal[False] = ...) -> Optional[str]: ... + def find(self, path: str, all: Literal[False] = ...) -> str | None: ... @overload def find(self, path: str, all: Literal[True]) -> List[str]: ... - def list(self, ignore_patterns: Optional[Iterable[str]]) -> Iterable[Any]: ... + def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... class BaseStorageFinder(BaseFinder): storage: Storage = ... - def __init__(self, storage: Optional[Storage] = ..., *args: Any, **kwargs: Any) -> None: ... + def __init__(self, storage: Storage | None = ..., *args: Any, **kwargs: Any) -> None: ... @overload - def find(self, path: str, all: Literal[False] = ...) -> Optional[str]: ... + def find(self, path: str, all: Literal[False] = ...) -> str | None: ... @overload def find(self, path: str, all: Literal[True]) -> List[str]: ... - def list(self, ignore_patterns: Optional[Iterable[str]]) -> Iterable[Any]: ... + def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... class DefaultStorageFinder(BaseStorageFinder): storage: Storage = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... @overload -def find(path: str, all: Literal[False] = ...) -> Optional[str]: ... +def find(path: str, all: Literal[False] = ...) -> str | None: ... @overload def find(path: str, all: Literal[True]) -> List[str]: ... def get_finders() -> Iterator[BaseFinder]: ... diff --git a/django-stubs/contrib/staticfiles/storage.pyi b/django-stubs/contrib/staticfiles/storage.pyi index 17e81b35e..67c438f3b 100644 --- a/django-stubs/contrib/staticfiles/storage.pyi +++ b/django-stubs/contrib/staticfiles/storage.pyi @@ -1,17 +1,17 @@ -from typing import Any, Callable, Dict, Iterator, Optional, Tuple, Union +from typing import Any, Callable, Dict, Iterator, Tuple from django.core.files.base import File from django.core.files.storage import FileSystemStorage, Storage from django.utils._os import _PathCompatible from django.utils.functional import LazyObject -_PostProcessT = Iterator[Union[Tuple[str, str, bool], Tuple[str, None, RuntimeError]]] +_PostProcessT = Iterator[Tuple[str, str, bool] | Tuple[str, None, RuntimeError]] class StaticFilesStorage(FileSystemStorage): base_location: str location: _PathCompatible def __init__( - self, location: Optional[_PathCompatible] = ..., base_url: Optional[str] = ..., *args: Any, **kwargs: Any + self, location: _PathCompatible | None = ..., base_url: str | None = ..., *args: Any, **kwargs: Any ) -> None: ... def path(self, name: _PathCompatible) -> str: ... @@ -23,7 +23,7 @@ class HashedFilesMixin: keep_intermediate_files: bool = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... def file_hash(self, name: str, content: File = ...) -> str: ... - def hashed_name(self, name: str, content: Optional[File] = ..., filename: Optional[str] = ...) -> str: ... + 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 post_process(self, paths: Dict[str, Any], dry_run: bool = ..., **options: Any) -> _PostProcessT: ... diff --git a/django-stubs/contrib/staticfiles/urls.pyi b/django-stubs/contrib/staticfiles/urls.pyi index dec7e6c6f..cb5a2415f 100644 --- a/django-stubs/contrib/staticfiles/urls.pyi +++ b/django-stubs/contrib/staticfiles/urls.pyi @@ -1,7 +1,7 @@ -from typing import List, Optional +from typing import List from django.urls import URLPattern, _AnyURL urlpatterns: List[_AnyURL] = ... -def staticfiles_urlpatterns(prefix: Optional[str] = ...) -> List[URLPattern]: ... +def staticfiles_urlpatterns(prefix: str | None = ...) -> List[URLPattern]: ... diff --git a/django-stubs/contrib/staticfiles/utils.pyi b/django-stubs/contrib/staticfiles/utils.pyi index 2151662b5..743293026 100644 --- a/django-stubs/contrib/staticfiles/utils.pyi +++ b/django-stubs/contrib/staticfiles/utils.pyi @@ -1,9 +1,7 @@ -from typing import Iterable, Iterator, Optional +from typing import Iterable, Iterator from django.core.files.storage import Storage def matches_patterns(path: str, patterns: Iterable[str]) -> bool: ... -def get_files( - storage: Storage, ignore_patterns: Optional[Iterable[str]] = ..., location: str = ... -) -> Iterator[str]: ... -def check_settings(base_url: Optional[str] = ...) -> None: ... +def get_files(storage: Storage, ignore_patterns: Iterable[str] | None = ..., location: str = ...) -> Iterator[str]: ... +def check_settings(base_url: str | None = ...) -> None: ... diff --git a/django-stubs/contrib/syndication/views.pyi b/django-stubs/contrib/syndication/views.pyi index f48e2c0a4..5a84dcce1 100644 --- a/django-stubs/contrib/syndication/views.pyi +++ b/django-stubs/contrib/syndication/views.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Generic, List, Optional, Type, TypeVar +from typing import Any, Dict, Generic, List, Type, TypeVar from django.core.exceptions import ObjectDoesNotExist from django.db.models import Model @@ -15,9 +15,9 @@ _Object = TypeVar("_Object") class Feed(Generic[_Item, _Object]): feed_type: Type[SyndicationFeed] = ... - title_template: Optional[str] = ... - description_template: Optional[str] = ... - language: Optional[str] = ... + title_template: str | None = ... + description_template: str | None = ... + language: str | None = ... # Dynamic attributes: title: Any @@ -46,7 +46,7 @@ class Feed(Generic[_Item, _Object]): item_copyright: Any item_comments: Any def __call__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... - def get_object(self, request: HttpRequest, *args: Any, **kwargs: Any) -> Optional[_Object]: ... + def get_object(self, request: HttpRequest, *args: Any, **kwargs: Any) -> _Object | None: ... def feed_extra_kwargs(self, obj: _Object) -> Dict[Any, Any]: ... def item_extra_kwargs(self, item: _Item) -> Dict[Any, Any]: ... def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... diff --git a/django-stubs/core/cache/backends/base.pyi b/django-stubs/core/cache/backends/base.pyi index e479223db..4998eeabd 100644 --- a/django-stubs/core/cache/backends/base.pyi +++ b/django-stubs/core/cache/backends/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, List, Optional, Union +from typing import Any, Callable, Dict, Iterable, List from django.core.exceptions import ImproperlyConfigured @@ -10,63 +10,57 @@ DEFAULT_TIMEOUT: Any MEMCACHE_MAX_KEY_LENGTH: int def default_key_func(key: Any, key_prefix: str, version: Any) -> str: ... -def get_key_func(key_func: Optional[Union[Callable, str]]) -> Callable: ... +def get_key_func(key_func: Callable | str | None) -> Callable: ... class BaseCache: _missing_key: object - default_timeout: Optional[float] = ... + default_timeout: float | None = ... _max_entries: int = ... _cull_frequency: int = ... key_prefix: str = ... version: int = ... key_func: Callable = ... def __init__(self, params: Dict[str, Any]) -> None: ... - def get_backend_timeout(self, timeout: Optional[float] = ...) -> Optional[float]: ... - def make_key(self, key: Any, version: Optional[int] = ...) -> str: ... + def get_backend_timeout(self, timeout: float | None = ...) -> float | None: ... + def make_key(self, key: Any, version: int | None = ...) -> str: ... def validate_key(self, key: Any) -> None: ... - def make_and_validate_key(self, key: Any, version: Optional[int] = ...) -> str: ... - def add(self, key: Any, value: Any, timeout: Optional[float] = ..., version: Optional[int] = ...) -> bool: ... - async def aadd( - self, key: Any, value: Any, timeout: Optional[float] = ..., version: Optional[int] = ... - ) -> bool: ... - def get(self, key: Any, default: Optional[Any] = ..., version: Optional[int] = ...) -> Any: ... - async def aget(self, key: Any, default: Optional[Any] = ..., version: Optional[int] = ...) -> Any: ... - def set(self, key: Any, value: Any, timeout: Optional[float] = ..., version: Optional[int] = ...) -> None: ... - async def aset( - self, key: Any, value: Any, timeout: Optional[float] = ..., version: Optional[int] = ... - ) -> None: ... - def touch(self, key: Any, timeout: Optional[float] = ..., version: Optional[int] = ...) -> bool: ... - async def atouch(self, key: Any, timeout: Optional[float] = ..., version: Optional[int] = ...) -> bool: ... - def delete(self, key: Any, version: Optional[int] = ...) -> None: ... - async def adelete(self, key: Any, version: Optional[int] = ...) -> None: ... - def get_many(self, keys: Iterable[Any], version: Optional[int] = ...) -> Dict[Any, Any]: ... - async def aget_many(self, keys: Iterable[Any], version: Optional[int] = ...) -> Dict[Any, Any]: ... + def make_and_validate_key(self, key: Any, version: int | None = ...) -> str: ... + def add(self, key: Any, value: Any, timeout: float | None = ..., version: int | None = ...) -> bool: ... + async def aadd(self, key: Any, value: Any, timeout: float | None = ..., version: int | None = ...) -> bool: ... + def get(self, key: Any, default: Any | None = ..., version: int | None = ...) -> Any: ... + async def aget(self, key: Any, default: Any | None = ..., version: int | None = ...) -> Any: ... + def set(self, key: Any, value: Any, timeout: float | None = ..., version: int | None = ...) -> None: ... + async def aset(self, key: Any, value: Any, timeout: float | None = ..., version: int | None = ...) -> None: ... + def touch(self, key: Any, timeout: float | None = ..., version: int | None = ...) -> bool: ... + async def atouch(self, key: Any, timeout: float | None = ..., version: int | None = ...) -> bool: ... + def delete(self, key: Any, version: int | None = ...) -> None: ... + async def adelete(self, key: Any, version: int | None = ...) -> None: ... + def get_many(self, keys: Iterable[Any], version: int | None = ...) -> Dict[Any, Any]: ... + async def aget_many(self, keys: Iterable[Any], version: int | None = ...) -> Dict[Any, Any]: ... def get_or_set( - self, key: Any, default: Optional[Any], timeout: Optional[float] = ..., version: Optional[int] = ... - ) -> Optional[Any]: ... + self, key: Any, default: Any | None, timeout: float | None = ..., version: int | None = ... + ) -> Any | None: ... async def aget_or_set( - self, key: Any, default: Optional[Any], timeout: Optional[float] = ..., version: Optional[int] = ... - ) -> Optional[Any]: ... - def has_key(self, key: Any, version: Optional[int] = ...) -> bool: ... - async def ahas_key(self, key: Any, version: Optional[int] = ...) -> bool: ... - def incr(self, key: Any, delta: int = ..., version: Optional[int] = ...) -> int: ... - async def aincr(self, key: Any, delta: int = ..., version: Optional[int] = ...) -> int: ... - def decr(self, key: Any, delta: int = ..., version: Optional[int] = ...) -> int: ... - async def adecr(self, key: Any, delta: int = ..., version: Optional[int] = ...) -> int: ... + self, key: Any, default: Any | None, timeout: float | None = ..., version: int | None = ... + ) -> Any | None: ... + def has_key(self, key: Any, version: int | None = ...) -> bool: ... + async def ahas_key(self, key: Any, version: int | None = ...) -> bool: ... + def incr(self, key: Any, delta: int = ..., version: int | None = ...) -> int: ... + async def aincr(self, key: Any, delta: int = ..., version: int | None = ...) -> int: ... + def decr(self, key: Any, delta: int = ..., version: int | None = ...) -> int: ... + async def adecr(self, key: Any, delta: int = ..., version: int | None = ...) -> int: ... def __contains__(self, key: Any) -> bool: ... - def set_many( - self, data: Dict[Any, Any], timeout: Optional[float] = ..., version: Optional[int] = ... - ) -> List[Any]: ... + def set_many(self, data: Dict[Any, Any], timeout: float | None = ..., version: int | None = ...) -> List[Any]: ... async def aset_many( - self, data: Dict[Any, Any], timeout: Optional[float] = ..., version: Optional[int] = ... + self, data: Dict[Any, Any], timeout: float | None = ..., version: int | None = ... ) -> List[Any]: ... - def delete_many(self, keys: Iterable[Any], version: Optional[int] = ...) -> None: ... - async def adelete_many(self, keys: Iterable[Any], version: Optional[int] = ...) -> None: ... + def delete_many(self, keys: Iterable[Any], version: int | None = ...) -> None: ... + async def adelete_many(self, keys: Iterable[Any], version: int | None = ...) -> None: ... def clear(self) -> None: ... async def aclear(self) -> None: ... - def incr_version(self, key: Any, delta: int = ..., version: Optional[int] = ...) -> int: ... - async def aincr_version(self, key: Any, delta: int = ..., version: Optional[int] = ...) -> int: ... - def decr_version(self, key: Any, delta: int = ..., version: Optional[int] = ...) -> int: ... - async def adecr_version(self, key: Any, delta: int = ..., version: Optional[int] = ...) -> int: ... + def incr_version(self, key: Any, delta: int = ..., version: int | None = ...) -> int: ... + async def aincr_version(self, key: Any, delta: int = ..., version: int | None = ...) -> int: ... + def decr_version(self, key: Any, delta: int = ..., version: int | None = ...) -> int: ... + async def adecr_version(self, key: Any, delta: int = ..., version: int | None = ...) -> int: ... def close(self, **kwargs: Any) -> None: ... async def aclose(self, **kwargs: Any) -> None: ... diff --git a/django-stubs/core/cache/backends/memcached.pyi b/django-stubs/core/cache/backends/memcached.pyi index 3956df32e..1adcdc2e0 100644 --- a/django-stubs/core/cache/backends/memcached.pyi +++ b/django-stubs/core/cache/backends/memcached.pyi @@ -1,19 +1,19 @@ from types import ModuleType -from typing import Any, Dict, Sequence, Type, Union +from typing import Any, Dict, Sequence, Type from django.core.cache.backends.base import BaseCache class BaseMemcachedCache(BaseCache): def __init__( self, - server: Union[str, Sequence[str]], + server: str | Sequence[str], params: Dict[str, Any], library: ModuleType, value_not_found_exception: Type[BaseException], ) -> None: ... class MemcachedCache(BaseMemcachedCache): - def __init__(self, server: Union[str, Sequence[str]], params: Dict[str, Any]) -> None: ... + def __init__(self, server: str | Sequence[str], params: Dict[str, Any]) -> None: ... class PyLibMCCache(BaseMemcachedCache): - def __init__(self, server: Union[str, Sequence[str]], params: Dict[str, Any]) -> None: ... + def __init__(self, server: str | Sequence[str], params: Dict[str, Any]) -> None: ... diff --git a/django-stubs/core/cache/utils.pyi b/django-stubs/core/cache/utils.pyi index 76df11959..1d4a3dbf2 100644 --- a/django-stubs/core/cache/utils.pyi +++ b/django-stubs/core/cache/utils.pyi @@ -1,5 +1,5 @@ -from typing import Any, Iterable, Optional +from typing import Any, Iterable TEMPLATE_FRAGMENT_KEY_TEMPLATE: str -def make_template_fragment_key(fragment_name: str, vary_on: Optional[Iterable[Any]] = ...) -> str: ... +def make_template_fragment_key(fragment_name: str, vary_on: Iterable[Any] | None = ...) -> str: ... diff --git a/django-stubs/core/checks/async_checks.pyi b/django-stubs/core/checks/async_checks.pyi index 9b32ba0e8..8039902af 100644 --- a/django-stubs/core/checks/async_checks.pyi +++ b/django-stubs/core/checks/async_checks.pyi @@ -1,8 +1,8 @@ -from typing import Any, Optional, Sequence +from typing import Any, Sequence from django.apps.config import AppConfig from django.core.checks.messages import Error E001: Error -def check_async_unsafe(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ... +def check_async_unsafe(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... diff --git a/django-stubs/core/checks/caches.pyi b/django-stubs/core/checks/caches.pyi index 63ee3d859..2ff4ef50a 100644 --- a/django-stubs/core/checks/caches.pyi +++ b/django-stubs/core/checks/caches.pyi @@ -1,14 +1,10 @@ -from typing import Any, Optional, Sequence +from typing import Any, Sequence from django.apps.config import AppConfig from django.core.checks.messages import Error, Warning E001: Error -def check_default_cache_is_configured(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ... -def check_cache_location_not_exposed( - app_configs: Optional[Sequence[AppConfig]], **kwargs: Any -) -> Sequence[Warning]: ... -def check_file_based_cache_is_absolute( - app_configs: Optional[Sequence[AppConfig]], **kwargs: Any -) -> Sequence[Warning]: ... +def check_default_cache_is_configured(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... +def check_cache_location_not_exposed(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_file_based_cache_is_absolute(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... diff --git a/django-stubs/core/checks/database.pyi b/django-stubs/core/checks/database.pyi index 18f5b5caf..4f745579a 100644 --- a/django-stubs/core/checks/database.pyi +++ b/django-stubs/core/checks/database.pyi @@ -1,5 +1,5 @@ -from typing import Any, Iterable, Optional, Sequence +from typing import Any, Iterable, Sequence from django.core.checks import CheckMessage -def check_database_backends(databases: Optional[Iterable[str]] = ..., **kwargs: Any) -> Sequence[CheckMessage]: ... +def check_database_backends(databases: Iterable[str] | None = ..., **kwargs: Any) -> Sequence[CheckMessage]: ... diff --git a/django-stubs/core/checks/messages.pyi b/django-stubs/core/checks/messages.pyi index e0b7d0a26..2d8dd7d41 100644 --- a/django-stubs/core/checks/messages.pyi +++ b/django-stubs/core/checks/messages.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any DEBUG: int INFO: int @@ -9,26 +9,24 @@ CRITICAL: int class CheckMessage: level: int = ... msg: str = ... - hint: Optional[str] = ... + hint: str | None = ... obj: Any = ... - id: Optional[str] = ... - def __init__( - self, level: int, msg: str, hint: Optional[str] = ..., obj: Any = ..., id: Optional[str] = ... - ) -> None: ... + id: str | None = ... + def __init__(self, level: int, msg: str, hint: str | None = ..., obj: Any = ..., id: str | None = ...) -> None: ... def is_serious(self, level: int = ...) -> bool: ... def is_silenced(self) -> bool: ... class Debug(CheckMessage): - def __init__(self, msg: str, hint: Optional[str] = ..., obj: Any = ..., id: Optional[str] = ...) -> None: ... + def __init__(self, msg: str, hint: str | None = ..., obj: Any = ..., id: str | None = ...) -> None: ... class Info(CheckMessage): - def __init__(self, msg: str, hint: Optional[str] = ..., obj: Any = ..., id: Optional[str] = ...) -> None: ... + def __init__(self, msg: str, hint: str | None = ..., obj: Any = ..., id: str | None = ...) -> None: ... class Warning(CheckMessage): - def __init__(self, msg: str, hint: Optional[str] = ..., obj: Any = ..., id: Optional[str] = ...) -> None: ... + def __init__(self, msg: str, hint: str | None = ..., obj: Any = ..., id: str | None = ...) -> None: ... class Error(CheckMessage): - def __init__(self, msg: str, hint: Optional[str] = ..., obj: Any = ..., id: Optional[str] = ...) -> None: ... + def __init__(self, msg: str, hint: str | None = ..., obj: Any = ..., id: str | None = ...) -> None: ... class Critical(CheckMessage): - def __init__(self, msg: str, hint: Optional[str] = ..., obj: Any = ..., id: Optional[str] = ...) -> None: ... + def __init__(self, msg: str, hint: str | None = ..., obj: Any = ..., id: str | None = ...) -> None: ... diff --git a/django-stubs/core/checks/model_checks.pyi b/django-stubs/core/checks/model_checks.pyi index a8c803640..fb48f9c66 100644 --- a/django-stubs/core/checks/model_checks.pyi +++ b/django-stubs/core/checks/model_checks.pyi @@ -1,9 +1,7 @@ -from typing import Any, Optional, Sequence +from typing import Any, Sequence from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage -def check_all_models(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> Sequence[CheckMessage]: ... -def check_lazy_references( - app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any -) -> Sequence[CheckMessage]: ... +def check_all_models(app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any) -> Sequence[CheckMessage]: ... +def check_lazy_references(app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any) -> Sequence[CheckMessage]: ... diff --git a/django-stubs/core/checks/registry.pyi b/django-stubs/core/checks/registry.pyi index a6d123440..9d3c71acd 100644 --- a/django-stubs/core/checks/registry.pyi +++ b/django-stubs/core/checks/registry.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Optional, Sequence, Set, TypeVar, Union +from typing import Any, Callable, List, Sequence, Set, TypeVar from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage @@ -30,14 +30,14 @@ class CheckRegistry: deployment_checks: Set[_ProcessedCheckCallable] = ... def __init__(self) -> None: ... def register( - self, check: Optional[Union[_CheckCallable, str]] = ..., *tags: str, **kwargs: Any - ) -> Union[Callable[[_CheckCallable], _ProcessedCheckCallable], _ProcessedCheckCallable]: ... + self, check: _CheckCallable | str | None = ..., *tags: str, **kwargs: Any + ) -> Callable[[_CheckCallable], _ProcessedCheckCallable] | _ProcessedCheckCallable: ... def run_checks( self, - app_configs: Optional[Sequence[AppConfig]] = ..., - tags: Optional[Sequence[str]] = ..., + app_configs: Sequence[AppConfig] | None = ..., + tags: Sequence[str] | None = ..., include_deployment_checks: bool = ..., - databases: Optional[Any] = ..., + databases: Any | None = ..., ) -> List[CheckMessage]: ... def tag_exists(self, tag: str, include_deployment_checks: bool = ...) -> bool: ... def tags_available(self, deployment_checks: bool = ...) -> Set[str]: ... diff --git a/django-stubs/core/checks/security/base.pyi b/django-stubs/core/checks/security/base.pyi index 994c7e192..4de228cd4 100644 --- a/django-stubs/core/checks/security/base.pyi +++ b/django-stubs/core/checks/security/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Sequence +from typing import Any, Sequence from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage, Error, Warning @@ -21,16 +21,16 @@ W022: Warning E023: Error E100: Error -def check_security_middleware(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_xframe_options_middleware(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_sts(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_sts_include_subdomains(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_sts_preload(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_content_type_nosniff(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_ssl_redirect(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_secret_key(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_debug(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_xframe_deny(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_allowed_hosts(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_referrer_policy(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[CheckMessage]: ... -def check_default_hashing_algorithm(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ... +def check_security_middleware(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_xframe_options_middleware(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_sts(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_sts_include_subdomains(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_sts_preload(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_content_type_nosniff(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_ssl_redirect(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_secret_key(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_debug(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_xframe_deny(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_allowed_hosts(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_referrer_policy(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[CheckMessage]: ... +def check_default_hashing_algorithm(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... diff --git a/django-stubs/core/checks/security/csrf.pyi b/django-stubs/core/checks/security/csrf.pyi index fabad5bc3..fcbb046d5 100644 --- a/django-stubs/core/checks/security/csrf.pyi +++ b/django-stubs/core/checks/security/csrf.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Sequence +from typing import Any, Sequence from django.apps.config import AppConfig from django.core.checks.messages import Warning @@ -6,5 +6,5 @@ from django.core.checks.messages import Warning W003: Warning W016: Warning -def check_csrf_middleware(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_csrf_cookie_secure(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... +def check_csrf_middleware(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_csrf_cookie_secure(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... diff --git a/django-stubs/core/checks/security/sessions.pyi b/django-stubs/core/checks/security/sessions.pyi index 18e9cc9a2..41a9fb1db 100644 --- a/django-stubs/core/checks/security/sessions.pyi +++ b/django-stubs/core/checks/security/sessions.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Sequence +from typing import Any, Sequence from django.apps.config import AppConfig from django.core.checks.messages import Warning @@ -15,5 +15,5 @@ W013: Warning W014: Warning W015: Warning -def check_session_cookie_secure(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... -def check_session_cookie_httponly(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... +def check_session_cookie_secure(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... +def check_session_cookie_httponly(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... diff --git a/django-stubs/core/checks/templates.pyi b/django-stubs/core/checks/templates.pyi index c018c737d..28ab6fe35 100644 --- a/django-stubs/core/checks/templates.pyi +++ b/django-stubs/core/checks/templates.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Sequence +from typing import Any, Sequence from django.apps.config import AppConfig from django.core.checks.messages import Error @@ -6,5 +6,5 @@ from django.core.checks.messages import Error E001: Error E002: Error -def check_setting_app_dirs_loaders(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ... -def check_string_if_invalid_is_string(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ... +def check_setting_app_dirs_loaders(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... +def check_string_if_invalid_is_string(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... diff --git a/django-stubs/core/checks/translation.pyi b/django-stubs/core/checks/translation.pyi index 20b4849b6..ede597f06 100644 --- a/django-stubs/core/checks/translation.pyi +++ b/django-stubs/core/checks/translation.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Sequence +from typing import Any, Sequence from django.apps.config import AppConfig @@ -9,9 +9,7 @@ E002: Error = ... E003: Error = ... E004: Error = ... -def check_setting_language_code(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ... -def check_setting_languages(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ... -def check_setting_languages_bidi(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ... -def check_language_settings_consistent( - app_configs: Optional[Sequence[AppConfig]], **kwargs: Any -) -> Sequence[Error]: ... +def check_setting_language_code(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... +def check_setting_languages(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... +def check_setting_languages_bidi(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... +def check_language_settings_consistent(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... diff --git a/django-stubs/core/checks/urls.pyi b/django-stubs/core/checks/urls.pyi index cf651724c..319035a88 100644 --- a/django-stubs/core/checks/urls.pyi +++ b/django-stubs/core/checks/urls.pyi @@ -1,12 +1,12 @@ -from typing import Any, Optional, Sequence +from typing import Any, Sequence from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage, Error, Warning from django.urls import _AnyURL -def check_url_config(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[CheckMessage]: ... +def check_url_config(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[CheckMessage]: ... def check_resolver(resolver: _AnyURL) -> Sequence[CheckMessage]: ... -def check_url_namespaces_unique(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ... +def check_url_namespaces_unique(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Warning]: ... def get_warning_for_invalid_pattern(pattern: Any) -> Sequence[Error]: ... -def check_url_settings(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ... +def check_url_settings(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... def E006(name: str) -> Error: ... diff --git a/django-stubs/core/exceptions.pyi b/django-stubs/core/exceptions.pyi index 9b0810e43..52c7d21d0 100644 --- a/django-stubs/core/exceptions.pyi +++ b/django-stubs/core/exceptions.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterator, List, Optional, Tuple, Union +from typing import Any, Dict, Iterator, List, Tuple from django.utils.functional import _StrPromise from typing_extensions import Literal @@ -31,21 +31,21 @@ class ValidationError(Exception): error_dict: Dict[str, List[ValidationError]] = ... error_list: List[ValidationError] = ... message: str = ... - code: Optional[str] = ... - params: Optional[Dict[str, Any]] = ... + code: str | None = ... + params: Dict[str, Any] | None = ... def __init__( self, # Accepts arbitrarily nested data structure, mypy doesn't allow describing it accurately. - message: Union[str, _StrPromise, ValidationError, Dict[str, Any], List[Any]], - code: Optional[str] = ..., - params: Optional[Dict[str, Any]] = ..., + message: str | _StrPromise | ValidationError | Dict[str, Any] | List[Any], + code: str | None = ..., + params: Dict[str, Any] | None = ..., ) -> None: ... @property def message_dict(self) -> Dict[str, List[str]]: ... @property def messages(self) -> List[str]: ... def update_error_dict(self, error_dict: Dict[str, List[ValidationError]]) -> Dict[str, List[ValidationError]]: ... - def __iter__(self) -> Iterator[Union[Tuple[str, List[str]], str]]: ... + def __iter__(self) -> Iterator[Tuple[str, List[str]] | str]: ... class EmptyResultSet(Exception): ... class SynchronousOnlyOperation(Exception): ... diff --git a/django-stubs/core/files/base.pyi b/django-stubs/core/files/base.pyi index 2b092ee35..5a2b8aa31 100644 --- a/django-stubs/core/files/base.pyi +++ b/django-stubs/core/files/base.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import IO, AnyStr, Iterator, Optional, Type, TypeVar, Union, type_check_only +from typing import IO, AnyStr, Iterator, Type, TypeVar, type_check_only from django.core.files.utils import FileProxyMixin @@ -7,27 +7,27 @@ _T = TypeVar("_T", bound="File") class File(FileProxyMixin[AnyStr], IO[AnyStr]): DEFAULT_CHUNK_SIZE: int = ... - file: Optional[IO[AnyStr]] = ... - name: Optional[str] = ... # type: ignore[assignment] + file: IO[AnyStr] | None = ... + name: str | None = ... # type: ignore[assignment] mode: str = ... - def __init__(self, file: Optional[IO[AnyStr]], name: Optional[str] = ...) -> None: ... + def __init__(self, file: IO[AnyStr] | None, name: str | None = ...) -> None: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... def __bool__(self) -> bool: ... def __len__(self) -> int: ... @property def size(self) -> int: ... - def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[AnyStr]: ... - def multiple_chunks(self, chunk_size: Optional[int] = ...) -> Optional[bool]: ... + def chunks(self, chunk_size: int | None = ...) -> Iterator[AnyStr]: ... + def multiple_chunks(self, chunk_size: int | None = ...) -> bool | None: ... def __iter__(self) -> Iterator[AnyStr]: ... def __enter__(self: _T) -> _T: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... - def open(self: _T, mode: Optional[str] = ...) -> _T: ... + def open(self: _T, mode: str | None = ...) -> _T: ... def close(self) -> None: ... @type_check_only def __next__(self) -> AnyStr: ... @@ -35,13 +35,13 @@ class File(FileProxyMixin[AnyStr], IO[AnyStr]): class ContentFile(File[AnyStr]): file: IO[AnyStr] size: int = ... - def __init__(self, content: AnyStr, name: Optional[str] = ...) -> None: ... + def __init__(self, content: AnyStr, name: str | None = ...) -> None: ... def __str__(self) -> str: ... def __bool__(self) -> bool: ... - def open(self: _T, mode: Optional[str] = ...) -> _T: ... + def open(self: _T, mode: str | None = ...) -> _T: ... def close(self) -> None: ... def write(self, data: AnyStr) -> int: ... -def endswith_cr(line: Union[bytes, str]) -> bool: ... -def endswith_lf(line: Union[bytes, str]) -> bool: ... -def equals_lf(line: Union[bytes, str]) -> bool: ... +def endswith_cr(line: bytes | str) -> bool: ... +def endswith_lf(line: bytes | str) -> bool: ... +def equals_lf(line: bytes | str) -> bool: ... diff --git a/django-stubs/core/files/images.pyi b/django-stubs/core/files/images.pyi index 5afb8478a..04fa0b3a4 100644 --- a/django-stubs/core/files/images.pyi +++ b/django-stubs/core/files/images.pyi @@ -1,4 +1,4 @@ -from typing import IO, Optional, Tuple, Union +from typing import IO, Tuple from django.core.files import File from django.utils._os import _PathCompatible @@ -10,5 +10,5 @@ class ImageFile(File[bytes]): def height(self) -> int: ... def get_image_dimensions( - file_or_path: Union[_PathCompatible, IO[bytes]], close: bool = ... -) -> Tuple[Optional[int], Optional[int]]: ... + file_or_path: _PathCompatible | IO[bytes], close: bool = ... +) -> Tuple[int | None, int | None]: ... diff --git a/django-stubs/core/files/storage.pyi b/django-stubs/core/files/storage.pyi index f116e4632..3adf10d98 100644 --- a/django-stubs/core/files/storage.pyi +++ b/django-stubs/core/files/storage.pyi @@ -1,5 +1,5 @@ from datetime import datetime -from typing import IO, Any, List, Optional, Tuple, Type +from typing import IO, Any, List, Tuple, Type from django.core.files.base import File from django.utils._os import _PathCompatible @@ -7,17 +7,17 @@ from django.utils.functional import LazyObject class Storage: def open(self, name: str, mode: str = ...) -> File: ... - def save(self, name: Optional[str], content: IO[Any], max_length: Optional[int] = ...) -> str: ... + def save(self, name: str | None, content: IO[Any], max_length: int | None = ...) -> str: ... def get_valid_name(self, name: str) -> str: ... def get_alternative_name(self, file_root: str, file_ext: str) -> str: ... - def get_available_name(self, name: str, max_length: Optional[int] = ...) -> str: ... + def get_available_name(self, name: str, max_length: int | None = ...) -> str: ... def generate_filename(self, filename: _PathCompatible) -> str: ... def path(self, name: str) -> str: ... def delete(self, name: str) -> None: ... def exists(self, name: str) -> bool: ... def listdir(self, path: str) -> Tuple[List[str], List[str]]: ... def size(self, name: str) -> int: ... - def url(self, name: Optional[str]) -> str: ... + def url(self, name: str | None) -> str: ... def get_accessed_time(self, name: str) -> datetime: ... def get_created_time(self, name: str) -> datetime: ... def get_modified_time(self, name: str) -> datetime: ... @@ -26,10 +26,10 @@ class FileSystemStorage(Storage): OS_OPEN_FLAGS: int = ... def __init__( self, - location: Optional[_PathCompatible] = ..., - base_url: Optional[str] = ..., - file_permissions_mode: Optional[int] = ..., - directory_permissions_mode: Optional[int] = ..., + location: _PathCompatible | None = ..., + base_url: str | None = ..., + file_permissions_mode: int | None = ..., + directory_permissions_mode: int | None = ..., ) -> None: ... @property def base_location(self) -> _PathCompatible: ... @@ -38,12 +38,12 @@ class FileSystemStorage(Storage): @property def base_url(self) -> str: ... @property - def file_permissions_mode(self) -> Optional[int]: ... + def file_permissions_mode(self) -> int | None: ... @property - def directory_permissions_mode(self) -> Optional[int]: ... + def directory_permissions_mode(self) -> int | None: ... class DefaultStorage(LazyObject): ... default_storage: Any -def get_storage_class(import_path: Optional[str] = ...) -> Type[Storage]: ... +def get_storage_class(import_path: str | None = ...) -> Type[Storage]: ... diff --git a/django-stubs/core/files/uploadedfile.pyi b/django-stubs/core/files/uploadedfile.pyi index cee170d46..9330e203e 100644 --- a/django-stubs/core/files/uploadedfile.pyi +++ b/django-stubs/core/files/uploadedfile.pyi @@ -1,50 +1,50 @@ -from typing import IO, Dict, Optional, Type, TypeVar, Union +from typing import IO, Dict, Type, TypeVar from django.core.files.base import File class UploadedFile(File): - content_type: Optional[str] = ... - charset: Optional[str] = ... - content_type_extra: Optional[Dict[str, str]] = ... - size: Optional[int] # type: ignore[assignment] - name: Optional[str] + content_type: str | None = ... + charset: str | None = ... + content_type_extra: Dict[str, str] | None = ... + size: int | None # type: ignore[assignment] + name: str | None def __init__( self, - file: Optional[IO] = ..., - name: Optional[str] = ..., - content_type: Optional[str] = ..., - size: Optional[int] = ..., - charset: Optional[str] = ..., - content_type_extra: Optional[Dict[str, str]] = ..., + file: IO | None = ..., + name: str | None = ..., + content_type: str | None = ..., + size: int | None = ..., + charset: str | None = ..., + content_type_extra: Dict[str, str] | None = ..., ) -> None: ... class TemporaryUploadedFile(UploadedFile): def __init__( self, name: str, - content_type: Optional[str], - size: Optional[int], - charset: Optional[str], - content_type_extra: Optional[Dict[str, str]] = ..., + content_type: str | None, + size: int | None, + charset: str | None, + content_type_extra: Dict[str, str] | None = ..., ) -> None: ... def temporary_file_path(self) -> str: ... class InMemoryUploadedFile(UploadedFile): - field_name: Optional[str] = ... + field_name: str | None = ... def __init__( self, file: IO, - field_name: Optional[str], - name: Optional[str], - content_type: Optional[str], - size: Optional[int], - charset: Optional[str], + field_name: str | None, + name: str | None, + content_type: str | None, + size: int | None, + charset: str | None, content_type_extra: Dict[str, str] = ..., ) -> None: ... _C = TypeVar("_C", bound="SimpleUploadedFile") class SimpleUploadedFile(InMemoryUploadedFile): - def __init__(self, name: str, content: Optional[bytes], content_type: str = ...) -> None: ... + def __init__(self, name: str, content: bytes | None, content_type: str = ...) -> None: ... @classmethod - def from_dict(cls: Type[_C], file_dict: Dict[str, Union[str, bytes]]) -> _C: ... + def from_dict(cls: Type[_C], file_dict: Dict[str, str | bytes]) -> _C: ... diff --git a/django-stubs/core/files/uploadhandler.pyi b/django-stubs/core/files/uploadhandler.pyi index 855d7f0c3..a024d13f1 100644 --- a/django-stubs/core/files/uploadhandler.pyi +++ b/django-stubs/core/files/uploadhandler.pyi @@ -1,6 +1,6 @@ # Stubs for django.core.files.uploadhandler (Python 3.5) -from typing import IO, Any, Dict, Optional, Tuple +from typing import IO, Any, Dict, Tuple from django.core.files.uploadedfile import TemporaryUploadedFile, UploadedFile from django.http.request import HttpRequest, QueryDict @@ -18,33 +18,33 @@ class StopFutureHandlers(UploadFileException): ... class FileUploadHandler: chunk_size: int = ... - file_name: Optional[str] = ... - content_type: Optional[str] = ... - content_length: Optional[int] = ... - charset: Optional[str] = ... - content_type_extra: Optional[Dict[str, str]] = ... - request: Optional[HttpRequest] = ... + file_name: str | None = ... + content_type: str | None = ... + content_length: int | None = ... + charset: str | None = ... + content_type_extra: Dict[str, str] | None = ... + request: HttpRequest | None = ... field_name: str = ... - def __init__(self, request: Optional[HttpRequest] = ...) -> None: ... + def __init__(self, request: HttpRequest | None = ...) -> None: ... def handle_raw_input( self, input_data: IO[bytes], META: Dict[str, str], content_length: int, boundary: str, - encoding: Optional[str] = ..., - ) -> Optional[Tuple[QueryDict, MultiValueDict[str, UploadedFile]]]: ... + encoding: str | None = ..., + ) -> Tuple[QueryDict, MultiValueDict[str, UploadedFile]] | None: ... def new_file( self, field_name: str, file_name: str, content_type: str, - content_length: Optional[int], - charset: Optional[str] = ..., - content_type_extra: Optional[Dict[str, str]] = ..., + content_length: int | None, + charset: str | None = ..., + content_type_extra: Dict[str, str] | None = ..., ) -> None: ... - def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ... - def file_complete(self, file_size: int) -> Optional[UploadedFile]: ... + def receive_data_chunk(self, raw_data: bytes, start: int) -> bytes | None: ... + def file_complete(self, file_size: int) -> UploadedFile | None: ... def upload_complete(self) -> None: ... def upload_interrupted(self) -> None: ... @@ -55,12 +55,12 @@ class TemporaryFileUploadHandler(FileUploadHandler): field_name: str, file_name: str, content_type: str, - content_length: Optional[int], - charset: Optional[str] = ..., - content_type_extra: Optional[Dict[str, str]] = ..., + content_length: int | None, + charset: str | None = ..., + content_type_extra: Dict[str, str] | None = ..., ) -> None: ... - def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ... - def file_complete(self, file_size: int) -> Optional[UploadedFile]: ... + def receive_data_chunk(self, raw_data: bytes, start: int) -> bytes | None: ... + def file_complete(self, file_size: int) -> UploadedFile | None: ... def upload_interrupted(self) -> None: ... class MemoryFileUploadHandler(FileUploadHandler): @@ -72,18 +72,18 @@ class MemoryFileUploadHandler(FileUploadHandler): META: Dict[str, str], content_length: int, boundary: str, - encoding: Optional[str] = ..., - ) -> Optional[Tuple[QueryDict, MultiValueDict[str, UploadedFile]]]: ... + encoding: str | None = ..., + ) -> Tuple[QueryDict, MultiValueDict[str, UploadedFile]] | None: ... def new_file( self, field_name: str, file_name: str, content_type: str, - content_length: Optional[int], - charset: Optional[str] = ..., - content_type_extra: Optional[Dict[str, str]] = ..., + content_length: int | None, + charset: str | None = ..., + content_type_extra: Dict[str, str] | None = ..., ) -> None: ... - def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ... - def file_complete(self, file_size: int) -> Optional[UploadedFile]: ... + def receive_data_chunk(self, raw_data: bytes, start: int) -> bytes | None: ... + def file_complete(self, file_size: int) -> UploadedFile | None: ... def load_handler(path: str, *args: Any, **kwargs: Any) -> FileUploadHandler: ... diff --git a/django-stubs/core/files/utils.pyi b/django-stubs/core/files/utils.pyi index 4d18021fd..0d26ff9e5 100644 --- a/django-stubs/core/files/utils.pyi +++ b/django-stubs/core/files/utils.pyi @@ -1,11 +1,11 @@ -from typing import IO, Any, AnyStr, Generic, Iterator, Optional +from typing import IO, Any, AnyStr, Generic, Iterator from django.utils._os import _PathCompatible def validate_file_name(name: _PathCompatible, allow_relative_path: bool = ...) -> _PathCompatible: ... class FileProxyMixin(Generic[AnyStr]): - file: Optional[IO[AnyStr]] + file: IO[AnyStr] | None encoding: Any = ... fileno: Any = ... flush: Any = ... diff --git a/django-stubs/core/handlers/asgi.pyi b/django-stubs/core/handlers/asgi.pyi index ddfe74700..dbac67cc2 100644 --- a/django-stubs/core/handlers/asgi.pyi +++ b/django-stubs/core/handlers/asgi.pyi @@ -1,18 +1,4 @@ -from typing import ( - IO, - Any, - Awaitable, - Callable, - Dict, - Iterator, - Mapping, - Optional, - Sequence, - Tuple, - Type, - TypeVar, - Union, -) +from typing import IO, Any, Awaitable, Callable, Dict, Iterator, Mapping, Sequence, Tuple, Type, TypeVar from django.core.handlers import base as base from django.http.request import HttpRequest, _ImmutableQueryDict @@ -26,8 +12,8 @@ _SendCallback = Callable[[Mapping[str, Any]], Awaitable[None]] class ASGIRequest(HttpRequest): body_receive_timeout: int = ... scope: Mapping[str, Any] = ... - resolver_match: Optional[ResolverMatch] = ... - script_name: Optional[str] = ... + resolver_match: ResolverMatch | None = ... + script_name: str | None = ... path_info: str = ... path: str = ... method: str = ... @@ -55,7 +41,7 @@ class ASGIHandler(base.BaseHandler): async def read_body(self, receive: _ReceiveCallback) -> IO[bytes]: ... def create_request( self, scope: Mapping[str, Any], body_file: IO[bytes] - ) -> Union[Tuple[ASGIRequest, None], Tuple[None, HttpResponseBase]]: ... + ) -> Tuple[ASGIRequest, None] | Tuple[None, HttpResponseBase]: ... def handle_uncaught_exception( self, request: HttpRequest, resolver: URLResolver, exc_info: Any ) -> HttpResponseBase: ... diff --git a/django-stubs/core/handlers/base.pyi b/django-stubs/core/handlers/base.pyi index 39f7d9322..411fc42f2 100644 --- a/django-stubs/core/handlers/base.pyi +++ b/django-stubs/core/handlers/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Awaitable, Callable, Optional, Union +from typing import Any, Awaitable, Callable from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponseBase @@ -9,14 +9,14 @@ class BaseHandler: def adapt_method_mode( self, is_async: bool, - method: Callable[[HttpRequest], Union[HttpResponseBase, Awaitable[HttpResponseBase]]], - method_is_async: Optional[bool] = ..., + method: Callable[[HttpRequest], HttpResponseBase | Awaitable[HttpResponseBase]], + method_is_async: bool | None = ..., debug: bool = False, - name: Optional[str] = ..., - ) -> Callable[[HttpRequest], Union[HttpResponseBase, Awaitable[HttpResponseBase]]]: ... + name: str | None = ..., + ) -> Callable[[HttpRequest], HttpResponseBase | Awaitable[HttpResponseBase]]: ... def get_response(self, request: HttpRequest) -> HttpResponseBase: ... async def get_response_async(self, request: HttpRequest) -> HttpResponseBase: ... def resolve_request(self, request: HttpRequest) -> ResolverMatch: ... - def check_response(self, response: HttpResponseBase, callback: Any, name: Optional[str] = ...) -> None: ... + def check_response(self, response: HttpResponseBase, callback: Any, name: str | None = ...) -> None: ... def make_view_atomic(self, view: Callable[..., HttpResponseBase]) -> Callable[..., HttpResponseBase]: ... def process_exception_by_middleware(self, exception: Exception, request: HttpRequest) -> HttpResponse: ... diff --git a/django-stubs/core/handlers/exception.pyi b/django-stubs/core/handlers/exception.pyi index 6465f1c30..6916bc3ab 100644 --- a/django-stubs/core/handlers/exception.pyi +++ b/django-stubs/core/handlers/exception.pyi @@ -1,12 +1,12 @@ -from typing import Any, Awaitable, Callable, Union +from typing import Any, Awaitable, Callable from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponseBase from django.urls.resolvers import URLResolver def convert_exception_to_response( - get_response: Callable[[HttpRequest], Union[HttpResponseBase, Awaitable[HttpResponseBase]]] -) -> Callable[[HttpRequest], Union[HttpResponseBase, Awaitable[HttpResponseBase]]]: ... + get_response: Callable[[HttpRequest], HttpResponseBase | Awaitable[HttpResponseBase]] +) -> Callable[[HttpRequest], HttpResponseBase | Awaitable[HttpResponseBase]]: ... def response_for_exception(request: HttpRequest, exc: Exception) -> HttpResponse: ... def get_exception_response( request: HttpRequest, resolver: URLResolver, status_code: int, exception: Exception diff --git a/django-stubs/core/handlers/wsgi.pyi b/django-stubs/core/handlers/wsgi.pyi index 07cfe2be0..0effda4df 100644 --- a/django-stubs/core/handlers/wsgi.pyi +++ b/django-stubs/core/handlers/wsgi.pyi @@ -1,5 +1,5 @@ from io import BytesIO -from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Type +from typing import Any, Callable, Dict, Sequence, Tuple, Type from django.contrib.sessions.backends.base import SessionBase from django.core.handlers import base @@ -14,8 +14,8 @@ class LimitedStream: buffer: bytes = ... buf_size: int = ... def __init__(self, stream: BytesIO, limit: int, buf_size: int = ...) -> None: ... - def read(self, size: Optional[int] = ...) -> bytes: ... - def readline(self, size: Optional[int] = ...) -> bytes: ... + def read(self, size: int | None = ...) -> bytes: ... + def readline(self, size: int | None = ...) -> bytes: ... class WSGIRequest(HttpRequest): environ: _WSGIEnviron = ... diff --git a/django-stubs/core/mail/__init__.pyi b/django-stubs/core/mail/__init__.pyi index c3e45ba0b..c36bbbc99 100644 --- a/django-stubs/core/mail/__init__.pyi +++ b/django-stubs/core/mail/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, Optional, Sequence, Tuple +from typing import Any, Iterable, List, Sequence, Tuple from .message import DEFAULT_ATTACHMENT_MIME_TYPE as DEFAULT_ATTACHMENT_MIME_TYPE from .message import BadHeaderError as BadHeaderError @@ -10,38 +10,38 @@ from .message import forbid_multi_line_headers as forbid_multi_line_headers from .utils import DNS_NAME as DNS_NAME from .utils import CachedDnsName as CachedDnsName -def get_connection(backend: Optional[str] = ..., fail_silently: bool = ..., **kwds: Any) -> Any: ... +def get_connection(backend: str | None = ..., fail_silently: bool = ..., **kwds: Any) -> Any: ... def send_mail( subject: str, message: str, - from_email: Optional[str], + from_email: str | None, recipient_list: Sequence[str], fail_silently: bool = ..., - auth_user: Optional[str] = ..., - auth_password: Optional[str] = ..., - connection: Optional[Any] = ..., - html_message: Optional[str] = ..., + auth_user: str | None = ..., + auth_password: str | None = ..., + connection: Any | None = ..., + html_message: str | None = ..., ) -> int: ... def send_mass_mail( datatuple: Iterable[Tuple[str, str, str, List[str]]], fail_silently: bool = ..., - auth_user: Optional[str] = ..., - auth_password: Optional[str] = ..., - connection: Optional[Any] = ..., + auth_user: str | None = ..., + auth_password: str | None = ..., + connection: Any | None = ..., ) -> int: ... def mail_admins( subject: str, message: str, fail_silently: bool = ..., - connection: Optional[Any] = ..., - html_message: Optional[str] = ..., + connection: Any | None = ..., + html_message: str | None = ..., ) -> None: ... def mail_managers( subject: str, message: str, fail_silently: bool = ..., - connection: Optional[Any] = ..., - html_message: Optional[str] = ..., + connection: Any | None = ..., + html_message: str | None = ..., ) -> None: ... outbox: List[EmailMessage] = ... diff --git a/django-stubs/core/mail/backends/base.pyi b/django-stubs/core/mail/backends/base.pyi index 2e8653f01..693b9ee3b 100644 --- a/django-stubs/core/mail/backends/base.pyi +++ b/django-stubs/core/mail/backends/base.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Any, Optional, Sequence, Type, TypeVar +from typing import Any, Sequence, Type, TypeVar from django.core.mail.message import EmailMessage @@ -8,13 +8,13 @@ _T = TypeVar("_T", bound="BaseEmailBackend") class BaseEmailBackend: fail_silently: bool def __init__(self, fail_silently: bool = ..., **kwargs: Any) -> None: ... - def open(self) -> Optional[bool]: ... + def open(self) -> bool | None: ... def close(self) -> None: ... def __enter__(self: _T) -> _T: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... def send_messages(self, email_messages: Sequence[EmailMessage]) -> int: ... diff --git a/django-stubs/core/mail/backends/smtp.pyi b/django-stubs/core/mail/backends/smtp.pyi index cce177068..3fae00f57 100644 --- a/django-stubs/core/mail/backends/smtp.pyi +++ b/django-stubs/core/mail/backends/smtp.pyi @@ -1,6 +1,5 @@ import smtplib import threading -from typing import Optional, Union from django.core.mail.backends.base import BaseEmailBackend @@ -11,8 +10,8 @@ class EmailBackend(BaseEmailBackend): password: str = ... use_tls: bool = ... use_ssl: bool = ... - timeout: Optional[int] = ... - ssl_keyfile: Optional[str] = ... - ssl_certfile: Optional[str] = ... - connection: Union[smtplib.SMTP_SSL, smtplib.SMTP, None] = ... + timeout: int | None = ... + ssl_keyfile: str | None = ... + ssl_certfile: str | None = ... + connection: smtplib.SMTP_SSL | smtplib.SMTP | None = ... _lock: threading.RLock = ... diff --git a/django-stubs/core/mail/message.pyi b/django-stubs/core/mail/message.pyi index ccc06375a..7013596cd 100644 --- a/django-stubs/core/mail/message.pyi +++ b/django-stubs/core/mail/message.pyi @@ -5,7 +5,7 @@ from email.mime.base import MIMEBase from email.mime.message import MIMEMessage from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText -from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, Union, overload +from typing import Any, Dict, List, Sequence, Set, Tuple, overload utf8_charset: Any utf8_charset_qp: Any @@ -17,7 +17,7 @@ class BadHeaderError(ValueError): ... ADDRESS_HEADERS: Set[str] def forbid_multi_line_headers(name: str, val: str, encoding: str) -> Tuple[str, str]: ... -def sanitize_address(addr: Union[Tuple[str, str], str], encoding: str) -> str: ... +def sanitize_address(addr: Tuple[str, str] | str, encoding: str) -> str: ... class MIMEMixin: def as_string(self, unixfrom: bool = ..., linesep: str = "\n") -> str: ... @@ -39,7 +39,7 @@ class SafeMIMEText(MIMEMixin, MIMEText): # type: ignore def __init__(self, _text: str, _subtype: str = ..., _charset: str = ...) -> None: ... def __setitem__(self, name: str, val: str) -> None: ... def set_payload( - self, payload: Union[List[Message], str, bytes], charset: Union[str, Charset.Charset, None] = ... + self, payload: List[Message] | str | bytes, charset: str | Charset.Charset | None = ... ) -> None: ... class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): # type: ignore @@ -51,17 +51,17 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): # type: ignore def __init__( self, _subtype: str = ..., - boundary: Optional[Any] = ..., - _subparts: Optional[Any] = ..., + boundary: Any | None = ..., + _subparts: Any | None = ..., encoding: str = ..., **_params: Any ) -> None: ... def __setitem__(self, name: str, val: str) -> None: ... -_AttachmentContent = Union[bytes, EmailMessage, Message, SafeMIMEText, str] -_AttachmentTuple = Union[ - Tuple[str, _AttachmentContent], Tuple[Optional[str], _AttachmentContent, str], Tuple[str, _AttachmentContent, None] -] +_AttachmentContent = bytes | EmailMessage | Message | SafeMIMEText | str +_AttachmentTuple = ( + Tuple[str, _AttachmentContent] | Tuple[str | None, _AttachmentContent, str] | Tuple[str, _AttachmentContent, None] +) class EmailMessage: content_subtype: str = ... @@ -80,15 +80,15 @@ class EmailMessage: def __init__( self, subject: str = ..., - body: Optional[str] = ..., - from_email: Optional[str] = ..., - to: Optional[Sequence[str]] = ..., - bcc: Optional[Sequence[str]] = ..., - connection: Optional[Any] = ..., - attachments: Optional[Sequence[Union[MIMEBase, _AttachmentTuple]]] = ..., - headers: Optional[Dict[str, str]] = ..., - cc: Optional[Sequence[str]] = ..., - reply_to: Optional[Sequence[str]] = ..., + body: str | None = ..., + from_email: str | None = ..., + to: Sequence[str] | None = ..., + bcc: Sequence[str] | None = ..., + connection: Any | None = ..., + attachments: Sequence[MIMEBase | _AttachmentTuple] | None = ..., + headers: Dict[str, str] | None = ..., + cc: Sequence[str] | None = ..., + reply_to: Sequence[str] | None = ..., ) -> None: ... def get_connection(self, fail_silently: bool = ...) -> Any: ... # TODO: when typeshed gets more types for email.Message, move it to MIMEMessage, now it has too many false-positives @@ -100,8 +100,8 @@ class EmailMessage: @overload def attach(self, filename: None = ..., content: _AttachmentContent = ..., mimetype: str = ...) -> None: ... @overload - def attach(self, filename: str = ..., content: _AttachmentContent = ..., mimetype: Optional[str] = ...) -> None: ... - def attach_file(self, path: str, mimetype: Optional[str] = ...) -> None: ... + def attach(self, filename: str = ..., content: _AttachmentContent = ..., mimetype: str | None = ...) -> None: ... + def attach_file(self, path: str, mimetype: str | None = ...) -> None: ... class EmailMultiAlternatives(EmailMessage): alternative_subtype: str = ... @@ -109,15 +109,15 @@ class EmailMultiAlternatives(EmailMessage): def __init__( self, subject: str = ..., - body: Optional[str] = ..., - from_email: Optional[str] = ..., - to: Optional[Sequence[str]] = ..., - bcc: Optional[Sequence[str]] = ..., - connection: Optional[Any] = ..., - attachments: Optional[Sequence[Union[MIMEBase, _AttachmentTuple]]] = ..., - headers: Optional[Dict[str, str]] = ..., - alternatives: Optional[List[Tuple[_AttachmentContent, str]]] = ..., - cc: Optional[Sequence[str]] = ..., - reply_to: Optional[Sequence[str]] = ..., + body: str | None = ..., + from_email: str | None = ..., + to: Sequence[str] | None = ..., + bcc: Sequence[str] | None = ..., + connection: Any | None = ..., + attachments: Sequence[MIMEBase | _AttachmentTuple] | None = ..., + headers: Dict[str, str] | None = ..., + alternatives: List[Tuple[_AttachmentContent, str]] | None = ..., + cc: Sequence[str] | None = ..., + reply_to: Sequence[str] | None = ..., ) -> None: ... def attach_alternative(self, content: _AttachmentContent, mimetype: str) -> None: ... diff --git a/django-stubs/core/management/__init__.pyi b/django-stubs/core/management/__init__.pyi index beadeedb7..e3890d1ac 100644 --- a/django-stubs/core/management/__init__.pyi +++ b/django-stubs/core/management/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List from .base import BaseCommand as BaseCommand from .base import CommandError as CommandError @@ -6,16 +6,16 @@ from .base import CommandError as CommandError def find_commands(management_dir: str) -> List[str]: ... def load_command_class(app_name: str, name: str) -> BaseCommand: ... def get_commands() -> Dict[str, str]: ... -def call_command(command_name: Union[BaseCommand, str], *args: Any, **options: Any) -> str: ... +def call_command(command_name: BaseCommand | str, *args: Any, **options: Any) -> str: ... class ManagementUtility: argv: List[str] = ... prog_name: str = ... - settings_exception: Optional[Exception] = ... - def __init__(self, argv: Optional[List[str]] = ...) -> None: ... + settings_exception: Exception | None = ... + def __init__(self, argv: List[str] | None = ...) -> None: ... def main_help_text(self, commands_only: bool = ...) -> str: ... def fetch_command(self, subcommand: str) -> BaseCommand: ... def autocomplete(self) -> None: ... def execute(self) -> None: ... -def execute_from_command_line(argv: Optional[List[str]] = ...) -> None: ... +def execute_from_command_line(argv: List[str] | None = ...) -> None: ... diff --git a/django-stubs/core/management/base.pyi b/django-stubs/core/management/base.pyi index a591f3c0b..c84ee5961 100644 --- a/django-stubs/core/management/base.pyi +++ b/django-stubs/core/management/base.pyi @@ -1,6 +1,6 @@ from argparse import ArgumentParser, HelpFormatter, Namespace from io import TextIOBase -from typing import Any, Callable, Iterable, List, Optional, Sequence, Set, TextIO, Tuple, Union +from typing import Any, Callable, Iterable, List, Sequence, Set, TextIO, Tuple from django.apps.config import AppConfig from django.core.management.color import Style @@ -13,14 +13,10 @@ class CommandError(Exception): class SystemCheckError(CommandError): ... class CommandParser(ArgumentParser): - missing_args_message: Optional[str] = ... - called_from_command_line: Optional[bool] = ... + missing_args_message: str | None = ... + called_from_command_line: bool | None = ... def __init__( - self, - *, - missing_args_message: Optional[str] = ..., - called_from_command_line: Optional[bool] = ..., - **kwargs: Any + self, *, missing_args_message: str | None = ..., called_from_command_line: bool | None = ..., **kwargs: Any ) -> None: ... def error(self, message: str) -> Any: ... @@ -29,28 +25,28 @@ def no_translations(handle_func: Callable) -> Callable: ... class DjangoHelpFormatter(HelpFormatter): show_last: Set[str] = ... - def add_usage(self, usage: Optional[str], actions: Iterable[Any], *args: Any, **kwargs: Any) -> Any: ... + def add_usage(self, usage: str | None, actions: Iterable[Any], *args: Any, **kwargs: Any) -> Any: ... def add_arguments(self, actions: Any) -> Any: ... class OutputWrapper(TextIOBase): @property def style_func(self) -> Callable[[str], str]: ... @style_func.setter - def style_func(self, style_func: Optional[Callable[[str], str]]) -> None: ... + def style_func(self, style_func: Callable[[str], str] | None) -> None: ... ending: str = ... def __init__(self, out: TextIO, ending: str = ...) -> None: ... def __getattr__(self, name: str) -> Callable: ... def flush(self) -> None: ... def isatty(self) -> bool: ... def write( # type: ignore[override] - self, msg: str = ..., style_func: Optional[Callable[[str], str]] = ..., ending: Optional[str] = ... + self, msg: str = ..., style_func: Callable[[str], str] | None = ..., ending: str | None = ... ) -> None: ... class BaseCommand: help: str = ... output_transaction: bool = ... requires_migrations_checks: bool = ... - requires_system_checks: Union[_ListOrTuple[str], Literal["__all__"]] = ... + requires_system_checks: _ListOrTuple[str] | Literal["__all__"] = ... base_stealth_options: Tuple[str, ...] = ... stealth_options: Tuple[str, ...] = ... stdout: OutputWrapper = ... @@ -58,8 +54,8 @@ class BaseCommand: style: Style = ... def __init__( self, - stdout: Optional[TextIO] = ..., - stderr: Optional[TextIO] = ..., + stdout: TextIO | None = ..., + stderr: TextIO | None = ..., no_color: bool = ..., force_color: bool = ..., ) -> None: ... @@ -68,28 +64,28 @@ class BaseCommand: def add_arguments(self, parser: CommandParser) -> None: ... def print_help(self, prog_name: str, subcommand: str) -> None: ... def run_from_argv(self, argv: List[str]) -> None: ... - def execute(self, *args: Any, **options: Any) -> Optional[str]: ... + def execute(self, *args: Any, **options: Any) -> str | None: ... def check( self, - app_configs: Optional[Sequence[AppConfig]] = ..., - tags: Optional[Sequence[str]] = ..., + app_configs: Sequence[AppConfig] | None = ..., + tags: Sequence[str] | None = ..., display_num_errors: bool = ..., include_deployment_checks: bool = ..., fail_level: int = ..., - databases: Optional[Sequence[str]] = ..., + databases: Sequence[str] | None = ..., ) -> None: ... def check_migrations(self) -> None: ... - def handle(self, *args: Any, **options: Any) -> Optional[str]: ... + def handle(self, *args: Any, **options: Any) -> str | None: ... class AppCommand(BaseCommand): missing_args_message: str = ... def add_arguments(self, parser: CommandParser) -> None: ... - def handle(self, *app_labels: str, **options: Any) -> Optional[str]: ... - def handle_app_config(self, app_config: Any, **options: Any) -> Optional[str]: ... + def handle(self, *app_labels: str, **options: Any) -> str | None: ... + def handle_app_config(self, app_config: Any, **options: Any) -> str | None: ... class LabelCommand(BaseCommand): label: str = ... missing_args_message: Any = ... def add_arguments(self, parser: CommandParser) -> None: ... - def handle(self, *labels: str, **options: Any) -> Optional[str]: ... - def handle_label(self, label: str, **options: Any) -> Optional[str]: ... + def handle(self, *labels: str, **options: Any) -> str | None: ... + def handle_label(self, label: str, **options: Any) -> str | None: ... diff --git a/django-stubs/core/management/commands/compilemessages.pyi b/django-stubs/core/management/commands/compilemessages.pyi index 6007cedfb..78c71c6c7 100644 --- a/django-stubs/core/management/commands/compilemessages.pyi +++ b/django-stubs/core/management/commands/compilemessages.pyi @@ -1,6 +1,6 @@ import os from pathlib import Path -from typing import List, Tuple, Union +from typing import List, Tuple from django.core.management.base import BaseCommand as BaseCommand from django.core.management.base import CommandError as CommandError diff --git a/django-stubs/core/management/commands/loaddata.pyi b/django-stubs/core/management/commands/loaddata.pyi index 509abed85..ad7d40adc 100644 --- a/django-stubs/core/management/commands/loaddata.pyi +++ b/django-stubs/core/management/commands/loaddata.pyi @@ -1,5 +1,5 @@ import zipfile -from typing import List, Optional, Sequence, Set, Tuple, Type +from typing import List, Sequence, Set, Tuple, Type from django.apps.config import AppConfig from django.core.management.base import BaseCommand @@ -18,10 +18,10 @@ class Command(BaseCommand): missing_args_message: str = ... def loaddata(self, fixture_labels: Sequence[str]) -> None: ... def load_label(self, fixture_label: str) -> None: ... - def find_fixtures(self, fixture_label: str) -> List[Tuple[str, Optional[str], Optional[str]]]: ... + def find_fixtures(self, fixture_label: str) -> List[Tuple[str, str | None, str | None]]: ... @property def fixture_dirs(self) -> List[str]: ... - def parse_name(self, fixture_name: str) -> Tuple[str, Optional[str], Optional[str]]: ... + def parse_name(self, fixture_name: str) -> Tuple[str, str | None, str | None]: ... class SingleZipReader(zipfile.ZipFile): # Incompatible override diff --git a/django-stubs/core/management/commands/makemessages.pyi b/django-stubs/core/management/commands/makemessages.pyi index 45a35c53a..bfaa30aa5 100644 --- a/django-stubs/core/management/commands/makemessages.pyi +++ b/django-stubs/core/management/commands/makemessages.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Pattern, Type +from typing import Any, List, Pattern, Type from django.core.management.base import BaseCommand @@ -12,7 +12,7 @@ class TranslatableFile: dirpath: str file_name: str locale_dir: str - def __init__(self, dirpath: str, file_name: str, locale_dir: Optional[str]) -> None: ... + def __init__(self, dirpath: str, file_name: str, locale_dir: str | None) -> None: ... class BuildFile: """ diff --git a/django-stubs/core/management/commands/migrate.pyi b/django-stubs/core/management/commands/migrate.pyi index 6be8d54c0..f757457a4 100644 --- a/django-stubs/core/management/commands/migrate.pyi +++ b/django-stubs/core/management/commands/migrate.pyi @@ -1,4 +1,4 @@ -from typing import Any, Container, Optional, Tuple +from typing import Any, Container, Tuple from django.apps import apps as apps from django.core.management.base import BaseCommand as BaseCommand @@ -23,7 +23,7 @@ class Command(BaseCommand): verbosity: int = ... interactive: bool = ... start: float = ... - def migration_progress_callback(self, action: str, migration: Optional[Any] = ..., fake: bool = ...) -> None: ... + def migration_progress_callback(self, action: str, migration: Any | None = ..., fake: bool = ...) -> None: ... def sync_apps(self, connection: BaseDatabaseWrapper, app_labels: Container[str]) -> None: ... @staticmethod def describe_operation(operation: Operation, backwards: bool) -> Tuple[str, bool]: ... diff --git a/django-stubs/core/management/commands/showmigrations.pyi b/django-stubs/core/management/commands/showmigrations.pyi index b7a59b3c1..8bc981926 100644 --- a/django-stubs/core/management/commands/showmigrations.pyi +++ b/django-stubs/core/management/commands/showmigrations.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List from django.apps import apps as apps from django.core.management.base import BaseCommand as BaseCommand @@ -9,5 +9,5 @@ from django.db.migrations.loader import MigrationLoader as MigrationLoader class Command(BaseCommand): verbosity: int = ... - def show_list(self, connection: BaseDatabaseWrapper, app_names: Optional[List[str]] = ...) -> None: ... - def show_plan(self, connection: BaseDatabaseWrapper, app_names: Optional[List[str]] = ...) -> None: ... + def show_list(self, connection: BaseDatabaseWrapper, app_names: List[str] | None = ...) -> None: ... + def show_plan(self, connection: BaseDatabaseWrapper, app_names: List[str] | None = ...) -> None: ... diff --git a/django-stubs/core/management/commands/sqlmigrate.pyi b/django-stubs/core/management/commands/sqlmigrate.pyi index 0bae1d95c..509ec6ce8 100644 --- a/django-stubs/core/management/commands/sqlmigrate.pyi +++ b/django-stubs/core/management/commands/sqlmigrate.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.apps import apps as apps from django.core.management.base import BaseCommand as BaseCommand @@ -10,4 +10,4 @@ from django.db.migrations.loader import MigrationLoader as MigrationLoader class Command(BaseCommand): output_transaction: bool = ... - def execute(self, *args: Any, **options: Any) -> Optional[str]: ... + def execute(self, *args: Any, **options: Any) -> str | None: ... diff --git a/django-stubs/core/management/templates.pyi b/django-stubs/core/management/templates.pyi index d5fc1354c..21dd8d6c3 100644 --- a/django-stubs/core/management/templates.pyi +++ b/django-stubs/core/management/templates.pyi @@ -1,5 +1,5 @@ from argparse import ArgumentParser -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Sequence, Tuple from django.core.management.base import BaseCommand @@ -11,8 +11,8 @@ class TemplateCommand(BaseCommand): paths_to_remove: Sequence[Any] verbosity: Any = ... def add_arguments(self, parser: ArgumentParser) -> None: ... - def handle(self, app_or_project: str, name: str, target: Optional[str] = ..., **options: Any) -> None: ... - def handle_template(self, template: Optional[str], subdir: Optional[str]) -> str: ... + def handle(self, app_or_project: str, name: str, target: str | None = ..., **options: Any) -> None: ... + def handle_template(self, template: str | None, subdir: str | None) -> str: ... def validate_name(self, name: str, name_or_dir: str = ...) -> None: ... def download(self, url: str) -> str: ... def splitext(self, the_path: str) -> Tuple[str, str]: ... diff --git a/django-stubs/core/management/utils.pyi b/django-stubs/core/management/utils.pyi index 62c07d3ec..664bc56dd 100644 --- a/django-stubs/core/management/utils.pyi +++ b/django-stubs/core/management/utils.pyi @@ -1,5 +1,5 @@ import os -from typing import Any, Iterable, List, Optional, Sequence, Set, Tuple, Type, Union +from typing import Any, Iterable, List, Sequence, Set, Tuple, Type from django.apps.config import AppConfig from django.db.models.base import Model @@ -8,11 +8,11 @@ def popen_wrapper(args: List[str], stdout_encoding: str = ...) -> Tuple[str, str def handle_extensions(extensions: Iterable[str]) -> Set[str]: ... def find_command( cmd: str, - path: Optional[Union[str, Iterable[str]]] = ..., - pathext: Optional[Union[str, Iterable[str]]] = ..., -) -> Optional[str]: ... + path: str | Iterable[str] | None = ..., + pathext: str | Iterable[str] | None = ..., +) -> str | None: ... def get_random_secret_key() -> str: ... def parse_apps_and_model_labels(labels: Iterable[str]) -> Tuple[Set[Type[Model]], Set[AppConfig]]: ... -def get_command_line_option(argv: Sequence[Any], option: Any) -> Optional[Any]: ... +def get_command_line_option(argv: Sequence[Any], option: Any) -> Any | None: ... def normalize_path_patterns(patterns: Iterable[str]) -> List[str]: ... -def is_ignored_path(path: Union[str, os.PathLike], ignore_patterns: Iterable[str]) -> bool: ... +def is_ignored_path(path: str | os.PathLike, ignore_patterns: Iterable[str]) -> bool: ... diff --git a/django-stubs/core/paginator.pyi b/django-stubs/core/paginator.pyi index 9fe4ca2a6..5b20bee7e 100644 --- a/django-stubs/core/paginator.pyi +++ b/django-stubs/core/paginator.pyi @@ -1,4 +1,4 @@ -from typing import Generic, Iterable, Iterator, Optional, Protocol, Sequence, Sized, TypeVar, Union, overload +from typing import Generic, Iterable, Iterator, Protocol, Sequence, Sized, TypeVar, overload from django.db.models.base import Model from django.db.models.query import QuerySet @@ -24,14 +24,14 @@ class Paginator(Generic[_T]): def __init__( self, object_list: _SupportsPagination[_T], - per_page: Union[int, str], + per_page: int | str, orphans: int = ..., allow_empty_first_page: bool = ..., ) -> None: ... def __iter__(self) -> Iterator[Page[_T]]: ... - def validate_number(self, number: Union[int, float, str]) -> int: ... - def get_page(self, number: Union[int, float, str, None]) -> Page[_T]: ... - def page(self, number: Union[int, str]) -> Page[_T]: ... + def validate_number(self, number: int | float | str) -> int: ... + def get_page(self, number: int | float | str | None) -> Page[_T]: ... + def page(self, number: int | str) -> Page[_T]: ... @property def count(self) -> int: ... @property @@ -39,8 +39,8 @@ class Paginator(Generic[_T]): @property def page_range(self) -> range: ... def get_elided_page_range( - self, number: Union[int, float, str] = ..., *, on_each_side: int = ..., on_ends: int = ... - ) -> Iterator[Union[str, int]]: ... + self, number: int | float | str = ..., *, on_each_side: int = ..., on_ends: int = ... + ) -> Iterator[str | int]: ... QuerySetPaginator = Paginator diff --git a/django-stubs/core/serializers/__init__.pyi b/django-stubs/core/serializers/__init__.pyi index 62ae4e2d5..9c1cdd353 100644 --- a/django-stubs/core/serializers/__init__.pyi +++ b/django-stubs/core/serializers/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Type, Union +from typing import Any, Callable, Dict, Iterable, Iterator, List, Type from django.db.models.base import Model @@ -18,12 +18,12 @@ class BadSerializer: def __init__(self, exception: BaseException) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... -def register_serializer(format: str, serializer_module: str, serializers: Optional[Dict[str, Any]] = ...) -> None: ... +def register_serializer(format: str, serializer_module: str, serializers: Dict[str, Any] | None = ...) -> None: ... def unregister_serializer(format: str) -> None: ... -def get_serializer(format: str) -> Union[Type[Serializer], BadSerializer]: ... +def get_serializer(format: str) -> Type[Serializer] | BadSerializer: ... def get_serializer_formats() -> List[str]: ... def get_public_serializer_formats() -> List[str]: ... -def get_deserializer(format: str) -> Union[Callable, Type[Deserializer]]: ... +def get_deserializer(format: str) -> Callable | Type[Deserializer]: ... def serialize(format: str, queryset: Iterable[Model], **options: Any) -> Any: ... def deserialize(format: str, stream_or_string: Any, **options: Any) -> Iterator[DeserializedObject]: ... def sort_dependencies(app_list: Iterable[Any], allow_cycles: bool = ...) -> List[Type[Model]]: ... diff --git a/django-stubs/core/serializers/base.pyi b/django-stubs/core/serializers/base.pyi index 0d7debe49..aa3aec795 100644 --- a/django-stubs/core/serializers/base.pyi +++ b/django-stubs/core/serializers/base.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Collection, Dict, Iterable, Optional, Sequence, Type, Union +from typing import IO, Any, Collection, Dict, Iterable, Sequence, Type from django.db.models.base import Model from django.db.models.fields import Field @@ -12,7 +12,7 @@ class SerializationError(Exception): ... class DeserializationError(Exception): @classmethod def WithData( - cls, original_exc: Exception, model: str, fk: Union[int, str], field_value: Optional[Union[Sequence[str], str]] + cls, original_exc: Exception, model: str, fk: int | str, field_value: Sequence[str] | str | None ) -> DeserializationError: ... class M2MDeserializationError(Exception): @@ -22,10 +22,10 @@ class M2MDeserializationError(Exception): class ProgressBar: progress_width: int = ... - output: Optional[IO[str]] = ... + output: IO[str] | None = ... total_count: int = ... prev_done: int = ... - def __init__(self, output: Optional[IO[str]], total_count: int) -> None: ... + def __init__(self, output: IO[str] | None, total_count: int) -> None: ... def update(self, count: int) -> None: ... class Serializer: @@ -34,7 +34,7 @@ class Serializer: stream_class: Type[IO[str]] = ... options: Dict[str, Any] = ... stream: IO[str] = ... - selected_fields: Optional[Collection[str]] = ... + selected_fields: Collection[str] | None = ... use_natural_foreign_keys: bool = ... use_natural_primary_keys: bool = ... first: bool = ... @@ -42,11 +42,11 @@ class Serializer: self, queryset: Iterable[Model], *, - stream: Optional[IO[str]] = ..., - fields: Optional[Collection[str]] = ..., + stream: IO[str] | None = ..., + fields: Collection[str] | None = ..., use_natural_foreign_keys: bool = ..., use_natural_primary_keys: bool = ..., - progress_output: Optional[IO[str]] = ..., + progress_output: IO[str] | None = ..., object_count: int = ..., **options: Any ) -> Any: ... @@ -57,32 +57,32 @@ class Serializer: def handle_field(self, obj: Any, field: Any) -> None: ... def handle_fk_field(self, obj: Any, field: Any) -> None: ... def handle_m2m_field(self, obj: Any, field: Any) -> None: ... - def getvalue(self) -> Optional[Union[bytes, str]]: ... + def getvalue(self) -> bytes | str | None: ... class Deserializer: options: Dict[str, Any] = ... - stream: Union[IO[str], IO[bytes]] = ... - def __init__(self, stream_or_string: Union[bytes, str, IO[bytes], IO[str]], **options: Any) -> None: ... + stream: IO[str] | IO[bytes] = ... + def __init__(self, stream_or_string: bytes | str | IO[bytes] | IO[str], **options: Any) -> None: ... def __iter__(self) -> Deserializer: ... def __next__(self) -> Any: ... class DeserializedObject: object: Any = ... - m2m_data: Optional[Dict[str, Sequence[Any]]] = ... + m2m_data: Dict[str, Sequence[Any]] | None = ... deferred_fields: Dict[Field, Any] def __init__( self, obj: Model, - m2m_data: Optional[Dict[str, Sequence[Any]]] = ..., - deferred_fields: Optional[Dict[Field, Any]] = ..., + m2m_data: Dict[str, Sequence[Any]] | None = ..., + deferred_fields: Dict[Field, Any] | None = ..., ) -> None: ... - def save(self, save_m2m: bool = ..., using: Optional[str] = ..., **kwargs: Any) -> None: ... - def save_deferred_fields(self, using: Optional[str] = ...) -> None: ... + def save(self, save_m2m: bool = ..., using: str | None = ..., **kwargs: Any) -> None: ... + def save_deferred_fields(self, using: str | None = ...) -> None: ... def build_instance(Model: Type[Model], data: Dict[str, Any], db: str) -> Model: ... def deserialize_m2m_values( - field: ManyToManyField, field_value: Iterable[Any], using: Optional[str], handle_forward_references: bool -) -> Union[Sequence[Any], object]: ... + field: ManyToManyField, field_value: Iterable[Any], using: str | None, handle_forward_references: bool +) -> Sequence[Any] | object: ... def deserialize_fk_value( - field: ForeignKey, field_value: Any, using: Optional[str], handle_forward_references: bool -) -> Union[Any, object]: ... + field: ForeignKey, field_value: Any, using: str | None, handle_forward_references: bool +) -> Any | object: ... diff --git a/django-stubs/core/serializers/json.pyi b/django-stubs/core/serializers/json.pyi index fd7499c7e..6618b041a 100644 --- a/django-stubs/core/serializers/json.pyi +++ b/django-stubs/core/serializers/json.pyi @@ -1,5 +1,5 @@ import json -from typing import IO, Any, Dict, Iterator, Union +from typing import IO, Any, Dict, Iterator from django.core.serializers.base import DeserializedObject from django.core.serializers.python import Serializer as PythonSerializer @@ -8,7 +8,7 @@ class Serializer(PythonSerializer): json_kwargs: Dict[str, Any] def Deserializer( - stream_or_string: Union[IO[bytes], IO[str], bytes, str], **options: Any + stream_or_string: IO[bytes] | IO[str] | bytes | str, **options: Any ) -> Iterator[DeserializedObject]: ... class DjangoJSONEncoder(json.JSONEncoder): diff --git a/django-stubs/core/serializers/jsonl.pyi b/django-stubs/core/serializers/jsonl.pyi index 127038515..764378eb6 100644 --- a/django-stubs/core/serializers/jsonl.pyi +++ b/django-stubs/core/serializers/jsonl.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Dict, Iterator, Union +from typing import IO, Any, Dict, Iterator from django.core.serializers.base import DeserializedObject from django.core.serializers.python import Serializer as PythonSerializer @@ -7,5 +7,5 @@ class Serializer(PythonSerializer): json_kwargs: Dict[str, Any] def Deserializer( - stream_or_string: Union[IO[bytes], IO[str], bytes, str], **options: Any + stream_or_string: IO[bytes] | IO[str] | bytes | str, **options: Any ) -> Iterator[DeserializedObject]: ... diff --git a/django-stubs/core/serializers/pyyaml.pyi b/django-stubs/core/serializers/pyyaml.pyi index 3cb695ba7..f37b90eb9 100644 --- a/django-stubs/core/serializers/pyyaml.pyi +++ b/django-stubs/core/serializers/pyyaml.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Iterator, Union +from typing import IO, Any, Iterator from django.core.serializers.base import DeserializedObject from django.core.serializers.python import Serializer as PythonSerializer @@ -17,5 +17,5 @@ class Serializer(PythonSerializer): def getvalue(self) -> Any: ... def Deserializer( - stream_or_string: Union[bytes, str, IO[bytes], IO[str]], **options: Any + stream_or_string: bytes | str | IO[bytes] | IO[str], **options: Any ) -> Iterator[DeserializedObject]: ... diff --git a/django-stubs/core/serializers/xml_serializer.pyi b/django-stubs/core/serializers/xml_serializer.pyi index 4a7216214..46a73e84f 100644 --- a/django-stubs/core/serializers/xml_serializer.pyi +++ b/django-stubs/core/serializers/xml_serializer.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Union +from typing import IO, Any from xml.sax.expatreader import ExpatParser as _ExpatParser from django.core.serializers import base as base @@ -21,7 +21,7 @@ class Deserializer(base.Deserializer): ignore: bool = ... def __init__( self, - stream_or_string: Union[bytes, str, IO[bytes], IO[str]], + stream_or_string: bytes | str | IO[bytes] | IO[str], *, using: str = ..., ignorenonexistent: bool = ..., diff --git a/django-stubs/core/signing.pyi b/django-stubs/core/signing.pyi index c07a3310b..605ba49b4 100644 --- a/django-stubs/core/signing.pyi +++ b/django-stubs/core/signing.pyi @@ -1,12 +1,12 @@ from datetime import timedelta -from typing import Any, Dict, Optional, Protocol, Type, Union +from typing import Any, Dict, Protocol, Type class BadSignature(Exception): ... class SignatureExpired(BadSignature): ... def b64_encode(s: bytes) -> bytes: ... def b64_decode(s: bytes) -> bytes: ... -def base64_hmac(salt: str, value: Union[bytes, str], key: Union[bytes, str], algorithm: str = ...) -> str: ... +def base64_hmac(salt: str, value: bytes | str, key: bytes | str, algorithm: str = ...) -> str: ... def get_cookie_signer(salt: str = ...) -> TimestampSigner: ... class Serializer(Protocol): @@ -19,17 +19,17 @@ class JSONSerializer: def dumps( obj: Any, - key: Optional[Union[bytes, str]] = ..., + key: bytes | str | None = ..., salt: str = ..., serializer: Type[Serializer] = ..., compress: bool = ..., ) -> str: ... def loads( s: str, - key: Optional[Union[bytes, str]] = ..., + key: bytes | str | None = ..., salt: str = ..., serializer: Type[Serializer] = ..., - max_age: Optional[Union[int, timedelta]] = ..., + max_age: int | timedelta | None = ..., ) -> Any: ... class Signer: @@ -39,12 +39,12 @@ class Signer: algorithm: str = ... def __init__( self, - key: Optional[Union[bytes, str]] = ..., + key: bytes | str | None = ..., sep: str = ..., - salt: Optional[str] = ..., - algorithm: Optional[str] = ..., + salt: str | None = ..., + algorithm: str | None = ..., ) -> None: ... - def signature(self, value: Union[bytes, str]) -> str: ... + def signature(self, value: bytes | str) -> str: ... def sign(self, value: str) -> str: ... def unsign(self, signed_value: str) -> str: ... def sign_object( @@ -63,4 +63,4 @@ class Signer: class TimestampSigner(Signer): def timestamp(self) -> str: ... def sign(self, value: str) -> str: ... - def unsign(self, value: str, max_age: Optional[Union[int, timedelta]] = ...) -> str: ... + def unsign(self, value: str, max_age: int | timedelta | None = ...) -> str: ... diff --git a/django-stubs/core/validators.pyi b/django-stubs/core/validators.pyi index d5b24d44b..404ab32f2 100644 --- a/django-stubs/core/validators.pyi +++ b/django-stubs/core/validators.pyi @@ -1,28 +1,28 @@ from decimal import Decimal from re import RegexFlag -from typing import Any, Callable, Collection, Dict, List, Optional, Pattern, Sequence, Sized, Tuple, Union +from typing import Any, Callable, Collection, Dict, List, Pattern, Sequence, Sized, Tuple from django.core.files.base import File from django.utils.functional import _StrPromise EMPTY_VALUES: Any -_Regex = Union[str, Pattern[str]] +_Regex = str | Pattern[str] _ValidatorCallable = Callable[[Any], None] class RegexValidator: regex: _Regex = ... # Pattern[str] on instance, but may be str on class definition - message: Union[str, _StrPromise] = ... + message: str | _StrPromise = ... code: str = ... inverse_match: bool = ... flags: int = ... def __init__( self, - regex: Optional[_Regex] = ..., - message: Union[str, _StrPromise, None] = ..., - code: Optional[str] = ..., - inverse_match: Optional[bool] = ..., - flags: Optional[RegexFlag] = ..., + regex: _Regex | None = ..., + message: str | _StrPromise | None = ..., + code: str | None = ..., + inverse_match: bool | None = ..., + flags: RegexFlag | None = ..., ) -> None: ... def __call__(self, value: Any) -> None: ... @@ -35,12 +35,12 @@ class URLValidator(RegexValidator): tld_re: str = ... host_re: str = ... schemes: Sequence[str] = ... - def __init__(self, schemes: Optional[Sequence[str]] = ..., **kwargs: Any) -> None: ... + def __init__(self, schemes: Sequence[str] | None = ..., **kwargs: Any) -> None: ... def __call__(self, value: str) -> None: ... integer_validator: RegexValidator = ... -def validate_integer(value: Optional[Union[float, str]]) -> None: ... +def validate_integer(value: float | str | None) -> None: ... class EmailValidator: message: str = ... @@ -51,17 +51,17 @@ class EmailValidator: domain_allowlist: Sequence[str] = ... def __init__( self, - message: Optional[str] = ..., - code: Optional[str] = ..., - allowlist: Optional[Sequence[str]] = ..., + message: str | None = ..., + code: str | None = ..., + allowlist: Sequence[str] | None = ..., *, - whitelist: Optional[Sequence[str]] = ..., + whitelist: Sequence[str] | None = ..., ) -> None: ... @property def domain_whitelist(self) -> Sequence[str]: ... @domain_whitelist.setter def domain_whitelist(self, allowlist: Sequence[str]) -> None: ... - def __call__(self, value: Optional[str]) -> None: ... + def __call__(self, value: str | None) -> None: ... def validate_domain_part(self, domain_part: str) -> bool: ... def __eq__(self, other: Any) -> bool: ... @@ -80,7 +80,7 @@ ip_address_validator_map: Dict[str, _IPValidator] def ip_address_validators(protocol: str, unpack_ipv4: bool) -> _IPValidator: ... def int_list_validator( - sep: str = ..., message: Optional[str] = ..., code: str = ..., allow_negative: bool = ... + sep: str = ..., message: str | None = ..., code: str = ..., allow_negative: bool = ... ) -> RegexValidator: ... validate_comma_separated_integer_list: RegexValidator @@ -89,7 +89,7 @@ class BaseValidator: message: str = ... code: str = ... limit_value: Any = ... - def __init__(self, limit_value: Any, message: Optional[str] = ...) -> None: ... + def __init__(self, limit_value: Any, message: str | None = ...) -> None: ... def __call__(self, value: Any) -> None: ... def compare(self, a: Any, b: Any) -> bool: ... def clean(self, x: Any) -> Any: ... @@ -119,21 +119,21 @@ class MaxLengthValidator(BaseValidator): class DecimalValidator: messages: Dict[str, str] = ... - max_digits: Optional[int] = ... - decimal_places: Optional[int] = ... - def __init__(self, max_digits: Optional[int], decimal_places: Optional[int]) -> None: ... + max_digits: int | None = ... + decimal_places: int | None = ... + def __init__(self, max_digits: int | None, decimal_places: int | None) -> None: ... def __call__(self, value: Decimal) -> None: ... def __eq__(self, other: Any) -> bool: ... class FileExtensionValidator: message: str = ... code: str = ... - allowed_extensions: Optional[Collection[str]] = ... + allowed_extensions: Collection[str] | None = ... def __init__( self, - allowed_extensions: Optional[Collection[str]] = ..., - message: Optional[str] = ..., - code: Optional[str] = ..., + allowed_extensions: Collection[str] | None = ..., + message: str | None = ..., + code: str | None = ..., ) -> None: ... def __call__(self, value: File) -> None: ... @@ -143,5 +143,5 @@ def validate_image_file_extension(value: File) -> None: ... class ProhibitNullCharactersValidator: message: str = ... code: str = ... - def __init__(self, message: Optional[str] = ..., code: Optional[str] = ...) -> None: ... + def __init__(self, message: str | None = ..., code: str | None = ...) -> None: ... def __call__(self, value: Any) -> None: ... diff --git a/django-stubs/db/backends/base/base.pyi b/django-stubs/db/backends/base/base.pyi index ba39dec70..04ae26b22 100644 --- a/django-stubs/db/backends/base/base.pyi +++ b/django-stubs/db/backends/base/base.pyi @@ -1,6 +1,6 @@ from contextlib import contextmanager from datetime import tzinfo -from typing import Any, Callable, Dict, Generator, Iterator, List, MutableMapping, Optional, Set, Tuple, Type, TypeVar +from typing import Any, Callable, Dict, Generator, Iterator, List, MutableMapping, Set, Tuple, Type, TypeVar from django.db.backends.base.client import BaseDatabaseClient from django.db.backends.base.creation import BaseDatabaseCreation @@ -42,7 +42,7 @@ class BaseDatabaseWrapper: savepoint_ids: List[str] = ... commit_on_exit: bool = ... needs_rollback: bool = ... - close_at: Optional[float] = ... + close_at: float | None = ... closed_in_transaction: bool = ... errors_occurred: bool = ... run_on_commit: List[Tuple[Set[str], Callable[[], None]]] = ... @@ -58,7 +58,7 @@ class BaseDatabaseWrapper: def __init__(self, settings_dict: Dict[str, Any], alias: str = ...) -> None: ... def ensure_timezone(self) -> bool: ... @property - def timezone(self) -> Optional[tzinfo]: ... + def timezone(self) -> tzinfo | None: ... @property def timezone_name(self) -> str: ... @property @@ -70,7 +70,7 @@ class BaseDatabaseWrapper: def get_connection_params(self) -> Dict[str, Any]: ... def get_new_connection(self, conn_params: Any) -> Any: ... def init_connection_state(self) -> None: ... - def create_cursor(self, name: Optional[Any] = ...) -> Any: ... + def create_cursor(self, name: Any | None = ...) -> Any: ... def connect(self) -> None: ... def check_settings(self) -> None: ... def ensure_connection(self) -> None: ... @@ -78,7 +78,7 @@ class BaseDatabaseWrapper: def commit(self) -> None: ... def rollback(self) -> None: ... def close(self) -> None: ... - def savepoint(self) -> Optional[str]: ... + def savepoint(self) -> str | None: ... def savepoint_rollback(self, sid: str) -> None: ... def savepoint_commit(self, sid: str) -> None: ... def clean_savepoints(self) -> None: ... @@ -92,7 +92,7 @@ class BaseDatabaseWrapper: def constraint_checks_disabled(self) -> Iterator[None]: ... def disable_constraint_checking(self) -> bool: ... def enable_constraint_checking(self) -> None: ... - def check_constraints(self, table_names: Optional[Any] = ...) -> None: ... + def check_constraints(self, table_names: Any | None = ...) -> None: ... def is_usable(self) -> bool: ... def close_if_unusable_or_obsolete(self) -> None: ... @property @@ -115,4 +115,4 @@ class BaseDatabaseWrapper: def run_and_clear_commit_hooks(self) -> None: ... @contextmanager def execute_wrapper(self, wrapper: _ExecuteWrapper) -> Generator[None, None, None]: ... - def copy(self: _T, alias: Optional[str] = ...) -> _T: ... + def copy(self: _T, alias: str | None = ...) -> _T: ... diff --git a/django-stubs/db/backends/base/client.pyi b/django-stubs/db/backends/base/client.pyi index c2a503a71..bdf313778 100644 --- a/django-stubs/db/backends/base/client.pyi +++ b/django-stubs/db/backends/base/client.pyi @@ -1,9 +1,9 @@ -from typing import Any, Dict, Iterable, Optional, Sequence, Tuple +from typing import Any, Dict, Iterable, Sequence, Tuple from django.db.backends.base.base import BaseDatabaseWrapper class BaseDatabaseClient: - executable_name: Optional[str] = ... + executable_name: str | None = ... connection: BaseDatabaseWrapper def __init__(self, connection: BaseDatabaseWrapper) -> None: ... @classmethod @@ -11,5 +11,5 @@ class BaseDatabaseClient: cls, settings_dict: Dict[str, Any], parameters: Iterable[str], - ) -> Tuple[Sequence[str], Optional[Dict[str, str]]]: ... + ) -> Tuple[Sequence[str], Dict[str, str] | None]: ... def runshell(self, parameters: Iterable[str]) -> None: ... diff --git a/django-stubs/db/backends/base/creation.pyi b/django-stubs/db/backends/base/creation.pyi index 95767f9f6..9c410d55d 100644 --- a/django-stubs/db/backends/base/creation.pyi +++ b/django-stubs/db/backends/base/creation.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Tuple, Union +from typing import Any, Dict, Tuple from django.db.backends.base.base import BaseDatabaseWrapper @@ -10,19 +10,17 @@ class BaseDatabaseCreation: def create_test_db( self, verbosity: int = ..., autoclobber: bool = ..., serialize: bool = ..., keepdb: bool = ... ) -> str: ... - def set_as_test_mirror( - self, primary_settings_dict: Dict[str, Optional[Union[Dict[str, None], int, str]]] - ) -> None: ... + def set_as_test_mirror(self, primary_settings_dict: Dict[str, Dict[str, None] | int | str | None]) -> None: ... def serialize_db_to_string(self) -> str: ... def deserialize_db_from_string(self, data: str) -> None: ... def clone_test_db(self, suffix: Any, verbosity: int = ..., autoclobber: bool = ..., keepdb: bool = ...) -> None: ... def get_test_db_clone_settings(self, suffix: str) -> Dict[str, Any]: ... def destroy_test_db( self, - old_database_name: Optional[str] = ..., + old_database_name: str | None = ..., verbosity: int = ..., keepdb: bool = ..., - suffix: Optional[str] = ..., + suffix: str | None = ..., ) -> None: ... def sql_table_creation_suffix(self) -> str: ... def test_db_signature(self) -> Tuple[str, str, str, str]: ... diff --git a/django-stubs/db/backends/base/features.pyi b/django-stubs/db/backends/base/features.pyi index 3aef289e6..53dc0a509 100644 --- a/django-stubs/db/backends/base/features.pyi +++ b/django-stubs/db/backends/base/features.pyi @@ -1,11 +1,11 @@ -from typing import Any, Dict, Optional, Sequence, Set, Tuple, Type +from typing import Any, Dict, Sequence, Set, Tuple, Type from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.base import Model from django.db.utils import DatabaseError class BaseDatabaseFeatures: - minimum_database_version: Optional[Tuple[int, ...]] + minimum_database_version: Tuple[int, ...] | None gis_enabled: bool allows_group_by_lob: bool allows_group_by_pk: bool @@ -47,7 +47,7 @@ class BaseDatabaseFeatures: nulls_order_largest: bool supports_order_by_nulls_modifier: bool order_by_nulls_first: bool - max_query_params: Optional[int] + max_query_params: int | None allows_auto_pk_0: bool can_defer_constraint_checks: bool supports_tablespaces: bool @@ -93,8 +93,8 @@ class BaseDatabaseFeatures: only_supports_unbounded_with_preceding_and_following: bool supports_cast_with_precision: bool time_cast_precision: int - create_test_procedure_without_params_sql: Optional[str] - create_test_procedure_with_int_param_sql: Optional[str] + create_test_procedure_without_params_sql: str | None + create_test_procedure_with_int_param_sql: str | None supports_callproc_kwargs: bool supported_explain_formats: Set[str] supports_default_in_lead_lag: bool @@ -120,8 +120,8 @@ class BaseDatabaseFeatures: supports_collation_on_charfield: bool supports_collation_on_textfield: bool supports_non_deterministic_collations: bool - test_collations: Dict[str, Optional[str]] - test_now_utc_template: Optional[str] + test_collations: Dict[str, str | None] + test_now_utc_template: str | None django_test_expected_failures: Set[str] django_test_skips: Dict[str, Set[str]] connection: BaseDatabaseWrapper diff --git a/django-stubs/db/backends/base/introspection.pyi b/django-stubs/db/backends/base/introspection.pyi index 2c976ee33..fe9706abd 100644 --- a/django-stubs/db/backends/base/introspection.pyi +++ b/django-stubs/db/backends/base/introspection.pyi @@ -1,5 +1,5 @@ from collections import namedtuple -from typing import Any, Dict, Iterable, List, Optional, Set, Type +from typing import Any, Dict, Iterable, List, Set, Type from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.utils import CursorWrapper @@ -17,15 +17,15 @@ class BaseDatabaseIntrospection: def __init__(self, connection: BaseDatabaseWrapper) -> None: ... def get_field_type(self, data_type: str, description: FieldInfo) -> str: ... def identifier_converter(self, name: str) -> str: ... - def table_names(self, cursor: Optional[CursorWrapper] = ..., include_views: bool = ...) -> List[str]: ... - def get_table_list(self, cursor: Optional[CursorWrapper]) -> Any: ... - def get_table_description(self, cursor: Optional[CursorWrapper], table_name: str) -> Any: ... + def table_names(self, cursor: CursorWrapper | None = ..., include_views: bool = ...) -> List[str]: ... + def get_table_list(self, cursor: CursorWrapper | None) -> Any: ... + def get_table_description(self, cursor: CursorWrapper | None, table_name: str) -> Any: ... def get_migratable_models(self) -> Iterable[Type[Model]]: ... def django_table_names(self, only_existing: bool = ..., include_views: bool = ...) -> List[str]: ... def installed_models(self, tables: List[str]) -> Set[Type[Model]]: ... def sequence_list(self) -> List[Dict[str, str]]: ... - def get_sequences(self, cursor: Optional[CursorWrapper], table_name: str, table_fields: Any = ...) -> Any: ... - def get_relations(self, cursor: Optional[CursorWrapper], table_name: str) -> Any: ... - def get_key_columns(self, cursor: Optional[CursorWrapper], table_name: str) -> Any: ... - def get_primary_key_column(self, cursor: Optional[CursorWrapper], table_name: str) -> Optional[str]: ... - def get_constraints(self, cursor: Optional[CursorWrapper], table_name: str) -> Any: ... + def get_sequences(self, cursor: CursorWrapper | None, table_name: str, table_fields: Any = ...) -> Any: ... + def get_relations(self, cursor: CursorWrapper | None, table_name: str) -> Any: ... + def get_key_columns(self, cursor: CursorWrapper | None, table_name: str) -> Any: ... + def get_primary_key_column(self, cursor: CursorWrapper | None, table_name: str) -> str | None: ... + def get_constraints(self, cursor: CursorWrapper | None, table_name: str) -> Any: ... diff --git a/django-stubs/db/backends/base/operations.pyi b/django-stubs/db/backends/base/operations.pyi index 9d0778b63..9fad1b069 100644 --- a/django-stubs/db/backends/base/operations.pyi +++ b/django-stubs/db/backends/base/operations.pyi @@ -2,7 +2,7 @@ from datetime import date from datetime import datetime as real_datetime from datetime import time, timedelta from decimal import Decimal -from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Type, Union +from typing import Any, Dict, Iterable, List, Sequence, Tuple, Type from django.core.management.color import Style from django.db.backends.base.base import BaseDatabaseWrapper @@ -23,35 +23,35 @@ class BaseDatabaseOperations: UNBOUNDED_PRECEDING: str = ... UNBOUNDED_FOLLOWING: str = ... CURRENT_ROW: str = ... - explain_prefix: Optional[str] = ... + explain_prefix: str | None = ... connection: BaseDatabaseWrapper def __init__(self, connection: BaseDatabaseWrapper) -> None: ... - def autoinc_sql(self, table: str, column: str) -> Optional[str]: ... + def autoinc_sql(self, table: str, column: str) -> str | None: ... def bulk_batch_size(self, fields: Any, objs: Any) -> int: ... def cache_key_culling_sql(self) -> str: ... def unification_cast_sql(self, output_field: Field) -> str: ... def date_extract_sql(self, lookup_type: str, field_name: str) -> Any: ... # def date_interval_sql(self, timedelta: None) -> Any: ... - def date_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str] = ...) -> str: ... - def datetime_cast_date_sql(self, field_name: str, tzname: Optional[str]) -> str: ... - def datetime_cast_time_sql(self, field_name: str, tzname: Optional[str]) -> str: ... - def datetime_extract_sql(self, lookup_type: str, field_name: str, tzname: Optional[str]) -> str: ... - def datetime_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str]) -> str: ... - def time_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str] = ...) -> str: ... + def date_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None = ...) -> str: ... + def datetime_cast_date_sql(self, field_name: str, tzname: str | None) -> str: ... + def datetime_cast_time_sql(self, field_name: str, tzname: str | None) -> str: ... + def datetime_extract_sql(self, lookup_type: str, field_name: str, tzname: str | None) -> str: ... + def datetime_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None) -> str: ... + def time_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None = ...) -> str: ... def time_extract_sql(self, lookup_type: str, field_name: str) -> str: ... def deferrable_sql(self) -> str: ... - def distinct_sql(self, fields: List[str], params: Optional[List[Any]]) -> Tuple[List[str], List[str]]: ... + def distinct_sql(self, fields: List[str], params: List[Any] | None) -> Tuple[List[str], List[str]]: ... def fetch_returned_insert_columns(self, cursor: Any, returning_params: Any) -> Any: ... - def field_cast_sql(self, db_type: Optional[str], internal_type: str) -> str: ... + def field_cast_sql(self, db_type: str | None, internal_type: str) -> str: ... def force_no_ordering(self) -> List[Any]: ... def for_update_sql(self, nowait: bool = ..., skip_locked: bool = ..., of: Any = ..., no_key: bool = ...) -> str: ... - def limit_offset_sql(self, low_mark: int, high_mark: Optional[int]) -> str: ... + def limit_offset_sql(self, low_mark: int, high_mark: int | None) -> str: ... def last_executed_query(self, cursor: Any, sql: Any, params: Any) -> str: ... def last_insert_id(self, cursor: CursorWrapper, table_name: str, pk_name: str) -> int: ... - def lookup_cast(self, lookup_type: str, internal_type: Optional[str] = ...) -> str: ... - def max_in_list_size(self) -> Optional[int]: ... - def max_name_length(self) -> Optional[int]: ... - def no_limit_value(self) -> Optional[str]: ... + def lookup_cast(self, lookup_type: str, internal_type: str | None = ...) -> str: ... + def max_in_list_size(self) -> int | None: ... + def max_name_length(self) -> int | None: ... + def no_limit_value(self) -> str | None: ... def pk_default_value(self) -> str: ... def prepare_sql_script(self, sql: Any) -> List[str]: ... def process_clob(self, value: str) -> str: ... @@ -67,40 +67,40 @@ class BaseDatabaseOperations: self, style: Any, tables: Sequence[str], *, reset_sequences: bool = ..., allow_cascade: bool = ... ) -> List[str]: ... def execute_sql_flush(self, sql_list: Iterable[str]) -> None: ... - def sequence_reset_by_name_sql(self, style: Optional[Style], sequences: List[Any]) -> List[Any]: ... + def sequence_reset_by_name_sql(self, style: Style | None, sequences: List[Any]) -> List[Any]: ... def sequence_reset_sql(self, style: Style, model_list: Sequence[Type[Model]]) -> List[Any]: ... def start_transaction_sql(self) -> str: ... def end_transaction_sql(self, success: bool = ...) -> str: ... - def tablespace_sql(self, tablespace: Optional[str], inline: bool = ...) -> str: ... + def tablespace_sql(self, tablespace: str | None, inline: bool = ...) -> str: ... def prep_for_like_query(self, x: str) -> str: ... prep_for_iexact_query: Any = ... def validate_autopk_value(self, value: int) -> int: ... def adapt_unknown_value(self, value: Any) -> Any: ... - def adapt_datefield_value(self, value: Optional[date]) -> Optional[str]: ... - def adapt_datetimefield_value(self, value: Optional[real_datetime]) -> Optional[str]: ... - def adapt_timefield_value(self, value: Optional[Union[real_datetime, time]]) -> Optional[str]: ... + def adapt_datefield_value(self, value: date | None) -> str | None: ... + def adapt_datetimefield_value(self, value: real_datetime | None) -> str | None: ... + def adapt_timefield_value(self, value: real_datetime | time | None) -> str | None: ... def adapt_decimalfield_value( - self, value: Optional[Decimal], max_digits: Optional[int] = ..., decimal_places: Optional[int] = ... - ) -> Optional[str]: ... - def adapt_ipaddressfield_value(self, value: Optional[str]) -> Optional[str]: ... + self, value: Decimal | None, max_digits: int | None = ..., decimal_places: int | None = ... + ) -> str | None: ... + def adapt_ipaddressfield_value(self, value: str | None) -> str | None: ... def year_lookup_bounds_for_date_field(self, value: int) -> List[str]: ... def year_lookup_bounds_for_datetime_field(self, value: int) -> List[str]: ... def get_db_converters(self, expression: Expression) -> List[Any]: ... def convert_durationfield_value( - self, value: Optional[float], expression: Expression, connection: BaseDatabaseWrapper - ) -> Optional[timedelta]: ... + self, value: float | None, expression: Expression, connection: BaseDatabaseWrapper + ) -> timedelta | None: ... def check_expression_support(self, expression: Any) -> None: ... def conditional_expression_supported_in_where_clause(self, expression: Any) -> bool: ... def combine_expression(self, connector: str, sub_expressions: List[str]) -> str: ... def combine_duration_expression(self, connector: Any, sub_expressions: Any) -> str: ... - def binary_placeholder_sql(self, value: Optional[Case]) -> str: ... + def binary_placeholder_sql(self, value: Case | None) -> str: ... def modify_insert_params(self, placeholder: str, params: Any) -> Any: ... def integer_field_range(self, internal_type: Any) -> Tuple[int, int]: ... def subtract_temporals(self, internal_type: Any, lhs: Any, rhs: Any) -> Tuple[str, Tuple[Any, ...]]: ... def window_frame_start(self, start: Any) -> str: ... def window_frame_end(self, end: Any) -> str: ... - def window_frame_rows_start_end(self, start: Optional[int] = ..., end: Optional[int] = ...) -> Tuple[str, str]: ... - def window_frame_range_start_end(self, start: Optional[int] = ..., end: Optional[int] = ...) -> Tuple[str, str]: ... - def explain_query_prefix(self, format: Optional[str] = ..., **options: Any) -> str: ... + def window_frame_rows_start_end(self, start: int | None = ..., end: int | None = ...) -> Tuple[str, str]: ... + def window_frame_range_start_end(self, start: int | None = ..., end: int | None = ...) -> Tuple[str, str]: ... + def explain_query_prefix(self, format: str | None = ..., **options: Any) -> str: ... def insert_statement(self, ignore_conflicts: bool = ...) -> str: ... - def ignore_conflicts_suffix_sql(self, ignore_conflicts: Optional[Any] = ...) -> str: ... + def ignore_conflicts_suffix_sql(self, ignore_conflicts: Any | None = ...) -> str: ... diff --git a/django-stubs/db/backends/base/schema.pyi b/django-stubs/db/backends/base/schema.pyi index b4ddba2bc..292faaa49 100644 --- a/django-stubs/db/backends/base/schema.pyi +++ b/django-stubs/db/backends/base/schema.pyi @@ -1,6 +1,6 @@ from logging import Logger from types import TracebackType -from typing import Any, ContextManager, List, Optional, Sequence, Tuple, Type, Union +from typing import Any, ContextManager, List, Sequence, Tuple, Type from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.ddl_references import Statement @@ -31,8 +31,8 @@ class BaseDatabaseSchemaEditor(ContextManager[Any]): sql_delete_unique: str = ... sql_create_fk: str = ... - sql_create_inline_fk: Optional[str] = ... - sql_create_column_inline_fk: Optional[str] = ... + sql_create_inline_fk: str | None = ... + sql_create_column_inline_fk: str | None = ... sql_delete_fk: str = ... sql_create_index: str = ... @@ -50,19 +50,19 @@ class BaseDatabaseSchemaEditor(ContextManager[Any]): def __enter__(self) -> BaseDatabaseSchemaEditor: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... - def execute(self, sql: Union[Statement, str], params: Optional[Sequence[Any]] = ...) -> None: ... + def execute(self, sql: Statement | str, params: Sequence[Any] | None = ...) -> None: ... def quote_name(self, name: str) -> str: ... def table_sql(self, model: Type[Model]) -> Tuple[str, List[Any]]: ... def column_sql( self, model: Type[Model], field: Field, include_default: bool = ... - ) -> Union[Tuple[None, None], Tuple[str, List[Any]]]: ... + ) -> Tuple[None, None] | Tuple[str, List[Any]]: ... def skip_default(self, field: Any) -> bool: ... def prepare_default(self, value: Any) -> Any: ... - def effective_default(self, field: Field) -> Union[int, str]: ... + def effective_default(self, field: Field) -> int | str: ... def quote_value(self, value: Any) -> str: ... def create_model(self, model: Type[Model]) -> None: ... def delete_model(self, model: Type[Model]) -> None: ... diff --git a/django-stubs/db/backends/mysql/base.pyi b/django-stubs/db/backends/mysql/base.pyi index 3761e1039..0da5925f6 100644 --- a/django-stubs/db/backends/mysql/base.pyi +++ b/django-stubs/db/backends/mysql/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Container, Dict, Iterator, Optional, Tuple, Type +from typing import Any, Container, Dict, Iterator, Tuple, Type from django.db.backends.base.base import BaseDatabaseWrapper as BaseDatabaseWrapper from typing_extensions import Literal @@ -18,7 +18,7 @@ class CursorWrapper: codes_for_integrityerror: Any = ... cursor: Any = ... def __init__(self, cursor: Any) -> None: ... - def execute(self, query: Any, args: Optional[Any] = ...) -> Any: ... + def execute(self, query: Any, args: Any | None = ...) -> Any: ... def executemany(self, query: Any, args: Any) -> Any: ... def __getattr__(self, attr: Any) -> Any: ... def __iter__(self) -> Iterator[Any]: ... @@ -50,11 +50,11 @@ class DatabaseWrapper(BaseDatabaseWrapper): def get_connection_params(self) -> Dict[str, Any]: ... def get_new_connection(self, conn_params: Any) -> Any: ... def init_connection_state(self) -> None: ... - def create_cursor(self, name: Optional[Any] = ...) -> CursorWrapper: ... + def create_cursor(self, name: Any | None = ...) -> CursorWrapper: ... def disable_constraint_checking(self) -> Literal[True]: ... needs_rollback: Any = ... def enable_constraint_checking(self) -> None: ... - def check_constraints(self, table_names: Optional[Any] = ...) -> None: ... + def check_constraints(self, table_names: Any | None = ...) -> None: ... def is_usable(self) -> bool: ... @property def display_name(self) -> str: ... # type: ignore [override] diff --git a/django-stubs/db/backends/mysql/client.pyi b/django-stubs/db/backends/mysql/client.pyi index 1c8aa3e9f..df2d36a4b 100644 --- a/django-stubs/db/backends/mysql/client.pyi +++ b/django-stubs/db/backends/mysql/client.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple +from typing import Any, Dict, Iterable, List, Sequence, Tuple from django.db.backends.base.client import BaseDatabaseClient from django.db.backends.mysql.base import DatabaseWrapper @@ -11,4 +11,4 @@ class DatabaseClient(BaseDatabaseClient): cls, settings_dict: Dict[str, Any], parameters: Iterable[str], - ) -> Tuple[List[str], Optional[Dict[str, str]]]: ... + ) -> Tuple[List[str], Dict[str, str] | None]: ... diff --git a/django-stubs/db/backends/mysql/operations.pyi b/django-stubs/db/backends/mysql/operations.pyi index 86701ba1c..457639c09 100644 --- a/django-stubs/db/backends/mysql/operations.pyi +++ b/django-stubs/db/backends/mysql/operations.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Tuple +from typing import Any, Dict, Tuple from django.db.backends.base.operations import BaseDatabaseOperations as BaseDatabaseOperations from django.db.backends.mysql.base import DatabaseWrapper @@ -11,12 +11,12 @@ class DatabaseOperations(BaseDatabaseOperations): cast_char_field_without_max_length: str = ... explain_prefix: str = ... def date_extract_sql(self, lookup_type: str, field_name: str) -> Any: ... - def date_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str] = ...) -> Any: ... - def datetime_cast_date_sql(self, field_name: str, tzname: Optional[str]) -> Any: ... - def datetime_cast_time_sql(self, field_name: str, tzname: Optional[str]) -> Any: ... - def datetime_extract_sql(self, lookup_type: str, field_name: str, tzname: Optional[str]) -> Any: ... - def datetime_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str]) -> Any: ... - def time_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str] = ...) -> Any: ... + def date_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None = ...) -> Any: ... + def datetime_cast_date_sql(self, field_name: str, tzname: str | None) -> Any: ... + def datetime_cast_time_sql(self, field_name: str, tzname: str | None) -> Any: ... + def datetime_extract_sql(self, lookup_type: str, field_name: str, tzname: str | None) -> Any: ... + def datetime_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None) -> Any: ... + def time_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None = ...) -> Any: ... def fetch_returned_insert_rows(self, cursor: Any) -> Any: ... def format_for_duration_arithmetic(self, sql: Any) -> Any: ... def force_no_ordering(self) -> Any: ... @@ -37,7 +37,7 @@ class DatabaseOperations(BaseDatabaseOperations): def convert_uuidfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ... def binary_placeholder_sql(self, value: Any) -> Any: ... def subtract_temporals(self, internal_type: Any, lhs: Any, rhs: Any) -> Any: ... - def explain_query_prefix(self, format: Optional[Any] = ..., **options: Any) -> Any: ... + def explain_query_prefix(self, format: Any | None = ..., **options: Any) -> Any: ... def regex_lookup(self, lookup_type: str) -> Any: ... def insert_statement(self, ignore_conflicts: bool = ...) -> Any: ... - def lookup_cast(self, lookup_type: str, internal_type: Optional[Any] = ...) -> Any: ... + def lookup_cast(self, lookup_type: str, internal_type: Any | None = ...) -> Any: ... diff --git a/django-stubs/db/backends/oracle/base.pyi b/django-stubs/db/backends/oracle/base.pyi index ea102547b..db72bbfc0 100644 --- a/django-stubs/db/backends/oracle/base.pyi +++ b/django-stubs/db/backends/oracle/base.pyi @@ -1,5 +1,5 @@ from contextlib import contextmanager -from typing import Any, Generator, Iterator, Optional, Type +from typing import Any, Generator, Iterator, Type from django.db.backends.base.base import BaseDatabaseWrapper as BaseDatabaseWrapper @@ -14,7 +14,7 @@ from .validation import DatabaseValidation def wrap_oracle_errors() -> Generator[None, None, None]: ... class _UninitializedOperatorsDescriptor: - def __get__(self, instance: Any, cls: Optional[Any] = ...) -> Any: ... + def __get__(self, instance: Any, cls: Any | None = ...) -> Any: ... class DatabaseWrapper(BaseDatabaseWrapper): client: DatabaseClient @@ -44,8 +44,8 @@ class DatabaseWrapper(BaseDatabaseWrapper): def get_new_connection(self, conn_params: Any) -> Any: ... pattern_ops: Any = ... def init_connection_state(self) -> None: ... - def create_cursor(self, name: Optional[Any] = ...) -> Any: ... - def check_constraints(self, table_names: Optional[Any] = ...) -> None: ... + def create_cursor(self, name: Any | None = ...) -> Any: ... + def check_constraints(self, table_names: Any | None = ...) -> None: ... def is_usable(self) -> Any: ... @property def cx_oracle_version(self) -> Any: ... @@ -68,8 +68,8 @@ class FormatStylePlaceholderCursor: charset: str = ... cursor: Any = ... def __init__(self, connection: Any) -> None: ... - def execute(self, query: Any, params: Optional[Any] = ...) -> Any: ... - def executemany(self, query: Any, params: Optional[Any] = ...) -> Any: ... + def execute(self, query: Any, params: Any | None = ...) -> Any: ... + def executemany(self, query: Any, params: Any | None = ...) -> Any: ... def close(self) -> None: ... def var(self, *args: Any) -> Any: ... def arrayvar(self, *args: Any) -> Any: ... diff --git a/django-stubs/db/backends/oracle/functions.pyi b/django-stubs/db/backends/oracle/functions.pyi index b536868f3..49d78c25e 100644 --- a/django-stubs/db/backends/oracle/functions.pyi +++ b/django-stubs/db/backends/oracle/functions.pyi @@ -1,13 +1,13 @@ -from typing import Any, Optional +from typing import Any from django.db.models import Func as Func class IntervalToSeconds(Func): function: str = ... template: str = ... - def __init__(self, expression: Any, *, output_field: Optional[Any] = ..., **extra: Any) -> None: ... + def __init__(self, expression: Any, *, output_field: Any | None = ..., **extra: Any) -> None: ... class SecondsToInterval(Func): function: str = ... template: str = ... - def __init__(self, expression: Any, *, output_field: Optional[Any] = ..., **extra: Any) -> None: ... + def __init__(self, expression: Any, *, output_field: Any | None = ..., **extra: Any) -> None: ... diff --git a/django-stubs/db/backends/oracle/operations.pyi b/django-stubs/db/backends/oracle/operations.pyi index 50f961ef2..e7d08d861 100644 --- a/django-stubs/db/backends/oracle/operations.pyi +++ b/django-stubs/db/backends/oracle/operations.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List from django.db.backends.base.operations import BaseDatabaseOperations as BaseDatabaseOperations from django.db.backends.oracle.base import DatabaseWrapper @@ -11,12 +11,12 @@ class DatabaseOperations(BaseDatabaseOperations): cast_data_types: Any = ... def cache_key_culling_sql(self) -> str: ... def date_extract_sql(self, lookup_type: str, field_name: str) -> str: ... - def date_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str] = ...) -> str: ... - def datetime_cast_date_sql(self, field_name: str, tzname: Optional[str]) -> str: ... - def datetime_cast_time_sql(self, field_name: str, tzname: Optional[str]) -> str: ... - def datetime_extract_sql(self, lookup_type: str, field_name: str, tzname: Optional[str]) -> str: ... - def datetime_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str]) -> str: ... - def time_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str] = ...) -> str: ... + def date_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None = ...) -> str: ... + def datetime_cast_date_sql(self, field_name: str, tzname: str | None) -> str: ... + def datetime_cast_time_sql(self, field_name: str, tzname: str | None) -> str: ... + def datetime_extract_sql(self, lookup_type: str, field_name: str, tzname: str | None) -> str: ... + def datetime_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None) -> str: ... + def time_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None = ...) -> str: ... def get_db_converters(self, expression: Any) -> List[Any]: ... def convert_textfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ... def convert_binaryfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ... @@ -32,11 +32,11 @@ class DatabaseOperations(BaseDatabaseOperations): def deferrable_sql(self) -> str: ... def fetch_returned_insert_columns(self, cursor: Any, returning_params: Any) -> Any: ... def field_cast_sql(self, db_type: Any, internal_type: Any) -> str: ... - def no_limit_value(self) -> Optional[str]: ... + def no_limit_value(self) -> str | None: ... def limit_offset_sql(self, low_mark: Any, high_mark: Any) -> str: ... def last_executed_query(self, cursor: Any, sql: Any, params: Any) -> str: ... def last_insert_id(self, cursor: Any, table_name: Any, pk_name: Any) -> Any: ... - def lookup_cast(self, lookup_type: str, internal_type: Optional[Any] = ...) -> str: ... + def lookup_cast(self, lookup_type: str, internal_type: Any | None = ...) -> str: ... def max_in_list_size(self) -> int: ... def max_name_length(self) -> int: ... def pk_default_value(self) -> str: ... diff --git a/django-stubs/db/backends/postgresql/client.pyi b/django-stubs/db/backends/postgresql/client.pyi index 7d67ac710..f9e8c8a39 100644 --- a/django-stubs/db/backends/postgresql/client.pyi +++ b/django-stubs/db/backends/postgresql/client.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, List, Optional, Tuple +from typing import Any, Dict, Iterable, List, Tuple from django.db.backends.base.client import BaseDatabaseClient from django.db.backends.postgresql.base import DatabaseWrapper @@ -9,5 +9,5 @@ class DatabaseClient(BaseDatabaseClient): @classmethod def settings_to_cmd_args_env( cls, settings_dict: Dict[str, Any], parameters: Iterable[str] - ) -> Tuple[List[str], Optional[Dict[str, str]]]: ... + ) -> Tuple[List[str], Dict[str, str] | None]: ... def runshell(self, parameters: Iterable[str]) -> None: ... diff --git a/django-stubs/db/backends/sqlite3/creation.pyi b/django-stubs/db/backends/sqlite3/creation.pyi index 25ab122b9..a5767a685 100644 --- a/django-stubs/db/backends/sqlite3/creation.pyi +++ b/django-stubs/db/backends/sqlite3/creation.pyi @@ -1,5 +1,4 @@ from os import PathLike -from typing import Union from django.db.backends.base.creation import BaseDatabaseCreation from django.db.backends.sqlite3.base import DatabaseWrapper @@ -8,4 +7,4 @@ class DatabaseCreation(BaseDatabaseCreation): connection: DatabaseWrapper @staticmethod - def is_in_memory_db(database_name: Union[str, PathLike[str]]) -> bool: ... + def is_in_memory_db(database_name: str | PathLike[str]) -> bool: ... diff --git a/django-stubs/db/backends/sqlite3/introspection.pyi b/django-stubs/db/backends/sqlite3/introspection.pyi index 13ebdb166..7b329f6f4 100644 --- a/django-stubs/db/backends/sqlite3/introspection.pyi +++ b/django-stubs/db/backends/sqlite3/introspection.pyi @@ -1,11 +1,11 @@ -from typing import Any, Optional +from typing import Any from django.db.backends.base.introspection import BaseDatabaseIntrospection from django.db.backends.sqlite3.base import DatabaseWrapper field_size_re: Any -def get_field_size(name: str) -> Optional[int]: ... +def get_field_size(name: str) -> int | None: ... class FlexibleFieldLookupDict: base_data_types_reverse: Any = ... diff --git a/django-stubs/db/backends/utils.pyi b/django-stubs/db/backends/utils.pyi index ca3a4f23b..17d19f35c 100644 --- a/django-stubs/db/backends/utils.pyi +++ b/django-stubs/db/backends/utils.pyi @@ -3,21 +3,7 @@ from contextlib import contextmanager from decimal import Decimal from logging import Logger from types import TracebackType -from typing import ( - Any, - Dict, - Generator, - Iterator, - List, - Mapping, - Optional, - Protocol, - Sequence, - Tuple, - Type, - Union, - overload, -) +from typing import Any, Dict, Generator, Iterator, List, Mapping, Protocol, Sequence, Tuple, Type, overload from uuid import UUID from typing_extensions import Literal @@ -30,13 +16,24 @@ class _Composable(Protocol): def __add__(self, other: _Composable) -> _Composable: ... def __mul__(self, n: int) -> _Composable: ... -_ExecuteQuery = Union[str, _Composable] +_ExecuteQuery = str | _Composable # Python types that can be adapted to SQL. -_SQLType = Union[ - None, bool, int, float, Decimal, str, bytes, datetime.date, datetime.datetime, UUID, Tuple[Any, ...], List[Any] -] -_ExecuteParameters = Optional[Union[Sequence[_SQLType], Mapping[str, _SQLType]]] +_SQLType = ( + None + | bool + | int + | float + | Decimal + | str + | bytes + | datetime.date + | datetime.datetime + | UUID + | Tuple[Any, ...] + | List[Any] +) +_ExecuteParameters = Sequence[_SQLType] | Mapping[str, _SQLType] | None class CursorWrapper: cursor: Any = ... @@ -48,12 +45,12 @@ class CursorWrapper: def __enter__(self) -> CursorWrapper: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... def callproc( - self, procname: str, params: Optional[Sequence[Any]] = ..., kparams: Optional[Dict[str, int]] = ... + self, procname: str, params: Sequence[Any] | None = ..., kparams: Dict[str, int] | None = ... ) -> Any: ... def execute(self, sql: _ExecuteQuery, params: _ExecuteParameters = ...) -> Any: ... def executemany(self, sql: _ExecuteQuery, param_list: Sequence[_ExecuteParameters]) -> Any: ... @@ -64,27 +61,25 @@ class CursorDebugWrapper(CursorWrapper): @contextmanager def debug_sql( self, - sql: Optional[str] = ..., - params: Optional[Union[_ExecuteParameters, Sequence[_ExecuteParameters]]] = ..., + sql: str | None = ..., + params: _ExecuteParameters | Sequence[_ExecuteParameters] | None = ..., use_last_executed_query: bool = ..., many: bool = ..., ) -> Generator[None, None, None]: ... @overload -def typecast_date(s: Union[None, Literal[""]]) -> None: ... # type: ignore +def typecast_date(s: None | Literal[""]) -> None: ... # type: ignore @overload def typecast_date(s: str) -> datetime.date: ... @overload -def typecast_time(s: Union[None, Literal[""]]) -> None: ... # type: ignore +def typecast_time(s: None | Literal[""]) -> None: ... # type: ignore @overload def typecast_time(s: str) -> datetime.time: ... @overload -def typecast_timestamp(s: Union[None, Literal[""]]) -> None: ... # type: ignore +def typecast_timestamp(s: None | Literal[""]) -> None: ... # type: ignore @overload def typecast_timestamp(s: str) -> datetime.datetime: ... def split_identifier(identifier: str) -> Tuple[str, str]: ... -def truncate_name(identifier: str, length: Optional[int] = ..., hash_len: int = ...) -> str: ... -def format_number( - value: Optional[Decimal], max_digits: Optional[int], decimal_places: Optional[int] -) -> Optional[str]: ... +def truncate_name(identifier: str, length: int | None = ..., hash_len: int = ...) -> str: ... +def format_number(value: Decimal | None, max_digits: int | None, decimal_places: int | None) -> str | None: ... def strip_quotes(table_name: str) -> str: ... diff --git a/django-stubs/db/migrations/autodetector.pyi b/django-stubs/db/migrations/autodetector.pyi index 9ff66ad25..0eaf8edb6 100644 --- a/django-stubs/db/migrations/autodetector.pyi +++ b/django-stubs/db/migrations/autodetector.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Union +from typing import Any, Callable, Dict, Iterable, List, Set, Tuple from django.db.migrations.graph import MigrationGraph from django.db.migrations.migration import Migration @@ -13,27 +13,25 @@ class MigrationAutodetector: questioner: MigrationQuestioner = ... existing_apps: Set[Any] = ... def __init__( - self, from_state: ProjectState, to_state: ProjectState, questioner: Optional[MigrationQuestioner] = ... + self, from_state: ProjectState, to_state: ProjectState, questioner: MigrationQuestioner | None = ... ) -> None: ... def changes( self, graph: MigrationGraph, - trim_to_apps: Optional[Set[str]] = ..., - convert_apps: Optional[Set[str]] = ..., - migration_name: Optional[str] = ..., + trim_to_apps: Set[str] | None = ..., + convert_apps: Set[str] | None = ..., + migration_name: str | None = ..., ) -> Dict[str, List[Migration]]: ... def deep_deconstruct(self, obj: Any) -> Any: ... def only_relation_agnostic_fields( self, fields: Dict[str, Field] - ) -> List[Tuple[str, List[Any], Dict[str, Union[Callable, int, str]]]]: ... - def check_dependency( - self, operation: Operation, dependency: Tuple[str, str, Optional[str], Union[bool, str]] - ) -> bool: ... + ) -> List[Tuple[str, List[Any], Dict[str, Callable | int | str]]]: ... + def check_dependency(self, operation: Operation, dependency: Tuple[str, str, str | None, bool | str]) -> bool: ... def add_operation( self, app_label: str, operation: Operation, - dependencies: Optional[Iterable[Tuple[str, str, Optional[str], Union[bool, str]]]] = ..., + dependencies: Iterable[Tuple[str, str, str | None, bool | str]] | None = ..., beginning: bool = ..., ) -> None: ... def swappable_first_key(self, item: Tuple[str, str]) -> Tuple[str, str]: ... @@ -59,7 +57,7 @@ class MigrationAutodetector: def generate_altered_order_with_respect_to(self) -> None: ... def generate_altered_managers(self) -> None: ... def arrange_for_graph( - self, changes: Dict[str, List[Migration]], graph: MigrationGraph, migration_name: Optional[str] = ... + self, changes: Dict[str, List[Migration]], graph: MigrationGraph, migration_name: str | None = ... ) -> Dict[str, List[Migration]]: ... @classmethod def parse_number(cls, name: str) -> int: ... diff --git a/django-stubs/db/migrations/exceptions.pyi b/django-stubs/db/migrations/exceptions.pyi index 1cf78855f..401afc26d 100644 --- a/django-stubs/db/migrations/exceptions.pyi +++ b/django-stubs/db/migrations/exceptions.pyi @@ -1,4 +1,4 @@ -from typing import Optional, Tuple +from typing import Tuple from django.db.migrations.migration import Migration from django.db.utils import DatabaseError @@ -12,9 +12,9 @@ class IrreversibleError(RuntimeError): ... class NodeNotFoundError(LookupError): message: str = ... - origin: Optional[Migration] = ... + origin: Migration | None = ... node: Tuple[str, str] = ... - def __init__(self, message: str, node: Tuple[str, str], origin: Optional[Migration] = ...) -> None: ... + def __init__(self, message: str, node: Tuple[str, str], origin: Migration | None = ...) -> None: ... class MigrationSchemaMissing(DatabaseError): ... class InvalidMigrationPlan(ValueError): ... diff --git a/django-stubs/db/migrations/executor.pyi b/django-stubs/db/migrations/executor.pyi index 6258594d1..ea7d21ea8 100644 --- a/django-stubs/db/migrations/executor.pyi +++ b/django-stubs/db/migrations/executor.pyi @@ -1,4 +1,4 @@ -from typing import List, Optional, Sequence, Set, Tuple, Union +from typing import List, Sequence, Set, Tuple from django.db.backends.base.base import BaseDatabaseWrapper from django.db.migrations.migration import Migration @@ -9,26 +9,26 @@ from .recorder import MigrationRecorder from .state import ProjectState class _ProgressCallbackT(Protocol): - def __call__(self, __action: str, __migration: Optional[Migration] = ..., __fake: Optional[bool] = ...) -> None: ... + def __call__(self, __action: str, __migration: Migration | None = ..., __fake: bool | None = ...) -> None: ... class MigrationExecutor: connection: BaseDatabaseWrapper = ... loader: MigrationLoader = ... recorder: MigrationRecorder = ... - progress_callback: Optional[_ProgressCallbackT] = ... + progress_callback: _ProgressCallbackT | None = ... def __init__( self, - connection: Optional[BaseDatabaseWrapper], - progress_callback: Optional[_ProgressCallbackT] = ..., + connection: BaseDatabaseWrapper | None, + progress_callback: _ProgressCallbackT | None = ..., ) -> None: ... def migration_plan( - self, targets: Union[Sequence[Tuple[str, Optional[str]]], Set[Tuple[str, str]]], clean_start: bool = ... + self, targets: Sequence[Tuple[str, str | None]] | Set[Tuple[str, str]], clean_start: bool = ... ) -> List[Tuple[Migration, bool]]: ... def migrate( self, - targets: Optional[Sequence[Tuple[str, Optional[str]]]], - plan: Optional[Sequence[Tuple[Migration, bool]]] = ..., - state: Optional[ProjectState] = ..., + targets: Sequence[Tuple[str, str | None]] | None, + plan: Sequence[Tuple[Migration, bool]] | None = ..., + state: ProjectState | None = ..., fake: bool = ..., fake_initial: bool = ..., ) -> ProjectState: ... @@ -39,5 +39,5 @@ class MigrationExecutor: def unapply_migration(self, state: ProjectState, migration: Migration, fake: bool = ...) -> ProjectState: ... def check_replacements(self) -> None: ... def detect_soft_applied( - self, project_state: Optional[ProjectState], migration: Migration + self, project_state: ProjectState | None, migration: Migration ) -> Tuple[bool, ProjectState]: ... diff --git a/django-stubs/db/migrations/graph.pyi b/django-stubs/db/migrations/graph.pyi index 7f933b137..acea2ce9d 100644 --- a/django-stubs/db/migrations/graph.pyi +++ b/django-stubs/db/migrations/graph.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, Union +from typing import Any, Dict, List, Sequence, Set, Tuple from django.db.migrations.migration import Migration, SwappableTuple from django.db.migrations.state import ProjectState @@ -11,7 +11,7 @@ class Node: parents: Set[Any] = ... def __init__(self, key: Tuple[str, str]) -> None: ... def __eq__(self, other: Any) -> bool: ... - def __lt__(self, other: Union[Tuple[str, str], Node]) -> bool: ... + def __lt__(self, other: Tuple[str, str] | Node) -> bool: ... def __getitem__(self, item: int) -> str: ... def __hash__(self) -> int: ... def add_child(self, child: Node) -> None: ... @@ -20,19 +20,19 @@ class Node: class DummyNode(Node): origin: Any = ... error_message: Any = ... - def __init__(self, key: Tuple[str, str], origin: Union[Migration, str], error_message: str) -> None: ... + def __init__(self, key: Tuple[str, str], origin: Migration | str, error_message: str) -> None: ... def raise_error(self) -> None: ... class MigrationGraph: node_map: Dict[Tuple[str, str], Node] = ... - nodes: Dict[Tuple[str, str], Optional[Migration]] = ... + nodes: Dict[Tuple[str, str], Migration | None] = ... cached: bool = ... def __init__(self) -> None: ... - def add_node(self, key: Tuple[str, str], migration: Optional[Migration]) -> None: ... - def add_dummy_node(self, key: Tuple[str, str], origin: Union[Migration, str], error_message: str) -> None: ... + def add_node(self, key: Tuple[str, str], migration: Migration | None) -> None: ... + def add_dummy_node(self, key: Tuple[str, str], origin: Migration | str, error_message: str) -> None: ... def add_dependency( self, - migration: Optional[Union[Migration, str]], + migration: Migration | str | None, child: Tuple[str, str], parent: Tuple[str, str], skip_validation: bool = ..., @@ -43,12 +43,12 @@ class MigrationGraph: def forwards_plan(self, target: Tuple[str, str]) -> List[Tuple[str, str]]: ... def backwards_plan(self, target: Tuple[str, str]) -> List[Tuple[str, str]]: ... def iterative_dfs(self, start: Any, forwards: bool = ...) -> List[Tuple[str, str]]: ... - def root_nodes(self, app: Optional[str] = ...) -> List[Tuple[str, str]]: ... - def leaf_nodes(self, app: Optional[str] = ...) -> List[Tuple[str, str]]: ... + def root_nodes(self, app: str | None = ...) -> List[Tuple[str, str]]: ... + def leaf_nodes(self, app: str | None = ...) -> List[Tuple[str, str]]: ... def ensure_not_cyclic(self) -> None: ... def make_state( self, - nodes: Union[None, Tuple[str, str], Sequence[Tuple[str, str]]] = ..., + nodes: None | Tuple[str, str] | Sequence[Tuple[str, str]] = ..., at_end: bool = ..., real_apps: List[str] = ..., ) -> ProjectState: ... diff --git a/django-stubs/db/migrations/loader.pyi b/django-stubs/db/migrations/loader.pyi index 5bb31a3bf..3925cc6cb 100644 --- a/django-stubs/db/migrations/loader.pyi +++ b/django-stubs/db/migrations/loader.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, Union +from typing import Any, Dict, List, Sequence, Set, Tuple from django.db.backends.base.base import BaseDatabaseWrapper from django.db.migrations.migration import Migration @@ -12,25 +12,25 @@ from .exceptions import NodeNotFoundError as NodeNotFoundError MIGRATIONS_MODULE_NAME: str class MigrationLoader: - connection: Optional[BaseDatabaseWrapper] = ... + connection: BaseDatabaseWrapper | None = ... disk_migrations: Dict[Tuple[str, str], Migration] = ... applied_migrations: Dict[Tuple[str, str], Migration] = ... ignore_no_migrations: bool = ... def __init__( self, - connection: Optional[BaseDatabaseWrapper], + connection: BaseDatabaseWrapper | None, load: bool = ..., ignore_no_migrations: bool = ..., replace_migrations: bool = ..., ) -> None: ... @classmethod - def migrations_module(cls, app_label: str) -> Tuple[Optional[str], bool]: ... + def migrations_module(cls, app_label: str) -> Tuple[str | None, bool]: ... unmigrated_apps: Set[str] = ... migrated_apps: Set[str] = ... def load_disk(self) -> None: ... def get_migration(self, app_label: str, name_prefix: str) -> Migration: ... def get_migration_by_prefix(self, app_label: str, name_prefix: str) -> Migration: ... - def check_key(self, key: Tuple[str, str], current_app: str) -> Optional[Tuple[str, str]]: ... + def check_key(self, key: Tuple[str, str], current_app: str) -> Tuple[str, str] | None: ... def add_internal_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ... def add_external_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ... graph: Any = ... @@ -39,5 +39,5 @@ class MigrationLoader: def check_consistent_history(self, connection: BaseDatabaseWrapper) -> None: ... def detect_conflicts(self) -> Dict[str, List[str]]: ... def project_state( - self, nodes: Optional[Union[Tuple[str, str], Sequence[Tuple[str, str]]]] = ..., at_end: bool = ... + self, nodes: Tuple[str, str] | Sequence[Tuple[str, str]] | None = ..., at_end: bool = ... ) -> ProjectState: ... diff --git a/django-stubs/db/migrations/migration.pyi b/django-stubs/db/migrations/migration.pyi index 29e732a08..4bc2c2bc8 100644 --- a/django-stubs/db/migrations/migration.pyi +++ b/django-stubs/db/migrations/migration.pyi @@ -1,4 +1,4 @@ -from typing import List, Optional, Tuple +from typing import List, Tuple from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.migrations.operations.base import Operation @@ -9,7 +9,7 @@ class Migration: dependencies: List[Tuple[str, str]] = ... run_before: List[Tuple[str, str]] = ... replaces: List[Tuple[str, str]] = ... - initial: Optional[bool] = ... + initial: bool | None = ... atomic: bool = ... name: str = ... app_label: str = ... diff --git a/django-stubs/db/migrations/operations/base.pyi b/django-stubs/db/migrations/operations/base.pyi index 2896df36b..c963f6252 100644 --- a/django-stubs/db/migrations/operations/base.pyi +++ b/django-stubs/db/migrations/operations/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Sequence, Tuple, Type, Union +from typing import Any, Dict, List, Sequence, Tuple, Type from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.base.schema import BaseDatabaseSchemaEditor @@ -23,7 +23,7 @@ class Operation: def describe(self) -> str: ... def references_model(self, name: str, app_label: str) -> bool: ... def references_field(self, model_name: str, name: str, app_label: str) -> bool: ... - def allow_migrate_model(self, connection_alias: Union[BaseDatabaseWrapper, str], model: Type[Model]) -> bool: ... - def reduce(self, operation: Operation, app_label: str) -> Union[bool, List[Operation]]: ... + def allow_migrate_model(self, connection_alias: BaseDatabaseWrapper | str, model: Type[Model]) -> bool: ... + def reduce(self, operation: Operation, app_label: str) -> bool | List[Operation]: ... @property def migration_name_fragment(self) -> str: ... diff --git a/django-stubs/db/migrations/operations/fields.pyi b/django-stubs/db/migrations/operations/fields.pyi index 0998008c0..7d3f830bc 100644 --- a/django-stubs/db/migrations/operations/fields.pyi +++ b/django-stubs/db/migrations/operations/fields.pyi @@ -1,5 +1,3 @@ -from typing import Optional - from django.db.models.fields import Field from .base import Operation @@ -7,7 +5,7 @@ from .base import Operation class FieldOperation(Operation): model_name: str = ... name: str = ... - def __init__(self, model_name: str, name: str, field: Optional[Field] = ...) -> None: ... + def __init__(self, model_name: str, name: str, field: Field | None = ...) -> None: ... @property def name_lower(self) -> str: ... @property diff --git a/django-stubs/db/migrations/operations/models.pyi b/django-stubs/db/migrations/operations/models.pyi index baf1fa2c6..509ee6b10 100644 --- a/django-stubs/db/migrations/operations/models.pyi +++ b/django-stubs/db/migrations/operations/models.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, Type, Union +from typing import Any, Dict, List, Sequence, Set, Tuple, Type from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.migrations.operations.base import Operation @@ -18,15 +18,15 @@ class ModelOperation(Operation): class CreateModel(ModelOperation): fields: List[Tuple[str, Field]] = ... options: Dict[str, Any] = ... - bases: Optional[Sequence[Union[Type[Model], str]]] = ... - managers: Optional[Sequence[Tuple[str, Manager]]] = ... + bases: Sequence[Type[Model] | str] | None = ... + managers: Sequence[Tuple[str, Manager]] | None = ... def __init__( self, name: str, fields: List[Tuple[str, Field]], - options: Optional[Dict[str, Any]] = ..., - bases: Optional[Sequence[Union[Type[Model], str]]] = ..., - managers: Optional[Sequence[Tuple[str, Manager]]] = ..., + options: Dict[str, Any] | None = ..., + bases: Sequence[Type[Model] | str] | None = ..., + managers: Sequence[Tuple[str, Manager]] | None = ..., ) -> None: ... class DeleteModel(ModelOperation): ... @@ -43,18 +43,18 @@ class RenameModel(ModelOperation): class ModelOptionOperation(ModelOperation): ... class AlterModelTable(ModelOptionOperation): - table: Optional[str] = ... - def __init__(self, name: str, table: Optional[str]) -> None: ... + table: str | None = ... + def __init__(self, name: str, table: str | None) -> None: ... class AlterTogetherOptionOperation(ModelOptionOperation): option_name: str = ... def __init__( self, name: str, - option_value: Optional[_OptionTogetherT], + option_value: _OptionTogetherT | None, ) -> None: ... @property - def option_value(self) -> Optional[Set[Tuple[str, ...]]]: ... + def option_value(self) -> Set[Tuple[str, ...]] | None: ... def deconstruct(self) -> Tuple[str, Sequence[Any], Dict[str, Any]]: ... def state_forwards(self, app_label: str, state: Any) -> None: ... def database_forwards( @@ -70,13 +70,13 @@ class AlterTogetherOptionOperation(ModelOptionOperation): class AlterUniqueTogether(AlterTogetherOptionOperation): option_name: str = ... - unique_together: Optional[Set[Tuple[str, ...]]] = ... - def __init__(self, name: str, unique_together: Optional[_OptionTogetherT]) -> None: ... + unique_together: Set[Tuple[str, ...]] | None = ... + def __init__(self, name: str, unique_together: _OptionTogetherT | None) -> None: ... class AlterIndexTogether(AlterTogetherOptionOperation): option_name: str = ... - index_together: Optional[Set[Tuple[str, ...]]] = ... - def __init__(self, name: str, index_together: Optional[_OptionTogetherT]) -> None: ... + index_together: Set[Tuple[str, ...]] | None = ... + def __init__(self, name: str, index_together: _OptionTogetherT | None) -> None: ... class AlterOrderWithRespectTo(ModelOptionOperation): order_with_respect_to: str = ... diff --git a/django-stubs/db/migrations/operations/special.pyi b/django-stubs/db/migrations/operations/special.pyi index 9edba8b25..c820b1d97 100644 --- a/django-stubs/db/migrations/operations/special.pyi +++ b/django-stubs/db/migrations/operations/special.pyi @@ -29,7 +29,7 @@ class RunSQL(Operation): Union[str, _ListOrTuple[Union[str, Tuple[str, Union[Dict[str, Any], Optional[_ListOrTuple[str]]]]]]] ] = ..., state_operations: Sequence[Operation] = ..., - hints: Optional[Mapping[str, Any]] = ..., + hints: Mapping[str, Any] | None = ..., elidable: bool = ..., ) -> None: ... @@ -38,14 +38,14 @@ class _CodeCallable(Protocol): class RunPython(Operation): code: _CodeCallable = ... - reverse_code: Optional[_CodeCallable] = ... + reverse_code: _CodeCallable | None = ... hints: Mapping[str, Any] = ... def __init__( self, code: _CodeCallable, - reverse_code: Optional[_CodeCallable] = ..., - atomic: Optional[bool] = ..., - hints: Optional[Mapping[str, Any]] = ..., + reverse_code: _CodeCallable | None = ..., + atomic: bool | None = ..., + hints: Mapping[str, Any] | None = ..., elidable: bool = ..., ) -> None: ... @staticmethod diff --git a/django-stubs/db/migrations/operations/utils.pyi b/django-stubs/db/migrations/operations/utils.pyi index 2d9a01cde..5bba18185 100644 --- a/django-stubs/db/migrations/operations/utils.pyi +++ b/django-stubs/db/migrations/operations/utils.pyi @@ -1,12 +1,12 @@ from collections import namedtuple -from typing import Iterator, Optional, Tuple, Type, Union +from typing import Iterator, Tuple, Type from django.db.migrations.state import ModelState, ProjectState from django.db.models import Field, Model from typing_extensions import Literal def resolve_relation( - model: Union[str, Type[Model]], app_label: Optional[str] = ..., model_name: Optional[str] = ... + model: str | Type[Model], app_label: str | None = ..., model_name: str | None = ... ) -> Tuple[str, str]: ... FieldReference = namedtuple("FieldReference", ["to", "through"]) @@ -15,12 +15,12 @@ def field_references( model_tuple: Tuple[str, str], field: Field, reference_model_tuple: Tuple[str, str], - reference_field_name: Optional[str] = ..., - reference_field: Optional[Field] = ..., -) -> Union[Literal[False], FieldReference]: ... + reference_field_name: str | None = ..., + reference_field: Field | None = ..., +) -> Literal[False] | FieldReference: ... def get_references( state: ProjectState, model_tuple: Tuple[str, str], - field_tuple: Union[Tuple[()], Tuple[str, Field]] = ..., + field_tuple: Tuple[()] | Tuple[str, Field] = ..., ) -> Iterator[Tuple[ModelState, str, Field, FieldReference]]: ... def field_is_referenced(state: ProjectState, model_tuple: Tuple[str, str], field_tuple: Tuple[str, Field]) -> bool: ... diff --git a/django-stubs/db/migrations/optimizer.pyi b/django-stubs/db/migrations/optimizer.pyi index e001cb9a9..a079b034b 100644 --- a/django-stubs/db/migrations/optimizer.pyi +++ b/django-stubs/db/migrations/optimizer.pyi @@ -1,7 +1,7 @@ -from typing import List, Optional +from typing import List from django.db.migrations.operations.base import Operation class MigrationOptimizer: - def optimize(self, operations: List[Operation], app_label: Optional[str]) -> List[Operation]: ... - def optimize_inner(self, operations: List[Operation], app_label: Optional[str]) -> List[Operation]: ... + def optimize(self, operations: List[Operation], app_label: str | None) -> List[Operation]: ... + def optimize_inner(self, operations: List[Operation], app_label: str | None) -> List[Operation]: ... diff --git a/django-stubs/db/migrations/questioner.pyi b/django-stubs/db/migrations/questioner.pyi index b80536907..91bd2b9f3 100644 --- a/django-stubs/db/migrations/questioner.pyi +++ b/django-stubs/db/migrations/questioner.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Set +from typing import Any, Dict, Set from django.db.migrations.state import ModelState from django.db.models.fields import Field @@ -6,12 +6,12 @@ from django.db.models.fields import Field class MigrationQuestioner: defaults: Dict[str, Any] = ... specified_apps: Set[str] = ... - dry_run: Optional[bool] = ... + dry_run: bool | None = ... def __init__( self, - defaults: Optional[Dict[str, bool]] = ..., - specified_apps: Optional[Set[str]] = ..., - dry_run: Optional[bool] = ..., + defaults: Dict[str, bool] | None = ..., + specified_apps: Set[str] | None = ..., + dry_run: bool | None = ..., ) -> None: ... def ask_initial(self, app_label: str) -> bool: ... def ask_not_null_addition(self, field_name: str, model_name: str) -> Any: ... diff --git a/django-stubs/db/migrations/serializer.pyi b/django-stubs/db/migrations/serializer.pyi index 5aed6629b..f187a3d10 100644 --- a/django-stubs/db/migrations/serializer.pyi +++ b/django-stubs/db/migrations/serializer.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, Set, Tuple, Type, Union +from typing import Any, Callable, Dict, List, Set, Tuple, Type class BaseSerializer: value: Any = ... @@ -14,7 +14,7 @@ class DecimalSerializer(BaseSerializer): ... class DeconstructableSerializer(BaseSerializer): @staticmethod def serialize_deconstructed( - path: str, args: List[Any], kwargs: Dict[str, Union[Callable, int, str]] + path: str, args: List[Any], kwargs: Dict[str, Callable | int | str] ) -> Tuple[str, Set[str]]: ... class DictionarySerializer(BaseSerializer): ... diff --git a/django-stubs/db/migrations/state.pyi b/django-stubs/db/migrations/state.pyi index d412d6d0e..2976b82b2 100644 --- a/django-stubs/db/migrations/state.pyi +++ b/django-stubs/db/migrations/state.pyi @@ -1,5 +1,5 @@ from contextlib import contextmanager -from typing import Any, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union +from typing import Any, Dict, Iterator, List, Sequence, Set, Tuple, Type from django.apps import AppConfig from django.apps.registry import Apps @@ -14,16 +14,16 @@ class ModelState: app_label: str fields: Dict[str, Field] options: Dict[str, Any] = ... - bases: Sequence[Union[Type[Model], str]] = ... + bases: Sequence[Type[Model] | str] = ... managers: List[Tuple[str, Manager]] = ... def __init__( self, app_label: str, name: str, - fields: Union[List[Tuple[str, Field]], Dict[str, Field]], - options: Optional[Dict[str, Any]] = ..., - bases: Optional[Sequence[Union[Type[Model], str]]] = ..., - managers: Optional[List[Tuple[str, Manager]]] = ..., + fields: List[Tuple[str, Field]] | Dict[str, Field], + options: Dict[str, Any] | None = ..., + bases: Sequence[Type[Model] | str] | None = ..., + managers: List[Tuple[str, Manager]] | None = ..., ) -> None: ... def clone(self) -> ModelState: ... def construct_managers(self) -> Iterator[Tuple[str, Manager]]: ... @@ -46,7 +46,7 @@ class ProjectState: models: Dict[Any, Any] real_apps: List[str] def __init__( - self, models: Optional[Dict[Tuple[str, str], ModelState]] = ..., real_apps: Optional[List[str]] = ... + self, models: Dict[Tuple[str, str], ModelState] | None = ..., real_apps: List[str] | None = ... ) -> None: ... def add_model(self, model_state: ModelState) -> None: ... @property diff --git a/django-stubs/db/models/aggregates.pyi b/django-stubs/db/models/aggregates.pyi index 33c83e58d..c1abb2132 100644 --- a/django-stubs/db/models/aggregates.pyi +++ b/django-stubs/db/models/aggregates.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.db.models.expressions import Func from django.db.models.functions.mixins import FixDurationInputMixin, NumericOutputFieldMixin @@ -7,7 +7,7 @@ class Aggregate(Func): filter_template: str = ... filter: Any = ... allow_distinct: bool = ... - def __init__(self, *expressions: Any, distinct: bool = ..., filter: Optional[Any] = ..., **extra: Any) -> None: ... + def __init__(self, *expressions: Any, distinct: bool = ..., filter: Any | None = ..., **extra: Any) -> None: ... class Avg(FixDurationInputMixin, NumericOutputFieldMixin, Aggregate): ... class Count(Aggregate): ... diff --git a/django-stubs/db/models/base.pyi b/django-stubs/db/models/base.pyi index d9beee070..4bdd15a89 100644 --- a/django-stubs/db/models/base.pyi +++ b/django-stubs/db/models/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Collection, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union +from typing import Any, Collection, Dict, Iterable, List, Sequence, Set, Tuple, Type, TypeVar from django.core.checks.messages import CheckMessage from django.core.exceptions import MultipleObjectsReturned as BaseMultipleObjectsReturned @@ -11,7 +11,7 @@ _Self = TypeVar("_Self", bound="Model") class ModelStateFieldsCacheDescriptor: ... class ModelState: - db: Optional[str] = ... + db: str | None = ... adding: bool = ... fields_cache: ModelStateFieldsCacheDescriptor = ... @@ -34,34 +34,32 @@ class Model(metaclass=ModelBase): @classmethod def add_to_class(cls, name: str, value: Any) -> Any: ... @classmethod - def from_db( - cls: Type[_Self], db: Optional[str], field_names: Collection[str], values: Collection[Any] - ) -> _Self: ... + def from_db(cls: Type[_Self], db: str | None, field_names: Collection[str], values: Collection[Any]) -> _Self: ... def delete(self, using: Any = ..., keep_parents: bool = ...) -> Tuple[int, Dict[str, int]]: ... - def full_clean(self, exclude: Optional[Iterable[str]] = ..., validate_unique: bool = ...) -> None: ... + def full_clean(self, exclude: Iterable[str] | None = ..., validate_unique: bool = ...) -> None: ... def clean(self) -> None: ... - def clean_fields(self, exclude: Optional[Collection[str]] = ...) -> None: ... - def validate_unique(self, exclude: Optional[Collection[str]] = ...) -> None: ... + def clean_fields(self, exclude: Collection[str] | None = ...) -> None: ... + def validate_unique(self, exclude: Collection[str] | None = ...) -> None: ... def unique_error_message(self, model_class: Type[_Self], unique_check: Sequence[str]) -> ValidationError: ... def save( self, force_insert: bool = ..., force_update: bool = ..., - using: Optional[str] = ..., - update_fields: Optional[Iterable[str]] = ..., + using: str | None = ..., + update_fields: Iterable[str] | None = ..., ) -> None: ... def save_base( self, raw: bool = ..., force_insert: bool = ..., force_update: bool = ..., - using: Optional[str] = ..., - update_fields: Optional[Iterable[str]] = ..., + using: str | None = ..., + update_fields: Iterable[str] | None = ..., ) -> None: ... - def refresh_from_db(self: _Self, using: Optional[str] = ..., fields: Optional[Sequence[str]] = ...) -> None: ... + def refresh_from_db(self: _Self, using: str | None = ..., fields: Sequence[str] | None = ...) -> None: ... def get_deferred_fields(self) -> Set[str]: ... @classmethod def check(cls, **kwargs: Any) -> List[CheckMessage]: ... def __getstate__(self) -> dict: ... -def model_unpickle(model_id: Union[Tuple[str, str], type[Model]]) -> Model: ... +def model_unpickle(model_id: Tuple[str, str] | type[Model]) -> Model: ... diff --git a/django-stubs/db/models/constraints.pyi b/django-stubs/db/models/constraints.pyi index 29df968ed..1de061595 100644 --- a/django-stubs/db/models/constraints.pyi +++ b/django-stubs/db/models/constraints.pyi @@ -1,5 +1,5 @@ from enum import Enum -from typing import Any, Optional, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import Any, Sequence, Tuple, Type, TypeVar, overload from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.models.base import Model @@ -15,11 +15,9 @@ class Deferrable(Enum): class BaseConstraint: name: str def __init__(self, name: str) -> None: ... - def constraint_sql( - self, model: Optional[Type[Model]], schema_editor: Optional[BaseDatabaseSchemaEditor] - ) -> str: ... - def create_sql(self, model: Optional[Type[Model]], schema_editor: Optional[BaseDatabaseSchemaEditor]) -> str: ... - def remove_sql(self, model: Optional[Type[Model]], schema_editor: Optional[BaseDatabaseSchemaEditor]) -> str: ... + def constraint_sql(self, model: Type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ... + def create_sql(self, model: Type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ... + def remove_sql(self, model: Type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ... def deconstruct(self) -> Any: ... def clone(self: _T) -> _T: ... @@ -30,18 +28,18 @@ class CheckConstraint(BaseConstraint): class UniqueConstraint(BaseConstraint): expressions: Tuple[Combinable, ...] fields: Tuple[str, ...] - condition: Optional[Q] - deferrable: Optional[Deferrable] + condition: Q | None + deferrable: Deferrable | None @overload def __init__( self, - *expressions: Union[str, Combinable], + *expressions: str | Combinable, fields: None = ..., name: str, - condition: Optional[Q] = ..., - deferrable: Optional[Deferrable] = ..., - include: Optional[Sequence[str]] = ..., + condition: Q | None = ..., + deferrable: Deferrable | None = ..., + include: Sequence[str] | None = ..., opclasses: Sequence[Any] = ..., ) -> None: ... @overload @@ -50,8 +48,8 @@ class UniqueConstraint(BaseConstraint): *, fields: Sequence[str], name: str, - condition: Optional[Q] = ..., - deferrable: Optional[Deferrable] = ..., - include: Optional[Sequence[str]] = ..., + condition: Q | None = ..., + deferrable: Deferrable | None = ..., + include: Sequence[str] | None = ..., opclasses: Sequence[Any] = ..., ) -> None: ... diff --git a/django-stubs/db/models/deletion.pyi b/django-stubs/db/models/deletion.pyi index 09637ef86..f07acda35 100644 --- a/django-stubs/db/models/deletion.pyi +++ b/django-stubs/db/models/deletion.pyi @@ -1,18 +1,4 @@ -from typing import ( - Any, - Callable, - Collection, - Dict, - Iterable, - Iterator, - List, - Optional, - Sequence, - Set, - Tuple, - Type, - Union, -) +from typing import Any, Callable, Collection, Dict, Iterable, Iterator, List, Sequence, Set, Tuple, Type from django.db import IntegrityError from django.db.models.base import Model @@ -79,7 +65,7 @@ class Collector: def add( self, objs: _IndexableCollection[Model], - source: Optional[Type[Model]] = ..., + source: Type[Model] | None = ..., nullable: bool = ..., reverse_dependency: bool = ..., ) -> List[Model]: ... @@ -88,17 +74,17 @@ class Collector: def add_restricted_objects(self, field: Field, objs: _IndexableCollection[Model]) -> None: ... def clear_restricted_objects_from_set(self, model: Type[Model], objs: Set[Model]) -> None: ... def clear_restricted_objects_from_queryset(self, model: Type[Model], qs: QuerySet[Model]) -> None: ... - def can_fast_delete(self, objs: Union[Model, Iterable[Model]], from_field: Optional[Field] = ...) -> bool: ... + def can_fast_delete(self, objs: Model | Iterable[Model], from_field: Field | None = ...) -> bool: ... def get_del_batches( self, objs: _IndexableCollection[Model], fields: Iterable[Field] ) -> Sequence[Sequence[Model]]: ... def collect( self, - objs: _IndexableCollection[Optional[Model]], - source: Optional[Type[Model]] = ..., + objs: _IndexableCollection[Model | None], + source: Type[Model] | None = ..., nullable: bool = ..., collect_related: bool = ..., - source_attr: Optional[str] = ..., + source_attr: str | None = ..., reverse_dependency: bool = ..., keep_parents: bool = ..., fail_on_restricted: bool = ..., diff --git a/django-stubs/db/models/expressions.pyi b/django-stubs/db/models/expressions.pyi index 5736f1f95..604cf377a 100644 --- a/django-stubs/db/models/expressions.pyi +++ b/django-stubs/db/models/expressions.pyi @@ -1,6 +1,6 @@ import datetime from decimal import Decimal -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, Iterator, List, Sequence, Set, Tuple, Type, TypeVar from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models import Q @@ -15,7 +15,7 @@ class SQLiteNumericMixin: def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... _Self = TypeVar("_Self") -_Numeric = Union[float, Decimal] +_Numeric = float | Decimal class Combinable: ADD: str = ... @@ -30,25 +30,25 @@ class Combinable: BITRIGHTSHIFT: str = ... BITXOR: str = ... def __neg__(self) -> CombinedExpression: ... - def __add__(self, other: Optional[Union[datetime.timedelta, Combinable, _Numeric, str]]) -> CombinedExpression: ... - def __sub__(self, other: Union[datetime.timedelta, Combinable, _Numeric]) -> CombinedExpression: ... - def __mul__(self, other: Union[datetime.timedelta, Combinable, _Numeric]) -> CombinedExpression: ... - def __truediv__(self, other: Union[Combinable, _Numeric]) -> CombinedExpression: ... - def __mod__(self, other: Union[int, Combinable]) -> CombinedExpression: ... - def __pow__(self, other: Union[_Numeric, Combinable]) -> CombinedExpression: ... - def __and__(self, other: Union[Combinable, Q]) -> Q: ... + def __add__(self, other: datetime.timedelta | Combinable | _Numeric | str | None) -> CombinedExpression: ... + def __sub__(self, other: datetime.timedelta | Combinable | _Numeric) -> CombinedExpression: ... + def __mul__(self, other: datetime.timedelta | Combinable | _Numeric) -> CombinedExpression: ... + def __truediv__(self, other: Combinable | _Numeric) -> CombinedExpression: ... + def __mod__(self, other: int | Combinable) -> CombinedExpression: ... + def __pow__(self, other: _Numeric | Combinable) -> CombinedExpression: ... + def __and__(self, other: Combinable | Q) -> Q: ... def bitand(self, other: int) -> CombinedExpression: ... def bitleftshift(self, other: int) -> CombinedExpression: ... def bitrightshift(self, other: int) -> CombinedExpression: ... def bitxor(self, other: int) -> CombinedExpression: ... - def __or__(self, other: Union[Combinable, Q]) -> Q: ... + def __or__(self, other: Combinable | Q) -> Q: ... def bitor(self, other: int) -> CombinedExpression: ... - def __radd__(self, other: Optional[Union[datetime.datetime, _Numeric, Combinable]]) -> CombinedExpression: ... - def __rsub__(self, other: Union[_Numeric, Combinable]) -> CombinedExpression: ... - def __rmul__(self, other: Union[_Numeric, Combinable]) -> CombinedExpression: ... - def __rtruediv__(self, other: Union[_Numeric, Combinable]) -> CombinedExpression: ... - def __rmod__(self, other: Union[int, Combinable]) -> CombinedExpression: ... - def __rpow__(self, other: Union[_Numeric, Combinable]) -> CombinedExpression: ... + def __radd__(self, other: datetime.datetime | _Numeric | Combinable | None) -> CombinedExpression: ... + def __rsub__(self, other: _Numeric | Combinable) -> CombinedExpression: ... + def __rmul__(self, other: _Numeric | Combinable) -> CombinedExpression: ... + def __rtruediv__(self, other: _Numeric | Combinable) -> CombinedExpression: ... + def __rmod__(self, other: int | Combinable) -> CombinedExpression: ... + def __rpow__(self, other: _Numeric | Combinable) -> CombinedExpression: ... def __rand__(self, other: Any) -> Combinable: ... def __ror__(self, other: Any) -> Combinable: ... @@ -58,7 +58,7 @@ class BaseExpression: is_summary: bool = ... filterable: bool = ... window_compatible: bool = ... - def __init__(self, output_field: Optional[Field] = ...) -> None: ... + def __init__(self, output_field: Field | None = ...) -> None: ... def get_db_converters(self, connection: BaseDatabaseWrapper) -> List[Callable]: ... def get_source_expressions(self) -> List[Any]: ... def set_source_expressions(self, exprs: Sequence[Combinable]) -> None: ... @@ -72,7 +72,7 @@ class BaseExpression: self: _SelfB, query: Any = ..., allow_joins: bool = ..., - reuse: Optional[Set[str]] = ..., + reuse: Set[str] | None = ..., summarize: bool = ..., for_save: bool = ..., ) -> _SelfB: ... @@ -84,12 +84,12 @@ class BaseExpression: def output_field(self) -> Field: ... @property def convert_value(self) -> Callable: ... - def get_lookup(self, lookup: str) -> Optional[Type[Lookup]]: ... - def get_transform(self, name: str) -> Optional[Type[Transform]]: ... - def relabeled_clone(self: _SelfB, change_map: Dict[Optional[str], str]) -> _SelfB: ... + def get_lookup(self, lookup: str) -> Type[Lookup] | None: ... + def get_transform(self, name: str) -> Type[Transform] | None: ... + def relabeled_clone(self: _SelfB, change_map: Dict[str | None, str]) -> _SelfB: ... def copy(self: _SelfB) -> _SelfB: ... - def get_group_by_cols(self: _SelfB, alias: Optional[str] = ...) -> List[_SelfB]: ... - def get_source_fields(self) -> List[Optional[Field]]: ... + def get_group_by_cols(self: _SelfB, alias: str | None = ...) -> List[_SelfB]: ... + def get_source_fields(self) -> List[Field | None]: ... def asc( self, *, @@ -114,9 +114,7 @@ class CombinedExpression(SQLiteNumericMixin, Expression): connector: str = ... lhs: Combinable = ... rhs: Combinable = ... - def __init__( - self, lhs: Combinable, connector: str, rhs: Combinable, output_field: Optional[Field] = ... - ) -> None: ... + def __init__(self, lhs: Combinable, connector: str, rhs: Combinable, output_field: Field | None = ...) -> None: ... class F(Combinable): name: str @@ -125,7 +123,7 @@ class F(Combinable): self, query: Any = ..., allow_joins: bool = ..., - reuse: Optional[Set[str]] = ..., + reuse: Set[str] | None = ..., summarize: bool = ..., for_save: bool = ..., ) -> F: ... @@ -147,7 +145,7 @@ class F(Combinable): class ResolvedOuterRef(F): ... class OuterRef(F): - def __init__(self, name: Union[str, OuterRef]) -> None: ... + def __init__(self, name: str | OuterRef) -> None: ... contains_aggregate: bool def relabeled_clone(self: _Self, relabels: Any) -> _Self: ... @@ -155,11 +153,11 @@ class Subquery(BaseExpression, Combinable): template: str = ... query: Query = ... extra: Dict[Any, Any] = ... - def __init__(self, queryset: Union[Query, QuerySet], output_field: Optional[Field] = ..., **extra: Any) -> None: ... + def __init__(self, queryset: Query | QuerySet, output_field: Field | None = ..., **extra: Any) -> None: ... class Exists(Subquery): negated: bool = ... - def __init__(self, queryset: Union[Query, QuerySet], negated: bool = ..., **kwargs: Any) -> None: ... + def __init__(self, queryset: Query | QuerySet, negated: bool = ..., **kwargs: Any) -> None: ... def __invert__(self) -> Exists: ... class OrderBy(Expression): @@ -167,10 +165,10 @@ class OrderBy(Expression): nulls_first: bool = ... nulls_last: bool = ... descending: bool = ... - expression: Union[Expression, F, Subquery] = ... + expression: Expression | F | Subquery = ... def __init__( self, - expression: Union[Expression, F, Subquery], + expression: Expression | F | Subquery, descending: bool = ..., nulls_first: bool = ..., nulls_last: bool = ..., @@ -178,22 +176,22 @@ class OrderBy(Expression): class Value(Expression): value: Any = ... - def __init__(self, value: Any, output_field: Optional[Field] = ...) -> None: ... + def __init__(self, value: Any, output_field: Field | None = ...) -> None: ... class RawSQL(Expression): params: List[Any] sql: str - def __init__(self, sql: str, params: Sequence[Any], output_field: Optional[Field] = ...) -> None: ... + def __init__(self, sql: str, params: Sequence[Any], output_field: Field | None = ...) -> None: ... class Func(SQLiteNumericMixin, Expression): function: str = ... name: str = ... template: str = ... arg_joiner: str = ... - arity: Optional[int] = ... + arity: int | None = ... source_expressions: List[Expression] = ... extra: Dict[Any, Any] = ... - def __init__(self, *expressions: Any, output_field: Optional[Field] = ..., **extra: Any) -> None: ... + def __init__(self, *expressions: Any, output_field: Field | None = ..., **extra: Any) -> None: ... class When(Expression): template: str = ... @@ -208,46 +206,46 @@ class Case(Expression): default: Any = ... extra: Any = ... def __init__( - self, *cases: Any, default: Optional[Any] = ..., output_field: Optional[Field] = ..., **extra: Any + self, *cases: Any, default: Any | None = ..., output_field: Field | None = ..., **extra: Any ) -> None: ... class ExpressionWrapper(Expression): - def __init__(self, expression: Union[Q, Combinable], output_field: Field) -> None: ... + def __init__(self, expression: Q | Combinable, output_field: Field) -> None: ... class Col(Expression): target: Field alias: str contains_column_references: Literal[True] = ... possibly_multivalued: Literal[False] = ... - def __init__(self, alias: str, target: Field, output_field: Optional[Field] = ...) -> None: ... + def __init__(self, alias: str, target: Field, output_field: Field | None = ...) -> None: ... class Ref(Expression): def __init__(self, refs: str, source: Expression) -> None: ... class ExpressionList(Func): - def __init__(self, *expressions: Union[BaseExpression, Combinable], **extra: Any) -> None: ... + def __init__(self, *expressions: BaseExpression | Combinable, **extra: Any) -> None: ... class Window(SQLiteNumericMixin, Expression): template: str = ... contains_aggregate: bool = ... contains_over_clause: bool = ... - partition_by: Optional[ExpressionList] - order_by: Optional[ExpressionList] + partition_by: ExpressionList | None + order_by: ExpressionList | None def __init__( self, expression: BaseExpression, - partition_by: Optional[Union[str, Iterable[Union[BaseExpression, F]], F, BaseExpression]] = ..., - order_by: Optional[Union[Sequence[Union[BaseExpression, F]], Union[BaseExpression, F]]] = ..., - frame: Optional[WindowFrame] = ..., - output_field: Optional[Field] = ..., + partition_by: str | Iterable[BaseExpression | F] | F | BaseExpression | None = ..., + order_by: Sequence[BaseExpression | F] | BaseExpression | F | None = ..., + frame: WindowFrame | None = ..., + output_field: Field | None = ..., ) -> None: ... class WindowFrame(Expression): template: str = ... frame_type: str = ... - def __init__(self, start: Optional[int] = ..., end: Optional[int] = ...) -> None: ... + def __init__(self, start: int | None = ..., end: int | None = ...) -> None: ... def window_frame_start_end( - self, connection: BaseDatabaseWrapper, start: Optional[int], end: Optional[int] + self, connection: BaseDatabaseWrapper, start: int | None, end: int | None ) -> Tuple[int, int]: ... class RowRange(WindowFrame): ... diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 15a11ee56..b3f548cdf 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -3,21 +3,7 @@ import uuid from datetime import date from datetime import datetime as real_datetime from datetime import time, timedelta -from typing import ( - Any, - Callable, - Dict, - Generic, - Iterable, - List, - Optional, - Sequence, - Tuple, - Type, - TypeVar, - Union, - overload, -) +from typing import Any, Callable, Dict, Generic, Iterable, List, Sequence, Tuple, Type, TypeVar, overload from django.core import validators # due to weird mypy.stubtest error from django.core.checks import CheckMessage @@ -40,14 +26,14 @@ BLANK_CHOICE_DASH: List[Tuple[str, str]] = ... _Choice = Tuple[Any, Any] _ChoiceNamedGroup = Tuple[str, Iterable[_Choice]] -_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]] -_ChoicesList = Union[Sequence[_Choice], Sequence[_ChoiceNamedGroup]] -_LimitChoicesTo = Union[Q, Dict[str, Any]] +_FieldChoices = Iterable[_Choice | _ChoiceNamedGroup] +_ChoicesList = Sequence[_Choice] | Sequence[_ChoiceNamedGroup] +_LimitChoicesTo = Q | Dict[str, Any] class _ChoicesCallable(Protocol): def __call__(self) -> _FieldChoices: ... -_AllLimitChoicesTo = Union[_LimitChoicesTo, _ChoicesCallable] +_AllLimitChoicesTo = _LimitChoicesTo | _ChoicesCallable _ErrorMessagesT = Dict[str, Any] _T = TypeVar("_T", bound="Field") @@ -124,25 +110,25 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): attname: str auto_created: bool primary_key: bool - remote_field: Optional[ForeignObjectRel] + remote_field: ForeignObjectRel | None is_relation: bool - related_model: Optional[Type[Model]] - one_to_many: Optional[bool] = ... - one_to_one: Optional[bool] = ... - many_to_many: Optional[bool] = ... - many_to_one: Optional[bool] = ... - max_length: Optional[int] + related_model: Type[Model] | None + one_to_many: bool | None = ... + one_to_one: bool | None = ... + many_to_many: bool | None = ... + many_to_one: bool | None = ... + max_length: int | None model: Type[Model] name: str verbose_name: _StrOrPromise - description: Union[str, _Getter[str]] + description: str | _Getter[str] blank: bool null: bool unique: bool editable: bool empty_strings_allowed: bool = ... - choices: Optional[_ChoicesList] = ... - db_column: Optional[str] + choices: _ChoicesList | None = ... + db_column: str | None column: str concrete: bool default: Any @@ -153,33 +139,33 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): default_validators: Sequence[validators._ValidatorCallable] default_error_messages: Dict[str, str] hidden: bool - system_check_removed_details: Optional[Any] - system_check_deprecated_details: Optional[Any] + system_check_removed_details: Any | None + system_check_deprecated_details: Any | None non_db_attrs: Tuple[str, ...] def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., db_index: bool = ..., - rel: Optional[ForeignObjectRel] = ..., + rel: ForeignObjectRel | None = ..., default: Any = ..., editable: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., auto_created: bool = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... def __set__(self, instance: Any, value: _ST) -> None: ... # class access @@ -194,31 +180,29 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): def deconstruct(self) -> Any: ... def set_attributes_from_name(self, name: str) -> None: ... def db_type_parameters(self, connection: BaseDatabaseWrapper) -> DictWrapper: ... - def db_check(self, connection: BaseDatabaseWrapper) -> Optional[str]: ... - def db_type(self, connection: BaseDatabaseWrapper) -> Optional[str]: ... - def db_parameters(self, connection: BaseDatabaseWrapper) -> Dict[str, Optional[str]]: ... + def db_check(self, connection: BaseDatabaseWrapper) -> str | None: ... + def db_type(self, connection: BaseDatabaseWrapper) -> str | None: ... + def db_parameters(self, connection: BaseDatabaseWrapper) -> Dict[str, str | None]: ... def pre_save(self, model_instance: Model, add: bool) -> Any: ... def get_prep_value(self, value: Any) -> Any: ... def get_db_prep_value(self, value: Any, connection: BaseDatabaseWrapper, prepared: bool = ...) -> Any: ... def get_db_prep_save(self, value: Any, connection: BaseDatabaseWrapper) -> Any: ... def get_internal_type(self) -> str: ... # TODO: plugin support - def formfield( - self, form_class: Optional[Any] = ..., choices_form_class: Optional[Any] = ..., **kwargs: Any - ) -> Any: ... + def formfield(self, form_class: Any | None = ..., choices_form_class: Any | None = ..., **kwargs: Any) -> Any: ... def save_form_data(self, instance: Model, data: Any) -> None: ... def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ... def to_python(self, value: Any) -> Any: ... @property def validators(self) -> List[validators._ValidatorCallable]: ... def run_validators(self, value: Any) -> None: ... - def validate(self, value: Any, model_instance: Optional[Model]) -> None: ... - def clean(self, value: Any, model_instance: Optional[Model]) -> Any: ... + def validate(self, value: Any, model_instance: Model | None) -> None: ... + def clean(self, value: Any, model_instance: Model | None) -> Any: ... def get_choices( self, include_blank: bool = ..., blank_choice: _ChoicesList = ..., - limit_choices_to: Optional[_LimitChoicesTo] = ..., + limit_choices_to: _LimitChoicesTo | None = ..., ordering: Sequence[str] = ..., ) -> _ChoicesList: ... def _get_flatchoices(self) -> List[_Choice]: ... @@ -227,7 +211,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): def has_default(self) -> bool: ... def get_default(self) -> Any: ... def check(self, **kwargs: Any) -> List[CheckMessage]: ... - def get_col(self, alias: str, output_field: Optional[Field] = ...) -> Col: ... + def get_col(self, alias: str, output_field: Field | None = ...) -> Col: ... @property def cached_col(self) -> Col: ... def value_from_object(self, obj: Model) -> _GT: ... @@ -235,9 +219,9 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): def value_to_string(self, obj: Model) -> str: ... class IntegerField(Field[_ST, _GT]): - _pyi_private_set_type: Union[float, int, str, Combinable] + _pyi_private_set_type: float | int | str | Combinable _pyi_private_get_type: int - _pyi_lookup_exact_type: Union[str, int] + _pyi_lookup_exact_type: str | int class PositiveIntegerRelDbTypeMixin: def rel_db_type(self, connection: BaseDatabaseWrapper) -> str: ... @@ -249,23 +233,23 @@ class SmallIntegerField(IntegerField[_ST, _GT]): ... class BigIntegerField(IntegerField[_ST, _GT]): ... class FloatField(Field[_ST, _GT]): - _pyi_private_set_type: Union[float, int, str, Combinable] + _pyi_private_set_type: float | int | str | Combinable _pyi_private_get_type: float _pyi_lookup_exact_type: float class DecimalField(Field[_ST, _GT]): - _pyi_private_set_type: Union[str, float, decimal.Decimal, Combinable] + _pyi_private_set_type: str | float | decimal.Decimal | Combinable _pyi_private_get_type: decimal.Decimal - _pyi_lookup_exact_type: Union[str, decimal.Decimal] + _pyi_lookup_exact_type: str | decimal.Decimal # attributes max_digits: int = ... decimal_places: int = ... def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., - max_digits: Optional[int] = ..., - decimal_places: Optional[int] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., + max_digits: int | None = ..., + decimal_places: int | None = ..., *, primary_key: bool = ..., unique: bool = ..., @@ -276,25 +260,25 @@ class DecimalField(Field[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - choices: Optional[_FieldChoices] = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... class CharField(Field[_ST, _GT]): - _pyi_private_set_type: Union[str, int, Combinable] + _pyi_private_set_type: str | int | Combinable _pyi_private_get_type: str # objects are converted to string before comparison _pyi_lookup_exact_type: Any def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., @@ -303,17 +287,17 @@ class CharField(Field[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., *, - db_collation: Optional[str] = ..., + db_collation: str | None = ..., ) -> None: ... class CommaSeparatedIntegerField(CharField[_ST, _GT]): ... @@ -321,8 +305,8 @@ class CommaSeparatedIntegerField(CharField[_ST, _GT]): ... class SlugField(CharField[_ST, _GT]): def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., primary_key: bool = ..., unique: bool = ..., blank: bool = ..., @@ -331,17 +315,17 @@ class SlugField(CharField[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., *, - max_length: Optional[int] = ..., + max_length: int | None = ..., db_index: bool = ..., allow_unicode: bool = ..., ) -> None: ... @@ -351,42 +335,42 @@ class EmailField(CharField[_ST, _GT]): ... class URLField(CharField[_ST, _GT]): def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., *, primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., db_index: bool = ..., - rel: Optional[ForeignObjectRel] = ..., + rel: ForeignObjectRel | None = ..., default: Any = ..., editable: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., auto_created: bool = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... class TextField(Field[_ST, _GT]): - _pyi_private_set_type: Union[str, Combinable] + _pyi_private_set_type: str | Combinable _pyi_private_get_type: str # objects are converted to string before comparison _pyi_lookup_exact_type: Any def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., @@ -395,35 +379,35 @@ class TextField(Field[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., *, - db_collation: Optional[str] = ..., + db_collation: str | None = ..., ) -> None: ... class BooleanField(Field[_ST, _GT]): - _pyi_private_set_type: Union[bool, Combinable] + _pyi_private_set_type: bool | Combinable _pyi_private_get_type: bool _pyi_lookup_exact_type: bool class NullBooleanField(BooleanField[_ST, _GT]): - _pyi_private_set_type: Optional[Union[bool, Combinable]] # type: ignore - _pyi_private_get_type: Optional[bool] # type: ignore - _pyi_lookup_exact_type: Optional[bool] # type: ignore + _pyi_private_set_type: bool | Combinable | None # type: ignore + _pyi_private_get_type: bool | None # type: ignore + _pyi_lookup_exact_type: bool | None # type: ignore class IPAddressField(Field[_ST, _GT]): - _pyi_private_set_type: Union[str, Combinable] + _pyi_private_set_type: str | Combinable _pyi_private_get_type: str class GenericIPAddressField(Field[_ST, _GT]): - _pyi_private_set_type: Union[str, int, Callable[..., Any], Combinable] + _pyi_private_set_type: str | int | Callable[..., Any] | Combinable _pyi_private_get_type: str default_error_messages: Dict[str, str] = ... @@ -431,8 +415,8 @@ class GenericIPAddressField(Field[_ST, _GT]): protocol: str = ... def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[Any] = ..., + verbose_name: _StrOrPromise | None = ..., + name: Any | None = ..., protocol: str = ..., unpack_ipv4: bool = ..., primary_key: bool = ..., @@ -444,31 +428,31 @@ class GenericIPAddressField(Field[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - choices: Optional[_FieldChoices] = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... class DateTimeCheckMixin: ... class DateField(DateTimeCheckMixin, Field[_ST, _GT]): - _pyi_private_set_type: Union[str, date, Combinable] + _pyi_private_set_type: str | date | Combinable _pyi_private_get_type: date - _pyi_lookup_exact_type: Union[str, date] + _pyi_lookup_exact_type: str | date auto_now: bool auto_now_add: bool def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., auto_now: bool = ..., auto_now_add: bool = ..., *, primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., @@ -477,23 +461,23 @@ class DateField(DateTimeCheckMixin, Field[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - choices: Optional[_FieldChoices] = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... class TimeField(DateTimeCheckMixin, Field[_ST, _GT]): - _pyi_private_set_type: Union[str, time, real_datetime, Combinable] + _pyi_private_set_type: str | time | real_datetime | Combinable _pyi_private_get_type: time auto_now: bool auto_now_add: bool def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., auto_now: bool = ..., auto_now_add: bool = ..., *, @@ -506,62 +490,62 @@ class TimeField(DateTimeCheckMixin, Field[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - choices: Optional[_FieldChoices] = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... class DateTimeField(DateField[_ST, _GT]): - _pyi_private_set_type: Union[str, real_datetime, date, Combinable] + _pyi_private_set_type: str | real_datetime | date | Combinable _pyi_private_get_type: real_datetime - _pyi_lookup_exact_type: Union[str, real_datetime] + _pyi_lookup_exact_type: str | real_datetime class UUIDField(Field[_ST, _GT]): - _pyi_private_set_type: Union[str, uuid.UUID] + _pyi_private_set_type: str | uuid.UUID _pyi_private_get_type: uuid.UUID - _pyi_lookup_exact_type: Union[uuid.UUID, str] + _pyi_lookup_exact_type: uuid.UUID | str def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., + verbose_name: _StrOrPromise | None = ..., *, - name: Optional[str] = ..., + name: str | None = ..., primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., db_index: bool = ..., - rel: Optional[ForeignObjectRel] = ..., + rel: ForeignObjectRel | None = ..., default: Any = ..., editable: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., auto_created: bool = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... class FilePathField(Field[_ST, _GT]): path: Any = ... - match: Optional[str] = ... + match: str | None = ... recursive: bool = ... allow_files: bool = ... allow_folders: bool = ... def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., - path: Union[str, Callable[..., str]] = ..., - match: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., + path: str | Callable[..., str] = ..., + match: str | None = ..., recursive: bool = ..., allow_files: bool = ..., allow_folders: bool = ..., @@ -576,16 +560,16 @@ class FilePathField(Field[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - choices: Optional[_FieldChoices] = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... class BinaryField(Field[_ST, _GT]): - _pyi_private_get_type: Union[bytes, memoryview] + _pyi_private_get_type: bytes | memoryview class DurationField(Field[_ST, _GT]): _pyi_private_get_type: timedelta @@ -596,9 +580,9 @@ class AutoFieldMixin: class AutoFieldMeta(type): ... class AutoField(AutoFieldMixin, IntegerField[_ST, _GT], metaclass=AutoFieldMeta): - _pyi_private_set_type: Union[Combinable, int, str] + _pyi_private_set_type: Combinable | int | str _pyi_private_get_type: int - _pyi_lookup_exact_type: Union[str, int] + _pyi_lookup_exact_type: str | int class BigAutoField(AutoFieldMixin, BigIntegerField[_ST, _GT]): ... class SmallAutoField(AutoFieldMixin, SmallIntegerField[_ST, _GT]): ... diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index 3f83253a0..743880460 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Iterable, Type, TypeVar, overload from django.core import validators # due to weird mypy.stubtest error from django.core.files.base import File @@ -15,8 +15,8 @@ class FieldFile(File): instance: Model = ... field: FileField = ... storage: Storage = ... - name: Optional[str] - def __init__(self, instance: Model, field: FileField, name: Optional[str]) -> None: ... + name: str | None + def __init__(self, instance: Model, field: FileField, name: str | None) -> None: ... file: Any = ... @property def path(self) -> str: ... @@ -31,10 +31,8 @@ class FieldFile(File): class FileDescriptor(DeferredAttribute): field: FileField = ... - def __set__(self, instance: Model, value: Optional[Any]) -> None: ... - def __get__( - self, instance: Optional[Model], cls: Optional[Type[Model]] = ... - ) -> Union[FieldFile, FileDescriptor]: ... + def __set__(self, instance: Model, value: Any | None) -> None: ... + def __get__(self, instance: Model | None, cls: Type[Model] | None = ...) -> FieldFile | FileDescriptor: ... _T = TypeVar("_T", bound="Field") _M = TypeVar("_M", bound=Model, contravariant=True) @@ -44,15 +42,15 @@ class _UploadToCallable(Protocol[_M]): class FileField(Field): storage: Storage = ... - upload_to: Union[_PathCompatible, _UploadToCallable] = ... + upload_to: _PathCompatible | _UploadToCallable = ... def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., - upload_to: Union[_PathCompatible, _UploadToCallable] = ..., - storage: Optional[Union[Storage, Callable[[], Storage]]] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., + upload_to: _PathCompatible | _UploadToCallable = ..., + storage: Storage | Callable[[], Storage] | None = ..., *, - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., @@ -61,15 +59,15 @@ class FileField(Field): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... # class access @overload # type: ignore @@ -80,11 +78,11 @@ class FileField(Field): # non-Model instances @overload def __get__(self: _T, instance: Any, owner: Any) -> _T: ... - def generate_filename(self, instance: Optional[Model], filename: _PathCompatible) -> str: ... + def generate_filename(self, instance: Model | None, filename: _PathCompatible) -> str: ... class ImageFileDescriptor(FileDescriptor): field: ImageField - def __set__(self, instance: Model, value: Optional[str]) -> None: ... + def __set__(self, instance: Model, value: str | None) -> None: ... class ImageFieldFile(ImageFile, FieldFile): field: ImageField @@ -93,10 +91,10 @@ class ImageFieldFile(ImageFile, FieldFile): class ImageField(FileField): def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., - width_field: Optional[str] = ..., - height_field: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., + width_field: str | None = ..., + height_field: str | None = ..., **kwargs: Any, ) -> None: ... # class access diff --git a/django-stubs/db/models/fields/json.pyi b/django-stubs/db/models/fields/json.pyi index 36b03b2f2..8f7177018 100644 --- a/django-stubs/db/models/fields/json.pyi +++ b/django-stubs/db/models/fields/json.pyi @@ -1,5 +1,5 @@ import json -from typing import Any, Optional, Type +from typing import Any, Type from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models import lookups @@ -11,14 +11,14 @@ from . import Field from .mixins import CheckFieldDefaultMixin class JSONField(CheckFieldDefaultMixin, Field): - encoder: Optional[Type[json.JSONEncoder]] - decoder: Optional[Type[json.JSONDecoder]] + encoder: Type[json.JSONEncoder] | None + decoder: Type[json.JSONDecoder] | None def __init__( self, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., - encoder: Optional[Type[json.JSONEncoder]] = ..., - decoder: Optional[Type[json.JSONDecoder]] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., + encoder: Type[json.JSONEncoder] | None = ..., + decoder: Type[json.JSONDecoder] | None = ..., **kwargs: Any ) -> None: ... @@ -26,7 +26,7 @@ class DataContains(PostgresOperatorLookup): ... class ContainedBy(PostgresOperatorLookup): ... class HasKeyLookup(PostgresOperatorLookup): - logical_operator: Optional[str] = ... + logical_operator: str | None = ... class HasKey(HasKeyLookup): postgres_operator: str = ... diff --git a/django-stubs/db/models/fields/mixins.pyi b/django-stubs/db/models/fields/mixins.pyi index 4ac08453a..28521f099 100644 --- a/django-stubs/db/models/fields/mixins.pyi +++ b/django-stubs/db/models/fields/mixins.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.db.models.base import Model @@ -6,9 +6,9 @@ NOT_PROVIDED: Any class FieldCacheMixin: def get_cache_name(self) -> str: ... - def get_cached_value(self, instance: Model, default: Any = ...) -> Optional[Model]: ... + def get_cached_value(self, instance: Model, default: Any = ...) -> Model | None: ... def is_cached(self, instance: Model) -> bool: ... - def set_cached_value(self, instance: Model, value: Optional[Model]) -> None: ... + def set_cached_value(self, instance: Model, value: Model | None) -> None: ... def delete_cached_value(self, instance: Model) -> None: ... class CheckFieldDefaultMixin: diff --git a/django-stubs/db/models/fields/related.pyi b/django-stubs/db/models/fields/related.pyi index 18c986a95..6c223bf42 100644 --- a/django-stubs/db/models/fields/related.pyi +++ b/django-stubs/db/models/fields/related.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, Iterable, List, Sequence, Tuple, Type, TypeVar, overload from uuid import UUID from django.core import validators # due to weird mypy.stubtest error @@ -28,7 +28,7 @@ _F = TypeVar("_F", bound=models.Field) RECURSIVE_RELATIONSHIP_CONSTANT: Literal["self"] = ... -def resolve_relation(scope_model: Type[Model], relation: Union[str, Type[Model]]) -> Union[str, Type[Model]]: ... +def resolve_relation(scope_model: Type[Model], relation: str | Type[Model]) -> str | Type[Model]: ... # __set__ value type _ST = TypeVar("_ST") @@ -47,10 +47,10 @@ class RelatedField(FieldCacheMixin, Field[_ST, _GT]): swappable: bool @property def related_model(self) -> Type[Model]: ... # type: ignore - def get_forward_related_filter(self, obj: Model) -> Dict[str, Union[int, UUID]]: ... + def get_forward_related_filter(self, obj: Model) -> Dict[str, int | UUID]: ... def get_reverse_related_filter(self, obj: Model) -> Q: ... @property - def swappable_setting(self) -> Optional[str]: ... + def swappable_setting(self) -> str | None: ... def set_attributes_from_rel(self) -> None: ... def do_related_class(self, other: Type[Model], cls: Type[Model]) -> None: ... def get_limit_choices_to(self) -> _LimitChoicesTo: ... @@ -66,20 +66,20 @@ class ForeignObject(RelatedField[_ST, _GT]): swappable: bool def __init__( self, - to: Union[Type[Model], str], + to: Type[Model] | str, on_delete: Callable[..., None], from_fields: Sequence[str], to_fields: Sequence[str], - rel: Optional[ForeignObjectRel] = ..., - related_name: Optional[str] = ..., - related_query_name: Optional[str] = ..., - limit_choices_to: Optional[_AllLimitChoicesTo] = ..., + rel: ForeignObjectRel | None = ..., + related_name: str | None = ..., + related_query_name: str | None = ..., + limit_choices_to: _AllLimitChoicesTo | None = ..., parent_link: bool = ..., swappable: bool = ..., *, db_constraint: bool = ..., - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., primary_key: bool = ..., unique: bool = ..., blank: bool = ..., @@ -89,12 +89,12 @@ class ForeignObject(RelatedField[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - choices: Optional[_FieldChoices] = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... def resolve_related_fields(self) -> List[Tuple[Field, Field]]: ... @property @@ -107,26 +107,26 @@ class ForeignObject(RelatedField[_ST, _GT]): def foreign_related_fields(self) -> Tuple[Field, ...]: ... class ForeignKey(ForeignObject[_ST, _GT]): - _pyi_private_set_type: Union[Any, Combinable] + _pyi_private_set_type: Any | Combinable _pyi_private_get_type: Any remote_field: ManyToOneRel rel_class: Type[ManyToOneRel] def __init__( self, - to: Union[Type[Model], str], + to: Type[Model] | str, on_delete: Callable[..., None], - related_name: Optional[str] = ..., - related_query_name: Optional[str] = ..., - limit_choices_to: Optional[_AllLimitChoicesTo] = ..., + related_name: str | None = ..., + related_query_name: str | None = ..., + limit_choices_to: _AllLimitChoicesTo | None = ..., parent_link: bool = ..., - to_field: Optional[str] = ..., + to_field: str | None = ..., db_constraint: bool = ..., *, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., @@ -135,15 +135,15 @@ class ForeignKey(ForeignObject[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... # class access @overload # type: ignore @@ -156,26 +156,26 @@ class ForeignKey(ForeignObject[_ST, _GT]): def __get__(self: _F, instance: Any, owner: Any) -> _F: ... class OneToOneField(ForeignKey[_ST, _GT]): - _pyi_private_set_type: Union[Any, Combinable] + _pyi_private_set_type: Any | Combinable _pyi_private_get_type: Any remote_field: OneToOneRel rel_class: Type[OneToOneRel] def __init__( self, - to: Union[Type[Model], str], + to: Type[Model] | str, on_delete: Any, - to_field: Optional[str] = ..., + to_field: str | None = ..., *, - related_name: Optional[str] = ..., - related_query_name: Optional[str] = ..., - limit_choices_to: Optional[_AllLimitChoicesTo] = ..., + related_name: str | None = ..., + related_query_name: str | None = ..., + limit_choices_to: _AllLimitChoicesTo | None = ..., parent_link: bool = ..., db_constraint: bool = ..., - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., @@ -184,15 +184,15 @@ class OneToOneField(ForeignKey[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... # class access @overload # type: ignore @@ -221,21 +221,21 @@ class ManyToManyField(RelatedField[_ST, _GT]): rel_class: Type[ManyToManyRel] def __init__( self, - to: Union[Type[Model], str], - related_name: Optional[str] = ..., - related_query_name: Optional[str] = ..., - limit_choices_to: Optional[_AllLimitChoicesTo] = ..., - symmetrical: Optional[bool] = ..., - through: Union[str, Type[Model], None] = ..., - through_fields: Optional[Tuple[str, str]] = ..., + to: Type[Model] | str, + related_name: str | None = ..., + related_query_name: str | None = ..., + limit_choices_to: _AllLimitChoicesTo | None = ..., + symmetrical: bool | None = ..., + through: str | Type[Model] | None = ..., + through_fields: Tuple[str, str] | None = ..., db_constraint: bool = ..., - db_table: Optional[str] = ..., + db_table: str | None = ..., swappable: bool = ..., *, - verbose_name: Optional[_StrOrPromise] = ..., - name: Optional[str] = ..., + verbose_name: _StrOrPromise | None = ..., + name: str | None = ..., primary_key: bool = ..., - max_length: Optional[int] = ..., + max_length: int | None = ..., unique: bool = ..., blank: bool = ..., null: bool = ..., @@ -244,15 +244,15 @@ class ManyToManyField(RelatedField[_ST, _GT]): editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., - unique_for_date: Optional[str] = ..., - unique_for_month: Optional[str] = ..., - unique_for_year: Optional[str] = ..., - choices: Optional[_FieldChoices] = ..., + unique_for_date: str | None = ..., + unique_for_month: str | None = ..., + unique_for_year: str | None = ..., + choices: _FieldChoices | None = ..., help_text: _StrOrPromise = ..., - db_column: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + db_column: str | None = ..., + db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., ) -> None: ... # class access @overload # type: ignore @@ -263,8 +263,8 @@ class ManyToManyField(RelatedField[_ST, _GT]): # non-Model instances @overload def __get__(self: _F, instance: Any, owner: Any) -> _F: ... - def get_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ... - def get_reverse_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ... + def get_path_info(self, filtered_relation: FilteredRelation | None = ...) -> List[PathInfo]: ... + def get_reverse_path_info(self, filtered_relation: FilteredRelation | None = ...) -> List[PathInfo]: ... def contribute_to_related_class(self, cls: Type[Model], related: RelatedField) -> None: ... def m2m_db_table(self) -> str: ... def m2m_column_name(self) -> str: ... diff --git a/django-stubs/db/models/fields/related_descriptors.pyi b/django-stubs/db/models/fields/related_descriptors.pyi index 9cc56a8bf..c1b479582 100644 --- a/django-stubs/db/models/fields/related_descriptors.pyi +++ b/django-stubs/db/models/fields/related_descriptors.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Generic, List, Optional, Tuple, Type, TypeVar, Union +from typing import Any, Callable, Generic, List, Tuple, Type, TypeVar from django.core.exceptions import ObjectDoesNotExist from django.db.models.base import Model @@ -23,13 +23,13 @@ class ForwardManyToOneDescriptor: def is_cached(self, instance: Model) -> bool: ... def get_queryset(self, **hints: Any) -> QuerySet: ... def get_prefetch_queryset( - self, instances: List[Model], queryset: Optional[QuerySet] = ... + self, instances: List[Model], queryset: QuerySet | None = ... ) -> Tuple[QuerySet, Callable, Callable, bool, str, bool]: ... def get_object(self, instance: Model) -> Model: ... def __get__( - self, instance: Optional[Model], cls: Optional[Type[Model]] = ... - ) -> Optional[Union[Model, ForwardManyToOneDescriptor]]: ... - def __set__(self, instance: Model, value: Optional[Model]) -> None: ... + self, instance: Model | None, cls: Type[Model] | None = ... + ) -> Model | ForwardManyToOneDescriptor | None: ... + def __set__(self, instance: Model, value: Model | None) -> None: ... def __reduce__(self) -> Tuple[Callable, Tuple[Type[Model], str]]: ... class ForwardOneToOneDescriptor(ForwardManyToOneDescriptor): @@ -44,12 +44,10 @@ class ReverseOneToOneDescriptor: def is_cached(self, instance: Model) -> bool: ... def get_queryset(self, **hints: Any) -> QuerySet: ... def get_prefetch_queryset( - self, instances: List[Model], queryset: Optional[QuerySet] = ... + self, instances: List[Model], queryset: QuerySet | None = ... ) -> Tuple[QuerySet, Callable, Callable, bool, str, bool]: ... - def __get__( - self, instance: Optional[Model], cls: Optional[Type[Model]] = ... - ) -> Union[Model, ReverseOneToOneDescriptor]: ... - def __set__(self, instance: Model, value: Optional[Model]) -> None: ... + def __get__(self, instance: Model | None, cls: Type[Model] | None = ...) -> Model | ReverseOneToOneDescriptor: ... + def __set__(self, instance: Model, value: Model | None) -> None: ... def __reduce__(self) -> Tuple[Callable, Tuple[Type[Model], str]]: ... class ReverseManyToOneDescriptor: @@ -58,7 +56,7 @@ class ReverseManyToOneDescriptor: def __init__(self, rel: ManyToOneRel) -> None: ... @property def related_manager_cls(self) -> Type[RelatedManager]: ... - def __get__(self, instance: Optional[Model], cls: Optional[Type[Model]] = ...) -> ReverseManyToOneDescriptor: ... + def __get__(self, instance: Model | None, cls: Type[Model] | None = ...) -> ReverseManyToOneDescriptor: ... def __set__(self, instance: Model, value: List[Model]) -> Any: ... def create_reverse_many_to_one_manager(superclass: Type, rel: Any) -> Type[RelatedManager]: ... diff --git a/django-stubs/db/models/fields/related_lookups.pyi b/django-stubs/db/models/fields/related_lookups.pyi index 826742993..2b9d868ad 100644 --- a/django-stubs/db/models/fields/related_lookups.pyi +++ b/django-stubs/db/models/fields/related_lookups.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, Mapping, Optional, Tuple, Type +from typing import Any, Iterable, List, Mapping, Tuple, Type from django.db.models.fields import Field from django.db.models.lookups import ( @@ -23,7 +23,7 @@ class MultiColSource: self, alias: str, targets: Tuple[Field, Field], sources: Tuple[Field, Field], field: Field ) -> None: ... def relabeled_clone(self, relabels: Mapping[str, str]) -> MultiColSource: ... - def get_lookup(self, lookup: str) -> Optional[Type[Lookup]]: ... + def get_lookup(self, lookup: str) -> Type[Lookup] | None: ... def get_normalized_value(value: Any, lhs: Any) -> Tuple[Any, ...]: ... diff --git a/django-stubs/db/models/fields/reverse_related.pyi b/django-stubs/db/models/fields/reverse_related.pyi index 1503cc66b..ed037ba5b 100644 --- a/django-stubs/db/models/fields/reverse_related.pyi +++ b/django-stubs/db/models/fields/reverse_related.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Optional, Sequence, Tuple, Type, Union +from typing import Any, Callable, List, Sequence, Tuple, Type from django.db.models.base import Model from django.db.models.fields import AutoField, Field, _AllLimitChoicesTo, _ChoicesList, _LimitChoicesTo @@ -24,21 +24,21 @@ class ForeignObjectRel(FieldCacheMixin): null: bool = ... field: ForeignObject = ... model: Type[Model] = ... - related_name: Optional[str] = ... - related_query_name: Optional[str] = ... - limit_choices_to: Optional[_AllLimitChoicesTo] = ... + related_name: str | None = ... + related_query_name: str | None = ... + limit_choices_to: _AllLimitChoicesTo | None = ... parent_link: bool = ... on_delete: Callable = ... symmetrical: bool = ... multiple: bool = ... - field_name: Optional[str] = ... + field_name: str | None = ... def __init__( self, field: ForeignObject, - to: Union[Type[Model], str], - related_name: Optional[str] = ..., - related_query_name: Optional[str] = ..., - limit_choices_to: Optional[_AllLimitChoicesTo] = ..., + to: Type[Model] | str, + related_name: str | None = ..., + related_query_name: str | None = ..., + limit_choices_to: _AllLimitChoicesTo | None = ..., parent_link: bool = ..., on_delete: Callable = ..., ) -> None: ... @@ -60,7 +60,7 @@ class ForeignObjectRel(FieldCacheMixin): def one_to_many(self) -> bool: ... @property def one_to_one(self) -> bool: ... - def get_lookup(self, lookup_name: str) -> Optional[Type[Lookup]]: ... + def get_lookup(self, lookup_name: str) -> Type[Lookup] | None: ... def get_internal_type(self) -> str: ... @property def db_type(self) -> Any: ... @@ -70,28 +70,28 @@ class ForeignObjectRel(FieldCacheMixin): self, include_blank: bool = ..., blank_choice: _ChoicesList = ..., - limit_choices_to: Optional[_LimitChoicesTo] = ..., + limit_choices_to: _LimitChoicesTo | None = ..., ordering: Sequence[str] = ..., ) -> _ChoicesList: ... def is_hidden(self) -> bool: ... def get_joining_columns(self) -> Tuple: ... def get_extra_restriction( self, where_class: Type[WhereNode], alias: str, related_alias: str - ) -> Optional[Union[StartsWith, WhereNode]]: ... + ) -> StartsWith | WhereNode | None: ... def set_field_name(self) -> None: ... - def get_accessor_name(self, model: Optional[Type[Model]] = ...) -> Optional[str]: ... - def get_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ... + def get_accessor_name(self, model: Type[Model] | None = ...) -> str | None: ... + def get_path_info(self, filtered_relation: FilteredRelation | None = ...) -> List[PathInfo]: ... class ManyToOneRel(ForeignObjectRel): field: ForeignKey def __init__( self, field: ForeignKey, - to: Union[Type[Model], str], + to: Type[Model] | str, field_name: str, - related_name: Optional[str] = ..., - related_query_name: Optional[str] = ..., - limit_choices_to: Optional[_AllLimitChoicesTo] = ..., + related_name: str | None = ..., + related_query_name: str | None = ..., + limit_choices_to: _AllLimitChoicesTo | None = ..., parent_link: bool = ..., on_delete: Callable = ..., ) -> None: ... @@ -102,30 +102,30 @@ class OneToOneRel(ManyToOneRel): def __init__( self, field: OneToOneField, - to: Union[Type[Model], str], - field_name: Optional[str], - related_name: Optional[str] = ..., - related_query_name: Optional[str] = ..., - limit_choices_to: Optional[_AllLimitChoicesTo] = ..., + to: Type[Model] | str, + field_name: str | None, + related_name: str | None = ..., + related_query_name: str | None = ..., + limit_choices_to: _AllLimitChoicesTo | None = ..., parent_link: bool = ..., on_delete: Callable = ..., ) -> None: ... class ManyToManyRel(ForeignObjectRel): field: ManyToManyField # type: ignore - through: Optional[Type[Model]] = ... - through_fields: Optional[Tuple[str, str]] = ... + through: Type[Model] | None = ... + through_fields: Tuple[str, str] | None = ... db_constraint: bool = ... def __init__( self, field: ManyToManyField, - to: Union[Type[Model], str], - related_name: Optional[str] = ..., - related_query_name: Optional[str] = ..., - limit_choices_to: Optional[_AllLimitChoicesTo] = ..., + to: Type[Model] | str, + related_name: str | None = ..., + related_query_name: str | None = ..., + limit_choices_to: _AllLimitChoicesTo | None = ..., symmetrical: bool = ..., - through: Union[Type[Model], str, None] = ..., - through_fields: Optional[Tuple[str, str]] = ..., + through: Type[Model] | str | None = ..., + through_fields: Tuple[str, str] | None = ..., db_constraint: bool = ..., ) -> None: ... def get_related_field(self) -> Field: ... diff --git a/django-stubs/db/models/functions/comparison.pyi b/django-stubs/db/models/functions/comparison.pyi index 4360f7098..7f96b6c03 100644 --- a/django-stubs/db/models/functions/comparison.pyi +++ b/django-stubs/db/models/functions/comparison.pyi @@ -1,11 +1,11 @@ -from typing import Any, Union +from typing import Any from django.db.models import Func from django.db.models.fields import Field from django.db.models.fields.json import JSONField class Cast(Func): - def __init__(self, expression: Any, output_field: Union[str, Field]) -> None: ... + def __init__(self, expression: Any, output_field: str | Field) -> None: ... class Coalesce(Func): ... diff --git a/django-stubs/db/models/functions/datetime.pyi b/django-stubs/db/models/functions/datetime.pyi index a5973e079..2680d8adb 100644 --- a/django-stubs/db/models/functions/datetime.pyi +++ b/django-stubs/db/models/functions/datetime.pyi @@ -1,17 +1,17 @@ -from typing import Any, Optional +from typing import Any from django.db import models from django.db.models import Func, Transform class TimezoneMixin: tzinfo: Any = ... - def get_tzname(self) -> Optional[str]: ... + def get_tzname(self) -> str | None: ... class Extract(TimezoneMixin, Transform): lookup_name: str output_field: models.IntegerField def __init__( - self, expression: Any, lookup_name: Optional[str] = ..., tzinfo: Optional[Any] = ..., **extra: Any + self, expression: Any, lookup_name: str | None = ..., tzinfo: Any | None = ..., **extra: Any ) -> None: ... class ExtractYear(Extract): ... diff --git a/django-stubs/db/models/functions/text.pyi b/django-stubs/db/models/functions/text.pyi index 19ebb4097..6d72c1a9f 100644 --- a/django-stubs/db/models/functions/text.pyi +++ b/django-stubs/db/models/functions/text.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Tuple, Union +from typing import Any, List, Tuple from django.db import models from django.db.backends.base.base import BaseDatabaseWrapper @@ -34,7 +34,7 @@ class Concat(Func): class Left(Func): output_field: models.CharField = ... - def __init__(self, expression: Union[Expression, str], length: Union[Expression, int], **extra: Any) -> None: ... + def __init__(self, expression: Expression | str, length: Expression | int, **extra: Any) -> None: ... def get_substr(self) -> Substr: ... def as_oracle(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... @@ -48,11 +48,7 @@ class Lower(Transform): ... class LPad(Func): output_field: models.CharField = ... def __init__( - self, - expression: Union[Expression, str], - length: Union[Expression, int, None], - fill_text: Expression = ..., - **extra: Any + self, expression: Expression | str, length: Expression | int | None, fill_text: Expression = ..., **extra: Any ) -> None: ... class LTrim(Transform): ... @@ -64,15 +60,11 @@ class Ord(Transform): class Repeat(Func): output_field: models.CharField = ... - def __init__( - self, expression: Union[Expression, str], number: Union[Expression, int, None], **extra: Any - ) -> None: ... + def __init__(self, expression: Expression | str, number: Expression | int | None, **extra: Any) -> None: ... def as_oracle(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... class Replace(Func): - def __init__( - self, expression: Union[Combinable, str], text: Value, replacement: Value = ..., **extra: Any - ) -> None: ... + def __init__(self, expression: Combinable | str, text: Value, replacement: Value = ..., **extra: Any) -> None: ... class Reverse(Transform): def as_oracle(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... @@ -100,11 +92,7 @@ class StrIndex(Func): class Substr(Func): output_field: models.CharField = ... def __init__( - self, - expression: Union[Expression, str], - pos: Union[Expression, int], - length: Union[Expression, int, None] = ..., - **extra: Any + self, expression: Expression | str, pos: Expression | int, length: Expression | int | None = ..., **extra: Any ) -> None: ... def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... def as_oracle(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... diff --git a/django-stubs/db/models/functions/window.pyi b/django-stubs/db/models/functions/window.pyi index 0807af12b..3b080a94c 100644 --- a/django-stubs/db/models/functions/window.pyi +++ b/django-stubs/db/models/functions/window.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.db import models from django.db.models.expressions import Func @@ -12,16 +12,14 @@ class DenseRank(Func): class FirstValue(Func): ... class LagLeadFunction(Func): - def __init__( - self, expression: Optional[str], offset: int = ..., default: Optional[int] = ..., **extra: Any - ) -> None: ... + def __init__(self, expression: str | None, offset: int = ..., default: int | None = ..., **extra: Any) -> None: ... class Lag(LagLeadFunction): ... class LastValue(Func): ... class Lead(LagLeadFunction): ... class NthValue(Func): - def __init__(self, expression: Optional[str], nth: int = ..., **extra: Any) -> None: ... + def __init__(self, expression: str | None, nth: int = ..., **extra: Any) -> None: ... class Ntile(Func): def __init__(self, num_buckets: int = ..., **extra: Any) -> None: ... diff --git a/django-stubs/db/models/indexes.pyi b/django-stubs/db/models/indexes.pyi index c37d6aa94..b10fd55ae 100644 --- a/django-stubs/db/models/indexes.pyi +++ b/django-stubs/db/models/indexes.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Sequence, Set, Tuple, Type, Union +from typing import Any, List, Sequence, Set, Tuple, Type from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.base.schema import BaseDatabaseSchemaEditor @@ -15,20 +15,20 @@ class Index: fields: Sequence[str] = ... fields_orders: Sequence[Tuple[str, str]] = ... name: str = ... - db_tablespace: Optional[str] = ... + db_tablespace: str | None = ... opclasses: Sequence[str] = ... - condition: Optional[Q] = ... - expressions: Sequence[Union[Union[BaseExpression, Combinable]]] + condition: Q | None = ... + expressions: Sequence[BaseExpression | Combinable] include: Sequence[str] def __init__( self, - *expressions: Union[BaseExpression, Combinable, str], + *expressions: BaseExpression | Combinable | str, fields: Sequence[str] = ..., - name: Optional[str] = ..., - db_tablespace: Optional[str] = ..., + name: str | None = ..., + db_tablespace: str | None = ..., opclasses: Sequence[str] = ..., - condition: Optional[Q] = ..., - include: Optional[Sequence[str]] = ..., + condition: Q | None = ..., + include: Sequence[str] | None = ..., ) -> None: ... @property def contains_expressions(self) -> bool: ... @@ -43,14 +43,14 @@ class Index: class IndexExpression(Func): template: str = ... wrapper_classes: Sequence[Expression] = ... - def set_wrapper_classes(self, connection: Optional[Any] = ...) -> None: ... + def set_wrapper_classes(self, connection: Any | None = ...) -> None: ... @classmethod def register_wrappers(cls, *wrapper_classes: Expression) -> None: ... def resolve_expression( self, - query: Optional[Any] = ..., + query: Any | None = ..., allow_joins: bool = ..., - reuse: Optional[Set[str]] = ..., + reuse: Set[str] | None = ..., summarize: bool = ..., for_save: bool = ..., ) -> IndexExpression: ... diff --git a/django-stubs/db/models/lookups.pyi b/django-stubs/db/models/lookups.pyi index 163d548cc..6fd5052a7 100644 --- a/django-stubs/db/models/lookups.pyi +++ b/django-stubs/db/models/lookups.pyi @@ -1,4 +1,4 @@ -from typing import Any, Generic, Iterable, List, Mapping, Optional, Tuple, Type, TypeVar, Union +from typing import Any, Generic, Iterable, List, Mapping, Tuple, Type, TypeVar from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.expressions import Expression, Func @@ -20,19 +20,19 @@ class Lookup(Generic[_T]): def __init__(self, lhs: Any, rhs: Any) -> None: ... def apply_bilateral_transforms(self, value: Expression) -> Expression: ... def batch_process_rhs( - self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, rhs: Optional[OrderedSet] = ... + self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, rhs: OrderedSet | None = ... ) -> Tuple[List[str], List[str]]: ... def get_source_expressions(self) -> List[Expression]: ... def set_source_expressions(self, new_exprs: List[Expression]) -> None: ... def get_prep_lookup(self) -> Any: ... def get_db_prep_lookup(self, value: _ParamT, connection: BaseDatabaseWrapper) -> _AsSqlType: ... def process_lhs( - self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, lhs: Optional[Expression] = ... + self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, lhs: Expression | None = ... ) -> _AsSqlType: ... def process_rhs(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... def rhs_is_direct_value(self) -> bool: ... def relabeled_clone(self: _L, relabels: Mapping[str, str]) -> _L: ... - def get_group_by_cols(self, alias: Optional[str] = ...) -> List[Expression]: ... + def get_group_by_cols(self, alias: str | None = ...) -> List[Expression]: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... def as_oracle(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... @property @@ -52,7 +52,7 @@ class Transform(RegisterLookupMixin, Func): class BuiltinLookup(Lookup[_T]): def process_lhs( - self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, lhs: Optional[Expression] = ... + self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, lhs: Expression | None = ... ) -> _AsSqlType: ... def get_rhs_op(self, connection: BaseDatabaseWrapper, rhs: str) -> str: ... @@ -82,8 +82,8 @@ class IntegerFieldFloatRounding: rhs: Any = ... def get_prep_lookup(self) -> Any: ... -class IntegerGreaterThanOrEqual(IntegerFieldFloatRounding, GreaterThanOrEqual[Union[int, float]]): ... -class IntegerLessThan(IntegerFieldFloatRounding, LessThan[Union[int, float]]): ... +class IntegerGreaterThanOrEqual(IntegerFieldFloatRounding, GreaterThanOrEqual[int | float]): ... +class IntegerLessThan(IntegerFieldFloatRounding, LessThan[int | float]): ... class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup): def split_parameter_list_as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> Any: ... diff --git a/django-stubs/db/models/manager.pyi b/django-stubs/db/models/manager.pyi index 8f0291c07..ea76d7e01 100644 --- a/django-stubs/db/models/manager.pyi +++ b/django-stubs/db/models/manager.pyi @@ -9,12 +9,10 @@ from typing import ( List, MutableMapping, NoReturn, - Optional, Sequence, Tuple, Type, TypeVar, - Union, overload, ) @@ -33,18 +31,18 @@ class BaseManager(Generic[_T]): use_in_migrations: bool = ... name: str = ... model: Type[_T] = ... - _db: Optional[str] + _db: str | None def __init__(self) -> None: ... def deconstruct( self, - ) -> Tuple[bool, Optional[str], Optional[str], Optional[Tuple[Any, ...]], Optional[Dict[str, Any]]]: ... + ) -> Tuple[bool, str | None, str | None, Tuple[Any, ...] | None, Dict[str, Any] | None]: ... def check(self, **kwargs: Any) -> List[Any]: ... @classmethod - def from_queryset(cls, queryset_class: Type[QuerySet], class_name: Optional[str] = ...) -> Any: ... + def from_queryset(cls, queryset_class: Type[QuerySet], class_name: str | None = ...) -> Any: ... @classmethod def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ... def contribute_to_class(self, cls: Type[Model], name: str) -> None: ... - def db_manager(self: _M, using: Optional[str] = ..., hints: Optional[Dict[str, Model]] = ...) -> _M: ... + def db_manager(self: _M, using: str | None = ..., hints: Dict[str, Model] | None = ...) -> _M: ... @property def db(self) -> str: ... def get_queryset(self) -> QuerySet[_T]: ... @@ -61,41 +59,39 @@ class BaseManager(Generic[_T]): def bulk_create( self, objs: Iterable[_T], - batch_size: Optional[int] = ..., + batch_size: int | None = ..., ignore_conflicts: bool = ..., update_conflicts: bool = ..., - update_fields: Optional[Collection[str]] = ..., - unique_fields: Optional[Collection[str]] = ..., + update_fields: Collection[str] | None = ..., + unique_fields: Collection[str] | None = ..., ) -> List[_T]: ... async def abulk_create( self, objs: Iterable[_T], - batch_size: Optional[int] = ..., + batch_size: int | None = ..., ignore_conflicts: bool = ..., update_conflicts: bool = ..., - update_fields: Optional[Collection[str]] = ..., - unique_fields: Optional[Collection[str]] = ..., + update_fields: Collection[str] | None = ..., + unique_fields: Collection[str] | None = ..., ) -> List[_T]: ... - def bulk_update(self, objs: Iterable[_T], fields: Sequence[str], batch_size: Optional[int] = ...) -> int: ... - async def abulk_update(self, objs: Iterable[_T], fields: Sequence[str], batch_size: Optional[int] = ...) -> int: ... - def get_or_create(self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ... + def bulk_update(self, objs: Iterable[_T], fields: Sequence[str], batch_size: int | None = ...) -> int: ... + async def abulk_update(self, objs: Iterable[_T], fields: Sequence[str], batch_size: int | None = ...) -> int: ... + def get_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> Tuple[_T, bool]: ... async def aget_or_create( - self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any - ) -> Tuple[_T, bool]: ... - def update_or_create( - self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any + self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any ) -> Tuple[_T, bool]: ... + def update_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> Tuple[_T, bool]: ... async def aupdate_or_create( - self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any + self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any ) -> Tuple[_T, bool]: ... - def earliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ... - async def aearliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ... - def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ... - async def alatest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ... - def first(self) -> Optional[_T]: ... - async def afirst(self) -> Optional[_T]: ... - def last(self) -> Optional[_T]: ... - async def alast(self) -> Optional[_T]: ... + def earliest(self, *fields: Any, field_name: Any | None = ...) -> _T: ... + async def aearliest(self, *fields: Any, field_name: Any | None = ...) -> _T: ... + def latest(self, *fields: Any, field_name: Any | None = ...) -> _T: ... + async def alatest(self, *fields: Any, field_name: Any | None = ...) -> _T: ... + def first(self) -> _T | None: ... + async def afirst(self) -> _T | None: ... + def last(self) -> _T | None: ... + async def alast(self) -> _T | None: ... def in_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ... async def ain_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ... def delete(self) -> Tuple[int, Dict[str, int]]: ... @@ -104,26 +100,26 @@ class BaseManager(Generic[_T]): async def aupdate(self, **kwargs: Any) -> int: ... def exists(self) -> bool: ... async def aexists(self) -> bool: ... - def explain(self, *, format: Optional[Any] = ..., **options: Any) -> str: ... - async def aexplain(self, *, format: Optional[Any] = ..., **options: Any) -> str: ... + def explain(self, *, format: Any | None = ..., **options: Any) -> str: ... + async def aexplain(self, *, format: Any | None = ..., **options: Any) -> str: ... def contains(self, objs: Model) -> bool: ... async def acontains(self, objs: Model) -> bool: ... def raw( self, raw_query: str, params: Any = ..., - translations: Optional[Dict[str, str]] = ..., - using: Optional[str] = ..., + translations: Dict[str, str] | None = ..., + using: str | None = ..., ) -> RawQuerySet: ... # The type of values may be overridden to be more specific in the mypy plugin, depending on the fields param - def values(self, *fields: Union[str, Combinable], **expressions: Any) -> ValuesQuerySet[_T, Dict[str, Any]]: ... + def values(self, *fields: str | Combinable, **expressions: Any) -> ValuesQuerySet[_T, Dict[str, Any]]: ... # The type of values_list may be overridden to be more specific in the mypy plugin, depending on the fields param def values_list( - self, *fields: Union[str, Combinable], flat: bool = ..., named: bool = ... + self, *fields: str | Combinable, flat: bool = ..., named: bool = ... ) -> ValuesQuerySet[_T, Any]: ... def dates(self, field_name: str, kind: str, order: str = ...) -> ValuesQuerySet[_T, datetime.date]: ... def datetimes( - self, field_name: str, kind: str, order: str = ..., tzinfo: Optional[datetime.tzinfo] = ... + self, field_name: str, kind: str, order: str = ..., tzinfo: datetime.tzinfo | None = ... ) -> ValuesQuerySet[_T, datetime.datetime]: ... def none(self) -> QuerySet[_T]: ... def all(self) -> QuerySet[_T]: ... @@ -147,17 +143,17 @@ class BaseManager(Generic[_T]): # extra() return type won't be supported any time soon def extra( self, - select: Optional[Dict[str, Any]] = ..., - where: Optional[List[str]] = ..., - params: Optional[List[Any]] = ..., - tables: Optional[List[str]] = ..., - order_by: Optional[Sequence[str]] = ..., - select_params: Optional[Sequence[Any]] = ..., + select: Dict[str, Any] | None = ..., + where: List[str] | None = ..., + params: List[Any] | None = ..., + tables: List[str] | None = ..., + order_by: Sequence[str] | None = ..., + select_params: Sequence[Any] | None = ..., ) -> QuerySet[Any]: ... def reverse(self) -> QuerySet[_T]: ... def defer(self, *fields: Any) -> QuerySet[_T]: ... def only(self, *fields: Any) -> QuerySet[_T]: ... - def using(self, alias: Optional[str]) -> QuerySet[_T]: ... + def using(self, alias: str | None) -> QuerySet[_T]: ... @property def ordered(self) -> bool: ... @@ -166,11 +162,9 @@ class Manager(BaseManager[_T]): ... # Fake to make ManyToMany work class RelatedManager(Manager[_T]): related_val: Tuple[int, ...] - def add(self, *objs: Union[_T, int], bulk: bool = ...) -> None: ... - def remove(self, *objs: Union[_T, int], bulk: bool = ...) -> None: ... - def set( - self, objs: Union[QuerySet[_T], Iterable[Union[_T, int]]], *, bulk: bool = ..., clear: bool = ... - ) -> None: ... + def add(self, *objs: _T | int, bulk: bool = ...) -> None: ... + def remove(self, *objs: _T | int, bulk: bool = ...) -> None: ... + def set(self, objs: QuerySet[_T] | Iterable[_T | int], *, bulk: bool = ..., clear: bool = ...) -> None: ... def clear(self) -> None: ... def __call__(self, *, manager: str) -> RelatedManager[_T]: ... @@ -178,9 +172,9 @@ class ManagerDescriptor: manager: BaseManager = ... def __init__(self, manager: BaseManager) -> None: ... @overload - def __get__(self, instance: None, cls: Optional[Type[Model]] = ...) -> BaseManager: ... + def __get__(self, instance: None, cls: Type[Model] | None = ...) -> BaseManager: ... @overload - def __get__(self, instance: Model, cls: Optional[Type[Model]] = ...) -> NoReturn: ... + def __get__(self, instance: Model, cls: Type[Model] | None = ...) -> NoReturn: ... class EmptyManager(Manager[_T]): def __init__(self, model: Type[_T]) -> None: ... diff --git a/django-stubs/db/models/options.pyi b/django-stubs/db/models/options.pyi index 42c5b1307..8663c01c3 100644 --- a/django-stubs/db/models/options.pyi +++ b/django-stubs/db/models/options.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Generic, Iterable, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union, overload +from typing import Any, Dict, Generic, Iterable, List, Sequence, Set, Tuple, Type, TypeVar, Union, overload from django.apps.config import AppConfig from django.apps.registry import Apps @@ -23,7 +23,7 @@ DEFAULT_NAMES: Tuple[str, ...] _OptionTogetherT = Union[_ListOrTuple[Union[_ListOrTuple[str], str]], Set[Tuple[str, ...]]] @overload -def normalize_together(option_together: _ListOrTuple[Union[_ListOrTuple[str], str]]) -> Tuple[Tuple[str, ...], ...]: ... +def normalize_together(option_together: _ListOrTuple[_ListOrTuple[str] | str]) -> Tuple[Tuple[str, ...], ...]: ... # Any other value will be returned unchanged, but probably only set is semantically allowed @overload @@ -44,43 +44,43 @@ class Options(Generic[_M]): local_many_to_many: List[ManyToManyField] = ... private_fields: List[Any] = ... local_managers: List[Manager] = ... - base_manager_name: Optional[str] = ... - default_manager_name: Optional[str] = ... - model_name: Optional[str] = ... - verbose_name: Optional[_StrOrPromise] = ... - verbose_name_plural: Optional[_StrOrPromise] = ... + base_manager_name: str | None = ... + default_manager_name: str | None = ... + model_name: str | None = ... + verbose_name: _StrOrPromise | None = ... + verbose_name_plural: _StrOrPromise | None = ... db_table: str = ... - ordering: Optional[Sequence[str]] = ... + ordering: Sequence[str] | None = ... indexes: List[Any] = ... unique_together: Sequence[Tuple[str]] = ... # Are always normalized index_together: Sequence[Tuple[str]] = ... # Are always normalized select_on_save: bool = ... default_permissions: Sequence[str] = ... permissions: List[Any] = ... - object_name: Optional[str] = ... + object_name: str | None = ... app_label: str = ... - get_latest_by: Optional[Sequence[str]] = ... - order_with_respect_to: Optional[str] = ... + get_latest_by: Sequence[str] | None = ... + order_with_respect_to: str | None = ... db_tablespace: str = ... required_db_features: List[str] = ... - required_db_vendor: Optional[Literal["sqlite", "postgresql", "mysql", "oracle"]] = ... - meta: Optional[type] = ... - pk: Optional[Field] = ... - auto_field: Optional[AutoField] = ... + required_db_vendor: Literal["sqlite", "postgresql", "mysql", "oracle"] | None = ... + meta: type | None = ... + pk: Field | None = ... + auto_field: AutoField | None = ... abstract: bool = ... managed: bool = ... proxy: bool = ... - proxy_for_model: Optional[Type[Model]] = ... - concrete_model: Optional[Type[Model]] = ... - swappable: Optional[str] = ... - parents: Dict[Type[Model], Union[GenericForeignKey, Field]] = ... + proxy_for_model: Type[Model] | None = ... + concrete_model: Type[Model] | None = ... + swappable: str | None = ... + parents: Dict[Type[Model], GenericForeignKey | Field] = ... auto_created: bool = ... related_fkey_lookups: List[Any] = ... apps: Apps = ... - default_related_name: Optional[str] = ... + default_related_name: str | None = ... model: Type[Model] = ... original_attrs: Dict[str, Any] = ... - def __init__(self, meta: Optional[type], app_label: Optional[str] = ...) -> None: ... + def __init__(self, meta: type | None, app_label: str | None = ...) -> None: ... @property def label(self) -> str: ... @property @@ -91,17 +91,17 @@ class Options(Generic[_M]): def installed(self) -> bool: ... def contribute_to_class(self, cls: Type[Model], name: str) -> None: ... def add_manager(self, manager: Manager) -> None: ... - def add_field(self, field: Union[GenericForeignKey, Field[Any, Any]], private: bool = ...) -> None: ... + def add_field(self, field: GenericForeignKey | Field[Any, Any], private: bool = ...) -> None: ... # if GenericForeignKey is passed as argument, it has primary_key = True set before - def setup_pk(self, field: Union[GenericForeignKey, Field[Any, Any]]) -> None: ... + def setup_pk(self, field: GenericForeignKey | Field[Any, Any]) -> None: ... def setup_proxy(self, target: Type[Model]) -> None: ... - def can_migrate(self, connection: Union[BaseDatabaseWrapper, str]) -> bool: ... + def can_migrate(self, connection: BaseDatabaseWrapper | str) -> bool: ... @property def verbose_name_raw(self) -> str: ... @property - def swapped(self) -> Optional[str]: ... + def swapped(self) -> str | None: ... @property - def fields_map(self) -> Dict[str, Union[Field[Any, Any], ForeignObjectRel]]: ... + def fields_map(self) -> Dict[str, Field[Any, Any] | ForeignObjectRel]: ... @property def managers(self) -> ImmutableList[Manager]: ... @property @@ -109,18 +109,18 @@ class Options(Generic[_M]): @property def base_manager(self) -> Manager: ... @property - def default_manager(self) -> Optional[Manager]: ... + def default_manager(self) -> Manager | None: ... @property def fields(self) -> ImmutableList[Field[Any, Any]]: ... - def get_field(self, field_name: str) -> Union[Field, ForeignObjectRel, GenericForeignKey]: ... + def get_field(self, field_name: str) -> Field | ForeignObjectRel | GenericForeignKey: ... def get_base_chain(self, model: Type[Model]) -> List[Type[Model]]: ... def get_parent_list(self) -> List[Type[Model]]: ... - def get_ancestor_link(self, ancestor: Type[Model]) -> Optional[OneToOneField]: ... + def get_ancestor_link(self, ancestor: Type[Model]) -> OneToOneField | None: ... def get_path_to_parent(self, parent: Type[Model]) -> List[PathInfo]: ... def get_path_from_parent(self, parent: Type[Model]) -> List[PathInfo]: ... def get_fields( self, include_parents: bool = ..., include_hidden: bool = ... - ) -> List[Union[Field[Any, Any], ForeignObjectRel, GenericForeignKey]]: ... + ) -> List[Field[Any, Any] | ForeignObjectRel | GenericForeignKey]: ... @property def total_unique_constraints(self) -> List[UniqueConstraint]: ... @property diff --git a/django-stubs/db/models/query.pyi b/django-stubs/db/models/query.pyi index c974392a9..4176724ce 100644 --- a/django-stubs/db/models/query.pyi +++ b/django-stubs/db/models/query.pyi @@ -10,14 +10,12 @@ from typing import ( List, MutableMapping, NamedTuple, - Optional, Reversible, Sequence, Sized, Tuple, Type, TypeVar, - Union, overload, ) @@ -66,10 +64,10 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): _iterable_class: Type[BaseIterable] def __init__( self, - model: Optional[Type[Model]] = ..., - query: Optional[Query] = ..., - using: Optional[str] = ..., - hints: Optional[Dict[str, Model]] = ..., + model: Type[Model] | None = ..., + query: Query | None = ..., + using: str | None = ..., + hints: Dict[str, Model] | None = ..., ) -> None: ... @classmethod def as_manager(cls) -> Manager[Any]: ... @@ -92,41 +90,39 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): def bulk_create( self, objs: Iterable[_T], - batch_size: Optional[int] = ..., + batch_size: int | None = ..., ignore_conflicts: bool = ..., update_conflicts: bool = ..., - update_fields: Optional[Collection[str]] = ..., - unique_fields: Optional[Collection[str]] = ..., + update_fields: Collection[str] | None = ..., + unique_fields: Collection[str] | None = ..., ) -> List[_T]: ... async def abulk_create( self, objs: Iterable[_T], - batch_size: Optional[int] = ..., + batch_size: int | None = ..., ignore_conflicts: bool = ..., update_conflicts: bool = ..., - update_fields: Optional[Collection[str]] = ..., - unique_fields: Optional[Collection[str]] = ..., + update_fields: Collection[str] | None = ..., + unique_fields: Collection[str] | None = ..., ) -> List[_T]: ... - def bulk_update(self, objs: Iterable[_T], fields: Iterable[str], batch_size: Optional[int] = ...) -> int: ... - async def abulk_update(self, objs: Iterable[_T], fields: Iterable[str], batch_size: Optional[int] = ...) -> int: ... - def get_or_create(self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ... + def bulk_update(self, objs: Iterable[_T], fields: Iterable[str], batch_size: int | None = ...) -> int: ... + async def abulk_update(self, objs: Iterable[_T], fields: Iterable[str], batch_size: int | None = ...) -> int: ... + def get_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> Tuple[_T, bool]: ... async def aget_or_create( - self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any - ) -> Tuple[_T, bool]: ... - def update_or_create( - self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any + self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any ) -> Tuple[_T, bool]: ... + def update_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> Tuple[_T, bool]: ... async def aupdate_or_create( - self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any + self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any ) -> Tuple[_T, bool]: ... - def earliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _Row: ... - async def aearliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _Row: ... - def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _Row: ... - async def alatest(self, *fields: Any, field_name: Optional[Any] = ...) -> _Row: ... - def first(self) -> Optional[_Row]: ... - async def afirst(self) -> Optional[_Row]: ... - def last(self) -> Optional[_Row]: ... - async def alast(self) -> Optional[_Row]: ... + def earliest(self, *fields: Any, field_name: Any | None = ...) -> _Row: ... + async def aearliest(self, *fields: Any, field_name: Any | None = ...) -> _Row: ... + def latest(self, *fields: Any, field_name: Any | None = ...) -> _Row: ... + async def alatest(self, *fields: Any, field_name: Any | None = ...) -> _Row: ... + def first(self) -> _Row | None: ... + async def afirst(self) -> _Row | None: ... + def last(self) -> _Row | None: ... + async def alast(self) -> _Row | None: ... def in_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ... async def ain_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ... def delete(self) -> Tuple[int, Dict[str, int]]: ... @@ -135,26 +131,24 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): async def aupdate(self, **kwargs: Any) -> int: ... def exists(self) -> bool: ... async def aexists(self) -> bool: ... - def explain(self, *, format: Optional[Any] = ..., **options: Any) -> str: ... - async def aexplain(self, *, format: Optional[Any] = ..., **options: Any) -> str: ... + def explain(self, *, format: Any | None = ..., **options: Any) -> str: ... + async def aexplain(self, *, format: Any | None = ..., **options: Any) -> str: ... def contains(self, obj: Model) -> bool: ... async def acontains(self, obj: Model) -> bool: ... def raw( self, raw_query: str, params: Any = ..., - translations: Optional[Dict[str, str]] = ..., - using: Optional[str] = ..., + translations: Dict[str, str] | None = ..., + using: str | None = ..., ) -> RawQuerySet: ... # The type of values may be overridden to be more specific in the mypy plugin, depending on the fields param - def values(self, *fields: Union[str, Combinable], **expressions: Any) -> _QuerySet[_T, Dict[str, Any]]: ... + def values(self, *fields: str | Combinable, **expressions: Any) -> _QuerySet[_T, Dict[str, Any]]: ... # The type of values_list may be overridden to be more specific in the mypy plugin, depending on the fields param - def values_list( - self, *fields: Union[str, Combinable], flat: bool = ..., named: bool = ... - ) -> _QuerySet[_T, Any]: ... + def values_list(self, *fields: str | Combinable, flat: bool = ..., named: bool = ...) -> _QuerySet[_T, Any]: ... def dates(self, field_name: str, kind: str, order: str = ...) -> _QuerySet[_T, datetime.date]: ... def datetimes( - self, field_name: str, kind: str, order: str = ..., tzinfo: Optional[datetime.tzinfo] = ... + self, field_name: str, kind: str, order: str = ..., tzinfo: datetime.tzinfo | None = ... ) -> _QuerySet[_T, datetime.datetime]: ... def none(self: _QS) -> _QS: ... def all(self: _QS) -> _QS: ... @@ -178,17 +172,17 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): # extra() return type won't be supported any time soon def extra( self, - select: Optional[Dict[str, Any]] = ..., - where: Optional[Sequence[str]] = ..., - params: Optional[Sequence[Any]] = ..., - tables: Optional[Sequence[str]] = ..., - order_by: Optional[Sequence[str]] = ..., - select_params: Optional[Sequence[Any]] = ..., + select: Dict[str, Any] | None = ..., + where: Sequence[str] | None = ..., + params: Sequence[Any] | None = ..., + tables: Sequence[str] | None = ..., + order_by: Sequence[str] | None = ..., + select_params: Sequence[Any] | None = ..., ) -> _QuerySet[Any, Any]: ... def reverse(self: _QS) -> _QS: ... def defer(self: _QS, *fields: Any) -> _QS: ... def only(self: _QS, *fields: Any) -> _QS: ... - def using(self: _QS, alias: Optional[str]) -> _QS: ... + def using(self: _QS, alias: str | None) -> _QS: ... @property def ordered(self) -> bool: ... @property @@ -207,13 +201,13 @@ class RawQuerySet(Iterable[_T], Sized): query: RawQuery def __init__( self, - raw_query: Union[RawQuery, str], - model: Optional[Type[Model]] = ..., - query: Optional[Query] = ..., + raw_query: RawQuery | str, + model: Type[Model] | None = ..., + query: Query | None = ..., params: Tuple[Any] = ..., - translations: Optional[Dict[str, str]] = ..., + translations: Dict[str, str] | None = ..., using: str = ..., - hints: Optional[Dict[str, Model]] = ..., + hints: Dict[str, Model] | None = ..., ) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... @@ -234,7 +228,7 @@ class RawQuerySet(Iterable[_T], Sized): def model_fields(self) -> Dict[str, str]: ... def prefetch_related(self, *lookups: Any) -> RawQuerySet[_T]: ... def resolve_model_init_order(self) -> Tuple[List[str], List[int], List[Tuple[str, int]]]: ... - def using(self, alias: Optional[str]) -> RawQuerySet[_T]: ... + def using(self, alias: str | None) -> RawQuerySet[_T]: ... _QuerySetAny = _QuerySet @@ -243,16 +237,16 @@ QuerySet = _QuerySet[_T, _T] class Prefetch: prefetch_through: str prefetch_to: str - queryset: Optional[QuerySet] - to_attr: Optional[str] - def __init__(self, lookup: str, queryset: Optional[QuerySet] = ..., to_attr: Optional[str] = ...) -> None: ... + queryset: QuerySet | None + to_attr: str | None + def __init__(self, lookup: str, queryset: QuerySet | None = ..., to_attr: str | None = ...) -> None: ... def __getstate__(self) -> Dict[str, Any]: ... def add_prefix(self, prefix: str) -> None: ... def get_current_prefetch_to(self, level: int) -> str: ... def get_current_to_attr(self, level: int) -> Tuple[str, str]: ... - def get_current_queryset(self, level: int) -> Optional[QuerySet]: ... + def get_current_queryset(self, level: int) -> QuerySet | None: ... -def prefetch_related_objects(model_instances: Iterable[_T], *related_lookups: Union[str, Prefetch]) -> None: ... +def prefetch_related_objects(model_instances: Iterable[_T], *related_lookups: str | Prefetch) -> None: ... def get_prefetcher(instance: Model, through_attr: str, to_attr: str) -> Tuple[Any, Any, bool, bool]: ... class InstanceCheckMeta(type): ... diff --git a/django-stubs/db/models/query_utils.pyi b/django-stubs/db/models/query_utils.pyi index c93ed01fc..ebe12799e 100644 --- a/django-stubs/db/models/query_utils.pyi +++ b/django-stubs/db/models/query_utils.pyi @@ -1,20 +1,5 @@ from collections import namedtuple -from typing import ( - Any, - Collection, - Dict, - Iterable, - Iterator, - List, - Mapping, - Optional, - Sequence, - Set, - Tuple, - Type, - TypeVar, - Union, -) +from typing import Any, Collection, Dict, Iterable, Iterator, List, Mapping, Sequence, Set, Tuple, Type, TypeVar from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.base import Model @@ -51,7 +36,7 @@ class Q(tree.Node): self, query: Query = ..., allow_joins: bool = ..., - reuse: Optional[Set[str]] = ..., + reuse: Set[str] | None = ..., summarize: bool = ..., for_save: bool = ..., ) -> WhereNode: ... @@ -69,20 +54,20 @@ class RegisterLookupMixin: lookup_name: str @classmethod def get_lookups(cls) -> Dict[str, Any]: ... - def get_lookup(self, lookup_name: str) -> Optional[Type[Lookup]]: ... - def get_transform(self, lookup_name: str) -> Optional[Type[Transform]]: ... + def get_lookup(self, lookup_name: str) -> Type[Lookup] | None: ... + def get_transform(self, lookup_name: str) -> Type[Transform] | None: ... @staticmethod def merge_dicts(dicts: Iterable[Dict[str, Any]]) -> Dict[str, Any]: ... @classmethod - def register_lookup(cls, lookup: _R, lookup_name: Optional[str] = ...) -> _R: ... + def register_lookup(cls, lookup: _R, lookup_name: str | None = ...) -> _R: ... @classmethod - def _unregister_lookup(cls, lookup: Type[Lookup], lookup_name: Optional[str] = ...) -> None: ... + def _unregister_lookup(cls, lookup: Type[Lookup], lookup_name: str | None = ...) -> None: ... def select_related_descend( field: Field, restricted: bool, - requested: Optional[Mapping[str, Any]], - load_fields: Optional[Collection[str]], + requested: Mapping[str, Any] | None, + load_fields: Collection[str] | None, reverse: bool = ..., ) -> bool: ... @@ -90,12 +75,12 @@ _E = TypeVar("_E", bound=BaseExpression) def refs_expression( lookup_parts: Sequence[str], annotations: Mapping[str, _E] -) -> Tuple[Union[Literal[False], _E], Sequence[str]]: ... +) -> Tuple[Literal[False] | _E, Sequence[str]]: ... def check_rel_lookup_compatibility(model: Type[Model], target_opts: Any, field: FieldCacheMixin) -> bool: ... class FilteredRelation: relation_name: str = ... - alias: Optional[str] = ... + alias: str | None = ... condition: Q = ... path: List[str] = ... def __init__(self, relation_name: str, *, condition: Q = ...) -> None: ... diff --git a/django-stubs/db/models/signals.pyi b/django-stubs/db/models/signals.pyi index 521d63776..03519a98c 100644 --- a/django-stubs/db/models/signals.pyi +++ b/django-stubs/db/models/signals.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Optional, Type, Union +from typing import Any, Callable, Type from django.apps.registry import Apps from django.db.models.base import Model @@ -10,18 +10,18 @@ class ModelSignal(Signal): def connect( # type: ignore self, receiver: Callable, - sender: Optional[Union[Type[Model], str]] = ..., + sender: Type[Model] | str | None = ..., weak: bool = ..., - dispatch_uid: Optional[str] = ..., - apps: Optional[Apps] = ..., + dispatch_uid: str | None = ..., + apps: Apps | None = ..., ) -> None: ... def disconnect( # type: ignore self, - receiver: Optional[Callable] = ..., - sender: Optional[Union[Type[Model], str]] = ..., - dispatch_uid: Optional[str] = ..., - apps: Optional[Apps] = ..., - ) -> Optional[bool]: ... + receiver: Callable | None = ..., + sender: Type[Model] | str | None = ..., + dispatch_uid: str | None = ..., + apps: Apps | None = ..., + ) -> bool | None: ... pre_init: ModelSignal post_init: ModelSignal diff --git a/django-stubs/db/models/sql/compiler.pyi b/django-stubs/db/models/sql/compiler.pyi index adbbf01fa..bfed85476 100644 --- a/django-stubs/db/models/sql/compiler.pyi +++ b/django-stubs/db/models/sql/compiler.pyi @@ -1,6 +1,6 @@ from datetime import date, datetime from decimal import Decimal -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union, overload +from typing import Any, Callable, Dict, Iterable, Iterator, List, Sequence, Set, Tuple, Type, overload from uuid import UUID from django.db.backends.base.base import BaseDatabaseWrapper @@ -11,21 +11,21 @@ from django.db.models.sql.query import Query from django.db.models.sql.subqueries import AggregateQuery, DeleteQuery, InsertQuery, UpdateQuery from typing_extensions import Literal -_ParamT = Union[str, int] +_ParamT = str | int _ParamsT = List[_ParamT] _AsSqlType = Tuple[str, _ParamsT] class SQLCompiler: query: Query = ... connection: BaseDatabaseWrapper = ... - using: Optional[str] = ... + using: str | None = ... quote_cache: Any = ... select: Any = ... annotation_col_map: Any = ... klass_info: Any = ... ordering_parts: Any = ... - def __init__(self, query: Query, connection: BaseDatabaseWrapper, using: Optional[str]) -> None: ... - col_count: Optional[int] = ... + def __init__(self, query: Query, connection: BaseDatabaseWrapper, using: str | None) -> None: ... + col_count: int | None = ... def setup_query(self) -> None: ... has_extra_select: Any = ... def pre_sql_setup( @@ -37,56 +37,56 @@ class SQLCompiler: ]: ... def get_group_by( self, - select: List[Tuple[BaseExpression, _AsSqlType, Optional[str]]], + select: List[Tuple[BaseExpression, _AsSqlType, str | None]], order_by: List[Tuple[Expression, Tuple[str, _ParamsT, bool]]], ) -> List[_AsSqlType]: ... def collapse_group_by( - self, expressions: List[Expression], having: Union[List[Expression], Tuple] + self, expressions: List[Expression], having: List[Expression] | Tuple ) -> List[Expression]: ... def get_select( self, - ) -> Tuple[List[Tuple[Expression, _AsSqlType, Optional[str]]], Optional[Dict[str, Any]], Dict[str, int],]: ... + ) -> Tuple[List[Tuple[Expression, _AsSqlType, str | None]], Dict[str, Any] | None, Dict[str, int],]: ... def get_order_by(self) -> List[Tuple[Expression, Tuple[str, _ParamsT, bool]]]: ... def get_extra_select( self, order_by: List[Tuple[Expression, Tuple[str, _ParamsT, bool]]], - select: List[Tuple[Expression, _AsSqlType, Optional[str]]], + select: List[Tuple[Expression, _AsSqlType, str | None]], ) -> List[Tuple[Expression, _AsSqlType, None]]: ... def quote_name_unless_alias(self, name: str) -> str: ... def compile(self, node: BaseExpression) -> _AsSqlType: ... - def get_combinator_sql(self, combinator: str, all: bool) -> Tuple[List[str], Union[List[int], List[str]]]: ... + def get_combinator_sql(self, combinator: str, all: bool) -> Tuple[List[str], List[int] | List[str]]: ... def as_sql(self, with_limits: bool = ..., with_col_aliases: bool = ...) -> _AsSqlType: ... def get_default_columns( - self, start_alias: Optional[str] = ..., opts: Optional[Any] = ..., from_parent: Optional[Type[Model]] = ... + self, start_alias: str | None = ..., opts: Any | None = ..., from_parent: Type[Model] | None = ... ) -> List[Expression]: ... def get_distinct(self) -> Tuple[List[Any], List[Any]]: ... def find_ordering_name( self, name: str, opts: Any, - alias: Optional[str] = ..., + alias: str | None = ..., default_order: str = ..., - already_seen: Optional[Set[Tuple[Optional[Tuple[Tuple[str, str]]], Tuple[Tuple[str, str]]]]] = ..., + already_seen: Set[Tuple[Tuple[Tuple[str, str]] | None, Tuple[Tuple[str, str]]]] | None = ..., ) -> List[Tuple[Expression, bool]]: ... def get_from_clause(self) -> Tuple[List[str], _ParamsT]: ... def get_related_selections( self, - select: List[Tuple[Expression, Optional[str]]], - opts: Optional[Any] = ..., - root_alias: Optional[str] = ..., + select: List[Tuple[Expression, str | None]], + opts: Any | None = ..., + root_alias: str | None = ..., cur_depth: int = ..., - requested: Optional[Dict[str, Dict[str, Dict[str, Dict[Any, Any]]]]] = ..., - restricted: Optional[bool] = ..., + requested: Dict[str, Dict[str, Dict[str, Dict[Any, Any]]]] | None = ..., + restricted: bool | None = ..., ) -> List[Dict[str, Any]]: ... def get_select_for_update_of_arguments(self) -> List[Any]: ... def deferred_to_columns(self) -> Dict[Type[Model], Set[str]]: ... def get_converters(self, expressions: List[Expression]) -> Dict[int, Tuple[List[Callable], Expression]]: ... def apply_converters( self, rows: Iterable[Iterable[Any]], converters: Dict[int, Tuple[List[Callable], Expression]] - ) -> Iterator[List[Union[None, date, datetime, float, Decimal, UUID, bytes, str]]]: ... + ) -> Iterator[List[None | date | datetime | float | Decimal | UUID | bytes | str]]: ... def results_iter( self, - results: Optional[Iterable[List[Sequence[Any]]]] = ..., + results: Iterable[List[Sequence[Any]]] | None = ..., tuple_expected: bool = ..., chunked_fetch: bool = ..., chunk_size: int = ..., @@ -98,22 +98,22 @@ class SQLCompiler: ) -> CursorWrapper: ... @overload def execute_sql( - self, result_type: Optional[Literal["no results"]] = ..., chunked_fetch: bool = ..., chunk_size: int = ... + self, result_type: Literal["no results"] | None = ..., chunked_fetch: bool = ..., chunk_size: int = ... ) -> None: ... @overload def execute_sql( # type: ignore self, result_type: Literal["single"] = ..., chunked_fetch: bool = ..., chunk_size: int = ... - ) -> Optional[Iterable[Sequence[Any]]]: ... + ) -> Iterable[Sequence[Any]] | None: ... @overload def execute_sql( self, result_type: Literal["multi"] = ..., chunked_fetch: bool = ..., chunk_size: int = ... - ) -> Optional[Iterable[List[Sequence[Any]]]]: ... + ) -> Iterable[List[Sequence[Any]]] | None: ... def as_subquery_condition(self, alias: str, columns: List[str], compiler: SQLCompiler) -> _AsSqlType: ... def explain_query(self) -> Iterator[str]: ... class SQLInsertCompiler(SQLCompiler): query: InsertQuery - returning_fields: Optional[Sequence[Any]] = ... + returning_fields: Sequence[Any] | None = ... returning_params: Sequence[Any] = ... def field_as_sql(self, field: Any, val: Any) -> _AsSqlType: ... def prepare_value(self, field: Any, value: Any) -> Any: ... @@ -121,7 +121,7 @@ class SQLInsertCompiler(SQLCompiler): def assemble_as_sql(self, fields: Any, value_rows: Any) -> Tuple[List[List[str]], List[List[Any]]]: ... def as_sql(self) -> List[_AsSqlType]: ... # type: ignore def execute_sql( # type: ignore - self, returning_fields: Optional[Sequence[str]] = ... + self, returning_fields: Sequence[str] | None = ... ) -> List[Tuple[Any]]: ... # 1-tuple class SQLDeleteCompiler(SQLCompiler): @@ -144,5 +144,5 @@ class SQLAggregateCompiler(SQLCompiler): def as_sql(self) -> _AsSqlType: ... # type: ignore def cursor_iter( - cursor: CursorWrapper, sentinel: Any, col_count: Optional[int], itersize: int + cursor: CursorWrapper, sentinel: Any, col_count: int | None, itersize: int ) -> Iterator[List[Sequence[Any]]]: ... diff --git a/django-stubs/db/models/sql/datastructures.pyi b/django-stubs/db/models/sql/datastructures.pyi index 698d059d3..f56b7e2ab 100644 --- a/django-stubs/db/models/sql/datastructures.pyi +++ b/django-stubs/db/models/sql/datastructures.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import Any, Dict, List, Tuple from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.fields.mixins import FieldCacheMixin @@ -15,25 +15,25 @@ class Empty: ... class Join: table_name: str = ... parent_alias: str = ... - table_alias: Optional[str] = ... + table_alias: str | None = ... join_type: str = ... join_cols: Tuple = ... join_field: FieldCacheMixin = ... nullable: bool = ... - filtered_relation: Optional[FilteredRelation] = ... + filtered_relation: FilteredRelation | None = ... def __init__( self, table_name: str, parent_alias: str, - table_alias: Optional[str], + table_alias: str | None, join_type: str, join_field: FieldCacheMixin, nullable: bool, - filtered_relation: Optional[FilteredRelation] = ..., + filtered_relation: FilteredRelation | None = ..., ) -> None: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... - def relabeled_clone(self, change_map: Dict[Optional[str], str]) -> Join: ... - def equals(self, other: Union[BaseTable, Join], with_filtered_relation: bool) -> bool: ... + def relabeled_clone(self, change_map: Dict[str | None, str]) -> Join: ... + def equals(self, other: BaseTable | Join, with_filtered_relation: bool) -> bool: ... def demote(self) -> Join: ... def promote(self) -> Join: ... @@ -42,8 +42,8 @@ class BaseTable: parent_alias: Any = ... filtered_relation: Any = ... table_name: str = ... - table_alias: Optional[str] = ... - def __init__(self, table_name: str, alias: Optional[str]) -> None: ... + table_alias: str | None = ... + def __init__(self, table_name: str, alias: str | None) -> None: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... - def relabeled_clone(self, change_map: Dict[Optional[str], str]) -> BaseTable: ... + def relabeled_clone(self, change_map: Dict[str | None, str]) -> BaseTable: ... def equals(self, other: Join, with_filtered_relation: bool) -> bool: ... diff --git a/django-stubs/db/models/sql/query.pyi b/django-stubs/db/models/sql/query.pyi index e815c4baf..3b2503432 100644 --- a/django-stubs/db/models/sql/query.pyi +++ b/django-stubs/db/models/sql/query.pyi @@ -1,6 +1,6 @@ import collections from collections import namedtuple -from typing import Any, Callable, Dict, FrozenSet, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union +from typing import Any, Callable, Dict, FrozenSet, Iterable, Iterator, List, Sequence, Set, Tuple, Type from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.utils import CursorWrapper @@ -17,32 +17,32 @@ from typing_extensions import Literal JoinInfo = namedtuple("JoinInfo", ("final_field", "targets", "opts", "joins", "path", "transform_function")) class RawQuery: - high_mark: Optional[int] - low_mark: Optional[int] - params: Union[Any] = ... + high_mark: int | None + low_mark: int | None + params: Any = ... sql: str = ... using: str = ... extra_select: Dict[Any, Any] = ... annotation_select: Dict[Any, Any] = ... - cursor: Optional[CursorWrapper] = ... + cursor: CursorWrapper | None = ... def __init__(self, sql: str, using: str, params: Any = ...) -> None: ... def chain(self, using: str) -> RawQuery: ... def clone(self, using: str) -> RawQuery: ... def get_columns(self) -> List[str]: ... def __iter__(self) -> Iterator[Any]: ... @property - def params_type(self) -> Union[None, Type[Dict], Type[Tuple]]: ... + def params_type(self) -> None | Type[Dict] | Type[Tuple]: ... class Query(BaseExpression): - related_ids: Optional[List[int]] - related_updates: Dict[Type[Model], List[Tuple[Field, None, Union[int, str]]]] + related_ids: List[int] | None + related_updates: Dict[Type[Model], List[Tuple[Field, None, int | str]]] values: List[Any] alias_prefix: str = ... subq_aliases: FrozenSet[Any] = ... compiler: str = ... - model: Optional[Type[Model]] = ... + model: Type[Model] | None = ... alias_refcount: Dict[str, int] = ... - alias_map: Dict[str, Union[BaseTable, Join]] = ... + alias_map: Dict[str, BaseTable | Join] = ... external_aliases: Dict[str, bool] = ... table_map: Dict[str, List[str]] = ... default_cols: bool = ... @@ -51,7 +51,7 @@ class Query(BaseExpression): used_aliases: Set[str] = ... filter_is_sticky: bool = ... subquery: bool = ... - group_by: Union[None, Sequence[Combinable], Sequence[str], Literal[True]] = ... + group_by: None | Sequence[Combinable] | Sequence[str] | Literal[True] = ... order_by: Sequence[Any] = ... distinct: bool = ... distinct_fields: Tuple[str, ...] = ... @@ -61,25 +61,25 @@ class Query(BaseExpression): select_for_update_skip_locked: bool = ... select_for_update_of: Tuple = ... select_for_no_key_update: bool = ... - select_related: Union[Dict[str, Any], bool] = ... + select_related: Dict[str, Any] | bool = ... max_depth: int = ... values_select: Tuple = ... - annotation_select_mask: Optional[Set[str]] = ... - combinator: Optional[str] = ... + annotation_select_mask: Set[str] | None = ... + combinator: str | None = ... combinator_all: bool = ... combined_queries: Tuple = ... - extra_select_mask: Optional[Set[str]] = ... + extra_select_mask: Set[str] | None = ... extra_tables: Tuple = ... extra_order_by: Sequence[Any] = ... - deferred_loading: Tuple[Union[Set[str], FrozenSet[str]], bool] = ... + deferred_loading: Tuple[Set[str] | FrozenSet[str], bool] = ... explain_query: bool = ... - explain_format: Optional[str] = ... + explain_format: str | None = ... explain_options: Dict[str, int] = ... - high_mark: Optional[int] = ... + high_mark: int | None = ... low_mark: int = ... extra: Dict[str, Any] annotations: Dict[str, Expression] - def __init__(self, model: Optional[Type[Model]], where: Type[WhereNode] = ..., alias_cols: bool = ...) -> None: ... + def __init__(self, model: Type[Model] | None, where: Type[WhereNode] = ..., alias_cols: bool = ...) -> None: ... @property def output_field(self) -> Field: ... @property @@ -88,17 +88,15 @@ class Query(BaseExpression): def base_table(self) -> str: ... def sql_with_params(self) -> Tuple[str, Tuple]: ... def __deepcopy__(self, memo: Dict[int, Any]) -> Query: ... - def get_compiler( - self, using: Optional[str] = ..., connection: Optional[BaseDatabaseWrapper] = ... - ) -> SQLCompiler: ... + def get_compiler(self, using: str | None = ..., connection: BaseDatabaseWrapper | None = ...) -> SQLCompiler: ... def get_meta(self) -> Options: ... def clone(self) -> Query: ... - def chain(self, klass: Optional[Type[Query]] = ...) -> Query: ... - def relabeled_clone(self, change_map: Dict[Optional[str], str]) -> Query: ... + def chain(self, klass: Type[Query] | None = ...) -> Query: ... + def relabeled_clone(self, change_map: Dict[str | None, str]) -> Query: ... def get_count(self, using: str) -> int: ... def has_filters(self) -> WhereNode: ... def has_results(self, using: str) -> bool: ... - def explain(self, using: str, format: Optional[str] = ..., **options: Any) -> str: ... + def explain(self, using: str, format: str | None = ..., **options: Any) -> str: ... def combine(self, rhs: Query, connector: str) -> None: ... def deferred_to_data(self, target: Dict[Any, Any], callback: Callable) -> None: ... def ref_alias(self, alias: str) -> None: ... @@ -106,21 +104,19 @@ class Query(BaseExpression): def promote_joins(self, aliases: Iterable[str]) -> None: ... def demote_joins(self, aliases: Iterable[str]) -> None: ... def reset_refcounts(self, to_counts: Dict[str, int]) -> None: ... - def change_aliases(self, change_map: Dict[Optional[str], str]) -> None: ... + def change_aliases(self, change_map: Dict[str | None, str]) -> None: ... def bump_prefix(self, outer_query: Query) -> None: ... def get_initial_alias(self) -> str: ... def count_active_tables(self) -> int: ... def resolve_expression(self, query: Query, *args: Any, **kwargs: Any) -> Query: ... # type: ignore - def resolve_lookup_value(self, value: Any, can_reuse: Optional[Set[str]], allow_joins: bool) -> Any: ... - def solve_lookup_type( - self, lookup: str - ) -> Tuple[Sequence[str], Sequence[str], Union[Expression, Literal[False]]]: ... + def resolve_lookup_value(self, value: Any, can_reuse: Set[str] | None, allow_joins: bool) -> Any: ... + def solve_lookup_type(self, lookup: str) -> Tuple[Sequence[str], Sequence[str], Expression | Literal[False]]: ... def build_filter( self, - filter_expr: Union[Q, Expression, Dict[str, str], Tuple[str, Any]], + filter_expr: Q | Expression | Dict[str, str] | Tuple[str, Any], branch_negated: bool = ..., current_negated: bool = ..., - can_reuse: Optional[Set[str]] = ..., + can_reuse: Set[str] | None = ..., allow_joins: bool = ..., split_subq: bool = ..., reuse_with_filtered_relation: bool = ..., @@ -128,7 +124,7 @@ class Query(BaseExpression): ) -> Tuple[WhereNode, Iterable[str]]: ... def add_filter(self, filter_clause: Tuple[str, Any]) -> None: ... def add_q(self, q_object: Q) -> None: ... - def build_where(self, filter_expr: Union[Q, Expression, Dict[str, str], Tuple[str, Any]]) -> WhereNode: ... + def build_where(self, filter_expr: Q | Expression | Dict[str, str] | Tuple[str, Any]) -> WhereNode: ... def build_filtered_relation_q( self, q_object: Q, reuse: Set[str], branch_negated: bool = ..., current_negated: bool = ... ) -> WhereNode: ... @@ -138,7 +134,7 @@ class Query(BaseExpression): names: Sequence[str], opts: Any, alias: str, - can_reuse: Optional[Set[str]] = ..., + can_reuse: Set[str] | None = ..., allow_many: bool = ..., reuse_with_filtered_relation: bool = ..., ) -> JoinInfo: ... @@ -146,7 +142,7 @@ class Query(BaseExpression): self, targets: Tuple[Field, ...], joins: List[str], path: List[PathInfo] ) -> Tuple[Tuple[Field, ...], str, List[str]]: ... def resolve_ref( - self, name: str, allow_joins: bool = ..., reuse: Optional[Set[str]] = ..., summarize: bool = ... + self, name: str, allow_joins: bool = ..., reuse: Set[str] | None = ..., summarize: bool = ... ) -> Expression: ... def split_exclude( self, @@ -156,7 +152,7 @@ class Query(BaseExpression): ) -> Tuple[WhereNode, Iterable[str]]: ... def set_empty(self) -> None: ... def is_empty(self) -> bool: ... - def set_limits(self, low: Optional[int] = ..., high: Optional[int] = ...) -> None: ... + def set_limits(self, low: int | None = ..., high: int | None = ...) -> None: ... def clear_limits(self) -> None: ... @property def is_sliced(self) -> bool: ... @@ -167,18 +163,18 @@ class Query(BaseExpression): def set_select(self, cols: List[Expression]) -> None: ... def add_distinct_fields(self, *field_names: Any) -> None: ... def add_fields(self, field_names: Iterable[str], allow_m2m: bool = ...) -> None: ... - def add_ordering(self, *ordering: Union[str, OrderBy]) -> None: ... + def add_ordering(self, *ordering: str | OrderBy) -> None: ... def clear_ordering(self, force_empty: bool) -> None: ... def set_group_by(self, allow_aliases: bool = ...) -> None: ... def add_select_related(self, fields: Iterable[str]) -> None: ... def add_extra( self, - select: Optional[Dict[str, Any]], - select_params: Optional[Iterable[Any]], - where: Optional[Sequence[str]], - params: Optional[Sequence[str]], - tables: Optional[Sequence[str]], - order_by: Optional[Sequence[str]], + select: Dict[str, Any] | None, + select_params: Iterable[Any] | None, + where: Sequence[str] | None, + params: Sequence[str] | None, + tables: Sequence[str] | None, + order_by: Sequence[str] | None, ) -> None: ... def clear_deferred_loading(self) -> None: ... def add_deferred_loading(self, field_names: Iterable[str]) -> None: ... @@ -187,10 +183,10 @@ class Query(BaseExpression): def get_loaded_field_names_cb( self, target: Dict[Type[Model], Set[str]], model: Type[Model], fields: Set[Field] ) -> None: ... - def set_annotation_mask(self, names: Optional[Iterable[str]]) -> None: ... + def set_annotation_mask(self, names: Iterable[str] | None) -> None: ... def append_annotation_mask(self, names: Iterable[str]) -> None: ... - def set_extra_mask(self, names: Optional[Iterable[str]]) -> None: ... - def set_values(self, fields: Optional[Iterable[str]]) -> None: ... + def set_extra_mask(self, names: Iterable[str] | None) -> None: ... + def set_values(self, fields: Iterable[str] | None) -> None: ... @property def annotation_select(self) -> Dict[str, Any]: ... @property @@ -198,8 +194,8 @@ class Query(BaseExpression): def trim_start(self, names_with_path: List[Tuple[str, List[PathInfo]]]) -> Tuple[str, bool]: ... def is_nullable(self, field: Field) -> bool: ... def check_filterable(self, expression: Any) -> None: ... - def build_lookup(self, lookups: Sequence[str], lhs: Union[Expression, Query], rhs: Any) -> Lookup: ... - def try_transform(self, lhs: Union[Expression, Query], name: str) -> Transform: ... + def build_lookup(self, lookups: Sequence[str], lhs: Expression | Query, rhs: Any) -> Lookup: ... + def try_transform(self, lhs: Expression | Query, name: str) -> Transform: ... class JoinPromoter: connector: str = ... diff --git a/django-stubs/db/models/sql/subqueries.pyi b/django-stubs/db/models/sql/subqueries.pyi index 074dd13dc..afdab04d0 100644 --- a/django-stubs/db/models/sql/subqueries.pyi +++ b/django-stubs/db/models/sql/subqueries.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, List, Optional, Tuple, Type, Union +from typing import Any, Dict, Iterable, List, Tuple, Type from django.db.models.base import Model from django.db.models.expressions import Case @@ -12,17 +12,17 @@ class DeleteQuery(Query): where_class: Type[WhereNode] where: WhereNode = ... def do_query(self, table: str, where: WhereNode, using: str) -> int: ... - def delete_batch(self, pk_list: Union[List[int], List[str]], using: str) -> int: ... + def delete_batch(self, pk_list: List[int] | List[str], using: str) -> int: ... class UpdateQuery(Query): select: Tuple where_class: Type[WhereNode] def __init__(self, *args: Any, **kwargs: Any) -> None: ... where: WhereNode = ... - def update_batch(self, pk_list: List[int], values: Dict[str, Optional[int]], using: str) -> None: ... + def update_batch(self, pk_list: List[int], values: Dict[str, int | None], using: str) -> None: ... def add_update_values(self, values: Dict[str, Any]) -> None: ... - def add_update_fields(self, values_seq: List[Tuple[Field, Optional[Type[Model]], Case]]) -> None: ... - def add_related_update(self, model: Type[Model], field: Field, value: Union[int, str]) -> None: ... + def add_update_fields(self, values_seq: List[Tuple[Field, Type[Model] | None, Case]]) -> None: ... + def add_related_update(self, model: Type[Model], field: Field, value: int | str) -> None: ... def get_related_updates(self) -> List[UpdateQuery]: ... class InsertQuery(Query): diff --git a/django-stubs/db/models/sql/where.pyi b/django-stubs/db/models/sql/where.pyi index db0929813..e4ccdce77 100644 --- a/django-stubs/db/models/sql/where.pyi +++ b/django-stubs/db/models/sql/where.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Sequence, Tuple, Union +from typing import Any, Dict, List, Sequence, Tuple from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.expressions import Expression @@ -15,12 +15,12 @@ class WhereNode(tree.Node): default: str = ... resolved: bool = ... conditional: bool = ... - def split_having(self, negated: bool = ...) -> Tuple[Optional[WhereNode], Optional[WhereNode]]: ... + def split_having(self, negated: bool = ...) -> Tuple[WhereNode | None, WhereNode | None]: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> Any: ... - def get_group_by_cols(self, alias: Optional[str] = ...) -> List[Expression]: ... - def relabel_aliases(self, change_map: Dict[Optional[str], str]) -> None: ... + def get_group_by_cols(self, alias: str | None = ...) -> List[Expression]: ... + def relabel_aliases(self, change_map: Dict[str | None, str]) -> None: ... def clone(self) -> WhereNode: ... - def relabeled_clone(self, change_map: Dict[Optional[str], str]) -> WhereNode: ... + def relabeled_clone(self, change_map: Dict[str | None, str]) -> WhereNode: ... def resolve_expression(self, *args: Any, **kwargs: Any) -> WhereNode: ... @property def contains_aggregate(self) -> bool: ... @@ -32,16 +32,16 @@ class WhereNode(tree.Node): class NothingNode: contains_aggregate: bool = ... def as_sql( - self, compiler: Optional[SQLCompiler] = ..., connection: Optional[BaseDatabaseWrapper] = ... + self, compiler: SQLCompiler | None = ..., connection: BaseDatabaseWrapper | None = ... ) -> _AsSqlType: ... class ExtraWhere: contains_aggregate: bool = ... sqls: Sequence[str] = ... - params: Optional[Union[Sequence[int], Sequence[str]]] = ... - def __init__(self, sqls: Sequence[str], params: Optional[Union[Sequence[int], Sequence[str]]]) -> None: ... + params: Sequence[int] | Sequence[str] | None = ... + def __init__(self, sqls: Sequence[str], params: Sequence[int] | Sequence[str] | None) -> None: ... def as_sql( - self, compiler: Optional[SQLCompiler] = ..., connection: Optional[BaseDatabaseWrapper] = ... + self, compiler: SQLCompiler | None = ..., connection: BaseDatabaseWrapper | None = ... ) -> _AsSqlType: ... class SubqueryConstraint: diff --git a/django-stubs/db/models/utils.pyi b/django-stubs/db/models/utils.pyi index 1d32c38bb..acfd0aaf2 100644 --- a/django-stubs/db/models/utils.pyi +++ b/django-stubs/db/models/utils.pyi @@ -1,8 +1,8 @@ -from typing import Any, Iterable, Iterator, MutableMapping, NamedTuple, Tuple, Type, Union +from typing import Any, Iterable, Iterator, MutableMapping, NamedTuple, Tuple, Type from django.db.models.base import Model -def make_model_tuple(model: Union[Type[Model], str, Tuple[str, str]]) -> Tuple[str, str]: ... +def make_model_tuple(model: Type[Model] | str | Tuple[str, str]) -> Tuple[str, str]: ... def resolve_callables(mapping: MutableMapping[str, Any]) -> Iterator[Tuple[str, Any]]: ... def unpickle_named_row(names: Iterable[str], values: Iterable[Any]) -> NamedTuple: ... def create_namedtuple_class(*names: str) -> Type[NamedTuple]: ... diff --git a/django-stubs/db/transaction.pyi b/django-stubs/db/transaction.pyi index 0532cd111..0aab49c48 100644 --- a/django-stubs/db/transaction.pyi +++ b/django-stubs/db/transaction.pyi @@ -1,41 +1,41 @@ from contextlib import contextmanager from types import TracebackType -from typing import Any, Callable, Iterator, Optional, Type, TypeVar, overload +from typing import Any, Callable, Iterator, Type, TypeVar, overload from django.db import ProgrammingError class TransactionManagementError(ProgrammingError): ... -def get_connection(using: Optional[str] = ...) -> Any: ... -def get_autocommit(using: Optional[str] = ...) -> bool: ... -def set_autocommit(autocommit: bool, using: Optional[str] = ...) -> Any: ... -def commit(using: Optional[str] = ...) -> None: ... -def rollback(using: Optional[str] = ...) -> None: ... -def savepoint(using: Optional[str] = ...) -> str: ... -def savepoint_rollback(sid: str, using: Optional[str] = ...) -> None: ... -def savepoint_commit(sid: str, using: Optional[str] = ...) -> None: ... -def clean_savepoints(using: Optional[str] = ...) -> None: ... -def get_rollback(using: Optional[str] = ...) -> bool: ... -def set_rollback(rollback: bool, using: Optional[str] = ...) -> None: ... +def get_connection(using: str | None = ...) -> Any: ... +def get_autocommit(using: str | None = ...) -> bool: ... +def set_autocommit(autocommit: bool, using: str | None = ...) -> Any: ... +def commit(using: str | None = ...) -> None: ... +def rollback(using: str | None = ...) -> None: ... +def savepoint(using: str | None = ...) -> str: ... +def savepoint_rollback(sid: str, using: str | None = ...) -> None: ... +def savepoint_commit(sid: str, using: str | None = ...) -> None: ... +def clean_savepoints(using: str | None = ...) -> None: ... +def get_rollback(using: str | None = ...) -> bool: ... +def set_rollback(rollback: bool, using: str | None = ...) -> None: ... @contextmanager -def mark_for_rollback_on_error(using: Optional[str] = ...) -> Iterator[None]: ... -def on_commit(func: Callable, using: Optional[str] = ...) -> None: ... +def mark_for_rollback_on_error(using: str | None = ...) -> Iterator[None]: ... +def on_commit(func: Callable, using: str | None = ...) -> None: ... _C = TypeVar("_C", bound=Callable) # Any callable # Don't inherit from ContextDecorator, so we can provide a more specific signature for __call__ class Atomic: - using: Optional[str] = ... + using: str | None = ... savepoint: bool = ... - def __init__(self, using: Optional[str], savepoint: bool, durable: bool) -> None: ... + def __init__(self, using: str | None, savepoint: bool, durable: bool) -> None: ... # When decorating, return the decorated function as-is, rather than clobbering it as ContextDecorator does. def __call__(self, func: _C) -> _C: ... def __enter__(self) -> None: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... # Bare decorator @@ -44,7 +44,7 @@ def atomic(using: _C) -> _C: ... # Decorator or context-manager with parameters @overload -def atomic(using: Optional[str] = ..., savepoint: bool = ..., durable: bool = ...) -> Atomic: ... +def atomic(using: str | None = ..., savepoint: bool = ..., durable: bool = ...) -> Atomic: ... # Bare decorator @overload @@ -52,4 +52,4 @@ def non_atomic_requests(using: _C) -> _C: ... # Decorator with arguments @overload -def non_atomic_requests(using: Optional[str] = ...) -> Callable[[_C], _C]: ... +def non_atomic_requests(using: str | None = ...) -> Callable[[_C], _C]: ... diff --git a/django-stubs/db/utils.pyi b/django-stubs/db/utils.pyi index 67d37e6dc..d327cfdde 100644 --- a/django-stubs/db/utils.pyi +++ b/django-stubs/db/utils.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Any, Dict, Iterable, List, Optional, Type +from typing import Any, Dict, Iterable, List, Type from django.apps import AppConfig from django.db.backends.base.base import BaseDatabaseWrapper @@ -25,9 +25,9 @@ class DatabaseErrorWrapper: def __enter__(self) -> None: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... def load_backend(backend_name: str) -> Any: ... @@ -41,7 +41,7 @@ class ConnectionHandler(BaseConnectionHandler[BaseDatabaseWrapper]): def close_all(self) -> None: ... class ConnectionRouter: - def __init__(self, routers: Optional[Iterable[Any]] = ...) -> None: ... + def __init__(self, routers: Iterable[Any] | None = ...) -> None: ... @property def routers(self) -> List[Any]: ... def db_for_read(self, model: Type[Model], **hints: Any) -> str: ... diff --git a/django-stubs/dispatch/dispatcher.pyi b/django-stubs/dispatch/dispatcher.pyi index e8fbfa011..55f069096 100644 --- a/django-stubs/dispatch/dispatcher.pyi +++ b/django-stubs/dispatch/dispatcher.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Optional, Tuple, Union +from typing import Any, Callable, List, Tuple NONE_ID: Any NO_RECEIVERS: Any @@ -11,13 +11,13 @@ class Signal: sender_receivers_cache: Any = ... def __init__(self, providing_args: List[str] = ..., use_caching: bool = ...) -> None: ... def connect( - self, receiver: Callable, sender: Optional[object] = ..., weak: bool = ..., dispatch_uid: Optional[str] = ... + self, receiver: Callable, sender: object | None = ..., weak: bool = ..., dispatch_uid: str | None = ... ) -> None: ... def disconnect( - self, receiver: Optional[Callable] = ..., sender: Optional[object] = ..., dispatch_uid: Optional[str] = ... + self, receiver: Callable | None = ..., sender: object | None = ..., dispatch_uid: str | None = ... ) -> bool: ... def has_listeners(self, sender: Any = ...) -> bool: ... - def send(self, sender: Any, **named: Any) -> List[Tuple[Callable, Optional[str]]]: ... - def send_robust(self, sender: Any, **named: Any) -> List[Tuple[Callable, Union[Exception, str]]]: ... + def send(self, sender: Any, **named: Any) -> List[Tuple[Callable, str | None]]: ... + def send_robust(self, sender: Any, **named: Any) -> List[Tuple[Callable, Exception | str]]: ... -def receiver(signal: Union[List[Signal], Signal], **kwargs: Any) -> Callable: ... +def receiver(signal: List[Signal] | Signal, **kwargs: Any) -> Callable: ... diff --git a/django-stubs/forms/boundfield.pyi b/django-stubs/forms/boundfield.pyi index 54b3e3b0e..8e6c8c5fa 100644 --- a/django-stubs/forms/boundfield.pyi +++ b/django-stubs/forms/boundfield.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, Iterator, List, Optional, Union, overload +from typing import Any, Dict, Iterable, Iterator, List, overload from django.forms.fields import Field from django.forms.forms import BaseForm @@ -8,7 +8,7 @@ from django.forms.widgets import Widget from django.utils.functional import _StrOrPromise from django.utils.safestring import SafeString -_AttrsT = Dict[str, Union[str, bool]] +_AttrsT = Dict[str, str | bool] class BoundField: form: BaseForm = ... @@ -26,24 +26,24 @@ class BoundField: def __iter__(self) -> Iterator[BoundWidget]: ... def __len__(self) -> int: ... @overload - def __getitem__(self, idx: Union[int, str]) -> BoundWidget: ... + def __getitem__(self, idx: int | str) -> BoundWidget: ... @overload def __getitem__(self, idx: slice) -> List[BoundWidget]: ... @property def errors(self) -> ErrorList: ... def as_widget( - self, widget: Optional[Widget] = ..., attrs: Optional[_AttrsT] = ..., only_initial: bool = ... + self, widget: Widget | None = ..., attrs: _AttrsT | None = ..., only_initial: bool = ... ) -> SafeString: ... - def as_text(self, attrs: Optional[_AttrsT] = ..., **kwargs: Any) -> SafeString: ... - def as_textarea(self, attrs: Optional[_AttrsT] = ..., **kwargs: Any) -> SafeString: ... - def as_hidden(self, attrs: Optional[_AttrsT] = ..., **kwargs: Any) -> SafeString: ... + def as_text(self, attrs: _AttrsT | None = ..., **kwargs: Any) -> SafeString: ... + def as_textarea(self, attrs: _AttrsT | None = ..., **kwargs: Any) -> SafeString: ... + def as_hidden(self, attrs: _AttrsT | None = ..., **kwargs: Any) -> SafeString: ... @property def data(self) -> Any: ... def value(self) -> Any: ... def label_tag( - self, contents: Optional[str] = ..., attrs: Optional[_AttrsT] = ..., label_suffix: Optional[str] = ... + self, contents: str | None = ..., attrs: _AttrsT | None = ..., label_suffix: str | None = ... ) -> SafeString: ... - def css_classes(self, extra_classes: Union[str, Iterable[str], None] = ...) -> str: ... + def css_classes(self, extra_classes: str | Iterable[str] | None = ...) -> str: ... @property def is_hidden(self) -> bool: ... @property @@ -52,7 +52,7 @@ class BoundField: def id_for_label(self) -> str: ... @property def initial(self) -> Any: ... - def build_widget_attrs(self, attrs: _AttrsT, widget: Optional[Widget] = ...) -> _AttrsT: ... + def build_widget_attrs(self, attrs: _AttrsT, widget: Widget | None = ...) -> _AttrsT: ... @property def widget_type(self) -> str: ... diff --git a/django-stubs/forms/fields.pyi b/django-stubs/forms/fields.pyi index 15d00c1c7..cc6def18b 100644 --- a/django-stubs/forms/fields.pyi +++ b/django-stubs/forms/fields.pyi @@ -1,6 +1,6 @@ import datetime from decimal import Decimal -from typing import Any, Collection, Dict, Iterator, List, Optional, Pattern, Protocol, Sequence, Tuple, Type, Union +from typing import Any, Collection, Dict, Iterator, List, Pattern, Protocol, Sequence, Tuple, Type from uuid import UUID from django.core.files import File @@ -23,7 +23,7 @@ _ClassLevelWidgetT = Any class Field: initial: Any - label: Optional[_StrOrPromise] + label: _StrOrPromise | None required: bool widget: _ClassLevelWidgetT = ... hidden_widget: Type[Widget] = ... @@ -33,133 +33,133 @@ class Field: show_hidden_initial: bool = ... help_text: _StrOrPromise = ... disabled: bool = ... - label_suffix: Optional[str] = ... + label_suffix: str | None = ... localize: bool = ... error_messages: _ErrorMessagesT = ... validators: List[_ValidatorCallable] = ... - max_length: Optional[int] = ... + max_length: int | None = ... def __init__( self, *, required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... def prepare_value(self, value: Any) -> Any: ... - def to_python(self, value: Optional[Any]) -> Optional[Any]: ... + def to_python(self, value: Any | None) -> Any | None: ... def validate(self, value: Any) -> None: ... def run_validators(self, value: Any) -> None: ... def clean(self, value: Any) -> Any: ... def bound_data(self, data: Any, initial: Any) -> Any: ... def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... - def has_changed(self, initial: Optional[Any], data: Optional[Any]) -> bool: ... + def has_changed(self, initial: Any | None, data: Any | None) -> bool: ... def get_bound_field(self, form: BaseForm, field_name: str) -> BoundField: ... def deconstruct(self) -> Any: ... class CharField(Field): - max_length: Optional[int] = ... - min_length: Optional[int] = ... + max_length: int | None = ... + min_length: int | None = ... strip: bool = ... - empty_value: Optional[str] = ... + empty_value: str | None = ... def __init__( self, *, - max_length: Optional[int] = ..., - min_length: Optional[int] = ..., + max_length: int | None = ..., + min_length: int | None = ..., strip: bool = ..., - empty_value: Optional[str] = ..., + empty_value: str | None = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... - def to_python(self, value: Optional[Any]) -> Optional[str]: ... + def to_python(self, value: Any | None) -> str | None: ... def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... class IntegerField(Field): - max_value: Optional[int] - min_value: Optional[int] + max_value: int | None + min_value: int | None re_decimal: Any = ... def __init__( self, *, - max_value: Optional[int] = ..., - min_value: Optional[int] = ..., + max_value: int | None = ..., + min_value: int | None = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... - def to_python(self, value: Optional[Any]) -> Optional[int]: ... + def to_python(self, value: Any | None) -> int | None: ... def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... class FloatField(IntegerField): def __init__( self, *, - max_value: Union[int, float, None] = ..., - min_value: Union[int, float, None] = ..., + max_value: int | float | None = ..., + min_value: int | float | None = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... - def to_python(self, value: Optional[Any]) -> Optional[float]: ... # type: ignore + def to_python(self, value: Any | None) -> float | None: ... # type: ignore def validate(self, value: float) -> None: ... def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... class DecimalField(IntegerField): - decimal_places: Optional[int] - max_digits: Optional[int] + decimal_places: int | None + max_digits: int | None def __init__( self, *, - max_value: Union[Decimal, int, float, None] = ..., - min_value: Union[Decimal, int, float, None] = ..., - max_digits: Optional[int] = ..., - decimal_places: Optional[int] = ..., + max_value: Decimal | int | float | None = ..., + min_value: Decimal | int | float | None = ..., + max_digits: int | None = ..., + decimal_places: int | None = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... - def to_python(self, value: Optional[Any]) -> Optional[Decimal]: ... # type: ignore + def to_python(self, value: Any | None) -> Decimal | None: ... # type: ignore def validate(self, value: Decimal) -> None: ... def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... @@ -168,83 +168,83 @@ class BaseTemporalField(Field): def __init__( self, *, - input_formats: Optional[Any] = ..., + input_formats: Any | None = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... - def to_python(self, value: Optional[str]) -> Optional[Any]: ... + def to_python(self, value: str | None) -> Any | None: ... def strptime(self, value: str, format: str) -> Any: ... class DateField(BaseTemporalField): - def to_python(self, value: Union[None, str, datetime.datetime, datetime.date]) -> Optional[datetime.date]: ... + def to_python(self, value: None | str | datetime.datetime | datetime.date) -> datetime.date | None: ... def strptime(self, value: str, format: str) -> datetime.date: ... class TimeField(BaseTemporalField): - def to_python(self, value: Union[None, str, datetime.time]) -> Optional[datetime.time]: ... + def to_python(self, value: None | str | datetime.time) -> datetime.time | None: ... def strptime(self, value: str, format: str) -> datetime.time: ... class DateTimeFormatsIterator: def __iter__(self) -> Iterator[str]: ... class DateTimeField(BaseTemporalField): - def to_python(self, value: Union[None, str, datetime.datetime, datetime.date]) -> Optional[datetime.datetime]: ... + def to_python(self, value: None | str | datetime.datetime | datetime.date) -> datetime.datetime | None: ... def strptime(self, value: str, format: str) -> datetime.datetime: ... class DurationField(Field): - def prepare_value(self, value: Optional[Union[datetime.timedelta, str]]) -> Optional[str]: ... - def to_python(self, value: Optional[Any]) -> Optional[datetime.timedelta]: ... + def prepare_value(self, value: datetime.timedelta | str | None) -> str | None: ... + def to_python(self, value: Any | None) -> datetime.timedelta | None: ... class RegexField(CharField): - regex: _PropertyDescriptor[Union[str, Pattern[str]], Pattern[str]] = ... + regex: _PropertyDescriptor[str | Pattern[str], Pattern[str]] = ... def __init__( self, - regex: Union[str, Pattern[str]], + regex: str | Pattern[str], *, - max_length: Optional[int] = ..., - min_length: Optional[int] = ..., + max_length: int | None = ..., + min_length: int | None = ..., strip: bool = ..., - empty_value: Optional[str] = ..., + empty_value: str | None = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... class EmailField(CharField): def __init__( self, *, - max_length: Optional[int] = ..., - min_length: Optional[int] = ..., + max_length: int | None = ..., + min_length: int | None = ..., strip: bool = ..., - empty_value: Optional[str] = ..., + empty_value: str | None = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... class FileField(Field): @@ -252,90 +252,90 @@ class FileField(Field): def __init__( self, *, - max_length: Optional[int] = ..., + max_length: int | None = ..., allow_empty_file: bool = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... - def clean(self, data: Any, initial: Optional[Any] = ...) -> Any: ... - def to_python(self, data: Optional[File]) -> Optional[File]: ... - def bound_data(self, data: Optional[Any], initial: Any) -> Any: ... - def has_changed(self, initial: Optional[Any], data: Optional[Any]) -> bool: ... + def clean(self, data: Any, initial: Any | None = ...) -> Any: ... + def to_python(self, data: File | None) -> File | None: ... + def bound_data(self, data: Any | None, initial: Any) -> Any: ... + def has_changed(self, initial: Any | None, data: Any | None) -> bool: ... class ImageField(FileField): - def to_python(self, data: Optional[File]) -> Optional[File]: ... + def to_python(self, data: File | None) -> File | None: ... def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... class URLField(CharField): def __init__( self, *, - max_length: Optional[int] = ..., - min_length: Optional[int] = ..., + max_length: int | None = ..., + min_length: int | None = ..., strip: bool = ..., - empty_value: Optional[str] = ..., + empty_value: str | None = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... - def to_python(self, value: Optional[Any]) -> Optional[str]: ... + def to_python(self, value: Any | None) -> str | None: ... class BooleanField(Field): - def to_python(self, value: Optional[Any]) -> bool: ... + def to_python(self, value: Any | None) -> bool: ... def validate(self, value: Any) -> None: ... - def has_changed(self, initial: Optional[Any], data: Optional[Any]) -> bool: ... + def has_changed(self, initial: Any | None, data: Any | None) -> bool: ... class NullBooleanField(BooleanField): - def to_python(self, value: Optional[Any]) -> Optional[bool]: ... # type: ignore + def to_python(self, value: Any | None) -> bool | None: ... # type: ignore def validate(self, value: Any) -> None: ... class CallableChoiceIterator: choices_func: _ChoicesCallable = ... def __init__(self, choices_func: _ChoicesCallable) -> None: ... - def __iter__(self) -> Iterator[Union[_Choice, _ChoiceNamedGroup]]: ... + def __iter__(self) -> Iterator[_Choice | _ChoiceNamedGroup]: ... class ChoiceField(Field): choices: _PropertyDescriptor[ - Union[_FieldChoices, _ChoicesCallable, CallableChoiceIterator], - Union[_FieldChoices, CallableChoiceIterator], + _FieldChoices | _ChoicesCallable | CallableChoiceIterator, + _FieldChoices | CallableChoiceIterator, ] = ... widget: _ClassLevelWidgetT def __init__( self, *, - choices: Union[_FieldChoices, _ChoicesCallable] = ..., + choices: _FieldChoices | _ChoicesCallable = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... # Real return type of `to_python` is `str`, but it results in errors when # subclassing `ModelChoiceField`: `# type: ignore[override]` is not inherited - def to_python(self, value: Optional[Any]) -> Any: ... + def to_python(self, value: Any | None) -> Any: ... def validate(self, value: Any) -> None: ... def valid_value(self, value: Any) -> bool: ... @@ -344,52 +344,52 @@ class _CoerceCallable(Protocol): class TypedChoiceField(ChoiceField): coerce: _CoerceCallable = ... - empty_value: Optional[str] = ... + empty_value: str | None = ... def __init__( self, *, coerce: _CoerceCallable = ..., - empty_value: Optional[str] = ..., - choices: Union[_FieldChoices, _ChoicesCallable] = ..., + empty_value: str | None = ..., + choices: _FieldChoices | _ChoicesCallable = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... def clean(self, value: Any) -> Any: ... class MultipleChoiceField(ChoiceField): - def to_python(self, value: Optional[Any]) -> List[str]: ... + def to_python(self, value: Any | None) -> List[str]: ... def validate(self, value: Any) -> None: ... - def has_changed(self, initial: Optional[Collection[Any]], data: Optional[Collection[Any]]) -> bool: ... + def has_changed(self, initial: Collection[Any] | None, data: Collection[Any] | None) -> bool: ... class TypedMultipleChoiceField(MultipleChoiceField): coerce: _CoerceCallable = ... - empty_value: Optional[List[Any]] = ... + empty_value: List[Any] | None = ... def __init__( self, *, coerce: _CoerceCallable = ..., - empty_value: Optional[List[Any]] = ..., - choices: Union[_FieldChoices, _ChoicesCallable] = ..., + empty_value: List[Any] | None = ..., + choices: _FieldChoices | _ChoicesCallable = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... def clean(self, value: Any) -> Any: ... def validate(self, value: Any) -> None: ... @@ -401,16 +401,16 @@ class ComboField(Field): fields: Sequence[Field], *, required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... def clean(self, value: Any) -> Any: ... @@ -423,72 +423,72 @@ class MultiValueField(Field): *, require_all_fields: bool = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... def compress(self, data_list: Any) -> Any: ... - def has_changed(self, initial: Optional[Any], data: Optional[Any]) -> bool: ... + def has_changed(self, initial: Any | None, data: Any | None) -> bool: ... def clean(self, value: Any) -> Any: ... def validate(self, value: Any) -> None: ... class FilePathField(ChoiceField): allow_files: bool allow_folders: bool - match: Optional[str] + match: str | None path: str recursive: bool - match_re: Optional[Pattern[str]] = ... + match_re: Pattern[str] | None = ... def __init__( self, path: str, *, - match: Optional[str] = ..., + match: str | None = ..., recursive: bool = ..., allow_files: bool = ..., allow_folders: bool = ..., - choices: Union[_FieldChoices, _ChoicesCallable] = ..., + choices: _FieldChoices | _ChoicesCallable = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... class SplitDateTimeField(MultiValueField): def __init__( self, *, - input_date_formats: Optional[Any] = ..., - input_time_formats: Optional[Any] = ..., + input_date_formats: Any | None = ..., + input_time_formats: Any | None = ..., fields: Sequence[Field] = ..., require_all_fields: bool = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... - def compress(self, data_list: Optional[Tuple[datetime.date, datetime.time]]) -> Optional[datetime.datetime]: ... + def compress(self, data_list: Tuple[datetime.date, datetime.time] | None) -> datetime.datetime | None: ... class GenericIPAddressField(CharField): unpack_ipv4: bool = ... @@ -498,16 +498,16 @@ class GenericIPAddressField(CharField): protocol: str = ..., unpack_ipv4: bool = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... def to_python(self, value: Any) -> str: ... @@ -517,26 +517,26 @@ class SlugField(CharField): self, *, allow_unicode: bool = ..., - max_length: Optional[Any] = ..., - min_length: Optional[Any] = ..., + max_length: Any | None = ..., + min_length: Any | None = ..., strip: bool = ..., - empty_value: Optional[str] = ..., + empty_value: str | None = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: Optional[_ErrorMessagesT] = ..., + error_messages: _ErrorMessagesT | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., ) -> None: ... class UUIDField(CharField): - def prepare_value(self, value: Optional[Any]) -> Optional[Any]: ... - def to_python(self, value: Any) -> Optional[UUID]: ... # type: ignore + def prepare_value(self, value: Any | None) -> Any | None: ... + def to_python(self, value: Any) -> UUID | None: ... # type: ignore class InvalidJSONInput(str): ... class JSONString(str): ... @@ -546,8 +546,8 @@ class JSONField(CharField): widget: _ClassLevelWidgetT = ... encoder: Any = ... decoder: Any = ... - def __init__(self, encoder: Optional[Any] = ..., decoder: Optional[Any] = ..., **kwargs: Any) -> None: ... + def __init__(self, encoder: Any | None = ..., decoder: Any | None = ..., **kwargs: Any) -> None: ... def to_python(self, value: Any) -> Any: ... def bound_data(self, data: Any, initial: Any) -> Any: ... def prepare_value(self, value: Any) -> str: ... - def has_changed(self, initial: Optional[Any], data: Optional[Any]) -> bool: ... + def has_changed(self, initial: Any | None, data: Any | None) -> bool: ... diff --git a/django-stubs/forms/forms.pyi b/django-stubs/forms/forms.pyi index 91f3f196a..d38cc70f4 100644 --- a/django-stubs/forms/forms.pyi +++ b/django-stubs/forms/forms.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Type, Union +from typing import Any, ClassVar, Dict, Iterable, Iterator, List, Mapping, Sequence, Type from django.core.exceptions import ValidationError as ValidationError from django.forms.boundfield import BoundField @@ -13,16 +13,16 @@ class DeclarativeFieldsMetaclass(MediaDefiningClass): ... class BaseForm: class Meta: fields: Sequence[str] = ... - default_renderer: Optional[Union[BaseRenderer, Type[BaseRenderer]]] = ... - field_order: Optional[Iterable[str]] = ... + default_renderer: BaseRenderer | Type[BaseRenderer] | None = ... + field_order: Iterable[str] | None = ... use_required_attribute: bool = ... is_bound: bool = ... data: _DataT = ... files: _FilesT = ... - auto_id: Union[bool, str] = ... + auto_id: bool | str = ... initial: Mapping[str, Any] = ... error_class: Type[ErrorList] = ... - prefix: Optional[str] = ... + prefix: str | None = ... label_suffix: str = ... empty_permitted: bool = ... fields: Dict[str, Field] = ... @@ -30,19 +30,19 @@ class BaseForm: cleaned_data: Dict[str, Any] = ... def __init__( self, - data: Optional[_DataT] = ..., - files: Optional[_FilesT] = ..., - auto_id: Union[bool, str] = ..., - prefix: Optional[str] = ..., - initial: Optional[Mapping[str, Any]] = ..., + data: _DataT | None = ..., + files: _FilesT | None = ..., + auto_id: bool | str = ..., + prefix: str | None = ..., + initial: Mapping[str, Any] | None = ..., error_class: Type[ErrorList] = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., empty_permitted: bool = ..., - field_order: Optional[Iterable[str]] = ..., - use_required_attribute: Optional[bool] = ..., - renderer: Optional[BaseRenderer] = ..., + field_order: Iterable[str] | None = ..., + use_required_attribute: bool | None = ..., + renderer: BaseRenderer | None = ..., ) -> None: ... - def order_fields(self, field_order: Optional[Iterable[str]]) -> None: ... + def order_fields(self, field_order: Iterable[str] | None) -> None: ... def __iter__(self) -> Iterator[BoundField]: ... def __getitem__(self, name: str) -> BoundField: ... @property @@ -54,10 +54,10 @@ class BaseForm: def as_ul(self) -> SafeString: ... def as_p(self) -> SafeString: ... def non_field_errors(self) -> ErrorList: ... - def add_error(self, field: Optional[str], error: Union[ValidationError, str]) -> None: ... - def has_error(self, field: Optional[str], code: Optional[str] = ...) -> bool: ... + def add_error(self, field: str | None, error: ValidationError | str) -> None: ... + def has_error(self, field: str | None, code: str | None = ...) -> bool: ... def full_clean(self) -> None: ... - def clean(self) -> Optional[Dict[str, Any]]: ... + def clean(self) -> Dict[str, Any] | None: ... def has_changed(self) -> bool: ... @property def changed_data(self) -> List[str]: ... diff --git a/django-stubs/forms/formsets.pyi b/django-stubs/forms/formsets.pyi index 27d5ae027..a27e7bcb1 100644 --- a/django-stubs/forms/formsets.pyi +++ b/django-stubs/forms/formsets.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Generic, Iterator, List, Mapping, Optional, Sequence, Sized, Type, TypeVar, Union +from typing import Any, Dict, Generic, Iterator, List, Mapping, Sequence, Sized, Type, TypeVar from django.forms.forms import BaseForm, Form from django.forms.utils import ErrorList, _DataT, _FilesT @@ -18,9 +18,9 @@ DEFAULT_MAX_NUM: int = ... _F = TypeVar("_F", bound=BaseForm) class ManagementForm(Form): - cleaned_data: Dict[str, Optional[int]] + cleaned_data: Dict[str, int | None] def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def clean(self) -> Dict[str, Optional[int]]: ... + def clean(self) -> Dict[str, int | None]: ... class BaseFormSet(Generic[_F], Sized): form: Type[_F] @@ -35,24 +35,24 @@ class BaseFormSet(Generic[_F], Sized): validate_max: bool is_bound: bool = ... - prefix: Optional[str] = ... + prefix: str | None = ... auto_id: str = ... data: _DataT = ... files: _FilesT = ... - initial: Optional[Sequence[Mapping[str, Any]]] = ... + initial: Sequence[Mapping[str, Any]] | None = ... form_kwargs: Dict[str, Any] = ... error_class: Type[ErrorList] = ... ordering_widget: Type[Widget] def __init__( self, - data: Optional[_DataT] = ..., - files: Optional[_FilesT] = ..., + data: _DataT | None = ..., + files: _FilesT | None = ..., auto_id: str = ..., - prefix: Optional[str] = ..., - initial: Optional[Sequence[Mapping[str, Any]]] = ..., + prefix: str | None = ..., + initial: Sequence[Mapping[str, Any]] | None = ..., error_class: Type[ErrorList] = ..., - form_kwargs: Optional[Dict[str, Any]] = ..., - error_messages: Optional[Mapping[str, str]] = ..., + form_kwargs: Dict[str, Any] | None = ..., + error_messages: Mapping[str, str] | None = ..., ) -> None: ... def __iter__(self) -> Iterator[_F]: ... def __getitem__(self, index: int) -> _F: ... @@ -64,7 +64,7 @@ class BaseFormSet(Generic[_F], Sized): def initial_form_count(self) -> int: ... @property def forms(self) -> List[_F]: ... - def get_form_kwargs(self, index: Optional[int]) -> Dict[str, Any]: ... + def get_form_kwargs(self, index: int | None) -> Dict[str, Any]: ... @property def initial_forms(self) -> List[_F]: ... @property @@ -89,8 +89,8 @@ class BaseFormSet(Generic[_F], Sized): def full_clean(self) -> None: ... def clean(self) -> None: ... def has_changed(self) -> bool: ... - def add_fields(self, form: _F, index: Optional[int]) -> None: ... - def add_prefix(self, index: Union[int, str]) -> str: ... + def add_fields(self, form: _F, index: int | None) -> None: ... + def add_prefix(self, index: int | str) -> str: ... def is_multipart(self) -> bool: ... @property def media(self) -> Media: ... @@ -104,11 +104,11 @@ def formset_factory( extra: int = ..., can_order: bool = ..., can_delete: bool = ..., - max_num: Optional[int] = ..., + max_num: int | None = ..., validate_max: bool = ..., - min_num: Optional[int] = ..., + min_num: int | None = ..., validate_min: bool = ..., - absolute_max: Optional[int] = ..., + absolute_max: int | None = ..., can_delete_extra: bool = ..., ) -> Type[BaseFormSet[_F]]: ... def all_valid(formsets: Sequence[BaseFormSet[_F]]) -> bool: ... diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index 2c9dd1e7d..43b154f8c 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -9,10 +9,10 @@ from typing import ( Iterator, List, Mapping, - Optional, Sequence, Tuple, Type, + TypeAlias, TypeVar, Union, overload, @@ -38,7 +38,7 @@ from typing_extensions import Literal ALL_FIELDS: Literal["__all__"] -_Fields = Union[_ListOrTuple[str], Literal["__all__"]] +_Fields: TypeAlias = Union[_ListOrTuple[str], Literal["__all__"]] # https://github.com/python/mypy/issues/12211 _Widgets = Dict[str, Union[Type[Widget], Widget]] _Labels = Dict[str, str] _HelpTexts = Dict[str, str] @@ -49,38 +49,36 @@ _M = TypeVar("_M", bound=Model) _ParentM = TypeVar("_ParentM", bound=Model) def construct_instance( - form: BaseForm, instance: _M, fields: Optional[Container[str]] = ..., exclude: Optional[Container[str]] = ... + form: BaseForm, instance: _M, fields: Container[str] | None = ..., exclude: Container[str] | None = ... ) -> _M: ... -def model_to_dict( - instance: Model, fields: Optional[_Fields] = ..., exclude: Optional[_Fields] = ... -) -> Dict[str, Any]: ... +def model_to_dict(instance: Model, fields: _Fields | None = ..., exclude: _Fields | None = ...) -> Dict[str, Any]: ... def apply_limit_choices_to_to_formfield(formfield: Field) -> None: ... def fields_for_model( model: Type[Model], - fields: Optional[_Fields] = ..., - exclude: Optional[_Fields] = ..., - widgets: Optional[_Widgets] = ..., - formfield_callback: Optional[_FormFieldCallback] = ..., - localized_fields: Optional[_Fields] = ..., - labels: Optional[_Labels] = ..., - help_texts: Optional[_HelpTexts] = ..., - error_messages: Optional[_ErrorMessages] = ..., - field_classes: Optional[Mapping[str, Type[Field]]] = ..., + fields: _Fields | None = ..., + exclude: _Fields | None = ..., + widgets: _Widgets | None = ..., + formfield_callback: _FormFieldCallback | None = ..., + localized_fields: _Fields | None = ..., + labels: _Labels | None = ..., + help_texts: _HelpTexts | None = ..., + error_messages: _ErrorMessages | None = ..., + field_classes: Mapping[str, Type[Field]] | None = ..., *, apply_limit_choices_to: bool = ..., ) -> Dict[str, Any]: ... class ModelFormOptions(Generic[_M]): model: Type[_M] = ... - fields: Optional[_Fields] = ... - exclude: Optional[_Fields] = ... - widgets: Optional[_Widgets] = ... - localized_fields: Optional[_Fields] = ... - labels: Optional[_Labels] = ... - help_texts: Optional[_HelpTexts] = ... - error_messages: Optional[_ErrorMessages] = ... - field_classes: Optional[Dict[str, Type[Field]]] = ... - def __init__(self, options: Optional[type] = ...) -> None: ... + fields: _Fields | None = ... + exclude: _Fields | None = ... + widgets: _Widgets | None = ... + localized_fields: _Fields | None = ... + labels: _Labels | None = ... + help_texts: _HelpTexts | None = ... + error_messages: _ErrorMessages | None = ... + field_classes: Dict[str, Type[Field]] | None = ... + def __init__(self, options: type | None = ...) -> None: ... class ModelFormMetaclass(DeclarativeFieldsMetaclass): ... @@ -89,16 +87,16 @@ class BaseModelForm(Generic[_M], BaseForm): _meta: ModelFormOptions[_M] def __init__( self, - data: Optional[_DataT] = ..., - files: Optional[_FilesT] = ..., - auto_id: Union[bool, str] = ..., - prefix: Optional[str] = ..., - initial: Optional[Mapping[str, Any]] = ..., + data: _DataT | None = ..., + files: _FilesT | None = ..., + auto_id: bool | str = ..., + prefix: str | None = ..., + initial: Mapping[str, Any] | None = ..., error_class: Type[ErrorList] = ..., - label_suffix: Optional[str] = ..., + label_suffix: str | None = ..., empty_permitted: bool = ..., - instance: Optional[_M] = ..., - use_required_attribute: Optional[bool] = ..., + instance: _M | None = ..., + use_required_attribute: bool | None = ..., renderer: BaseRenderer = ..., ) -> None: ... def validate_unique(self) -> None: ... @@ -111,15 +109,15 @@ class ModelForm(BaseModelForm[_M], metaclass=ModelFormMetaclass): def modelform_factory( model: Type[_M], form: Type[ModelForm[_M]] = ..., - fields: Optional[_Fields] = ..., - exclude: Optional[_Fields] = ..., - formfield_callback: Optional[_FormFieldCallback] = ..., - widgets: Optional[_Widgets] = ..., - localized_fields: Optional[_Fields] = ..., - labels: Optional[_Labels] = ..., - help_texts: Optional[_HelpTexts] = ..., - error_messages: Optional[_ErrorMessages] = ..., - field_classes: Optional[Mapping[str, Type[Field]]] = ..., + fields: _Fields | None = ..., + exclude: _Fields | None = ..., + formfield_callback: _FormFieldCallback | None = ..., + widgets: _Widgets | None = ..., + localized_fields: _Fields | None = ..., + labels: _Labels | None = ..., + help_texts: _HelpTexts | None = ..., + error_messages: _ErrorMessages | None = ..., + field_classes: Mapping[str, Type[Field]] | None = ..., ) -> Type[ModelForm[_M]]: ... _ModelFormT = TypeVar("_ModelFormT", bound=ModelForm) @@ -127,17 +125,17 @@ _ModelFormT = TypeVar("_ModelFormT", bound=ModelForm) class BaseModelFormSet(Generic[_M, _ModelFormT], BaseFormSet[_ModelFormT]): model: Type[_M] = ... unique_fields: Collection[str] = ... - queryset: Optional[QuerySet[_M]] = ... - initial_extra: Optional[Sequence[Dict[str, Any]]] = ... + queryset: QuerySet[_M] | None = ... + initial_extra: Sequence[Dict[str, Any]] | None = ... def __init__( self, - data: Optional[_DataT] = ..., - files: Optional[_FilesT] = ..., + data: _DataT | None = ..., + files: _FilesT | None = ..., auto_id: str = ..., - prefix: Optional[str] = ..., - queryset: Optional[QuerySet[_M]] = ..., + prefix: str | None = ..., + queryset: QuerySet[_M] | None = ..., *, - initial: Optional[Sequence[Dict[str, Any]]] = ..., + initial: Sequence[Dict[str, Any]] | None = ..., **kwargs: Any, ) -> None: ... def initial_form_count(self) -> int: ... @@ -158,29 +156,29 @@ class BaseModelFormSet(Generic[_M, _ModelFormT], BaseFormSet[_ModelFormT]): def save_existing_objects(self, commit: bool = ...) -> List[_M]: ... new_objects: List[_M] = ... def save_new_objects(self, commit: bool = ...) -> List[_M]: ... - def add_fields(self, form: _ModelFormT, index: Optional[int]) -> None: ... + def add_fields(self, form: _ModelFormT, index: int | None) -> None: ... def modelformset_factory( model: Type[_M], form: Type[_ModelFormT] = ..., - formfield_callback: Optional[_FormFieldCallback] = ..., + formfield_callback: _FormFieldCallback | None = ..., formset: Type[BaseModelFormSet] = ..., extra: int = ..., can_delete: bool = ..., can_order: bool = ..., - max_num: Optional[int] = ..., - fields: Optional[_Fields] = ..., - exclude: Optional[_Fields] = ..., - widgets: Optional[_Widgets] = ..., + max_num: int | None = ..., + fields: _Fields | None = ..., + exclude: _Fields | None = ..., + widgets: _Widgets | None = ..., validate_max: bool = ..., - localized_fields: Optional[_Fields] = ..., - labels: Optional[_Labels] = ..., - help_texts: Optional[_HelpTexts] = ..., - error_messages: Optional[_ErrorMessages] = ..., - min_num: Optional[int] = ..., + localized_fields: _Fields | None = ..., + labels: _Labels | None = ..., + help_texts: _HelpTexts | None = ..., + error_messages: _ErrorMessages | None = ..., + min_num: int | None = ..., validate_min: bool = ..., - field_classes: Optional[Mapping[str, Type[Field]]] = ..., - absolute_max: Optional[int] = ..., + field_classes: Mapping[str, Type[Field]] | None = ..., + absolute_max: int | None = ..., can_delete_extra: bool = ..., ) -> Type[BaseModelFormSet[_M, _ModelFormT]]: ... @@ -191,19 +189,19 @@ class BaseInlineFormSet(Generic[_M, _ParentM, _ModelFormT], BaseModelFormSet[_M, fk: ForeignKey # set by inlineformset_set def __init__( self, - data: Optional[_DataT] = ..., - files: Optional[_FilesT] = ..., - instance: Optional[_ParentM] = ..., + data: _DataT | None = ..., + files: _FilesT | None = ..., + instance: _ParentM | None = ..., save_as_new: bool = ..., - prefix: Optional[str] = ..., - queryset: Optional[QuerySet[_M]] = ..., + prefix: str | None = ..., + queryset: QuerySet[_M] | None = ..., **kwargs: Any, ) -> None: ... def initial_form_count(self) -> int: ... @classmethod def get_default_prefix(cls) -> str: ... def save_new(self, form: _ModelFormT, commit: bool = ...) -> _M: ... - def add_fields(self, form: _ModelFormT, index: Optional[int]) -> None: ... + def add_fields(self, form: _ModelFormT, index: int | None) -> None: ... def get_unique_error_message(self, unique_check: Sequence[str]) -> str: ... def inlineformset_factory( @@ -211,24 +209,24 @@ def inlineformset_factory( model: Type[_M], form: Type[_ModelFormT] = ..., formset: Type[BaseInlineFormSet] = ..., - fk_name: Optional[str] = ..., - fields: Optional[_Fields] = ..., - exclude: Optional[_Fields] = ..., + fk_name: str | None = ..., + fields: _Fields | None = ..., + exclude: _Fields | None = ..., extra: int = ..., can_order: bool = ..., can_delete: bool = ..., - max_num: Optional[int] = ..., - formfield_callback: Optional[_FormFieldCallback] = ..., - widgets: Optional[_Widgets] = ..., + max_num: int | None = ..., + formfield_callback: _FormFieldCallback | None = ..., + widgets: _Widgets | None = ..., validate_max: bool = ..., - localized_fields: Optional[Sequence[str]] = ..., - labels: Optional[_Labels] = ..., - help_texts: Optional[_HelpTexts] = ..., - error_messages: Optional[_ErrorMessages] = ..., - min_num: Optional[int] = ..., + localized_fields: Sequence[str] | None = ..., + labels: _Labels | None = ..., + help_texts: _HelpTexts | None = ..., + error_messages: _ErrorMessages | None = ..., + min_num: int | None = ..., validate_min: bool = ..., - field_classes: Optional[Mapping[str, Type[Field]]] = ..., - absolute_max: Optional[int] = ..., + field_classes: Mapping[str, Type[Field]] | None = ..., + absolute_max: int | None = ..., can_delete_extra: bool = ..., ) -> Type[BaseInlineFormSet[_M, _ParentM, _ModelFormT]]: ... @@ -241,13 +239,13 @@ class InlineForeignKeyField(Field): default_error_messages: Dict[str, str] = ... parent_instance: Model = ... pk_field: bool = ... - to_field: Optional[str] = ... + to_field: str | None = ... def __init__( self, parent_instance: Model, *args: Any, pk_field: bool = ..., - to_field: Optional[str] = ..., + to_field: str | None = ..., **kwargs: Any, ) -> None: ... def clean(self, value: Any) -> Model: ... @@ -261,7 +259,7 @@ class ModelChoiceIterator: field: ModelChoiceField = ... queryset: QuerySet = ... def __init__(self, field: ModelChoiceField) -> None: ... - def __iter__(self) -> Iterator[Tuple[Union[ModelChoiceIteratorValue, str], str]]: ... + def __iter__(self) -> Iterator[Tuple[ModelChoiceIteratorValue | str, str]]: ... def __len__(self) -> int: ... def __bool__(self) -> bool: ... def choice(self, obj: Model) -> Tuple[ModelChoiceIteratorValue, str]: ... @@ -275,57 +273,57 @@ class ModelChoiceField(ChoiceField): validators: List[Any] default_error_messages: Dict[str, str] = ... iterator: Type[ModelChoiceIterator] = ... - empty_label: Optional[_StrOrPromise] = ... - queryset: Optional[QuerySet[models.Model]] = ... - limit_choices_to: Optional[_AllLimitChoicesTo] = ... - to_field_name: Optional[str] = ... + empty_label: _StrOrPromise | None = ... + queryset: QuerySet[models.Model] | None = ... + limit_choices_to: _AllLimitChoicesTo | None = ... + to_field_name: str | None = ... def __init__( self, - queryset: Union[None, Manager[models.Model], QuerySet[models.Model]], + queryset: None | Manager[models.Model] | QuerySet[models.Model], *, - empty_label: Optional[_StrOrPromise] = ..., + empty_label: _StrOrPromise | None = ..., required: bool = ..., - widget: Optional[Union[Widget, Type[Widget]]] = ..., - label: Optional[_StrOrPromise] = ..., - initial: Optional[Any] = ..., + widget: Widget | Type[Widget] | None = ..., + label: _StrOrPromise | None = ..., + initial: Any | None = ..., help_text: _StrOrPromise = ..., - to_field_name: Optional[str] = ..., - limit_choices_to: Optional[_AllLimitChoicesTo] = ..., + to_field_name: str | None = ..., + limit_choices_to: _AllLimitChoicesTo | None = ..., blank: bool = ..., **kwargs: Any, ) -> None: ... def get_limit_choices_to(self) -> _LimitChoicesTo: ... def label_from_instance(self, obj: Model) -> str: ... choices: _PropertyDescriptor[ - Union[_FieldChoices, _ChoicesCallable, CallableChoiceIterator], - Union[_FieldChoices, CallableChoiceIterator, ModelChoiceIterator], + _FieldChoices | _ChoicesCallable | CallableChoiceIterator, + _FieldChoices | CallableChoiceIterator | ModelChoiceIterator, ] = ... def prepare_value(self, value: Any) -> Any: ... - def to_python(self, value: Optional[Any]) -> Optional[Model]: ... - def validate(self, value: Optional[Model]) -> None: ... - def has_changed(self, initial: Optional[Union[Model, int, str, UUID]], data: Optional[Union[int, str]]) -> bool: ... + def to_python(self, value: Any | None) -> Model | None: ... + def validate(self, value: Model | None) -> None: ... + def has_changed(self, initial: Model | int | str | UUID | None, data: int | str | None) -> bool: ... class ModelMultipleChoiceField(ModelChoiceField): disabled: bool - empty_label: Optional[_StrOrPromise] + empty_label: _StrOrPromise | None help_text: _StrOrPromise required: bool show_hidden_initial: bool widget: _ClassLevelWidgetT = ... hidden_widget: Type[Widget] = ... default_error_messages: Dict[str, str] = ... - def __init__(self, queryset: Union[None, Manager[Model], QuerySet[Model]], **kwargs: Any) -> None: ... + def __init__(self, queryset: None | Manager[Model] | QuerySet[Model], **kwargs: Any) -> None: ... def to_python(self, value: Any) -> List[Model]: ... # type: ignore[override] def clean(self, value: Any) -> QuerySet[Model]: ... def prepare_value(self, value: Any) -> Any: ... - def has_changed(self, initial: Optional[Collection[Any]], data: Optional[Collection[Any]]) -> bool: ... # type: ignore + def has_changed(self, initial: Collection[Any] | None, data: Collection[Any] | None) -> bool: ... # type: ignore def modelform_defines_fields(form_class: Type[ModelForm]) -> bool: ... @overload def _get_foreign_key( # type: ignore - parent_model: Type[Model], model: Type[Model], fk_name: Optional[str] = ..., can_fail: Literal[True] = ... -) -> Optional[ForeignKey]: ... + parent_model: Type[Model], model: Type[Model], fk_name: str | None = ..., can_fail: Literal[True] = ... +) -> ForeignKey | None: ... @overload def _get_foreign_key( - parent_model: Type[Model], model: Type[Model], fk_name: Optional[str] = ..., can_fail: Literal[False] = ... + parent_model: Type[Model], model: Type[Model], fk_name: str | None = ..., can_fail: Literal[False] = ... ) -> ForeignKey: ... diff --git a/django-stubs/forms/renderers.pyi b/django-stubs/forms/renderers.pyi index 6246af0ed..d59fdb18d 100644 --- a/django-stubs/forms/renderers.pyi +++ b/django-stubs/forms/renderers.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Type +from typing import Any, Dict, Type from django.http import HttpRequest from django.template.backends.base import BaseEngine @@ -10,7 +10,7 @@ def get_default_renderer() -> BaseRenderer: ... class BaseRenderer: def get_template(self, template_name: str) -> Any: ... - def render(self, template_name: str, context: Dict[str, Any], request: Optional[HttpRequest] = ...) -> str: ... + def render(self, template_name: str, context: Dict[str, Any], request: HttpRequest | None = ...) -> str: ... class EngineMixin: def get_template(self, template_name: str) -> Any: ... @@ -25,4 +25,4 @@ class Jinja2(EngineMixin, BaseRenderer): def backend(self) -> Type[Jinja2R]: ... class TemplatesSetting(BaseRenderer): - def get_template(self, template_name: str) -> Optional[Template]: ... + def get_template(self, template_name: str) -> Template | None: ... diff --git a/django-stubs/forms/utils.pyi b/django-stubs/forms/utils.pyi index 1fa219097..5c239ac63 100644 --- a/django-stubs/forms/utils.pyi +++ b/django-stubs/forms/utils.pyi @@ -1,6 +1,6 @@ from collections import UserList from datetime import datetime -from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Union +from typing import Any, Dict, Iterable, List, Mapping, Sequence from django.core.exceptions import ValidationError from django.core.files.uploadedfile import UploadedFile @@ -21,12 +21,12 @@ class ErrorDict(dict): def as_text(self) -> str: ... class ErrorList(UserList): - data: List[Union[ValidationError, str]] + data: List[ValidationError | str] error_class: str = ... def __init__( self, - initlist: Optional[Union[ErrorList, Sequence[Union[str, Exception]]]] = ..., - error_class: Optional[str] = ..., + initlist: ErrorList | Sequence[str | Exception] | None = ..., + error_class: str | None = ..., ) -> None: ... def as_data(self) -> List[ValidationError]: ... def get_json_data(self, escape_html: bool = ...) -> List[Dict[str, str]]: ... diff --git a/django-stubs/forms/widgets.pyi b/django-stubs/forms/widgets.pyi index a9b1101e3..8428bff2f 100644 --- a/django-stubs/forms/widgets.pyi +++ b/django-stubs/forms/widgets.pyi @@ -1,5 +1,5 @@ import datetime -from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Tuple, Type, Union +from typing import Any, Dict, Iterable, Iterator, List, Mapping, Sequence, Tuple, Type from django.core.files.base import File from django.db.models.fields import _FieldChoices @@ -17,9 +17,9 @@ class MediaOrderConflictWarning(RuntimeWarning): ... class Media: def __init__( self, - media: Optional[type] = ..., - css: Optional[Dict[str, Sequence[str]]] = ..., - js: Optional[Sequence[str]] = ..., + media: type | None = ..., + css: Dict[str, Sequence[str]] | None = ..., + js: Sequence[str] | None = ..., ) -> None: ... def render(self) -> SafeString: ... def render_js(self) -> List[SafeString]: ... @@ -40,16 +40,16 @@ class Widget(metaclass=MediaDefiningClass): attrs: _OptAttrs = ... template_name: str media: _Getter[Media] - def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... @property def is_hidden(self) -> bool: ... def subwidgets(self, name: str, value: Any, attrs: _OptAttrs = ...) -> Iterator[Dict[str, Any]]: ... - def format_value(self, value: Any) -> Optional[str]: ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... + def format_value(self, value: Any) -> str | None: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... def render( - self, name: str, value: Any, attrs: Optional[_OptAttrs] = ..., renderer: Optional[BaseRenderer] = ... + self, name: str, value: Any, attrs: _OptAttrs | None = ..., renderer: BaseRenderer | None = ... ) -> SafeString: ... - def build_attrs(self, base_attrs: _OptAttrs, extra_attrs: Optional[_OptAttrs] = ...) -> Dict[str, Any]: ... + def build_attrs(self, base_attrs: _OptAttrs, extra_attrs: _OptAttrs | None = ...) -> Dict[str, Any]: ... def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... def id_for_label(self, id_: str) -> str: ... @@ -79,8 +79,8 @@ class PasswordInput(Input): render_value: bool = ... input_type: str = ... template_name: str = ... - def __init__(self, attrs: Optional[_OptAttrs] = ..., render_value: bool = ...) -> None: ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... + def __init__(self, attrs: _OptAttrs | None = ..., render_value: bool = ...) -> None: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... class HiddenInput(Input): choices: _FieldChoices @@ -108,20 +108,20 @@ class ClearableFileInput(FileInput): template_name: str = ... def clear_checkbox_name(self, name: str) -> str: ... def clear_checkbox_id(self, name: str) -> str: ... - def is_initial(self, value: Optional[Union[File, str]]) -> bool: ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... + def is_initial(self, value: File | str | None) -> bool: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... class Textarea(Widget): template_name: str = ... - def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... class DateTimeBaseInput(TextInput): format_key: str = ... - format: Optional[str] = ... + format: str | None = ... supports_microseconds: bool = ... - def __init__(self, attrs: Optional[_OptAttrs] = ..., format: Optional[str] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ..., format: str | None = ...) -> None: ... class DateInput(DateTimeBaseInput): format_key: str = ... @@ -144,52 +144,52 @@ class CheckboxInput(Input): check_test: _CheckCallable = ... input_type: str = ... template_name: str = ... - def __init__(self, attrs: Optional[_OptAttrs] = ..., check_test: Optional[_CheckCallable] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ..., check_test: _CheckCallable | None = ...) -> None: ... class ChoiceWidget(Widget): allow_multiple_selected: bool = ... - input_type: Optional[str] = ... + input_type: str | None = ... template_name: str = ... - option_template_name: Optional[str] = ... + option_template_name: str | None = ... add_id_index: bool = ... checked_attribute: Any = ... option_inherits_attrs: bool = ... choices: _FieldChoices = ... - def __init__(self, attrs: Optional[_OptAttrs] = ..., choices: _FieldChoices = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ..., choices: _FieldChoices = ...) -> None: ... def subwidgets(self, name: str, value: Any, attrs: _OptAttrs = ...) -> Iterator[Dict[str, Any]]: ... - def options(self, name: str, value: List[str], attrs: Optional[_OptAttrs] = ...) -> Iterator[Dict[str, Any]]: ... + def options(self, name: str, value: List[str], attrs: _OptAttrs | None = ...) -> Iterator[Dict[str, Any]]: ... def optgroups( - self, name: str, value: List[str], attrs: Optional[_OptAttrs] = ... - ) -> List[Tuple[Optional[str], List[Dict[str, Any]], Optional[int]]]: ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... + self, name: str, value: List[str], attrs: _OptAttrs | None = ... + ) -> List[Tuple[str | None, List[Dict[str, Any]], int | None]]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... def create_option( self, name: str, value: Any, - label: Union[int, str], + label: int | str, selected: bool, index: int, - subindex: Optional[int] = ..., - attrs: Optional[_OptAttrs] = ..., + subindex: int | None = ..., + attrs: _OptAttrs | None = ..., ) -> Dict[str, Any]: ... def id_for_label(self, id_: str, index: str = ...) -> str: ... def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ... def format_value(self, value: Any) -> List[str]: ... # type: ignore class Select(ChoiceWidget): - input_type: Optional[str] = ... + input_type: str | None = ... template_name: str = ... option_template_name: str = ... add_id_index: bool = ... checked_attribute: Any = ... option_inherits_attrs: bool = ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... def use_required_attribute(self, initial: Any) -> bool: ... class NullBooleanSelect(Select): - def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ... + def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... def format_value(self, value: Any) -> str: ... # type: ignore - def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Optional[bool]: ... + def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> bool | None: ... class SelectMultiple(Select): allow_multiple_selected: bool = ... @@ -209,23 +209,23 @@ class CheckboxSelectMultiple(ChoiceWidget): option_template_name: str = ... def use_required_attribute(self, initial: Any) -> bool: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... - def id_for_label(self, id_: str, index: Optional[str] = ...) -> str: ... + def id_for_label(self, id_: str, index: str | None = ...) -> str: ... class MultiWidget(Widget): template_name: str = ... widgets: Sequence[Widget] = ... def __init__( self, - widgets: Union[Dict[str, Union[Widget, Type[Widget]]], Sequence[Union[Widget, Type[Widget]]]], - attrs: Optional[_OptAttrs] = ..., + widgets: Dict[str, Widget | Type[Widget]] | Sequence[Widget | Type[Widget]], + attrs: _OptAttrs | None = ..., ) -> None: ... @property def is_hidden(self) -> bool: ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... def id_for_label(self, id_: str) -> str: ... def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> List[Any]: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... - def decompress(self, value: Any) -> Optional[Any]: ... + def decompress(self, value: Any) -> Any | None: ... media: _Getter[Media] = ... @property def needs_multipart_form(self) -> bool: ... # type: ignore @@ -236,23 +236,23 @@ class SplitDateTimeWidget(MultiWidget): widgets: Tuple[DateInput, TimeInput] def __init__( self, - attrs: Optional[_OptAttrs] = ..., - date_format: Optional[str] = ..., - time_format: Optional[str] = ..., - date_attrs: Optional[Dict[str, str]] = ..., - time_attrs: Optional[Dict[str, str]] = ..., + attrs: _OptAttrs | None = ..., + date_format: str | None = ..., + time_format: str | None = ..., + date_attrs: Dict[str, str] | None = ..., + time_attrs: Dict[str, str] | None = ..., ) -> None: ... - def decompress(self, value: Any) -> Tuple[Optional[datetime.date], Optional[datetime.time]]: ... + def decompress(self, value: Any) -> Tuple[datetime.date | None, datetime.time | None]: ... class SplitHiddenDateTimeWidget(SplitDateTimeWidget): template_name: str = ... def __init__( self, - attrs: Optional[_OptAttrs] = ..., - date_format: Optional[str] = ..., - time_format: Optional[str] = ..., - date_attrs: Optional[Dict[str, str]] = ..., - time_attrs: Optional[Dict[str, str]] = ..., + attrs: _OptAttrs | None = ..., + date_format: str | None = ..., + time_format: str | None = ..., + date_attrs: Dict[str, str] | None = ..., + time_attrs: Dict[str, str] | None = ..., ) -> None: ... class SelectDateWidget(Widget): @@ -264,20 +264,20 @@ class SelectDateWidget(Widget): input_type: str = ... select_widget: Type[ChoiceWidget] = ... date_re: Any = ... - years: Iterable[Union[int, str]] = ... + years: Iterable[int | str] = ... months: Mapping[int, str] = ... year_none_value: Tuple[Literal[""], str] = ... month_none_value: Tuple[Literal[""], str] = ... day_none_value: Tuple[Literal[""], str] = ... def __init__( self, - attrs: Optional[_OptAttrs] = ..., - years: Optional[Iterable[Union[int, str]]] = ..., - months: Optional[Mapping[int, str]] = ..., - empty_label: Optional[Union[str, _ListOrTuple[str]]] = ..., + attrs: _OptAttrs | None = ..., + years: Iterable[int | str] | None = ..., + months: Mapping[int, str] | None = ..., + empty_label: str | _ListOrTuple[str] | None = ..., ) -> None: ... - def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... - def format_value(self, value: Any) -> Dict[str, Union[str, int, None]]: ... # type: ignore + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... + def format_value(self, value: Any) -> Dict[str, str | int | None]: ... # type: ignore def id_for_label(self, id_: str) -> str: ... - def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Union[str, None, Any]: ... + def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> str | None | Any: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... diff --git a/django-stubs/http/multipartparser.pyi b/django-stubs/http/multipartparser.pyi index 28ddab7a2..87ac8a5f6 100644 --- a/django-stubs/http/multipartparser.pyi +++ b/django-stubs/http/multipartparser.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Dict, Iterator, List, Mapping, Optional, Tuple, Union +from typing import IO, Any, Dict, Iterator, List, Mapping, Tuple from django.http.request import QueryDict from django.utils.datastructures import ImmutableList, MultiValueDict @@ -16,19 +16,19 @@ class MultiPartParser: self, META: Mapping[str, Any], input_data: IO[bytes], - upload_handlers: Union[List[Any], ImmutableList[Any]], - encoding: Optional[str] = ..., + upload_handlers: List[Any] | ImmutableList[Any], + encoding: str | None = ..., ) -> None: ... def parse(self) -> Tuple[QueryDict, MultiValueDict]: ... def handle_file_complete(self, old_field_name: str, counters: List[int]) -> None: ... - def sanitize_file_name(self, file_name: str) -> Optional[str]: ... + def sanitize_file_name(self, file_name: str) -> str | None: ... class LazyStream: - length: Optional[int] = ... + length: int | None = ... position: int = ... - def __init__(self, producer: Union[BoundaryIter, ChunkIter], length: Optional[int] = ...) -> None: ... + def __init__(self, producer: BoundaryIter | ChunkIter, length: int | None = ...) -> None: ... def tell(self) -> int: ... - def read(self, size: Optional[int] = ...) -> bytes: ... + def read(self, size: int | None = ...) -> bytes: ... def __next__(self) -> bytes: ... def close(self) -> None: ... def __iter__(self) -> LazyStream: ... @@ -53,6 +53,6 @@ class BoundaryIter: class Parser: def __init__(self, stream: LazyStream, boundary: bytes) -> None: ... - def __iter__(self) -> Iterator[Tuple[str, Dict[str, Tuple[str, Dict[str, Union[bytes, str]]]], LazyStream]]: ... + def __iter__(self) -> Iterator[Tuple[str, Dict[str, Tuple[str, Dict[str, bytes | str]]], LazyStream]]: ... def parse_header(line: bytes) -> Tuple[str, Dict[str, bytes]]: ... diff --git a/django-stubs/http/request.pyi b/django-stubs/http/request.pyi index f4d849b4e..8126697f8 100644 --- a/django-stubs/http/request.pyi +++ b/django-stubs/http/request.pyi @@ -1,21 +1,5 @@ from io import BytesIO -from typing import ( - Any, - BinaryIO, - Dict, - Iterable, - List, - Mapping, - NoReturn, - Optional, - Pattern, - Set, - Tuple, - Type, - TypeVar, - Union, - overload, -) +from typing import Any, BinaryIO, Dict, Iterable, List, Mapping, NoReturn, Pattern, Set, Tuple, Type, TypeVar, overload from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import AnonymousUser @@ -32,14 +16,14 @@ host_validation_re: Pattern[str] = ... class UnreadablePostError(OSError): ... class RawPostDataException(Exception): ... -UploadHandlerList = Union[List[uploadhandler.FileUploadHandler], ImmutableList[uploadhandler.FileUploadHandler]] +UploadHandlerList = List[uploadhandler.FileUploadHandler] | ImmutableList[uploadhandler.FileUploadHandler] class HttpHeaders(CaseInsensitiveMapping[str]): HTTP_PREFIX: str = ... UNPREFIXED_HEADERS: Set[str] = ... def __init__(self, environ: Mapping[str, Any]) -> None: ... @classmethod - def parse_header_name(cls, header: str) -> Optional[str]: ... + def parse_header_name(cls, header: str) -> str | None: ... class HttpRequest(BytesIO): GET: _ImmutableQueryDict = ... @@ -49,16 +33,16 @@ class HttpRequest(BytesIO): FILES: MultiValueDict[str, uploadedfile.UploadedFile] = ... path: str = ... path_info: str = ... - method: Optional[str] = ... - resolver_match: Optional[ResolverMatch] = ... - content_type: Optional[str] = ... - content_params: Optional[Dict[str, str]] = ... + method: str | None = ... + resolver_match: ResolverMatch | None = ... + content_type: str | None = ... + content_params: Dict[str, str] | None = ... _stream: BinaryIO # Attributes added by optional parts of Django # django.contrib.admin views: current_app: str # django.contrib.auth.middleware.AuthenticationMiddleware: - user: Union[AbstractBaseUser, AnonymousUser] + user: AbstractBaseUser | AnonymousUser # django.middleware.locale.LocaleMiddleware: LANGUAGE_CODE: str # django.contrib.sites.middleware.CurrentSiteMiddleware @@ -79,16 +63,16 @@ class HttpRequest(BytesIO): def get_full_path(self, force_append_slash: bool = ...) -> str: ... def get_full_path_info(self, force_append_slash: bool = ...) -> str: ... def get_signed_cookie( - self, key: str, default: Any = ..., salt: str = ..., max_age: Optional[int] = ... - ) -> Optional[str]: ... + self, key: str, default: Any = ..., salt: str = ..., max_age: int | None = ... + ) -> str | None: ... def get_raw_uri(self) -> str: ... - def build_absolute_uri(self, location: Optional[str] = ...) -> str: ... + def build_absolute_uri(self, location: str | None = ...) -> str: ... @property - def scheme(self) -> Optional[str]: ... + def scheme(self) -> str | None: ... def is_secure(self) -> bool: ... def is_ajax(self) -> bool: ... @property - def encoding(self) -> Optional[str]: ... + def encoding(self) -> str | None: ... @encoding.setter def encoding(self, val: str) -> None: ... @property @@ -124,9 +108,9 @@ class QueryDict(MultiValueDict[str, str]): @overload def __init__( self: QueryDict, - query_string: Optional[Union[str, bytes]], + query_string: str | bytes | None, mutable: Literal[True], - encoding: Optional[str] = ..., + encoding: str | None = ..., ) -> None: ... # ([querystring='string',] mutable=True, [...]) @overload @@ -134,65 +118,65 @@ class QueryDict(MultiValueDict[str, str]): self: QueryDict, *, mutable: Literal[True], - query_string: Optional[Union[str, bytes]] = ..., - encoding: Optional[str] = ..., + query_string: str | bytes | None = ..., + encoding: str | None = ..., ) -> None: ... # Otherwise it's immutable @overload def __init__( # type: ignore[misc] self: _ImmutableQueryDict, - query_string: Optional[Union[str, bytes]] = ..., + query_string: str | bytes | None = ..., mutable: bool = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., ) -> None: ... @classmethod def fromkeys( # type: ignore cls: Type[_Q], - iterable: Iterable[Union[bytes, str]], - value: Union[str, bytes] = ..., + iterable: Iterable[bytes | str], + value: str | bytes = ..., mutable: bool = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., ) -> _Q: ... @property def encoding(self) -> str: ... @encoding.setter def encoding(self, value: str) -> None: ... - def __setitem__(self, key: Union[str, bytes], value: Union[str, bytes]) -> None: ... - def __delitem__(self, key: Union[str, bytes]) -> None: ... - def setlist(self, key: Union[str, bytes], list_: Iterable[Union[str, bytes]]) -> None: ... - def setlistdefault(self, key: Union[str, bytes], default_list: Optional[List[str]] = ...) -> List[str]: ... - def appendlist(self, key: Union[str, bytes], value: Union[str, bytes]) -> None: ... + def __setitem__(self, key: str | bytes, value: str | bytes) -> None: ... + def __delitem__(self, key: str | bytes) -> None: ... + def setlist(self, key: str | bytes, list_: Iterable[str | bytes]) -> None: ... + def setlistdefault(self, key: str | bytes, default_list: List[str] | None = ...) -> List[str]: ... + def appendlist(self, key: str | bytes, value: str | bytes) -> None: ... # Fake signature (because *args is used in source, but it fails with more that 1 argument) @overload - def pop(self, __key: Union[str, bytes]) -> str: ... + def pop(self, __key: str | bytes) -> str: ... @overload - def pop(self, __key: Union[str, bytes], __default: Union[str, _Z] = ...) -> Union[str, _Z]: ... + def pop(self, __key: str | bytes, __default: str | _Z = ...) -> str | _Z: ... def popitem(self) -> Tuple[str, str]: ... def clear(self) -> None: ... - def setdefault(self, key: Union[str, bytes], default: Union[str, bytes, None] = ...) -> str: ... + def setdefault(self, key: str | bytes, default: str | bytes | None = ...) -> str: ... def copy(self) -> QueryDict: ... - def urlencode(self, safe: Optional[str] = ...) -> str: ... + def urlencode(self, safe: str | None = ...) -> str: ... class _ImmutableQueryDict(QueryDict): _mutable: Literal[False] # def __init__( # self, query_string: Optional[Union[str, bytes]] = ..., mutable: bool = ..., encoding: Optional[str] = ... # ) -> None: ... - def __setitem__(self, key: Union[str, bytes], value: Union[str, bytes]) -> NoReturn: ... - def __delitem__(self, key: Union[str, bytes]) -> NoReturn: ... - def setlist(self, key: Union[str, bytes], list_: Iterable[Union[str, bytes]]) -> NoReturn: ... - def setlistdefault(self, key: Union[str, bytes], default_list: Optional[List[str]] = ...) -> NoReturn: ... - def appendlist(self, key: Union[str, bytes], value: Union[str, bytes]) -> NoReturn: ... + def __setitem__(self, key: str | bytes, value: str | bytes) -> NoReturn: ... + def __delitem__(self, key: str | bytes) -> NoReturn: ... + def setlist(self, key: str | bytes, list_: Iterable[str | bytes]) -> NoReturn: ... + def setlistdefault(self, key: str | bytes, default_list: List[str] | None = ...) -> NoReturn: ... + def appendlist(self, key: str | bytes, value: str | bytes) -> NoReturn: ... # Fake signature (because *args is used in source, but it fails with more that 1 argument) @overload - def pop(self, __key: Union[str, bytes]) -> NoReturn: ... + def pop(self, __key: str | bytes) -> NoReturn: ... @overload - def pop(self, __key: Union[str, bytes], __default: Union[str, _Z] = ...) -> NoReturn: ... + def pop(self, __key: str | bytes, __default: str | _Z = ...) -> NoReturn: ... def popitem(self) -> NoReturn: ... def clear(self) -> NoReturn: ... - def setdefault(self, key: Union[str, bytes], default: Union[str, bytes, None] = ...) -> NoReturn: ... + def setdefault(self, key: str | bytes, default: str | bytes | None = ...) -> NoReturn: ... def copy(self) -> QueryDict: ... # type: ignore[override] - def urlencode(self, safe: Optional[str] = ...) -> str: ... + def urlencode(self, safe: str | None = ...) -> str: ... # Fakes for convenience (for `request.GET` and `request.POST`). If dict # was created by Django, there is no chance to hit `List[object]` (empty list) # edge case. @@ -211,6 +195,6 @@ class MediaType: @overload def bytes_to_text(s: None, encoding: str) -> None: ... @overload -def bytes_to_text(s: Union[bytes, str], encoding: str) -> str: ... +def bytes_to_text(s: bytes | str, encoding: str) -> str: ... def split_domain_port(host: str) -> Tuple[str, str]: ... def validate_host(host: str, allowed_hosts: Iterable[str]) -> bool: ... diff --git a/django-stubs/http/response.pyi b/django-stubs/http/response.pyi index 449c989eb..f7c604360 100644 --- a/django-stubs/http/response.pyi +++ b/django-stubs/http/response.pyi @@ -1,7 +1,7 @@ import datetime from io import BytesIO from json import JSONEncoder -from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Type, TypeVar, Union, overload, type_check_only +from typing import Any, Dict, Iterable, Iterator, List, Tuple, Type, TypeVar, overload, type_check_only from django.http.cookie import SimpleCookie from django.utils.datastructures import CaseInsensitiveMapping, _PropertyDescriptor @@ -13,11 +13,11 @@ _Z = TypeVar("_Z") class ResponseHeaders(CaseInsensitiveMapping[str]): def __init__(self, data: Dict[str, str]) -> None: ... - def _convert_to_charset(self, value: Union[bytes, str, int], charset: str, mime_encode: bool = ...) -> str: ... + def _convert_to_charset(self, value: bytes | str | int, charset: str, mime_encode: bool = ...) -> str: ... def __delitem__(self, key: str) -> None: ... - def __setitem__(self, key: str, value: Union[str, bytes, int]) -> None: ... - def pop(self, key: str, default: _Z = ...) -> Union[_Z, Tuple[str, str]]: ... - def setdefault(self, key: str, value: Union[str, bytes, int]) -> None: ... + def __setitem__(self, key: str, value: str | bytes | int) -> None: ... + def pop(self, key: str, default: _Z = ...) -> _Z | Tuple[str, str]: ... + def setdefault(self, key: str, value: str | bytes | int) -> None: ... class HttpResponseBase: status_code: int = ... @@ -27,11 +27,11 @@ class HttpResponseBase: headers: ResponseHeaders = ... def __init__( self, - content_type: Optional[str] = ..., - status: Optional[int] = ..., - reason: Optional[str] = ..., - charset: Optional[str] = ..., - headers: Optional[Dict[str, str]] = ..., + content_type: str | None = ..., + status: int | None = ..., + reason: str | None = ..., + charset: str | None = ..., + headers: Dict[str, str] | None = ..., ) -> None: ... @property def reason_phrase(self) -> str: ... @@ -43,7 +43,7 @@ class HttpResponseBase: def charset(self, value: str) -> None: ... def serialize_headers(self) -> bytes: ... __bytes__ = serialize_headers - def __setitem__(self, header: str, value: Union[str, bytes, int]) -> None: ... + def __setitem__(self, header: str, value: str | bytes | int) -> None: ... def __delitem__(self, header: str) -> None: ... def __getitem__(self, header: str) -> str: ... def has_header(self, header: str) -> bool: ... @@ -52,18 +52,18 @@ class HttpResponseBase: @overload def get(self, header: str, alternate: str) -> str: ... @overload - def get(self, header: str, alternate: None = ...) -> Optional[str]: ... + def get(self, header: str, alternate: None = ...) -> str | None: ... def set_cookie( self, key: str, value: str = ..., - max_age: Optional[int] = ..., - expires: Optional[Union[str, datetime.datetime]] = ..., + max_age: int | None = ..., + expires: str | datetime.datetime | None = ..., path: str = ..., - domain: Optional[str] = ..., + domain: str | None = ..., secure: bool = ..., httponly: bool = ..., - samesite: Optional[Literal["Lax", "Strict", "None", False]] = ..., + samesite: Literal["Lax", "Strict", "None", False] | None = ..., ) -> None: ... def setdefault(self, key: str, value: str) -> None: ... def set_signed_cookie(self, key: str, value: str, salt: str = ..., **kwargs: Any) -> None: ... @@ -71,12 +71,12 @@ class HttpResponseBase: self, key: str, path: str = ..., - domain: Optional[str] = ..., - samesite: Optional[Literal["Lax", "Strict", "None", False]] = ..., + domain: str | None = ..., + samesite: Literal["Lax", "Strict", "None", False] | None = ..., ) -> None: ... def make_bytes(self, value: object) -> bytes: ... def close(self) -> None: ... - def write(self, content: Union[str, bytes]) -> None: ... + def write(self, content: str | bytes) -> None: ... def flush(self) -> None: ... def tell(self) -> int: ... def readable(self) -> bool: ... @@ -110,7 +110,7 @@ class StreamingHttpResponse(HttpResponseBase, Iterable[bytes]): def getvalue(self) -> bytes: ... class FileResponse(StreamingHttpResponse): - file_to_stream: Optional[BytesIO] + file_to_stream: BytesIO | None block_size: int = ... as_attachment: bool = ... filename: str = ... @@ -146,6 +146,6 @@ class JsonResponse(HttpResponse): data: Any, encoder: Type[JSONEncoder] = ..., safe: bool = ..., - json_dumps_params: Optional[Dict[str, Any]] = ..., + json_dumps_params: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... diff --git a/django-stubs/middleware/cache.pyi b/django-stubs/middleware/cache.pyi index 7923a936e..da13dc32f 100644 --- a/django-stubs/middleware/cache.pyi +++ b/django-stubs/middleware/cache.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Optional, Union +from typing import Any, Callable from django.core.cache import BaseCache from django.http.request import HttpRequest @@ -10,15 +10,13 @@ class UpdateCacheMiddleware(MiddlewareMixin): key_prefix: str = ... cache_alias: str = ... cache: BaseCache = ... - def process_response( - self, request: HttpRequest, response: Union[HttpResponseBase, str] - ) -> Union[HttpResponseBase, str]: ... + def process_response(self, request: HttpRequest, response: HttpResponseBase | str) -> HttpResponseBase | str: ... class FetchFromCacheMiddleware(MiddlewareMixin): key_prefix: str = ... cache_alias: str = ... cache: BaseCache = ... - def process_request(self, request: HttpRequest) -> Optional[HttpResponse]: ... + def process_request(self, request: HttpRequest) -> HttpResponse | None: ... class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware): key_prefix: str = ... @@ -28,7 +26,7 @@ class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware): def __init__( self, get_response: Callable = ..., - cache_timeout: Optional[float] = ..., - page_timeout: Optional[float] = ..., + cache_timeout: float | None = ..., + page_timeout: float | None = ..., **kwargs: Any ) -> None: ... diff --git a/django-stubs/middleware/common.pyi b/django-stubs/middleware/common.pyi index a5aa8f915..2fe18ff99 100644 --- a/django-stubs/middleware/common.pyi +++ b/django-stubs/middleware/common.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.http.request import HttpRequest from django.http.response import HttpResponseBase, HttpResponsePermanentRedirect @@ -6,7 +6,7 @@ from django.utils.deprecation import MiddlewareMixin class CommonMiddleware(MiddlewareMixin): response_redirect_class: Any = ... - def process_request(self, request: HttpRequest) -> Optional[HttpResponsePermanentRedirect]: ... + def process_request(self, request: HttpRequest) -> HttpResponsePermanentRedirect | None: ... def should_redirect_with_slash(self, request: HttpRequest) -> bool: ... def get_full_path_with_slash(self, request: HttpRequest) -> str: ... def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ... diff --git a/django-stubs/middleware/csrf.pyi b/django-stubs/middleware/csrf.pyi index c8affb23a..0f354518a 100644 --- a/django-stubs/middleware/csrf.pyi +++ b/django-stubs/middleware/csrf.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing import Any, Callable, Dict, Optional, Tuple +from typing import Any, Callable, Dict, Tuple from django.http.request import HttpRequest from django.http.response import HttpResponseBase, HttpResponseForbidden @@ -23,8 +23,8 @@ def rotate_token(request: HttpRequest) -> None: ... class CsrfViewMiddleware(MiddlewareMixin): def process_request(self, request: HttpRequest) -> None: ... def process_view( - self, request: HttpRequest, callback: Optional[Callable], callback_args: Tuple, callback_kwargs: Dict[str, Any] - ) -> Optional[HttpResponseForbidden]: ... + self, request: HttpRequest, callback: Callable | None, callback_args: Tuple, callback_kwargs: Dict[str, Any] + ) -> HttpResponseForbidden | None: ... def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ... def _get_new_csrf_string() -> str: ... diff --git a/django-stubs/middleware/security.pyi b/django-stubs/middleware/security.pyi index 1a449335b..800a25452 100644 --- a/django-stubs/middleware/security.pyi +++ b/django-stubs/middleware/security.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponsePermanentRedirect @@ -11,7 +11,7 @@ class SecurityMiddleware(MiddlewareMixin): content_type_nosniff: bool = ... xss_filter: bool = ... redirect: bool = ... - redirect_host: Optional[str] = ... + redirect_host: str | None = ... redirect_exempt: List[Any] = ... - def process_request(self, request: HttpRequest) -> Optional[HttpResponsePermanentRedirect]: ... + def process_request(self, request: HttpRequest) -> HttpResponsePermanentRedirect | None: ... def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ... diff --git a/django-stubs/shortcuts.pyi b/django-stubs/shortcuts.pyi index ad3f2c7d2..57e5a6117 100644 --- a/django-stubs/shortcuts.pyi +++ b/django-stubs/shortcuts.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Mapping, Optional, Protocol, Sequence, Type, TypeVar, Union, overload +from typing import Any, Callable, List, Mapping, Protocol, Sequence, Type, TypeVar, overload from django.db.models import Manager, QuerySet from django.db.models.base import Model @@ -10,11 +10,11 @@ from typing_extensions import Literal def render( request: HttpRequest, - template_name: Union[str, Sequence[str]], - context: Optional[Mapping[str, Any]] = ..., - content_type: Optional[str] = ..., - status: Optional[int] = ..., - using: Optional[str] = ..., + template_name: str | Sequence[str], + context: Mapping[str, Any] | None = ..., + content_type: str | None = ..., + status: int | None = ..., + using: str | None = ..., ) -> HttpResponse: ... class SupportsGetAbsoluteUrl(Protocol): @@ -22,19 +22,19 @@ class SupportsGetAbsoluteUrl(Protocol): @overload def redirect( - to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: Literal[True], **kwargs: Any + to: Callable | str | SupportsGetAbsoluteUrl, *args: Any, permanent: Literal[True], **kwargs: Any ) -> HttpResponsePermanentRedirect: ... @overload def redirect( - to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: Literal[False] = ..., **kwargs: Any + to: Callable | str | SupportsGetAbsoluteUrl, *args: Any, permanent: Literal[False] = ..., **kwargs: Any ) -> HttpResponseRedirect: ... @overload def redirect( - to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: bool, **kwargs: Any -) -> Union[HttpResponseRedirect, HttpResponsePermanentRedirect]: ... + to: Callable | str | SupportsGetAbsoluteUrl, *args: Any, permanent: bool, **kwargs: Any +) -> HttpResponseRedirect | HttpResponsePermanentRedirect: ... _T = TypeVar("_T", bound=Model) -def get_object_or_404(klass: Union[Type[_T], Manager[_T], QuerySet[_T]], *args: Any, **kwargs: Any) -> _T: ... -def get_list_or_404(klass: Union[Type[_T], Manager[_T], QuerySet[_T]], *args: Any, **kwargs: Any) -> List[_T]: ... -def resolve_url(to: Union[Callable, Model, str], *args: Any, **kwargs: Any) -> str: ... +def get_object_or_404(klass: Type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> _T: ... +def get_list_or_404(klass: Type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> List[_T]: ... +def resolve_url(to: Callable | Model | str, *args: Any, **kwargs: Any) -> str: ... diff --git a/django-stubs/template/backends/base.pyi b/django-stubs/template/backends/base.pyi index b09ad995f..7baa26b09 100644 --- a/django-stubs/template/backends/base.pyi +++ b/django-stubs/template/backends/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterator, List, Mapping, Optional, Protocol, Tuple, Union +from typing import Any, Dict, Iterator, List, Mapping, Protocol, Tuple from django.http.request import HttpRequest from django.template import TemplateDoesNotExist @@ -11,7 +11,7 @@ class BaseEngine: app_dirs: bool = ... def __init__(self, params: Mapping[str, Any]) -> None: ... @property - def app_dirname(self) -> Optional[str]: ... + def app_dirname(self) -> str | None: ... def from_string(self, template_code: str) -> _EngineTemplate: ... def get_template(self, template_name: str) -> _EngineTemplate: ... @property @@ -21,6 +21,6 @@ class BaseEngine: class _EngineTemplate(Protocol): def render( self, - context: Optional[Union[Context, Dict[str, Any]]] = ..., - request: Optional[HttpRequest] = ..., + context: Context | Dict[str, Any] | None = ..., + request: HttpRequest | None = ..., ) -> SafeString: ... diff --git a/django-stubs/template/backends/django.pyi b/django-stubs/template/backends/django.pyi index 553b13d31..ea8e430fc 100644 --- a/django-stubs/template/backends/django.pyi +++ b/django-stubs/template/backends/django.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterator, NoReturn, Optional +from typing import Any, Dict, Iterator, NoReturn from django.template.engine import Engine from django.template.exceptions import TemplateDoesNotExist @@ -10,7 +10,7 @@ class DjangoTemplates(BaseEngine): def __init__(self, params: Dict[str, Any]) -> None: ... def get_templatetag_libraries(self, custom_libraries: Dict[str, str]) -> Dict[str, str]: ... -def copy_exception(exc: TemplateDoesNotExist, backend: Optional[DjangoTemplates] = ...) -> TemplateDoesNotExist: ... +def copy_exception(exc: TemplateDoesNotExist, backend: DjangoTemplates | None = ...) -> TemplateDoesNotExist: ... def reraise(exc: TemplateDoesNotExist, backend: DjangoTemplates) -> NoReturn: ... def get_installed_libraries() -> Dict[str, str]: ... def get_package_libraries(pkg: Any) -> Iterator[str]: ... diff --git a/django-stubs/template/backends/dummy.pyi b/django-stubs/template/backends/dummy.pyi index 6a8a759da..5eb6283e6 100644 --- a/django-stubs/template/backends/dummy.pyi +++ b/django-stubs/template/backends/dummy.pyi @@ -1,5 +1,5 @@ import string -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import Any, Dict, List, Tuple from django.http.request import HttpRequest @@ -7,8 +7,8 @@ from .base import BaseEngine class TemplateStrings(BaseEngine): template_dirs: Tuple[str] - def __init__(self, params: Dict[str, Union[Dict[Any, Any], List[Any], bool, str]]) -> None: ... + def __init__(self, params: Dict[str, Dict[Any, Any] | List[Any] | bool | str]) -> None: ... class Template(string.Template): template: str - def render(self, context: Optional[Dict[str, str]] = ..., request: Optional[HttpRequest] = ...) -> str: ... + def render(self, context: Dict[str, str] | None = ..., request: HttpRequest | None = ...) -> str: ... diff --git a/django-stubs/template/backends/jinja2.pyi b/django-stubs/template/backends/jinja2.pyi index 32b52a27a..7578a6c1b 100644 --- a/django-stubs/template/backends/jinja2.pyi +++ b/django-stubs/template/backends/jinja2.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, Optional +from typing import Any, Callable, Dict, List from django.template.exceptions import TemplateSyntaxError @@ -13,7 +13,7 @@ class Jinja2(BaseEngine): class Origin: name: str = ... - template_name: Optional[str] = ... - def __init__(self, name: str, template_name: Optional[str]) -> None: ... + template_name: str | None = ... + def __init__(self, name: str, template_name: str | None) -> None: ... def get_exception_info(exception: TemplateSyntaxError) -> Dict[str, Any]: ... diff --git a/django-stubs/template/base.pyi b/django-stubs/template/base.pyi index f70a1d0b8..9e975c711 100644 --- a/django-stubs/template/base.pyi +++ b/django-stubs/template/base.pyi @@ -1,20 +1,6 @@ from enum import Enum from logging import Logger -from typing import ( - Any, - Callable, - Dict, - Iterable, - Iterator, - List, - Mapping, - Optional, - Pattern, - Sequence, - Tuple, - Type, - Union, -) +from typing import Any, Callable, Dict, Iterable, Iterator, List, Mapping, Pattern, Sequence, Tuple, Type from django.template.context import Context as Context from django.template.engine import Engine @@ -46,34 +32,32 @@ class TokenType(Enum): class VariableDoesNotExist(Exception): msg: str = ... - params: Tuple[Union[Dict[str, str], str]] = ... - def __init__(self, msg: str, params: Tuple[Union[Dict[str, str], str]] = ...) -> None: ... + params: Tuple[Dict[str, str] | str] = ... + def __init__(self, msg: str, params: Tuple[Dict[str, str] | str] = ...) -> None: ... class Origin: name: str = ... - template_name: Optional[Union[bytes, str]] = ... - loader: Optional[Loader] = ... - def __init__( - self, name: str, template_name: Optional[Union[bytes, str]] = ..., loader: Optional[Loader] = ... - ) -> None: ... + template_name: bytes | str | None = ... + loader: Loader | None = ... + def __init__(self, name: str, template_name: bytes | str | None = ..., loader: Loader | None = ...) -> None: ... @property - def loader_name(self) -> Optional[str]: ... + def loader_name(self) -> str | None: ... class Template: - name: Optional[str] = ... + name: str | None = ... origin: Origin = ... engine: Engine = ... source: str = ... nodelist: NodeList = ... def __init__( self, - template_string: Union[Template, str], - origin: Optional[Origin] = ..., - name: Optional[str] = ..., - engine: Optional[Engine] = ..., + template_string: Template | str, + origin: Origin | None = ..., + name: str | None = ..., + engine: Engine | None = ..., ) -> None: ... def __iter__(self) -> Iterator[Node]: ... - def render(self, context: Optional[Union[Context, Dict[str, Any]]]) -> SafeString: ... + def render(self, context: Context | Dict[str, Any] | None) -> SafeString: ... def compile_nodelist(self) -> NodeList: ... def get_exception_info(self, exception: Exception, token: Token) -> Dict[str, Any]: ... @@ -82,50 +66,48 @@ def linebreak_iter(template_source: str) -> Iterator[int]: ... class Token: contents: str token_type: TokenType - lineno: Optional[int] = ... - position: Optional[Tuple[int, int]] = ... + lineno: int | None = ... + position: Tuple[int, int] | None = ... def __init__( self, token_type: TokenType, contents: str, - position: Optional[Tuple[int, int]] = ..., - lineno: Optional[int] = ..., + position: Tuple[int, int] | None = ..., + lineno: int | None = ..., ) -> None: ... def split_contents(self) -> List[str]: ... class Lexer: template_string: str = ... - verbatim: Union[bool, str] = ... + verbatim: bool | str = ... def __init__(self, template_string: str) -> None: ... def tokenize(self) -> List[Token]: ... - def create_token( - self, token_string: str, position: Optional[Tuple[int, int]], lineno: int, in_tag: bool - ) -> Token: ... + def create_token(self, token_string: str, position: Tuple[int, int] | None, lineno: int, in_tag: bool) -> Token: ... class DebugLexer(Lexer): template_string: str - verbatim: Union[bool, str] + verbatim: bool | str def tokenize(self) -> List[Token]: ... class Parser: - tokens: Union[List[Token], str] = ... + tokens: List[Token] | str = ... tags: Dict[str, Callable] = ... filters: Dict[str, Callable] = ... command_stack: List[Tuple[str, Token]] = ... libraries: Dict[str, Library] = ... - origin: Optional[Origin] = ... + origin: Origin | None = ... def __init__( self, - tokens: Union[List[Token], str], - libraries: Optional[Dict[str, Library]] = ..., - builtins: Optional[List[Library]] = ..., - origin: Optional[Origin] = ..., + tokens: List[Token] | str, + libraries: Dict[str, Library] | None = ..., + builtins: List[Library] | None = ..., + origin: Origin | None = ..., ) -> None: ... - def parse(self, parse_until: Optional[Iterable[str]] = ...) -> NodeList: ... + def parse(self, parse_until: Iterable[str] | None = ...) -> NodeList: ... def skip_past(self, endtag: str) -> None: ... def extend_nodelist(self, nodelist: NodeList, node: Node, token: Token) -> None: ... - def error(self, token: Token, e: Union[Exception, str]) -> Exception: ... - def invalid_block_tag(self, token: Token, command: str, parse_until: Optional[Iterable[str]] = ...) -> Any: ... + def error(self, token: Token, e: Exception | str) -> Exception: ... + def invalid_block_tag(self, token: Token, command: str, parse_until: Iterable[str] | None = ...) -> Any: ... def unclosed_block_tag(self, parse_until: Iterable[str]) -> Any: ... def next_token(self) -> Token: ... def prepend_token(self, token: Token) -> None: ... @@ -148,21 +130,21 @@ class FilterExpression: def args_check(name: str, func: Callable, provided: List[Tuple[bool, Any]]) -> bool: ... class Variable: - var: Union[Dict[Any, Any], str] = ... - literal: Optional[Union[SafeString, float]] = ... - lookups: Optional[Tuple[str]] = ... + var: Dict[Any, Any] | str = ... + literal: SafeString | float | None = ... + lookups: Tuple[str] | None = ... translate: bool = ... - message_context: Optional[str] = ... - def __init__(self, var: Union[Dict[Any, Any], str]) -> None: ... - def resolve(self, context: Union[Mapping[str, Mapping[str, Any]], Context, int, str]) -> Any: ... + message_context: str | None = ... + def __init__(self, var: Dict[Any, Any] | str) -> None: ... + def resolve(self, context: Mapping[str, Mapping[str, Any]] | Context | int | str) -> Any: ... class Node: must_be_first: bool = ... child_nodelists: Any = ... origin: Origin - token: Optional[Token] = ... + token: Token | None = ... def render(self, context: Context) -> str: ... - def render_annotated(self, context: Context) -> Union[int, str]: ... + def render_annotated(self, context: Context) -> int | str: ... def __iter__(self) -> Iterator[Node]: ... def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ... diff --git a/django-stubs/template/context.pyi b/django-stubs/template/context.pyi index 9dc1e04bc..7e1e5f2b4 100644 --- a/django-stubs/template/context.pyi +++ b/django-stubs/template/context.pyi @@ -1,14 +1,14 @@ from contextlib import contextmanager from types import TracebackType -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Type, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, Iterator, List, Type, TypeVar from django.http.request import HttpRequest from django.template.base import Node, Origin, Template from django.template.defaulttags import IfChangedNode from django.template.loader_tags import IncludeNode -_ContextKeys = Union[int, str, Node] -_ContextValues = Union[Dict[str, Any], "Context"] +_ContextKeys = int | str | Node +_ContextValues = Dict[str, Any] | "Context" _ContextCopy = TypeVar("_ContextCopy", bound="BaseContext") class ContextPopException(Exception): ... @@ -19,9 +19,9 @@ class ContextDict(dict): def __enter__(self) -> ContextDict: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... class BaseContext(Iterable[Any]): @@ -31,35 +31,33 @@ class BaseContext(Iterable[Any]): def push(self, *args: Any, **kwargs: Any) -> ContextDict: ... def pop(self) -> ContextDict: ... def __setitem__(self, key: _ContextKeys, value: Any) -> None: ... - def set_upward(self, key: _ContextKeys, value: Union[int, str]) -> None: ... + def set_upward(self, key: _ContextKeys, value: int | str) -> None: ... def __getitem__(self, key: _ContextKeys) -> Any: ... def __delitem__(self, key: _ContextKeys) -> None: ... def __contains__(self, key: _ContextKeys) -> bool: ... - def get(self, key: _ContextKeys, otherwise: Optional[Any] = ...) -> Optional[Any]: ... - def setdefault( - self, key: _ContextKeys, default: Optional[Union[List[Origin], int]] = ... - ) -> Optional[Union[List[Origin], int]]: ... - def new(self, values: Optional[_ContextValues] = ...) -> Context: ... - def flatten(self) -> Dict[_ContextKeys, Optional[Union[Dict[_ContextKeys, Union[Type[Any], str]], int, str]]]: ... + def get(self, key: _ContextKeys, otherwise: Any | None = ...) -> Any | None: ... + def setdefault(self, key: _ContextKeys, default: List[Origin] | int | None = ...) -> List[Origin] | int | None: ... + def new(self, values: _ContextValues | None = ...) -> Context: ... + def flatten(self) -> Dict[_ContextKeys, Dict[_ContextKeys, Type[Any] | str] | int | str | None]: ... class Context(BaseContext): dicts: Any autoescape: bool = ... - use_l10n: Optional[bool] = ... - use_tz: Optional[bool] = ... - template_name: Optional[str] = ... + use_l10n: bool | None = ... + use_tz: bool | None = ... + template_name: str | None = ... render_context: RenderContext = ... - template: Optional[Template] = ... + template: Template | None = ... def __init__( - self, dict_: Any = ..., autoescape: bool = ..., use_l10n: Optional[bool] = ..., use_tz: Optional[bool] = ... + self, dict_: Any = ..., autoescape: bool = ..., use_l10n: bool | None = ..., use_tz: bool | None = ... ) -> None: ... @contextmanager def bind_template(self, template: Template) -> Iterator[None]: ... - def update(self, other_dict: Union[Dict[str, Any], Context]) -> ContextDict: ... + def update(self, other_dict: Dict[str, Any] | Context) -> ContextDict: ... class RenderContext(BaseContext): - dicts: List[Dict[Union[IncludeNode, str], str]] - template: Optional[Template] = ... + dicts: List[Dict[IncludeNode | str, str]] + template: Template | None = ... @contextmanager def push_state(self, template: Template, isolated_context: bool = ...) -> Iterator[None]: ... @@ -67,22 +65,22 @@ class RequestContext(Context): autoescape: bool dicts: List[Dict[str, str]] render_context: RenderContext - template_name: Optional[str] - use_l10n: Optional[bool] - use_tz: Optional[bool] + template_name: str | None + use_l10n: bool | None + use_tz: bool | None request: HttpRequest = ... def __init__( self, request: HttpRequest, - dict_: Optional[Dict[str, Any]] = ..., - processors: Optional[List[Callable]] = ..., - use_l10n: Optional[bool] = ..., - use_tz: Optional[bool] = ..., + dict_: Dict[str, Any] | None = ..., + processors: List[Callable] | None = ..., + use_l10n: bool | None = ..., + use_tz: bool | None = ..., autoescape: bool = ..., ) -> None: ... - template: Optional[Template] = ... + template: Template | None = ... @contextmanager def bind_template(self, template: Template) -> Iterator[None]: ... - def new(self, values: Optional[_ContextValues] = ...) -> RequestContext: ... + def new(self, values: _ContextValues | None = ...) -> RequestContext: ... -def make_context(context: Any, request: Optional[HttpRequest] = ..., **kwargs: Any) -> Context: ... +def make_context(context: Any, request: HttpRequest | None = ..., **kwargs: Any) -> Context: ... diff --git a/django-stubs/template/context_processors.pyi b/django-stubs/template/context_processors.pyi index fec32e3b5..4460cba6c 100644 --- a/django-stubs/template/context_processors.pyi +++ b/django-stubs/template/context_processors.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Dict, List, Tuple, TypeVar, Union +from typing import Callable, Dict, List, Tuple, TypeVar from django.http.request import HttpRequest from django.utils.functional import SimpleLazyObject @@ -6,8 +6,8 @@ from django.utils.functional import SimpleLazyObject _R = TypeVar("_R", bound=HttpRequest) def csrf(request: HttpRequest) -> Dict[str, SimpleLazyObject]: ... -def debug(request: HttpRequest) -> Dict[str, Union[Callable, bool]]: ... -def i18n(request: HttpRequest) -> Dict[str, Union[List[Tuple[str, str]], bool, str]]: ... +def debug(request: HttpRequest) -> Dict[str, Callable | bool]: ... +def i18n(request: HttpRequest) -> Dict[str, List[Tuple[str, str]] | bool | str]: ... def tz(request: HttpRequest) -> Dict[str, str]: ... def static(request: HttpRequest) -> Dict[str, str]: ... def media(request: HttpRequest) -> Dict[str, str]: ... diff --git a/django-stubs/template/defaultfilters.pyi b/django-stubs/template/defaultfilters.pyi index a64b67563..d973a5448 100644 --- a/django-stubs/template/defaultfilters.pyi +++ b/django-stubs/template/defaultfilters.pyi @@ -1,7 +1,7 @@ from datetime import date as _date from datetime import datetime from datetime import time as _time -from typing import Any, Callable, Dict, List, Optional, Union +from typing import Any, Callable, Dict, List from django.utils.html import escape as escape # noqa: F401 from django.utils.safestring import SafeString @@ -13,7 +13,7 @@ def addslashes(value: str) -> str: ... def capfirst(value: str) -> str: ... def escapejs_filter(value: str) -> SafeString: ... def json_script(value: Dict[str, str], element_id: SafeString) -> SafeString: ... -def floatformat(text: Optional[Any], arg: Union[int, str] = ...) -> str: ... +def floatformat(text: Any | None, arg: int | str = ...) -> str: ... def iriencode(value: str) -> str: ... def linenumbers(value: str, autoescape: bool = ...) -> SafeString: ... def lower(value: str) -> str: ... @@ -21,19 +21,19 @@ def make_list(value: str) -> List[str]: ... def slugify(value: str) -> SafeString: ... def stringformat(value: Any, arg: str) -> str: ... def title(value: str) -> str: ... -def truncatechars(value: str, arg: Union[SafeString, int]) -> str: ... -def truncatechars_html(value: str, arg: Union[int, str]) -> str: ... -def truncatewords(value: str, arg: Union[int, str]) -> str: ... -def truncatewords_html(value: str, arg: Union[int, str]) -> str: ... +def truncatechars(value: str, arg: SafeString | int) -> str: ... +def truncatechars_html(value: str, arg: int | str) -> str: ... +def truncatewords(value: str, arg: int | str) -> str: ... +def truncatewords_html(value: str, arg: int | str) -> str: ... def upper(value: str) -> str: ... -def urlencode(value: str, safe: Optional[SafeString] = ...) -> str: ... +def urlencode(value: str, safe: SafeString | None = ...) -> str: ... def urlize(value: str, autoescape: bool = ...) -> SafeString: ... -def urlizetrunc(value: str, limit: Union[SafeString, int], autoescape: bool = ...) -> SafeString: ... +def urlizetrunc(value: str, limit: SafeString | int, autoescape: bool = ...) -> SafeString: ... def wordcount(value: str) -> int: ... -def wordwrap(value: str, arg: Union[SafeString, int]) -> str: ... -def ljust(value: str, arg: Union[SafeString, int]) -> str: ... -def rjust(value: str, arg: Union[SafeString, int]) -> str: ... -def center(value: str, arg: Union[SafeString, int]) -> str: ... +def wordwrap(value: str, arg: SafeString | int) -> str: ... +def ljust(value: str, arg: SafeString | int) -> str: ... +def rjust(value: str, arg: SafeString | int) -> str: ... +def center(value: str, arg: SafeString | int) -> str: ... def cut(value: str, arg: str) -> str: ... def escape_filter(value: str) -> SafeString: ... def force_escape(value: str) -> SafeString: ... @@ -42,27 +42,27 @@ def linebreaksbr(value: str, autoescape: bool = ...) -> SafeString: ... def safe(value: str) -> SafeString: ... def safeseq(value: List[str]) -> List[SafeString]: ... def striptags(value: str) -> str: ... -def dictsort(value: Any, arg: Union[int, str]) -> Any: ... -def dictsortreversed(value: Any, arg: Union[int, str]) -> Any: ... +def dictsort(value: Any, arg: int | str) -> Any: ... +def dictsortreversed(value: Any, arg: int | str) -> Any: ... def first(value: Any) -> Any: ... def join(value: Any, arg: str, autoescape: bool = ...) -> Any: ... def last(value: List[str]) -> str: ... def length(value: Any) -> int: ... -def length_is(value: Optional[Any], arg: Union[SafeString, int]) -> Union[bool, str]: ... +def length_is(value: Any | None, arg: SafeString | int) -> bool | str: ... def random(value: List[str]) -> str: ... -def slice_filter(value: Any, arg: Union[str, int]) -> Any: ... +def slice_filter(value: Any, arg: str | int) -> Any: ... def unordered_list(value: Any, autoescape: bool = ...) -> Any: ... def add(value: Any, arg: Any) -> Any: ... def get_digit(value: Any, arg: int) -> Any: ... -def date(value: Optional[Union[_date, datetime, str]], arg: Optional[str] = ...) -> str: ... -def time(value: Optional[Union[datetime, _time, str]], arg: Optional[str] = ...) -> str: ... -def timesince_filter(value: Optional[_date], arg: Optional[_date] = ...) -> str: ... -def timeuntil_filter(value: Optional[_date], arg: Optional[_date] = ...) -> str: ... -def default(value: Optional[Union[int, str]], arg: Union[int, str]) -> Union[int, str]: ... -def default_if_none(value: Optional[str], arg: Union[int, str]) -> Union[int, str]: ... +def date(value: _date | datetime | str | None, arg: str | None = ...) -> str: ... +def time(value: datetime | _time | str | None, arg: str | None = ...) -> str: ... +def timesince_filter(value: _date | None, arg: _date | None = ...) -> str: ... +def timeuntil_filter(value: _date | None, arg: _date | None = ...) -> str: ... +def default(value: int | str | None, arg: int | str) -> int | str: ... +def default_if_none(value: str | None, arg: int | str) -> int | str: ... def divisibleby(value: int, arg: int) -> bool: ... -def yesno(value: Optional[int], arg: Optional[str] = ...) -> Optional[Union[bool, str]]: ... -def filesizeformat(bytes_: Union[complex, int, str]) -> str: ... +def yesno(value: int | None, arg: str | None = ...) -> bool | str | None: ... +def filesizeformat(bytes_: complex | int | str) -> str: ... def pluralize(value: Any, arg: str = ...) -> str: ... def phone2numeric_filter(value: str) -> str: ... def pprint(value: Any) -> str: ... diff --git a/django-stubs/template/defaulttags.pyi b/django-stubs/template/defaulttags.pyi index a72082941..808c9f459 100644 --- a/django-stubs/template/defaulttags.pyi +++ b/django-stubs/template/defaulttags.pyi @@ -1,6 +1,6 @@ from collections import namedtuple from datetime import date as real_date -from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, Union +from typing import Any, Dict, Iterator, List, Sequence, Tuple from django.template.base import FilterExpression, Parser, Token from django.template.context import Context @@ -22,10 +22,10 @@ class CsrfTokenNode(Node): ... class CycleNode(Node): cyclevars: List[FilterExpression] = ... - variable_name: Optional[str] = ... + variable_name: str | None = ... silent: bool = ... def __init__( - self, cyclevars: List[FilterExpression], variable_name: Optional[str] = ..., silent: bool = ... + self, cyclevars: List[FilterExpression], variable_name: str | None = ..., silent: bool = ... ) -> None: ... def reset(self, context: Context) -> None: ... @@ -38,23 +38,23 @@ class FilterNode(Node): class FirstOfNode(Node): vars: List[FilterExpression] = ... - asvar: Optional[str] = ... - def __init__(self, variables: List[FilterExpression], asvar: Optional[str] = ...) -> None: ... + asvar: str | None = ... + def __init__(self, variables: List[FilterExpression], asvar: str | None = ...) -> None: ... class ForNode(Node): - loopvars: Union[List[str], str] - sequence: Union[FilterExpression, str] + loopvars: List[str] | str + sequence: FilterExpression | str child_nodelists: Any = ... is_reversed: bool = ... - nodelist_loop: Union[List[str], NodeList] = ... - nodelist_empty: Union[List[str], NodeList] = ... + nodelist_loop: List[str] | NodeList = ... + nodelist_empty: List[str] | NodeList = ... def __init__( self, - loopvars: Union[List[str], str], - sequence: Union[FilterExpression, str], + loopvars: List[str] | str, + sequence: FilterExpression | str, is_reversed: bool, - nodelist_loop: Union[List[str], NodeList], - nodelist_empty: Optional[Union[List[str], NodeList]] = ..., + nodelist_loop: List[str] | NodeList, + nodelist_empty: List[str] | NodeList | None = ..., ) -> None: ... class IfChangedNode(Node): @@ -64,24 +64,24 @@ class IfChangedNode(Node): def __init__(self, nodelist_true: NodeList, nodelist_false: NodeList, *varlist: Any) -> None: ... class IfEqualNode(Node): - nodelist_false: Union[List[Any], NodeList] - nodelist_true: Union[List[Any], NodeList] - var1: Union[FilterExpression, str] - var2: Union[FilterExpression, str] + nodelist_false: List[Any] | NodeList + nodelist_true: List[Any] | NodeList + var1: FilterExpression | str + var2: FilterExpression | str child_nodelists: Any = ... negate: bool = ... def __init__( self, - var1: Union[FilterExpression, str], - var2: Union[FilterExpression, str], - nodelist_true: Union[List[Any], NodeList], - nodelist_false: Union[List[Any], NodeList], + var1: FilterExpression | str, + var2: FilterExpression | str, + nodelist_true: List[Any] | NodeList, + nodelist_false: List[Any] | NodeList, negate: bool, ) -> None: ... class IfNode(Node): - conditions_nodelists: List[Tuple[Optional[TemplateLiteral], NodeList]] = ... - def __init__(self, conditions_nodelists: List[Tuple[Optional[TemplateLiteral], NodeList]]) -> None: ... + conditions_nodelists: List[Tuple[TemplateLiteral | None, NodeList]] = ... + def __init__(self, conditions_nodelists: List[Tuple[TemplateLiteral | None, NodeList]]) -> None: ... def __iter__(self) -> Iterator[Node]: ... @property def nodelist(self) -> NodeList: ... @@ -99,14 +99,14 @@ class RegroupNode(Node): target: FilterExpression var_name: str = ... def __init__(self, target: FilterExpression, expression: FilterExpression, var_name: str) -> None: ... - def resolve_expression(self, obj: Dict[str, real_date], context: Context) -> Union[int, str]: ... + def resolve_expression(self, obj: Dict[str, real_date], context: Context) -> int | str: ... class LoadNode(Node): ... class NowNode(Node): format_string: str = ... - asvar: Optional[str] = ... - def __init__(self, format_string: str, asvar: Optional[str] = ...) -> None: ... + asvar: str | None = ... + def __init__(self, format_string: str, asvar: str | None = ...) -> None: ... class ResetCycleNode(Node): node: CycleNode = ... @@ -125,13 +125,13 @@ class URLNode(Node): view_name: FilterExpression = ... args: List[FilterExpression] = ... kwargs: Dict[str, FilterExpression] = ... - asvar: Optional[str] = ... + asvar: str | None = ... def __init__( self, view_name: FilterExpression, args: List[FilterExpression], kwargs: Dict[str, FilterExpression], - asvar: Optional[str], + asvar: str | None, ) -> None: ... class VerbatimNode(Node): @@ -142,13 +142,13 @@ class WidthRatioNode(Node): val_expr: FilterExpression = ... max_expr: FilterExpression = ... max_width: FilterExpression = ... - asvar: Optional[str] = ... + asvar: str | None = ... def __init__( self, val_expr: FilterExpression, max_expr: FilterExpression, max_width: FilterExpression, - asvar: Optional[str] = ..., + asvar: str | None = ..., ) -> None: ... class WithNode(Node): @@ -156,10 +156,10 @@ class WithNode(Node): extra_context: Dict[str, Any] = ... def __init__( self, - var: Optional[str], - name: Optional[str], - nodelist: Union[NodeList, Sequence[Node]], - extra_context: Optional[Dict[str, Any]] = ..., + var: str | None, + name: str | None, + nodelist: NodeList | Sequence[Node], + extra_context: Dict[str, Any] | None = ..., ) -> None: ... def autoescape(parser: Parser, token: Token) -> AutoEscapeControlNode: ... diff --git a/django-stubs/template/engine.pyi b/django-stubs/template/engine.pyi index 9d06c95b9..137079579 100644 --- a/django-stubs/template/engine.pyi +++ b/django-stubs/template/engine.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union +from typing import Any, Callable, Dict, List, Sequence, Tuple from django.template.base import Origin from django.template.library import Library @@ -14,7 +14,7 @@ class Engine: dirs: List[str] = ... app_dirs: bool = ... autoescape: bool = ... - context_processors: Union[List[str], Tuple[str]] = ... + context_processors: List[str] | Tuple[str] = ... debug: bool = ... loaders: Sequence[_Loader] = ... string_if_invalid: str = ... @@ -25,15 +25,15 @@ class Engine: template_builtins: List[Library] = ... def __init__( self, - dirs: Optional[List[str]] = ..., + dirs: List[str] | None = ..., app_dirs: bool = ..., - context_processors: Optional[Union[List[str], Tuple[str]]] = ..., + context_processors: List[str] | Tuple[str] | None = ..., debug: bool = ..., - loaders: Optional[Sequence[_Loader]] = ..., + loaders: Sequence[_Loader] | None = ..., string_if_invalid: str = ..., file_charset: str = ..., - libraries: Optional[Dict[str, str]] = ..., - builtins: Optional[List[str]] = ..., + libraries: Dict[str, str] | None = ..., + builtins: List[str] | None = ..., autoescape: bool = ..., ) -> None: ... @staticmethod @@ -47,9 +47,9 @@ class Engine: def get_template_loaders(self, template_loaders: Sequence[_Loader]) -> List[Loader]: ... def find_template_loader(self, loader: _Loader) -> Loader: ... def find_template( - self, name: str, dirs: None = ..., skip: Optional[List[Origin]] = ... + self, name: str, dirs: None = ..., skip: List[Origin] | None = ... ) -> Tuple[Template, Origin]: ... def from_string(self, template_code: str) -> Template: ... def get_template(self, template_name: str) -> Template: ... - def render_to_string(self, template_name: str, context: Optional[Dict[str, Any]] = ...) -> SafeString: ... + def render_to_string(self, template_name: str, context: Dict[str, Any] | None = ...) -> SafeString: ... def select_template(self, template_name_list: List[str]) -> Template: ... diff --git a/django-stubs/template/exceptions.pyi b/django-stubs/template/exceptions.pyi index c16758a10..8ce0b76b9 100644 --- a/django-stubs/template/exceptions.pyi +++ b/django-stubs/template/exceptions.pyi @@ -1,18 +1,18 @@ -from typing import List, Optional, Tuple, Union +from typing import List, Tuple from django.template.backends.base import BaseEngine from django.template.base import Origin class TemplateDoesNotExist(Exception): - backend: Optional[BaseEngine] = ... + backend: BaseEngine | None = ... tried: List[Tuple[Origin, str]] = ... chain: List[TemplateDoesNotExist] = ... def __init__( self, - msg: Union[Origin, str], - tried: Optional[List[Tuple[Origin, str]]] = ..., - backend: Optional[BaseEngine] = ..., - chain: Optional[List[TemplateDoesNotExist]] = ..., + msg: Origin | str, + tried: List[Tuple[Origin, str]] | None = ..., + backend: BaseEngine | None = ..., + chain: List[TemplateDoesNotExist] | None = ..., ) -> None: ... class TemplateSyntaxError(Exception): ... diff --git a/django-stubs/template/library.pyi b/django-stubs/template/library.pyi index a75bf0701..cfd5b1eb8 100644 --- a/django-stubs/template/library.pyi +++ b/django-stubs/template/library.pyi @@ -1,19 +1,4 @@ -from typing import ( - Any, - Callable, - Collection, - Dict, - Iterable, - List, - Mapping, - Optional, - Sequence, - Sized, - Tuple, - TypeVar, - Union, - overload, -) +from typing import Any, Callable, Collection, Dict, Iterable, List, Mapping, Sequence, Sized, Tuple, TypeVar, overload from django.template.base import FilterExpression, Origin, Parser, Token from django.template.context import Context @@ -34,24 +19,24 @@ class Library: @overload def tag(self, name: str, compile_function: _C) -> _C: ... @overload - def tag(self, name: Optional[str] = ..., compile_function: None = ...) -> Callable[[_C], _C]: ... + def tag(self, name: str | None = ..., compile_function: None = ...) -> Callable[[_C], _C]: ... def tag_function(self, func: _C) -> _C: ... @overload def filter(self, name: _C, filter_func: None = ..., **flags: Any) -> _C: ... @overload - def filter(self, name: Optional[str], filter_func: _C, **flags: Any) -> _C: ... + def filter(self, name: str | None, filter_func: _C, **flags: Any) -> _C: ... @overload - def filter(self, name: Optional[str] = ..., filter_func: None = ..., **flags: Any) -> Callable[[_C], _C]: ... + def filter(self, name: str | None = ..., filter_func: None = ..., **flags: Any) -> Callable[[_C], _C]: ... @overload def simple_tag(self, func: _C) -> _C: ... @overload - def simple_tag(self, takes_context: Optional[bool] = ..., name: Optional[str] = ...) -> Callable[[_C], _C]: ... + def simple_tag(self, takes_context: bool | None = ..., name: str | None = ...) -> Callable[[_C], _C]: ... def inclusion_tag( self, - filename: Union[Template, str], - func: Optional[Callable] = ..., - takes_context: Optional[bool] = ..., - name: Optional[str] = ..., + filename: Template | str, + func: Callable | None = ..., + takes_context: bool | None = ..., + name: str | None = ..., ) -> Callable[[_C], _C]: ... class TagHelperNode(Node): @@ -62,27 +47,27 @@ class TagHelperNode(Node): def __init__( self, func: Callable, - takes_context: Optional[bool], + takes_context: bool | None, args: List[FilterExpression], kwargs: Dict[str, FilterExpression], ) -> None: ... - def get_resolved_arguments(self, context: Context) -> Tuple[List[int], Dict[str, Union[SafeString, int]]]: ... + def get_resolved_arguments(self, context: Context) -> Tuple[List[int], Dict[str, SafeString | int]]: ... class SimpleNode(TagHelperNode): args: List[FilterExpression] func: Callable kwargs: Dict[str, FilterExpression] origin: Origin - takes_context: Optional[bool] + takes_context: bool | None token: Token - target_var: Optional[str] = ... + target_var: str | None = ... def __init__( self, func: Callable, - takes_context: Optional[bool], + takes_context: bool | None, args: List[FilterExpression], kwargs: Dict[str, FilterExpression], - target_var: Optional[str], + target_var: str | None, ) -> None: ... class InclusionNode(TagHelperNode): @@ -90,28 +75,28 @@ class InclusionNode(TagHelperNode): func: Callable kwargs: Dict[str, FilterExpression] origin: Origin - takes_context: Optional[bool] + takes_context: bool | None token: Token - filename: Union[Template, str] = ... + filename: Template | str = ... def __init__( self, func: Callable, - takes_context: Optional[bool], + takes_context: bool | None, args: List[FilterExpression], kwargs: Dict[str, FilterExpression], - filename: Optional[Union[Template, str]], + filename: Template | str | None, ) -> None: ... def parse_bits( parser: Parser, bits: Iterable[str], params: Sequence[str], - varargs: Optional[str], - varkw: Optional[str], - defaults: Optional[Sized], + varargs: str | None, + varkw: str | None, + defaults: Sized | None, kwonly: Collection[str], - kwonly_defaults: Optional[Mapping[str, int]], - takes_context: Optional[bool], + kwonly_defaults: Mapping[str, int] | None, + takes_context: bool | None, name: str, ) -> Tuple[List[FilterExpression], Dict[str, FilterExpression]]: ... def import_library(name: str) -> Library: ... diff --git a/django-stubs/template/loader.pyi b/django-stubs/template/loader.pyi index 6344ff118..b0d3d1907 100644 --- a/django-stubs/template/loader.pyi +++ b/django-stubs/template/loader.pyi @@ -1,4 +1,4 @@ -from typing import Any, Mapping, Optional, Sequence, Union +from typing import Any, Mapping, Sequence from django.http.request import HttpRequest from django.template.exceptions import TemplateDoesNotExist as TemplateDoesNotExist # noqa: F401 @@ -7,11 +7,11 @@ from django.utils.safestring import SafeString from . import engines as engines # noqa: F401 from .backends.base import _EngineTemplate -def get_template(template_name: str, using: Optional[str] = ...) -> _EngineTemplate: ... -def select_template(template_name_list: Union[Sequence[str], str], using: Optional[str] = ...) -> Any: ... +def get_template(template_name: str, using: str | None = ...) -> _EngineTemplate: ... +def select_template(template_name_list: Sequence[str] | str, using: str | None = ...) -> Any: ... def render_to_string( - template_name: Union[Sequence[str], str], - context: Optional[Mapping[str, Any]] = ..., - request: Optional[HttpRequest] = ..., - using: Optional[str] = ..., + template_name: Sequence[str] | str, + context: Mapping[str, Any] | None = ..., + request: HttpRequest | None = ..., + using: str | None = ..., ) -> SafeString: ... diff --git a/django-stubs/template/loader_tags.pyi b/django-stubs/template/loader_tags.pyi index 32b3b2517..9909e8e81 100644 --- a/django-stubs/template/loader_tags.pyi +++ b/django-stubs/template/loader_tags.pyi @@ -1,5 +1,5 @@ import collections -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List from django.template.base import FilterExpression, NodeList, Origin, Parser, Token from django.template.context import Context @@ -23,9 +23,9 @@ class BlockNode(Node): name: str nodelist: NodeList origin: Origin - parent: Optional[Node] + parent: Node | None token: Token - def __init__(self, name: str, nodelist: NodeList, parent: Optional[Node] = ...) -> None: ... + def __init__(self, name: str, nodelist: NodeList, parent: Node | None = ...) -> None: ... def render(self, context: Context) -> SafeString: ... def super(self) -> SafeString: ... @@ -35,11 +35,11 @@ class ExtendsNode(Node): must_be_first: bool = ... context_key: str = ... nodelist: NodeList = ... - parent_name: Union[FilterExpression, Node] = ... - template_dirs: Optional[List[Any]] = ... + parent_name: FilterExpression | Node = ... + template_dirs: List[Any] | None = ... blocks: Dict[str, BlockNode] = ... def __init__( - self, nodelist: NodeList, parent_name: Union[FilterExpression, Node], template_dirs: Optional[List[Any]] = ... + self, nodelist: NodeList, parent_name: FilterExpression | Node, template_dirs: List[Any] | None = ... ) -> None: ... def find_template(self, template_name: str, context: Context) -> Template: ... def get_parent(self, context: Context) -> Template: ... @@ -56,13 +56,13 @@ class IncludeNode(Node): self, template: FilterExpression, *args: Any, - extra_context: Optional[Any] = ..., + extra_context: Any | None = ..., isolated_context: bool = ..., **kwargs: Any ) -> None: ... def render(self, context: Context) -> SafeString: ... def do_block(parser: Parser, token: Token) -> BlockNode: ... -def construct_relative_path(current_template_name: Optional[str], relative_name: str) -> str: ... +def construct_relative_path(current_template_name: str | None, relative_name: str) -> str: ... def do_extends(parser: Parser, token: Token) -> ExtendsNode: ... def do_include(parser: Parser, token: Token) -> IncludeNode: ... diff --git a/django-stubs/template/loaders/base.pyi b/django-stubs/template/loaders/base.pyi index a397854ec..b109fbcf4 100644 --- a/django-stubs/template/loaders/base.pyi +++ b/django-stubs/template/loaders/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, List, Optional +from typing import Any, Dict, Iterable, List from django.template.base import Origin, Template from django.template.engine import Engine @@ -7,6 +7,6 @@ class Loader: engine: Engine = ... get_template_cache: Dict[str, Any] = ... def __init__(self, engine: Engine) -> None: ... - def get_template(self, template_name: str, skip: Optional[List[Origin]] = ...) -> Template: ... + def get_template(self, template_name: str, skip: List[Origin] | None = ...) -> Template: ... def get_template_sources(self, template_name: str) -> Iterable[Origin]: ... def reset(self) -> None: ... diff --git a/django-stubs/template/loaders/cached.pyi b/django-stubs/template/loaders/cached.pyi index 956e9dc0f..c4c082c48 100644 --- a/django-stubs/template/loaders/cached.pyi +++ b/django-stubs/template/loaders/cached.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Sequence +from typing import Any, Dict, List, Sequence from django.template.base import Origin from django.template.engine import Engine @@ -10,5 +10,5 @@ class Loader(BaseLoader): loaders: List[BaseLoader] = ... def __init__(self, engine: Engine, loaders: Sequence[Any]) -> None: ... def get_contents(self, origin: Origin) -> str: ... - def cache_key(self, template_name: str, skip: Optional[List[Origin]] = ...) -> str: ... + def cache_key(self, template_name: str, skip: List[Origin] | None = ...) -> str: ... def generate_hash(self, values: List[str]) -> str: ... diff --git a/django-stubs/template/loaders/filesystem.pyi b/django-stubs/template/loaders/filesystem.pyi index 8931c630d..79bf07adf 100644 --- a/django-stubs/template/loaders/filesystem.pyi +++ b/django-stubs/template/loaders/filesystem.pyi @@ -1,5 +1,5 @@ from pathlib import Path -from typing import Iterator, List, Optional, Union +from typing import Iterator, List from django.template.base import Origin from django.template.engine import Engine @@ -7,8 +7,8 @@ from django.template.engine import Engine from .base import Loader as BaseLoader class Loader(BaseLoader): - dirs: Optional[List[Union[str, Path]]] = ... - def __init__(self, engine: Engine, dirs: Optional[List[Union[str, Path]]] = ...) -> None: ... - def get_dirs(self) -> List[Union[str, Path]]: ... + dirs: List[str | Path] | None = ... + def __init__(self, engine: Engine, dirs: List[str | Path] | None = ...) -> None: ... + def get_dirs(self) -> List[str | Path]: ... def get_contents(self, origin: Origin) -> str: ... def get_template_sources(self, template_name: str) -> Iterator[Origin]: ... diff --git a/django-stubs/template/response.pyi b/django-stubs/template/response.pyi index 90d9e4d1c..495d7abd5 100644 --- a/django-stubs/template/response.pyi +++ b/django-stubs/template/response.pyi @@ -1,6 +1,6 @@ import functools from http.cookies import SimpleCookie -from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Union +from typing import Any, Callable, Dict, Iterator, List, Sequence, Union from django.core.handlers.wsgi import WSGIRequest from django.http import HttpResponse @@ -21,20 +21,20 @@ class SimpleTemplateResponse(HttpResponse): status_code: int rendering_attrs: Any = ... template_name: _TemplateForResponseT = ... - context_data: Optional[Dict[str, Any]] = ... - using: Optional[str] = ... + context_data: Dict[str, Any] | None = ... + using: str | None = ... def __init__( self, template: _TemplateForResponseT, - context: Optional[Dict[str, Any]] = ..., - content_type: Optional[str] = ..., - status: Optional[int] = ..., - charset: Optional[str] = ..., - using: Optional[str] = ..., - headers: Optional[Dict[str, Any]] = ..., + context: Dict[str, Any] | None = ..., + content_type: str | None = ..., + status: int | None = ..., + charset: str | None = ..., + using: str | None = ..., + headers: Dict[str, Any] | None = ..., ) -> None: ... - def resolve_template(self, template: Union[Sequence[str], Template, str]) -> Template: ... - def resolve_context(self, context: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: ... + def resolve_template(self, template: Sequence[str] | Template | str) -> Template: ... + def resolve_context(self, context: Dict[str, Any] | None) -> Dict[str, Any] | None: ... @property def rendered_content(self) -> str: ... def add_post_render_callback(self, callback: Callable) -> None: ... @@ -47,7 +47,7 @@ class TemplateResponse(SimpleTemplateResponse): client: Client closed: bool context: RequestContext - context_data: Optional[Dict[str, Any]] + context_data: Dict[str, Any] | None cookies: SimpleCookie[str] csrf_cookie_set: bool json: functools.partial @@ -55,17 +55,17 @@ class TemplateResponse(SimpleTemplateResponse): status_code: int template_name: _TemplateForResponseT templates: List[Template] - using: Optional[str] + using: str | None wsgi_request: WSGIRequest rendering_attrs: Any = ... def __init__( self, request: HttpRequest, template: _TemplateForResponseT, - context: Optional[Dict[str, Any]] = ..., - content_type: Optional[str] = ..., - status: Optional[int] = ..., - charset: Optional[str] = ..., - using: Optional[str] = ..., - headers: Optional[Dict[str, Any]] = ..., + context: Dict[str, Any] | None = ..., + content_type: str | None = ..., + status: int | None = ..., + charset: str | None = ..., + using: str | None = ..., + headers: Dict[str, Any] | None = ..., ) -> None: ... diff --git a/django-stubs/template/smartif.pyi b/django-stubs/template/smartif.pyi index 8bce5f312..3aa2338cb 100644 --- a/django-stubs/template/smartif.pyi +++ b/django-stubs/template/smartif.pyi @@ -1,8 +1,8 @@ -from typing import Any, Dict, List, Optional, Type, Union +from typing import Any, Dict, List, Type from django.template.defaulttags import TemplateLiteral -_Token = Union[List[int], int, str] +_Token = List[int] | int | str class TokenBase: id: Any = ... @@ -21,10 +21,10 @@ OPERATORS: Any class Literal(TokenBase): id: str = ... lbp: int = ... - value: Optional[_Token] = ... - def __init__(self, value: Optional[_Token]) -> None: ... + value: _Token | None = ... + def __init__(self, value: _Token | None) -> None: ... def display(self) -> str: ... - def eval(self, context: Dict[Any, Any]) -> Optional[_Token]: ... + def eval(self, context: Dict[Any, Any]) -> _Token | None: ... class EndToken(TokenBase): lbp: int = ... @@ -35,9 +35,9 @@ class IfParser: tokens: Any = ... pos: int = ... current_token: Any = ... - def __init__(self, tokens: List[Optional[_Token]]) -> None: ... - def translate_token(self, token: Optional[_Token]) -> Literal: ... + def __init__(self, tokens: List[_Token | None]) -> None: ... + def translate_token(self, token: _Token | None) -> Literal: ... def next_token(self) -> Literal: ... def parse(self) -> TemplateLiteral: ... def expression(self, rbp: int = ...) -> Literal: ... - def create_var(self, value: Optional[_Token]) -> Literal: ... + def create_var(self, value: _Token | None) -> Literal: ... diff --git a/django-stubs/templatetags/cache.pyi b/django-stubs/templatetags/cache.pyi index 70eaee63d..ef074743e 100644 --- a/django-stubs/templatetags/cache.pyi +++ b/django-stubs/templatetags/cache.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List from django.template import Node from django.template.base import FilterExpression, NodeList, Parser, Token @@ -10,14 +10,14 @@ class CacheNode(Node): expire_time_var: FilterExpression = ... fragment_name: str = ... vary_on: List[FilterExpression] = ... - cache_name: Optional[FilterExpression] = ... + cache_name: FilterExpression | None = ... def __init__( self, nodelist: NodeList, expire_time_var: FilterExpression, fragment_name: str, vary_on: List[FilterExpression], - cache_name: Optional[FilterExpression], + cache_name: FilterExpression | None, ) -> None: ... def do_cache(parser: Parser, token: Token) -> CacheNode: ... diff --git a/django-stubs/templatetags/i18n.pyi b/django-stubs/templatetags/i18n.pyi index 432525c14..6542d04ea 100644 --- a/django-stubs/templatetags/i18n.pyi +++ b/django-stubs/templatetags/i18n.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Tuple +from typing import Any, Dict, List, Tuple from django.template import Node from django.template.base import FilterExpression, NodeList, Parser, Token @@ -36,15 +36,15 @@ class GetCurrentLanguageBidiNode(Node): class TranslateNode(Node): noop: bool = ... - asvar: Optional[str] = ... - message_context: Optional[FilterExpression] = ... + asvar: str | None = ... + message_context: FilterExpression | None = ... filter_expression: FilterExpression = ... def __init__( self, filter_expression: FilterExpression, noop: bool, - asvar: Optional[str] = ..., - message_context: Optional[FilterExpression] = ..., + asvar: str | None = ..., + message_context: FilterExpression | None = ..., ) -> None: ... def render(self, context: Context) -> str: ... @@ -52,21 +52,21 @@ class BlockTranslateNode(Node): extra_context: Dict[str, FilterExpression] = ... singular: List[Token] = ... plural: List[Token] = ... - countervar: Optional[str] = ... - counter: Optional[FilterExpression] = ... - message_context: Optional[FilterExpression] = ... + countervar: str | None = ... + counter: FilterExpression | None = ... + message_context: FilterExpression | None = ... trimmed: bool = ... - asvar: Optional[str] = ... + asvar: str | None = ... def __init__( self, extra_context: Dict[str, FilterExpression], singular: List[Token], plural: List[Token] = ..., - countervar: Optional[str] = ..., - counter: Optional[FilterExpression] = ..., - message_context: Optional[FilterExpression] = ..., + countervar: str | None = ..., + counter: FilterExpression | None = ..., + message_context: FilterExpression | None = ..., trimmed: bool = ..., - asvar: Optional[str] = ..., + asvar: str | None = ..., tag_name: str = ..., ) -> None: ... def render_token_list(self, tokens: List[Token]) -> Tuple[str, List[str]]: ... diff --git a/django-stubs/templatetags/static.pyi b/django-stubs/templatetags/static.pyi index d9f81c43e..141284b36 100644 --- a/django-stubs/templatetags/static.pyi +++ b/django-stubs/templatetags/static.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django import template from django.template.base import FilterExpression, Parser, Token @@ -7,9 +7,9 @@ from django.template.context import Context register: Any class PrefixNode(template.Node): - varname: Optional[str] = ... + varname: str | None = ... name: str = ... - def __init__(self, varname: Optional[str] = ..., name: str = ...) -> None: ... + def __init__(self, varname: str | None = ..., name: str = ...) -> None: ... @classmethod def handle_token(cls, parser: Parser, token: Token, name: str) -> PrefixNode: ... @classmethod @@ -20,8 +20,8 @@ def get_media_prefix(parser: Parser, token: Token) -> PrefixNode: ... class StaticNode(template.Node): path: FilterExpression = ... - varname: Optional[str] = ... - def __init__(self, varname: Optional[str] = ..., path: FilterExpression = ...) -> None: ... + varname: str | None = ... + def __init__(self, varname: str | None = ..., path: FilterExpression = ...) -> None: ... def url(self, context: Context) -> str: ... @classmethod def handle_simple(cls, path: str) -> str: ... diff --git a/django-stubs/templatetags/tz.pyi b/django-stubs/templatetags/tz.pyi index f773d12e6..99ffd00ad 100644 --- a/django-stubs/templatetags/tz.pyi +++ b/django-stubs/templatetags/tz.pyi @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Optional, Union +from typing import Any from django.template import Node from django.template.base import FilterExpression, NodeList, Parser, Token @@ -9,9 +9,9 @@ register: Any class datetimeobject(datetime): ... -def localtime(value: Optional[Union[datetime, str]]) -> Any: ... -def utc(value: Optional[Union[datetime, str]]) -> Any: ... -def do_timezone(value: Optional[Union[datetime, str]], arg: Optional[Union[_TzInfoT, str]]) -> Any: ... +def localtime(value: datetime | str | None) -> Any: ... +def utc(value: datetime | str | None) -> Any: ... +def do_timezone(value: datetime | str | None, arg: _TzInfoT | str | None) -> Any: ... class LocalTimeNode(Node): nodelist: NodeList = ... diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index b6bd8a577..69f9b5b7c 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -11,12 +11,10 @@ from typing import ( Iterator, List, NoReturn, - Optional, Pattern, Tuple, Type, TypeVar, - Union, overload, ) @@ -45,10 +43,10 @@ class RedirectCycleError(Exception): class FakePayload: read_started: bool = ... - def __init__(self, content: Optional[Union[bytes, str]] = ...) -> None: ... + def __init__(self, content: bytes | str | None = ...) -> None: ... def __len__(self) -> int: ... def read(self, num_bytes: int = ...) -> bytes: ... - def write(self, content: Union[bytes, str]) -> None: ... + def write(self, content: bytes | str) -> None: ... _T = TypeVar("_T") @@ -86,24 +84,13 @@ class _RequestFactory(Generic[_T]): def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> _T: ... def trace(self, path: str, secure: bool = ..., **extra: Any) -> _T: ... def options( - self, - path: str, - data: Union[Dict[str, str], str] = ..., - content_type: str = ..., - secure: bool = ..., - **extra: Any + self, path: str, data: Dict[str, str] | str = ..., content_type: str = ..., secure: bool = ..., **extra: Any ) -> _T: ... def put(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> _T: ... def patch(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> _T: ... def delete(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> _T: ... def generic( - self, - method: str, - path: str, - data: Any = ..., - content_type: Optional[str] = ..., - secure: bool = ..., - **extra: Any + self, method: str, path: str, data: Any = ..., content_type: str | None = ..., secure: bool = ..., **extra: Any ) -> _T: ... class RequestFactory(_RequestFactory[WSGIRequest]): ... @@ -111,13 +98,7 @@ class RequestFactory(_RequestFactory[WSGIRequest]): ... class _AsyncRequestFactory(_RequestFactory[_T]): def request(self, **request: Any) -> _T: ... def generic( - self, - method: str, - path: str, - data: Any = ..., - content_type: Optional[str] = ..., - secure: bool = ..., - **extra: Any + self, method: str, path: str, data: Any = ..., content_type: str | None = ..., secure: bool = ..., **extra: Any ) -> _T: ... class AsyncRequestFactory(_AsyncRequestFactory[ASGIRequest]): ... @@ -151,13 +132,13 @@ class ClientMixin: @property def session(self) -> SessionBase: ... def login(self, **credentials: Any) -> bool: ... - def force_login(self, user: AbstractBaseUser, backend: Optional[str] = ...) -> None: ... + def force_login(self, user: AbstractBaseUser, backend: str | None = ...) -> None: ... def logout(self) -> None: ... class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]): handler: ClientHandler raise_request_exception: bool - exc_info: Optional[Tuple[Type[BaseException], BaseException, TracebackType]] + exc_info: Tuple[Type[BaseException], BaseException, TracebackType] | None def __init__( self, enforce_csrf_checks: bool = ..., raise_request_exception: bool = ..., **defaults: Any ) -> None: ... diff --git a/django-stubs/test/html.pyi b/django-stubs/test/html.pyi index 67d69f856..75994764f 100644 --- a/django-stubs/test/html.pyi +++ b/django-stubs/test/html.pyi @@ -1,5 +1,5 @@ from html.parser import HTMLParser -from typing import Any, List, Optional, Sequence, Tuple, TypeVar, Union +from typing import Any, List, Sequence, Tuple, TypeVar _Self = TypeVar("_Self") @@ -7,17 +7,17 @@ WHITESPACE: Any def normalize_whitespace(string: str) -> str: ... -_ElementAttribute = Tuple[str, Optional[str]] +_ElementAttribute = Tuple[str, str | None] class Element: - name: Optional[str] = ... + name: str | None = ... attributes: List[_ElementAttribute] = ... children: List[Any] = ... - def __init__(self, name: Optional[str], attributes: Sequence[_ElementAttribute]) -> None: ... - def append(self, element: Union[Element, str]) -> None: ... + def __init__(self, name: str | None, attributes: Sequence[_ElementAttribute]) -> None: ... + def append(self, element: Element | str) -> None: ... def finalize(self) -> None: ... - def __contains__(self, element: Union[Element, str]) -> bool: ... - def count(self, element: Union[Element, str]) -> int: ... + def __contains__(self, element: Element | str) -> bool: ... + def count(self, element: Element | str) -> int: ... def __getitem__(self, key: int) -> Any: ... class RootElement(Element): diff --git a/django-stubs/test/runner.pyi b/django-stubs/test/runner.pyi index 22ba19b62..1e468573c 100644 --- a/django-stubs/test/runner.pyi +++ b/django-stubs/test/runner.pyi @@ -2,7 +2,7 @@ import logging from argparse import ArgumentParser from contextlib import contextmanager from io import StringIO -from typing import Any, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union +from typing import Any, Dict, Iterator, List, Sequence, Set, Tuple, Type from unittest import TestCase, TestLoader, TestSuite, TextTestResult, TextTestRunner from django.db.backends.base.base import BaseDatabaseWrapper @@ -67,7 +67,7 @@ class RemoteTestRunner: resultclass: Any = ... failfast: bool = ... buffer: bool = ... - def __init__(self, failfast: bool = ..., resultclass: Optional[Any] = ..., buffer: bool = ...) -> None: ... + def __init__(self, failfast: bool = ..., resultclass: Any | None = ..., buffer: bool = ...) -> None: ... def run(self, test: Any) -> Any: ... def default_test_processes() -> int: ... @@ -93,8 +93,8 @@ class DiscoverRunner: test_runner: Type[TextTestRunner] = ... test_loader: TestLoader = ... reorder_by: Tuple[SimpleTestCase, ...] = ... - pattern: Optional[str] = ... - top_level: Optional[str] = ... + pattern: str | None = ... + top_level: str | None = ... verbosity: int = ... interactive: bool = ... failfast: bool = ... @@ -107,14 +107,14 @@ class DiscoverRunner: exclude_tags: Set[str] = ... pdb: bool = ... buffer: bool = ... - test_name_patterns: Optional[Set[str]] = ... + test_name_patterns: Set[str] | None = ... time_keeper: TimeKeeperProtocol = ... - shuffle: Union[int, Literal[False]] = ... - logger: Optional[logging.Logger] = ... + shuffle: int | Literal[False] = ... + logger: logging.Logger | None = ... def __init__( self, - pattern: Optional[str] = ..., - top_level: Optional[str] = ..., + pattern: str | None = ..., + top_level: str | None = ..., verbosity: int = ..., interactive: bool = ..., failfast: bool = ..., @@ -123,32 +123,32 @@ class DiscoverRunner: debug_mode: bool = ..., debug_sql: bool = ..., parallel: int = ..., - tags: Optional[List[str]] = ..., - exclude_tags: Optional[List[str]] = ..., - test_name_patterns: Optional[List[str]] = ..., + tags: List[str] | None = ..., + exclude_tags: List[str] | None = ..., + test_name_patterns: List[str] | None = ..., pdb: bool = ..., buffer: bool = ..., enable_faulthandler: bool = ..., timing: bool = ..., - shuffle: Union[int, Literal[False]] = ..., - logger: Optional[logging.Logger] = ..., + shuffle: int | Literal[False] = ..., + logger: logging.Logger | None = ..., **kwargs: Any ) -> None: ... @classmethod def add_arguments(cls, parser: ArgumentParser) -> None: ... @property - def shuffle_seed(self) -> Optional[int]: ... - def log(self, msg: str, level: Optional[int]) -> None: ... + def shuffle_seed(self) -> int | None: ... + def log(self, msg: str, level: int | None) -> None: ... def setup_test_environment(self, **kwargs: Any) -> None: ... def setup_shuffler(self) -> None: ... @contextmanager def load_with_patterns(self) -> Iterator[None]: ... def load_tests_for_label(self, label: str, discover_kwargs: Dict[str, str]) -> TestSuite: ... def build_suite( - self, test_labels: Sequence[str] = ..., extra_tests: Optional[List[Any]] = ..., **kwargs: Any + self, test_labels: Sequence[str] = ..., extra_tests: List[Any] | None = ..., **kwargs: Any ) -> TestSuite: ... def setup_databases(self, **kwargs: Any) -> List[Tuple[BaseDatabaseWrapper, str, bool]]: ... - def get_resultclass(self) -> Optional[Type[TextTestResult]]: ... + def get_resultclass(self) -> Type[TextTestResult] | None: ... def get_test_runner_kwargs(self) -> Dict[str, Any]: ... def run_checks(self, databases: Set[str]) -> None: ... def run_suite(self, suite: TestSuite, **kwargs: Any) -> TextTestResult: ... @@ -157,7 +157,7 @@ class DiscoverRunner: def suite_result(self, suite: TestSuite, result: TextTestResult, **kwargs: Any) -> int: ... def _get_databases(self, suite: TestSuite) -> Set[str]: ... def get_databases(self, suite: TestSuite) -> Set[str]: ... - def run_tests(self, test_labels: List[str], extra_tests: Optional[List[Any]] = ..., **kwargs: Any) -> int: ... + def run_tests(self, test_labels: List[str], extra_tests: List[Any] | None = ..., **kwargs: Any) -> int: ... def is_discoverable(label: str) -> bool: ... def reorder_suite( diff --git a/django-stubs/test/testcases.pyi b/django-stubs/test/testcases.pyi index 15355548a..9f06eeaa2 100644 --- a/django-stubs/test/testcases.pyi +++ b/django-stubs/test/testcases.pyi @@ -13,12 +13,10 @@ from typing import ( Iterator, List, Mapping, - Optional, Sequence, Set, Tuple, Type, - Union, overload, ) @@ -60,9 +58,9 @@ class _AssertTemplateUsedContext: def __enter__(self) -> _AssertTemplateUsedContext: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... class _AssertTemplateNotUsedContext(_AssertTemplateUsedContext): ... @@ -80,8 +78,8 @@ class SimpleTestCase(unittest.TestCase): async_client: AsyncClient allow_database_queries: bool = ... # TODO: str -> Literal['__all__'] - databases: Union[Set[str], str] = ... - def __call__(self, result: Optional[unittest.TestResult] = ...) -> None: ... + databases: Set[str] | str = ... + def __call__(self, result: unittest.TestResult | None = ...) -> None: ... def settings(self, **kwargs: Any) -> Any: ... def modify_settings(self, **kwargs: Any) -> Any: ... def assertRedirects( @@ -102,8 +100,8 @@ class SimpleTestCase(unittest.TestCase): def assertContains( self, response: HttpResponseBase, - text: Union[bytes, int, str], - count: Optional[int] = ..., + text: bytes | int | str, + count: int | None = ..., status_code: int = ..., msg_prefix: str = ..., html: bool = ..., @@ -111,7 +109,7 @@ class SimpleTestCase(unittest.TestCase): def assertNotContains( self, response: HttpResponseBase, - text: Union[bytes, str], + text: bytes | str, status_code: int = ..., msg_prefix: str = ..., html: bool = ..., @@ -120,8 +118,8 @@ class SimpleTestCase(unittest.TestCase): def assertFormError( self, form: Form, - field: Optional[str], - errors: Union[List[str], str], + field: str | None, + errors: List[str] | str, msg_prefix: str = ..., ) -> None: ... @overload @@ -129,17 +127,17 @@ class SimpleTestCase(unittest.TestCase): self, response: HttpResponseBase, form: str, - field: Optional[str], - errors: Union[List[str], str], + field: str | None, + errors: List[str] | str, msg_prefix: str = ..., ) -> None: ... @overload def assertFormsetError( self, formset: BaseFormSet, - form_index: Optional[int], - field: Optional[str], - errors: Union[List[str], str], + form_index: int | None, + field: str | None, + errors: List[str] | str, msg_prefix: str = ..., ) -> None: ... @overload @@ -147,21 +145,21 @@ class SimpleTestCase(unittest.TestCase): self, response: HttpResponseBase, formset: str, - form_index: Optional[int], - field: Optional[str], - errors: Union[List[str], str], + form_index: int | None, + field: str | None, + errors: List[str] | str, msg_prefix: str = ..., ) -> None: ... def assertTemplateUsed( self, - response: Optional[Union[HttpResponseBase, str]] = ..., - template_name: Optional[str] = ..., + response: HttpResponseBase | str | None = ..., + template_name: str | None = ..., msg_prefix: str = ..., - count: Optional[int] = ..., - ) -> Optional[_AssertTemplateUsedContext]: ... + count: int | None = ..., + ) -> _AssertTemplateUsedContext | None: ... def assertTemplateNotUsed( - self, response: Union[HttpResponseBase, str] = ..., template_name: Optional[str] = ..., msg_prefix: str = ... - ) -> Optional[_AssertTemplateNotUsedContext]: ... + self, response: HttpResponseBase | str = ..., template_name: str | None = ..., msg_prefix: str = ... + ) -> _AssertTemplateNotUsedContext | None: ... def assertRaisesMessage( self, expected_exception: Type[Exception], expected_message: str, *args: Any, **kwargs: Any ) -> Any: ... @@ -173,27 +171,27 @@ class SimpleTestCase(unittest.TestCase): fieldclass: Type[EmailField], valid: Dict[str, str], invalid: Dict[str, List[str]], - field_args: Optional[Iterable[Any]] = ..., - field_kwargs: Optional[Mapping[str, Any]] = ..., + field_args: Iterable[Any] | None = ..., + field_kwargs: Mapping[str, Any] | None = ..., empty_value: str = ..., ) -> Any: ... - def assertHTMLEqual(self, html1: str, html2: str, msg: Optional[str] = ...) -> None: ... - def assertHTMLNotEqual(self, html1: str, html2: str, msg: Optional[str] = ...) -> None: ... - def assertInHTML(self, needle: str, haystack: str, count: Optional[int] = ..., msg_prefix: str = ...) -> None: ... + def assertHTMLEqual(self, html1: str, html2: str, msg: str | None = ...) -> None: ... + def assertHTMLNotEqual(self, html1: str, html2: str, msg: str | None = ...) -> None: ... + def assertInHTML(self, needle: str, haystack: str, count: int | None = ..., msg_prefix: str = ...) -> None: ... def assertJSONEqual( self, raw: str, - expected_data: Union[Dict[str, Any], List[Any], str, int, float, bool, None], - msg: Optional[str] = ..., + expected_data: Dict[str, Any] | List[Any] | str | int | float | bool | None, + msg: str | None = ..., ) -> None: ... def assertJSONNotEqual( self, raw: str, - expected_data: Union[Dict[str, Any], List[Any], str, int, float, bool, None], - msg: Optional[str] = ..., + expected_data: Dict[str, Any] | List[Any] | str | int | float | bool | None, + msg: str | None = ..., ) -> None: ... - def assertXMLEqual(self, xml1: str, xml2: str, msg: Optional[str] = ...) -> None: ... - def assertXMLNotEqual(self, xml1: str, xml2: str, msg: Optional[str] = ...) -> None: ... + def assertXMLEqual(self, xml1: str, xml2: str, msg: str | None = ...) -> None: ... + def assertXMLNotEqual(self, xml1: str, xml2: str, msg: str | None = ...) -> None: ... class TransactionTestCase(SimpleTestCase): reset_sequences: bool = ... @@ -203,11 +201,11 @@ class TransactionTestCase(SimpleTestCase): serialized_rollback: bool = ... def assertQuerysetEqual( self, - qs: Union[Iterator[Any], List[Model], QuerySet, RawQuerySet], + qs: Iterator[Any] | List[Model] | QuerySet | RawQuerySet, values: Collection[Any], - transform: Union[Callable[[Model], Any], Type[str]] = ..., + transform: Callable[[Model], Any] | Type[str] = ..., ordered: bool = ..., - msg: Optional[str] = ..., + msg: str | None = ..., ) -> None: ... @overload def assertNumQueries(self, num: int, using: str = ...) -> _AssertNumQueriesContext: ... # type: ignore @@ -229,7 +227,7 @@ class CheckCondition: conditions: Sequence[Tuple[Callable, str]] = ... def __init__(self, *conditions: Tuple[Callable, str]) -> None: ... def add_condition(self, condition: Callable, reason: str) -> CheckCondition: ... - def __get__(self, instance: None, cls: Optional[Type[TransactionTestCase]] = ...) -> bool: ... + def __get__(self, instance: None, cls: Type[TransactionTestCase] | None = ...) -> bool: ... def skipIfDBFeature(*features: Any) -> Callable: ... def skipUnlessDBFeature(*features: Any) -> Callable: ... @@ -256,7 +254,7 @@ class LiveServerThread(threading.Thread): host: str = ... port: int = ... is_ready: threading.Event = ... - error: Optional[ImproperlyConfigured] = ... + error: ImproperlyConfigured | None = ... static_handler: Type[WSGIHandler] = ... connections_override: Dict[str, BaseDatabaseWrapper] = ... def __init__( @@ -287,4 +285,4 @@ class SerializeMixin: @classmethod def tearDownClass(cls) -> None: ... -def connections_support_transactions(aliases: Optional[Iterable[str]] = ...) -> bool: ... +def connections_support_transactions(aliases: Iterable[str] | None = ...) -> bool: ... diff --git a/django-stubs/test/utils.pyi b/django-stubs/test/utils.pyi index f318b716a..254a80b0b 100644 --- a/django-stubs/test/utils.pyi +++ b/django-stubs/test/utils.pyi @@ -13,13 +13,11 @@ from typing import ( Iterator, List, Mapping, - Optional, Protocol, Set, Tuple, Type, TypeVar, - Union, ) from django.apps.registry import Apps @@ -33,40 +31,40 @@ from django.test.testcases import SimpleTestCase from typing_extensions import SupportsIndex _TestClass = Type[SimpleTestCase] -_DecoratedTest = Union[Callable, _TestClass] +_DecoratedTest = Callable | _TestClass _C = TypeVar("_C", bound=Callable) # Any callable TZ_SUPPORT: bool = ... class Approximate: - val: Union[decimal.Decimal, float] = ... + val: decimal.Decimal | float = ... places: int = ... - def __init__(self, val: Union[Decimal, float], places: int = ...) -> None: ... + def __init__(self, val: Decimal | float, places: int = ...) -> None: ... class ContextList(List[Dict[str, Any]]): - def __getitem__(self, key: Union[str, SupportsIndex, slice]) -> Any: ... - def get(self, key: str, default: Optional[Any] = ...) -> Any: ... + def __getitem__(self, key: str | SupportsIndex | slice) -> Any: ... + def get(self, key: str, default: Any | None = ...) -> Any: ... def __contains__(self, key: object) -> bool: ... def keys(self) -> Set[str]: ... class _TestState: ... -def setup_test_environment(debug: Optional[bool] = ...) -> None: ... +def setup_test_environment(debug: bool | None = ...) -> None: ... def teardown_test_environment() -> None: ... -def get_runner(settings: LazySettings, test_runner_class: Optional[str] = ...) -> Type[DiscoverRunner]: ... +def get_runner(settings: LazySettings, test_runner_class: str | None = ...) -> Type[DiscoverRunner]: ... class TestContextDecorator: - attr_name: Optional[str] = ... - kwarg_name: Optional[str] = ... - def __init__(self, attr_name: Optional[str] = ..., kwarg_name: Optional[str] = ...) -> None: ... + attr_name: str | None = ... + kwarg_name: str | None = ... + def __init__(self, attr_name: str | None = ..., kwarg_name: str | None = ...) -> None: ... def enable(self) -> Any: ... def disable(self) -> None: ... - def __enter__(self) -> Optional[Apps]: ... + def __enter__(self) -> Apps | None: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... def decorate_class(self, cls: _TestClass) -> _TestClass: ... def decorate_callable(self, func: _C) -> _C: ... @@ -81,16 +79,16 @@ class override_settings(TestContextDecorator): class modify_settings(override_settings): wrapped: Settings - operations: List[Tuple[str, Dict[str, Union[List[str], str]]]] = ... + operations: List[Tuple[str, Dict[str, List[str] | str]]] = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... def save_options(self, test_func: _DecoratedTest) -> None: ... - options: Dict[str, List[Union[Tuple[str, str], str]]] = ... + options: Dict[str, List[Tuple[str, str] | str]] = ... class override_system_checks(TestContextDecorator): registry: CheckRegistry = ... new_checks: List[Callable] = ... - deployment_checks: Optional[List[Callable]] = ... - def __init__(self, new_checks: List[Callable], deployment_checks: Optional[List[Callable]] = ...) -> None: ... + deployment_checks: List[Callable] | None = ... + def __init__(self, new_checks: List[Callable], deployment_checks: List[Callable] | None = ...) -> None: ... old_checks: Set[Callable] = ... old_deployment_checks: Set[Callable] = ... @@ -98,7 +96,7 @@ class CaptureQueriesContext: connection: BaseDatabaseWrapper = ... force_debug_cursor: bool = ... initial_queries: int = ... - final_queries: Optional[int] = ... + final_queries: int | None = ... def __init__(self, connection: BaseDatabaseWrapper) -> None: ... def __iter__(self) -> Iterator[Dict[str, str]]: ... def __getitem__(self, index: int) -> Dict[str, str]: ... @@ -108,16 +106,16 @@ class CaptureQueriesContext: def __enter__(self) -> CaptureQueriesContext: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... class ignore_warnings(TestContextDecorator): ignore_kwargs: Dict[str, Any] = ... filter_func: Callable = ... def __init__(self, **kwargs: Any) -> None: ... - catch_warnings: ContextManager[Optional[list]] = ... + catch_warnings: ContextManager[list | None] = ... requires_tz_support: Any @@ -164,17 +162,17 @@ def dependency_ordered( test_databases: Iterable[Tuple[_Signature, _TestDatabase]], dependencies: Mapping[str, List[str]] ) -> List[Tuple[_Signature, _TestDatabase]]: ... def get_unique_databases_and_mirrors( - aliases: Optional[Set[str]] = ..., + aliases: Set[str] | None = ..., ) -> Tuple[Dict[_Signature, _TestDatabase], Dict[str, Any]]: ... def setup_databases( verbosity: int, interactive: bool, *, - time_keeper: Optional[TimeKeeperProtocol] = ..., + time_keeper: TimeKeeperProtocol | None = ..., keepdb: bool = ..., debug_sql: bool = ..., parallel: int = ..., - aliases: Optional[Mapping[str, Any]] = ..., + aliases: Mapping[str, Any] | None = ..., **kwargs: Any ) -> List[Tuple[BaseDatabaseWrapper, str, bool]]: ... def teardown_databases( @@ -183,5 +181,5 @@ def teardown_databases( def require_jinja2(test_func: _C) -> _C: ... @contextmanager def register_lookup( - field: Type[RegisterLookupMixin], *lookups: Type[Union[Lookup, Transform]], lookup_name: Optional[str] = ... + field: Type[RegisterLookupMixin], *lookups: Type[Lookup | Transform], lookup_name: str | None = ... ) -> Iterator[None]: ... diff --git a/django-stubs/urls/__init__.pyi b/django-stubs/urls/__init__.pyi index f5942362f..91104f24e 100644 --- a/django-stubs/urls/__init__.pyi +++ b/django-stubs/urls/__init__.pyi @@ -1,5 +1,3 @@ -from typing import Union - # noinspection PyUnresolvedReferences from .base import clear_script_prefix as clear_script_prefix from .base import clear_url_caches as clear_url_caches @@ -37,4 +35,4 @@ from .resolvers import get_resolver as get_resolver from .utils import get_callable as get_callable from .utils import get_mod_func as get_mod_func -_AnyURL = Union[URLPattern, URLResolver] +_AnyURL = URLPattern | URLResolver diff --git a/django-stubs/urls/base.pyi b/django-stubs/urls/base.pyi index 25f46900b..e5c72a134 100644 --- a/django-stubs/urls/base.pyi +++ b/django-stubs/urls/base.pyi @@ -1,15 +1,15 @@ -from typing import Any, Callable, Dict, Optional, Sequence, Union +from typing import Any, Callable, Dict, Sequence from django.urls.resolvers import ResolverMatch from typing_extensions import Literal -def resolve(path: str, urlconf: Optional[str] = ...) -> ResolverMatch: ... +def resolve(path: str, urlconf: str | None = ...) -> ResolverMatch: ... def reverse( - viewname: Optional[Union[Callable, str]], - urlconf: Optional[str] = ..., - args: Optional[Sequence[Any]] = ..., - kwargs: Optional[Dict[str, Any]] = ..., - current_app: Optional[str] = ..., + viewname: Callable | str | None, + urlconf: str | None = ..., + args: Sequence[Any] | None = ..., + kwargs: Dict[str, Any] | None = ..., + current_app: str | None = ..., ) -> str: ... reverse_lazy: Any @@ -18,7 +18,7 @@ def clear_url_caches() -> None: ... def set_script_prefix(prefix: str) -> None: ... def get_script_prefix() -> str: ... def clear_script_prefix() -> None: ... -def set_urlconf(urlconf_name: Optional[str]) -> None: ... -def get_urlconf(default: Optional[str] = ...) -> Optional[str]: ... -def is_valid_path(path: str, urlconf: Optional[str] = ...) -> Union[Literal[False], ResolverMatch]: ... +def set_urlconf(urlconf_name: str | None) -> None: ... +def get_urlconf(default: str | None = ...) -> str | None: ... +def is_valid_path(path: str, urlconf: str | None = ...) -> Literal[False] | ResolverMatch: ... def translate_url(url: str, lang_code: str) -> str: ... diff --git a/django-stubs/urls/conf.pyi b/django-stubs/urls/conf.pyi index 47cd6b4f1..e46a1232d 100644 --- a/django-stubs/urls/conf.pyi +++ b/django-stubs/urls/conf.pyi @@ -1,16 +1,16 @@ from types import ModuleType -from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Union, overload +from typing import Any, Callable, Dict, Sequence, Tuple, overload from django.urls import URLPattern, URLResolver, _AnyURL from ..conf.urls import IncludedURLConf from ..http.response import HttpResponseBase -_URLConf = Union[str, ModuleType, Sequence[_AnyURL]] +_URLConf = str | ModuleType | Sequence[_AnyURL] def include( - arg: Union[_URLConf, tuple[_URLConf, str]], namespace: Optional[str] = ... -) -> Tuple[Sequence[Union[URLResolver, URLPattern]], Optional[str], Optional[str]]: ... + arg: _URLConf | tuple[_URLConf, str], namespace: str | None = ... +) -> Tuple[Sequence[URLResolver | URLPattern], str | None, str | None]: ... # path() @overload @@ -21,7 +21,7 @@ def path( def path(route: str, view: IncludedURLConf, kwargs: Dict[str, Any] = ..., name: str = ...) -> URLResolver: ... @overload def path( - route: str, view: Sequence[Union[URLResolver, str]], kwargs: Dict[str, Any] = ..., name: str = ... + route: str, view: Sequence[URLResolver | str], kwargs: Dict[str, Any] = ..., name: str = ... ) -> URLResolver: ... # re_path() @@ -33,5 +33,5 @@ def re_path( def re_path(route: str, view: IncludedURLConf, kwargs: Dict[str, Any] = ..., name: str = ...) -> URLResolver: ... @overload def re_path( - route: str, view: Sequence[Union[URLResolver, str]], kwargs: Dict[str, Any] = ..., name: str = ... + route: str, view: Sequence[URLResolver | str], kwargs: Dict[str, Any] = ..., name: str = ... ) -> URLResolver: ... diff --git a/django-stubs/urls/converters.pyi b/django-stubs/urls/converters.pyi index fd5d6e1fa..f8c5eb0a0 100644 --- a/django-stubs/urls/converters.pyi +++ b/django-stubs/urls/converters.pyi @@ -1,10 +1,10 @@ -from typing import Any, Dict, Type, Union +from typing import Any, Dict, Type from uuid import UUID class IntConverter: regex: str = ... def to_python(self, value: str) -> int: ... - def to_url(self, value: Union[str, int]) -> str: ... + def to_url(self, value: str | int) -> str: ... class StringConverter: regex: str = ... @@ -14,7 +14,7 @@ class StringConverter: class UUIDConverter: regex: str = ... def to_python(self, value: str) -> UUID: ... - def to_url(self, value: Union[str, UUID]) -> str: ... + def to_url(self, value: str | UUID) -> str: ... class SlugConverter(StringConverter): ... class PathConverter(StringConverter): ... diff --git a/django-stubs/urls/resolvers.pyi b/django-stubs/urls/resolvers.pyi index 52111e7b2..0756a2ee7 100644 --- a/django-stubs/urls/resolvers.pyi +++ b/django-stubs/urls/resolvers.pyi @@ -1,5 +1,5 @@ from types import ModuleType -from typing import Any, Callable, Dict, Iterator, List, Optional, Pattern, Sequence, Tuple, Type, Union, overload +from typing import Any, Callable, Dict, Iterator, List, Pattern, Sequence, Tuple, Type, overload from django.core.checks.messages import CheckMessage from django.urls import _AnyURL @@ -10,34 +10,34 @@ class ResolverMatch: func: Callable = ... args: Tuple[Any, ...] = ... kwargs: Dict[str, Any] = ... - url_name: Optional[str] = ... + url_name: str | None = ... app_names: List[str] = ... app_name: str = ... namespaces: List[str] = ... namespace: str = ... view_name: str = ... route: str = ... - tried: Optional[Any] + tried: Any | None _func_path: str def __init__( self, func: Callable, args: Tuple[Any, ...], kwargs: Dict[str, Any], - url_name: Optional[str] = ..., - app_names: Optional[List[Optional[str]]] = ..., - namespaces: Optional[List[Optional[str]]] = ..., - route: Optional[str] = ..., - tried: Optional[Any] = ..., + url_name: str | None = ..., + app_names: List[str | None] | None = ..., + namespaces: List[str | None] | None = ..., + route: str | None = ..., + tried: Any | None = ..., ) -> None: ... def __getitem__(self, index: int) -> Any: ... # for tuple unpacking def __iter__(self) -> Iterator[Any]: ... -def get_resolver(urlconf: Optional[str] = ...) -> URLResolver: ... +def get_resolver(urlconf: str | None = ...) -> URLResolver: ... def get_ns_resolver(ns_pattern: str, resolver: URLResolver, converters: Tuple) -> URLResolver: ... -_Pattern = Union[RegexPattern, RoutePattern, LocalePrefixPattern] +_Pattern = RegexPattern | RoutePattern | LocalePrefixPattern class LocaleRegexDescriptor: attr: str = ... @@ -52,18 +52,18 @@ class CheckURLMixin: class RegexPattern(CheckURLMixin): regex: LocaleRegexDescriptor = ... - name: Optional[str] = ... + name: str | None = ... converters: Dict[Any, Any] = ... - def __init__(self, regex: str, name: Optional[str] = ..., is_endpoint: bool = ...) -> None: ... - def match(self, path: str) -> Optional[Tuple[str, Tuple, Dict[str, str]]]: ... + def __init__(self, regex: str, name: str | None = ..., is_endpoint: bool = ...) -> None: ... + def match(self, path: str) -> Tuple[str, Tuple, Dict[str, str]] | None: ... def check(self) -> List[CheckMessage]: ... class RoutePattern(CheckURLMixin): regex: LocaleRegexDescriptor = ... - name: Optional[str] = ... + name: str | None = ... converters: Dict[str, UUIDConverter] = ... - def __init__(self, route: str, name: Optional[str] = ..., is_endpoint: bool = ...) -> None: ... - def match(self, path: str) -> Optional[Tuple[str, Tuple, Dict[str, Union[int, str]]]]: ... + def __init__(self, route: str, name: str | None = ..., is_endpoint: bool = ...) -> None: ... + def match(self, path: str) -> Tuple[str, Tuple, Dict[str, int | str]] | None: ... def check(self) -> List[CheckMessage]: ... class LocalePrefixPattern: @@ -74,43 +74,43 @@ class LocalePrefixPattern: def regex(self) -> Pattern[str]: ... @property def language_prefix(self) -> str: ... - def match(self, path: str) -> Optional[Tuple[str, Tuple, Dict[str, Any]]]: ... + def match(self, path: str) -> Tuple[str, Tuple, Dict[str, Any]] | None: ... def check(self) -> List[CheckMessage]: ... def describe(self) -> str: ... class URLPattern: pattern: _Pattern = ... callback: Callable = ... - default_args: Optional[Dict[str, str]] = ... - name: Optional[str] = ... + default_args: Dict[str, str] | None = ... + name: str | None = ... def __init__( self, pattern: _Pattern, callback: Callable, - default_args: Optional[Dict[str, str]] = ..., - name: Optional[str] = ..., + default_args: Dict[str, str] | None = ..., + name: str | None = ..., ) -> None: ... def check(self) -> List[CheckMessage]: ... - def resolve(self, path: str) -> Optional[ResolverMatch]: ... + def resolve(self, path: str) -> ResolverMatch | None: ... @property def lookup_str(self) -> str: ... class URLResolver: pattern: _Pattern = ... - urlconf_name: Union[str, None, Sequence[_AnyURL]] = ... + urlconf_name: str | None | Sequence[_AnyURL] = ... callback: None = ... default_kwargs: Dict[str, Any] = ... - namespace: Optional[str] = ... - app_name: Optional[str] = ... + namespace: str | None = ... + app_name: str | None = ... _local: Any _reverse_dict: MultiValueDict def __init__( self, pattern: _Pattern, - urlconf_name: Union[str, None, Sequence[_AnyURL]], - default_kwargs: Optional[Dict[str, Any]] = ..., - app_name: Optional[str] = ..., - namespace: Optional[str] = ..., + urlconf_name: str | None | Sequence[_AnyURL], + default_kwargs: Dict[str, Any] | None = ..., + app_name: str | None = ..., + namespace: str | None = ..., ) -> None: ... @property def reverse_dict(self) -> MultiValueDict: ... @@ -119,7 +119,7 @@ class URLResolver: @property def app_dict(self) -> Dict[str, List[str]]: ... @property - def urlconf_module(self) -> Union[ModuleType, None, Sequence[_AnyURL]]: ... + def urlconf_module(self) -> ModuleType | None | Sequence[_AnyURL]: ... @property def url_patterns(self) -> List[_AnyURL]: ... def resolve(self, path: str) -> ResolverMatch: ... diff --git a/django-stubs/urls/utils.pyi b/django-stubs/urls/utils.pyi index 79349df67..f92d5b271 100644 --- a/django-stubs/urls/utils.pyi +++ b/django-stubs/urls/utils.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Tuple, Union +from typing import Callable, Tuple -def get_callable(lookup_view: Union[Callable, str]) -> Callable: ... +def get_callable(lookup_view: Callable | str) -> Callable: ... def get_mod_func(callback: str) -> Tuple[str, str]: ... diff --git a/django-stubs/utils/_os.pyi b/django-stubs/utils/_os.pyi index 52b452d92..011894a90 100644 --- a/django-stubs/utils/_os.pyi +++ b/django-stubs/utils/_os.pyi @@ -1,9 +1,8 @@ import os from pathlib import Path -from typing import Union -_PathCompatible = Union[str, os.PathLike[str]] +_PathCompatible = str | os.PathLike[str] def safe_join(base: _PathCompatible, *paths: _PathCompatible) -> str: ... def symlinks_supported() -> bool: ... -def to_path(value: Union[Path, str]) -> Path: ... +def to_path(value: Path | str) -> Path: ... diff --git a/django-stubs/utils/archive.pyi b/django-stubs/utils/archive.pyi index c18db0887..cb58491a8 100644 --- a/django-stubs/utils/archive.pyi +++ b/django-stubs/utils/archive.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Any, Dict, Iterable, Optional, Sequence, Type +from typing import Any, Dict, Iterable, Sequence, Type class ArchiveException(Exception): ... class UnrecognizedArchiveFormat(ArchiveException): ... @@ -11,9 +11,9 @@ class Archive: def __enter__(self) -> Archive: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - traceback: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + traceback: TracebackType | None, ) -> None: ... def extract(self, to_path: str) -> None: ... def list(self) -> None: ... diff --git a/django-stubs/utils/autoreload.pyi b/django-stubs/utils/autoreload.pyi index e1031fe8f..1c259eb07 100644 --- a/django-stubs/utils/autoreload.pyi +++ b/django-stubs/utils/autoreload.pyi @@ -1,7 +1,7 @@ import threading import types from pathlib import Path -from typing import Any, Callable, Dict, FrozenSet, Iterable, Iterator, List, Optional, Set, Tuple +from typing import Any, Callable, Dict, FrozenSet, Iterable, Iterator, List, Set, Tuple from django.apps.registry import Apps from django.dispatch import Signal @@ -40,7 +40,7 @@ class BaseReloader: def run_loop(self) -> None: ... def tick(self) -> Iterator[None]: ... @classmethod - def check_availability(cls) -> Optional[bool]: ... + def check_availability(cls) -> bool | None: ... def notify_file_changed(self, path: _PathCompatible) -> None: ... @property def should_stop(self) -> bool: ... @@ -63,7 +63,7 @@ class WatchmanReloader(BaseReloader): def watched_roots(self, watched_files: Iterable[Path]) -> FrozenSet[Path]: ... def update_watches(self) -> None: ... def request_processed(self, **kwargs: Any) -> None: ... - def check_server_status(self, inner_ex: Optional[BaseException] = ...) -> bool: ... + def check_server_status(self, inner_ex: BaseException | None = ...) -> bool: ... @classmethod def check_availability(cls) -> None: ... def stop(self) -> None: ... diff --git a/django-stubs/utils/baseconv.pyi b/django-stubs/utils/baseconv.pyi index 6c3bd02e9..6b2b34e03 100644 --- a/django-stubs/utils/baseconv.pyi +++ b/django-stubs/utils/baseconv.pyi @@ -1,4 +1,4 @@ -from typing import Tuple, Union +from typing import Tuple BASE2_ALPHABET: str BASE16_ALPHABET: str @@ -14,7 +14,7 @@ class BaseConverter: def __init__(self, digits: str, sign: str = ...) -> None: ... def encode(self, i: int) -> str: ... def decode(self, s: str) -> int: ... - def convert(self, number: Union[int, str], from_digits: str, to_digits: str, sign: str) -> Tuple[int, str]: ... + def convert(self, number: int | str, from_digits: str, to_digits: str, sign: str) -> Tuple[int, str]: ... base2: BaseConverter base16: BaseConverter diff --git a/django-stubs/utils/cache.pyi b/django-stubs/utils/cache.pyi index c8a94f62c..b30ecd842 100644 --- a/django-stubs/utils/cache.pyi +++ b/django-stubs/utils/cache.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Tuple +from typing import Any, Tuple from django.core.cache.backends.base import BaseCache from django.http.request import HttpRequest @@ -7,25 +7,25 @@ from django.http.response import HttpResponse, HttpResponseBase cc_delim_re: Any def patch_cache_control(response: HttpResponseBase, **kwargs: Any) -> None: ... -def get_max_age(response: HttpResponse) -> Optional[int]: ... +def get_max_age(response: HttpResponse) -> int | None: ... def set_response_etag(response: HttpResponseBase) -> HttpResponseBase: ... def get_conditional_response( request: HttpRequest, - etag: Optional[str] = ..., - last_modified: Optional[int] = ..., - response: Optional[HttpResponse] = ..., -) -> Optional[HttpResponse]: ... -def patch_response_headers(response: HttpResponseBase, cache_timeout: Optional[int] = ...) -> None: ... + etag: str | None = ..., + last_modified: int | None = ..., + response: HttpResponse | None = ..., +) -> HttpResponse | None: ... +def patch_response_headers(response: HttpResponseBase, cache_timeout: int | None = ...) -> None: ... def add_never_cache_headers(response: HttpResponseBase) -> None: ... def patch_vary_headers(response: HttpResponseBase, newheaders: Tuple[str]) -> None: ... def has_vary_header(response: HttpResponse, header_query: str) -> bool: ... def get_cache_key( - request: HttpRequest, key_prefix: Optional[str] = ..., method: str = ..., cache: Optional[BaseCache] = ... -) -> Optional[str]: ... + request: HttpRequest, key_prefix: str | None = ..., method: str = ..., cache: BaseCache | None = ... +) -> str | None: ... def learn_cache_key( request: HttpRequest, response: HttpResponse, - cache_timeout: Optional[float] = ..., - key_prefix: Optional[str] = ..., - cache: Optional[BaseCache] = ..., + cache_timeout: float | None = ..., + key_prefix: str | None = ..., + cache: BaseCache | None = ..., ) -> str: ... diff --git a/django-stubs/utils/connection.pyi b/django-stubs/utils/connection.pyi index 681b91379..873b6715c 100644 --- a/django-stubs/utils/connection.pyi +++ b/django-stubs/utils/connection.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Generic, Iterator, Mapping, Optional, Sequence, Type, TypeVar +from typing import Any, Dict, Generic, Iterator, Mapping, Sequence, Type, TypeVar class ConnectionProxy: def __init__(self, connections: Mapping[str, Any], alias: str) -> None: ... @@ -13,13 +13,13 @@ class ConnectionDoesNotExist(Exception): ... _T = TypeVar("_T") class BaseConnectionHandler(Generic[_T]): - settings_name: Optional[str] = ... + settings_name: str | None = ... exception_class: Type[Exception] = ... thread_critical: bool = ... - def __init__(self, settings: Optional[Any] = ...) -> None: ... + def __init__(self, settings: Any | None = ...) -> None: ... @property def settings(self) -> Dict[str, Any]: ... - def configure_settings(self, settings: Optional[Dict[str, Any]]) -> Dict[str, Any]: ... + def configure_settings(self, settings: Dict[str, Any] | None) -> Dict[str, Any]: ... def create_connection(self, alias: str) -> _T: ... def __getitem__(self, alias: str) -> _T: ... def __setitem__(self, key: str, value: _T) -> None: ... diff --git a/django-stubs/utils/crypto.pyi b/django-stubs/utils/crypto.pyi index bc7dbaa16..68d7c82ac 100644 --- a/django-stubs/utils/crypto.pyi +++ b/django-stubs/utils/crypto.pyi @@ -1,22 +1,18 @@ from hmac import HMAC -from typing import Callable, Optional, Union +from typing import Callable using_sysrandom: bool RANDOM_STRING_CHARS: str def salted_hmac( - key_salt: Union[bytes, str], - value: Union[bytes, str], - secret: Optional[Union[bytes, str]] = ..., - *, - algorithm: str = ... + key_salt: bytes | str, value: bytes | str, secret: bytes | str | None = ..., *, algorithm: str = ... ) -> HMAC: ... def get_random_string(length: int = ..., allowed_chars: str = ...) -> str: ... -def constant_time_compare(val1: Union[bytes, str], val2: Union[bytes, str]) -> bool: ... +def constant_time_compare(val1: bytes | str, val2: bytes | str) -> bool: ... def pbkdf2( - password: Union[bytes, str], - salt: Union[bytes, str], + password: bytes | str, + salt: bytes | str, iterations: int, dklen: int = ..., - digest: Optional[Callable] = ..., + digest: Callable | None = ..., ) -> bytes: ... diff --git a/django-stubs/utils/datastructures.pyi b/django-stubs/utils/datastructures.pyi index 3fc57fd54..b3419bbc3 100644 --- a/django-stubs/utils/datastructures.pyi +++ b/django-stubs/utils/datastructures.pyi @@ -8,10 +8,8 @@ from typing import ( List, Mapping, MutableSet, - Optional, Tuple, TypeVar, - Union, overload, ) @@ -24,7 +22,7 @@ _I = TypeVar("_I", covariant=True) # Unfortunately, there's often check `if isinstance(var, (list, tuple))` in django # codebase. So we need sometimes to declare exactly list or tuple. -_ListOrTuple = Union[List[_K], Tuple[_K, ...], Tuple[()]] +_ListOrTuple = List[_K] | Tuple[_K, ...] | Tuple[()] class _PropertyDescriptor(Generic[_K, _V]): """ @@ -45,7 +43,7 @@ class _PropertyDescriptor(Generic[_K, _V]): content = property(_get_content, _set_content) """ - def __get__(self, instance: Any, owner: Optional[Any]) -> _V: ... + def __get__(self, instance: Any, owner: Any | None) -> _V: ... def __set__(self, instance: Any, value: _K) -> None: ... _IC = TypeVar("_IC", bound="_IndexableCollection") @@ -58,7 +56,7 @@ class _IndexableCollection(Protocol[_I], Collection[_I]): class OrderedSet(MutableSet[_K]): dict: Dict[_K, None] = ... - def __init__(self, iterable: Optional[Iterable[_K]] = ...) -> None: ... + def __init__(self, iterable: Iterable[_K] | None = ...) -> None: ... def __contains__(self, item: object) -> bool: ... def __iter__(self) -> Iterator[_K]: ... def __bool__(self) -> bool: ... @@ -73,30 +71,30 @@ _D = TypeVar("_D", bound="MultiValueDict") class MultiValueDict(Dict[_K, _V]): @overload - def __init__(self, key_to_list_mapping: Mapping[_K, Optional[List[_V]]] = ...) -> None: ... + def __init__(self, key_to_list_mapping: Mapping[_K, List[_V] | None] = ...) -> None: ... @overload def __init__(self, key_to_list_mapping: Iterable[Tuple[_K, List[_V]]] = ...) -> None: ... @overload - def get(self, key: _K) -> Optional[_V]: ... + def get(self, key: _K) -> _V | None: ... @overload - def get(self, key: _K, default: _Z = ...) -> Union[_V, _Z]: ... - def getlist(self, key: _K, default: _Z = ...) -> Union[List[_V], _Z]: ... + def get(self, key: _K, default: _Z = ...) -> _V | _Z: ... + def getlist(self, key: _K, default: _Z = ...) -> List[_V] | _Z: ... def setlist(self, key: _K, list_: List[_V]) -> None: ... def setdefault(self, key: _K, default: _V = ...) -> _V: ... - def setlistdefault(self, key: _K, default_list: Optional[List[_V]] = ...) -> List[_V]: ... + def setlistdefault(self, key: _K, default_list: List[_V] | None = ...) -> List[_V]: ... def appendlist(self, key: _K, value: _V) -> None: ... - def items(self) -> Iterator[Tuple[_K, Union[_V, List[object]]]]: ... # type: ignore + def items(self) -> Iterator[Tuple[_K, _V | List[object]]]: ... # type: ignore def lists(self) -> Iterable[Tuple[_K, List[_V]]]: ... - def dict(self) -> Dict[_K, Union[_V, List[object]]]: ... + def dict(self) -> Dict[_K, _V | List[object]]: ... def copy(self: _D) -> _D: ... - def __getitem__(self, key: _K) -> Union[_V, List[object]]: ... # type: ignore + def __getitem__(self, key: _K) -> _V | List[object]: ... # type: ignore def __setitem__(self, key: _K, value: _V) -> None: ... # These overrides are needed to convince mypy that this isn't an abstract class def __delitem__(self, item: _K) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_K]: ... # Fake to make `values` work properly - def values(self) -> Iterator[Union[_V, List[object]]]: ... # type: ignore[override] + def values(self) -> Iterator[_V | List[object]]: ... # type: ignore[override] class ImmutableList(Tuple[_V, ...]): warning: str = ... @@ -121,7 +119,7 @@ _T = TypeVar("_T", bound="CaseInsensitiveMapping") class CaseInsensitiveMapping(Mapping[str, _V]): _store: Dict[str, Tuple[str, _V]] - def __init__(self, data: Union[Mapping[str, _V], Iterable[Tuple[str, _V]]]) -> None: ... + def __init__(self, data: Mapping[str, _V] | Iterable[Tuple[str, _V]]) -> None: ... def __getitem__(self, key: str) -> _V: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[str]: ... diff --git a/django-stubs/utils/dateformat.pyi b/django-stubs/utils/dateformat.pyi index 9b6919b69..dd6812ccf 100644 --- a/django-stubs/utils/dateformat.pyi +++ b/django-stubs/utils/dateformat.pyi @@ -1,7 +1,7 @@ from datetime import date from datetime import datetime as builtin_datetime from datetime import time as builtin_time -from typing import Any, Optional, Pattern, Union +from typing import Any, Pattern from django.utils.timezone import _TzInfoT from typing_extensions import Literal @@ -13,13 +13,13 @@ class Formatter: def format(self, formatstr: str) -> str: ... class TimeFormat(Formatter): - data: Union[builtin_datetime, builtin_time] = ... - timezone: Optional[_TzInfoT] = ... - def __init__(self, obj: Union[builtin_datetime, builtin_time]) -> None: ... + data: builtin_datetime | builtin_time = ... + timezone: _TzInfoT | None = ... + def __init__(self, obj: builtin_datetime | builtin_time) -> None: ... def a(self) -> str: ... def A(self) -> str: ... def e(self) -> str: ... - def f(self) -> Union[int, str]: ... + def f(self) -> int | str: ... def g(self) -> int: ... def G(self) -> int: ... def h(self) -> str: ... @@ -30,13 +30,13 @@ class TimeFormat(Formatter): def s(self) -> str: ... def T(self) -> str: ... def u(self) -> str: ... - def Z(self) -> Union[int, Literal[""]]: ... + def Z(self) -> int | Literal[""]: ... class DateFormat(TimeFormat): - data: Union[builtin_datetime, date, builtin_time] # type: ignore - timezone: Optional[_TzInfoT] + data: builtin_datetime | date | builtin_time # type: ignore + timezone: _TzInfoT | None year_days: Any = ... - def __init__(self, obj: Union[builtin_datetime, builtin_time, date]) -> None: ... + def __init__(self, obj: builtin_datetime | builtin_time | date) -> None: ... def b(self) -> str: ... def c(self) -> str: ... def d(self) -> str: ... @@ -62,5 +62,5 @@ class DateFormat(TimeFormat): def Y(self) -> int: ... def z(self) -> int: ... -def format(value: Union[builtin_datetime, date, builtin_time], format_string: str) -> str: ... -def time_format(value: Union[builtin_datetime, builtin_time], format_string: str) -> str: ... +def format(value: builtin_datetime | date | builtin_time, format_string: str) -> str: ... +def time_format(value: builtin_datetime | builtin_time, format_string: str) -> str: ... diff --git a/django-stubs/utils/dateparse.pyi b/django-stubs/utils/dateparse.pyi index 4dfe52cb3..ab3b661fc 100644 --- a/django-stubs/utils/dateparse.pyi +++ b/django-stubs/utils/dateparse.pyi @@ -1,7 +1,7 @@ from datetime import date from datetime import datetime as builtin_datetime from datetime import time, timedelta -from typing import Optional, Pattern +from typing import Pattern date_re: Pattern[str] time_re: Pattern[str] @@ -10,7 +10,7 @@ standard_duration_re: Pattern[str] iso8601_duration_re: Pattern[str] postgres_interval_re: Pattern[str] -def parse_date(value: str) -> Optional[date]: ... -def parse_time(value: str) -> Optional[time]: ... -def parse_datetime(value: str) -> Optional[builtin_datetime]: ... -def parse_duration(value: str) -> Optional[timedelta]: ... +def parse_date(value: str) -> date | None: ... +def parse_time(value: str) -> time | None: ... +def parse_datetime(value: str) -> builtin_datetime | None: ... +def parse_duration(value: str) -> timedelta | None: ... diff --git a/django-stubs/utils/datetime_safe.pyi b/django-stubs/utils/datetime_safe.pyi index 095683afd..c44ae436b 100644 --- a/django-stubs/utils/datetime_safe.pyi +++ b/django-stubs/utils/datetime_safe.pyi @@ -1,12 +1,11 @@ from datetime import date as real_date from datetime import datetime as real_datetime from datetime import time as real_time -from typing import Union class date(real_date): ... class datetime(real_datetime): ... class time(real_time): ... def new_date(d: real_date) -> date: ... -def new_datetime(d: Union[real_date, real_datetime]) -> datetime: ... -def strftime(dt: Union[real_date, real_datetime], fmt: str) -> str: ... +def new_datetime(d: real_date | real_datetime) -> datetime: ... +def strftime(dt: real_date | real_datetime, fmt: str) -> str: ... diff --git a/django-stubs/utils/deconstruct.pyi b/django-stubs/utils/deconstruct.pyi index bc9d638b1..9198d95ec 100644 --- a/django-stubs/utils/deconstruct.pyi +++ b/django-stubs/utils/deconstruct.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Optional, TypeVar, overload +from typing import Any, Callable, TypeVar, overload _T = TypeVar("_T") _TCallable = TypeVar("_TCallable", bound=Callable[..., Any]) @@ -6,4 +6,4 @@ _TCallable = TypeVar("_TCallable", bound=Callable[..., Any]) @overload def deconstructible(_type: type[_T]) -> type[_T]: ... @overload -def deconstructible(*, path: Optional[str] = ...) -> Callable[[_TCallable], _TCallable]: ... +def deconstructible(*, path: str | None = ...) -> Callable[[_TCallable], _TCallable]: ... diff --git a/django-stubs/utils/decorators.pyi b/django-stubs/utils/decorators.pyi index 293e61803..f458ecb08 100644 --- a/django-stubs/utils/decorators.pyi +++ b/django-stubs/utils/decorators.pyi @@ -1,15 +1,15 @@ -from typing import Callable, Iterable, Type, TypeVar, Union +from typing import Callable, Iterable, Type, TypeVar from django.utils.deprecation import MiddlewareMixin from django.utils.functional import classproperty as classproperty from django.views.generic.base import View -_T = TypeVar("_T", bound=Union[View, Callable]) # Any callable +_T = TypeVar("_T", bound=View | Callable) # Any callable _CallableType = TypeVar("_CallableType", bound=Callable) class classonlymethod(classmethod): ... -def method_decorator(decorator: Union[Callable, Iterable[Callable]], name: str = ...) -> Callable[[_T], _T]: ... +def method_decorator(decorator: Callable | Iterable[Callable], name: str = ...) -> Callable[[_T], _T]: ... def decorator_from_middleware_with_args(middleware_class: type) -> Callable: ... def decorator_from_middleware(middleware_class: type) -> Callable: ... def make_middleware_decorator(middleware_class: Type[MiddlewareMixin]) -> Callable: ... diff --git a/django-stubs/utils/deprecation.pyi b/django-stubs/utils/deprecation.pyi index 366dbc8fb..f7d5354c8 100644 --- a/django-stubs/utils/deprecation.pyi +++ b/django-stubs/utils/deprecation.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Optional, Protocol, Type +from typing import Any, Callable, Protocol, Type from django.http.request import HttpRequest from django.http.response import HttpResponse diff --git a/django-stubs/utils/encoding.pyi b/django-stubs/utils/encoding.pyi index 34388e910..3b2ead945 100644 --- a/django-stubs/utils/encoding.pyi +++ b/django-stubs/utils/encoding.pyi @@ -1,6 +1,6 @@ import datetime from decimal import Decimal -from typing import Any, TypeVar, Union, overload +from typing import Any, TypeVar, overload from django.utils.functional import Promise from typing_extensions import Literal, TypeGuard @@ -64,7 +64,7 @@ def force_bytes(s: Any, encoding: str = ..., strings_only: bool = ..., errors: s @overload def iri_to_uri(iri: None) -> None: ... @overload -def iri_to_uri(iri: Union[str, Promise]) -> str: ... +def iri_to_uri(iri: str | Promise) -> str: ... @overload def uri_to_iri(uri: None) -> None: ... # type: ignore @overload diff --git a/django-stubs/utils/feedgenerator.pyi b/django-stubs/utils/feedgenerator.pyi index 097854844..c25036a2e 100644 --- a/django-stubs/utils/feedgenerator.pyi +++ b/django-stubs/utils/feedgenerator.pyi @@ -1,10 +1,10 @@ import datetime -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import Any, Dict, List, Tuple from xml.sax import ContentHandler def rfc2822_date(date: datetime.date) -> str: ... def rfc3339_date(date: datetime.date) -> str: ... -def get_tag_uri(url: str, date: Optional[datetime.date]) -> str: ... +def get_tag_uri(url: str, date: datetime.date | None) -> str: ... class SyndicationFeed: feed: Dict[str, Any] = ... @@ -13,17 +13,17 @@ class SyndicationFeed: self, title: str, link: str, - description: Optional[str], - language: Optional[str] = ..., - author_email: Optional[str] = ..., - author_name: Optional[str] = ..., - author_link: Optional[str] = ..., - subtitle: Optional[str] = ..., - categories: Optional[Tuple[str, str]] = ..., - feed_url: Optional[str] = ..., - feed_copyright: Optional[str] = ..., - feed_guid: Optional[str] = ..., - ttl: Optional[int] = ..., + description: str | None, + language: str | None = ..., + author_email: str | None = ..., + author_name: str | None = ..., + author_link: str | None = ..., + subtitle: str | None = ..., + categories: Tuple[str, str] | None = ..., + feed_url: str | None = ..., + feed_copyright: str | None = ..., + feed_guid: str | None = ..., + ttl: int | None = ..., **kwargs: Any ) -> None: ... def add_item( @@ -31,18 +31,18 @@ class SyndicationFeed: title: str, link: str, description: str, - author_email: Optional[str] = ..., - author_name: Optional[str] = ..., - author_link: Optional[str] = ..., - pubdate: Optional[datetime.datetime] = ..., - comments: Optional[str] = ..., - unique_id: Optional[str] = ..., - unique_id_is_permalink: Optional[bool] = ..., - categories: Optional[Tuple] = ..., - item_copyright: Optional[str] = ..., - ttl: Optional[int] = ..., - updateddate: Optional[datetime.datetime] = ..., - enclosures: Optional[List[Enclosure]] = ..., + author_email: str | None = ..., + author_name: str | None = ..., + author_link: str | None = ..., + pubdate: datetime.datetime | None = ..., + comments: str | None = ..., + unique_id: str | None = ..., + unique_id_is_permalink: bool | None = ..., + categories: Tuple | None = ..., + item_copyright: str | None = ..., + ttl: int | None = ..., + updateddate: datetime.datetime | None = ..., + enclosures: List[Enclosure] | None = ..., **kwargs: Any ) -> None: ... def num_items(self) -> int: ... @@ -58,7 +58,7 @@ class Enclosure: length: Any mime_type: str url: str = ... - def __init__(self, url: str, length: Union[int, str], mime_type: str) -> None: ... + def __init__(self, url: str, length: int | str, mime_type: str) -> None: ... class RssFeed(SyndicationFeed): content_type: str = ... diff --git a/django-stubs/utils/formats.pyi b/django-stubs/utils/formats.pyi index cc4b0f627..02c100029 100644 --- a/django-stubs/utils/formats.pyi +++ b/django-stubs/utils/formats.pyi @@ -3,30 +3,24 @@ from datetime import date from datetime import datetime as builtin_datetime from datetime import time from decimal import Decimal -from typing import Any, Dict, FrozenSet, Iterator, List, Optional, TypeVar, Union, overload +from typing import Any, Dict, FrozenSet, Iterator, List, TypeVar, overload ISO_INPUT_FORMATS: Dict[str, List[str]] FORMAT_SETTINGS: FrozenSet[str] def reset_format_cache() -> None: ... -def iter_format_modules( - lang: str, format_module_path: Optional[Union[List[str], str]] = ... -) -> Iterator[types.ModuleType]: ... -def get_format_modules(lang: Optional[str] = ..., reverse: bool = ...) -> List[types.ModuleType]: ... -def get_format(format_type: str, lang: Optional[str] = ..., use_l10n: Optional[bool] = ...) -> Any: ... +def iter_format_modules(lang: str, format_module_path: List[str] | str | None = ...) -> Iterator[types.ModuleType]: ... +def get_format_modules(lang: str | None = ..., reverse: bool = ...) -> List[types.ModuleType]: ... +def get_format(format_type: str, lang: str | None = ..., use_l10n: bool | None = ...) -> Any: ... get_format_lazy: Any -def date_format( - value: Union[date, builtin_datetime, str], format: Optional[str] = ..., use_l10n: Optional[bool] = ... -) -> str: ... -def time_format( - value: Union[time, builtin_datetime, str], format: Optional[str] = ..., use_l10n: Optional[bool] = ... -) -> str: ... +def date_format(value: date | builtin_datetime | str, format: str | None = ..., use_l10n: bool | None = ...) -> str: ... +def time_format(value: time | builtin_datetime | str, format: str | None = ..., use_l10n: bool | None = ...) -> str: ... def number_format( - value: Union[Decimal, float, str], - decimal_pos: Optional[int] = ..., - use_l10n: Optional[bool] = ..., + value: Decimal | float | str, + decimal_pos: int | None = ..., + use_l10n: bool | None = ..., force_grouping: bool = ..., ) -> str: ... @@ -37,14 +31,14 @@ _T = TypeVar("_T") # while type of others is preserved) @overload def localize( # type: ignore - value: Union[builtin_datetime, date, time, Decimal, float, str], use_l10n: Optional[bool] = ... + value: builtin_datetime | date | time | Decimal | float | str, use_l10n: bool | None = ... ) -> str: ... @overload -def localize(value: _T, use_l10n: Optional[bool] = ...) -> _T: ... +def localize(value: _T, use_l10n: bool | None = ...) -> _T: ... @overload def localize_input( # type: ignore - value: Union[builtin_datetime, date, time, Decimal, float, str], default: Optional[str] = ... + value: builtin_datetime | date | time | Decimal | float | str, default: str | None = ... ) -> str: ... @overload -def localize_input(value: _T, default: Optional[str] = ...) -> _T: ... +def localize_input(value: _T, default: str | None = ...) -> _T: ... def sanitize_separators(value: _T) -> _T: ... diff --git a/django-stubs/utils/functional.pyi b/django-stubs/utils/functional.pyi index 56b3ef7ab..0e5780ebc 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -1,5 +1,5 @@ from functools import wraps as wraps # noqa: F401 -from typing import Any, Callable, Generic, List, Optional, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Generic, List, Sequence, Tuple, Type, TypeVar, overload from django.db.models.base import Model from typing_extensions import Protocol, SupportsIndex @@ -43,7 +43,7 @@ class _StrPromise(Promise, Sequence[str]): # Mypy requires this for the attribute hook to take effect def __getattribute__(self, __name: str) -> Any: ... -_StrOrPromise = Union[str, _StrPromise] +_StrOrPromise = str | _StrPromise _C = TypeVar("_C", bound=Callable) def lazy(func: _C, *resultclasses: Any) -> _C: ... @@ -83,16 +83,16 @@ class SimpleLazyObject(LazyObject): _PartitionMember = TypeVar("_PartitionMember") def partition( - predicate: Callable[[_PartitionMember], Union[int, bool]], values: List[_PartitionMember] + predicate: Callable[[_PartitionMember], int | bool], values: List[_PartitionMember] ) -> Tuple[List[_PartitionMember], List[_PartitionMember]]: ... _Get = TypeVar("_Get", covariant=True) _Self = TypeVar("_Self") class classproperty(Generic[_Get]): - fget: Optional[Callable[[_Self], _Get]] = ... - def __init__(self, method: Optional[Callable[[_Self], _Get]] = ...) -> None: ... - def __get__(self, instance: Optional[_Self], cls: Type[_Self] = ...) -> _Get: ... + fget: Callable[[_Self], _Get] | None = ... + def __init__(self, method: Callable[[_Self], _Get] | None = ...) -> None: ... + def __get__(self, instance: _Self | None, cls: Type[_Self] = ...) -> _Get: ... def getter(self, method: Callable[[_Self], _Get]) -> classproperty[_Get]: ... class _Getter(Protocol[_Get]): @@ -103,6 +103,6 @@ class _Getter(Protocol[_Get]): """ @overload - def __get__(self: _Self, __instance: None, __typeobj: Optional[Type[Any]]) -> _Self: ... + def __get__(self: _Self, __instance: None, __typeobj: Type[Any] | None) -> _Self: ... @overload - def __get__(self, __instance: Any, __typeobj: Optional[Type[Any]]) -> _Get: ... + def __get__(self, __instance: Any, __typeobj: Type[Any] | None) -> _Get: ... diff --git a/django-stubs/utils/html.pyi b/django-stubs/utils/html.pyi index e5b0dc3d4..2645bcb02 100644 --- a/django-stubs/utils/html.pyi +++ b/django-stubs/utils/html.pyi @@ -1,5 +1,5 @@ from html.parser import HTMLParser -from typing import Any, Iterable, List, Optional, Pattern, Tuple, Type +from typing import Any, Iterable, List, Pattern, Tuple, Type from django.utils.safestring import SafeString @@ -29,6 +29,6 @@ class MLStripper(HTMLParser): def strip_tags(value: str) -> str: ... def strip_spaces_between_tags(value: str) -> str: ... def smart_urlquote(url: str) -> str: ... -def urlize(text: str, trim_url_limit: Optional[int] = ..., nofollow: bool = ..., autoescape: bool = ...) -> str: ... +def urlize(text: str, trim_url_limit: int | None = ..., nofollow: bool = ..., autoescape: bool = ...) -> str: ... def avoid_wrapping(value: str) -> str: ... def html_safe(klass: Type) -> Type: ... diff --git a/django-stubs/utils/http.pyi b/django-stubs/utils/http.pyi index bd0c3eaca..ae3df78fc 100644 --- a/django-stubs/utils/http.pyi +++ b/django-stubs/utils/http.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, Optional, Pattern, Tuple, Union +from typing import Any, Iterable, List, Pattern, Tuple ETAG_MATCH: Pattern[str] MONTHS: List[str] @@ -13,9 +13,9 @@ def urlquote_plus(url: str, safe: str = ...) -> str: ... def urlunquote(quoted_url: str) -> str: ... def urlunquote_plus(quoted_url: str) -> str: ... def urlencode(query: Any, doseq: bool = ...) -> str: ... -def http_date(epoch_seconds: Optional[float] = ...) -> str: ... +def http_date(epoch_seconds: float | None = ...) -> str: ... def parse_http_date(date: str) -> int: ... -def parse_http_date_safe(date: str) -> Optional[int]: ... +def parse_http_date_safe(date: str) -> int | None: ... def base36_to_int(s: str) -> int: ... def int_to_base36(i: int) -> str: ... def urlsafe_base64_encode(s: bytes) -> str: ... @@ -24,18 +24,16 @@ def parse_etags(etag_str: str) -> List[str]: ... def quote_etag(etag_str: str) -> str: ... def is_same_domain(host: str, pattern: str) -> bool: ... def url_has_allowed_host_and_scheme( - url: Optional[str], allowed_hosts: Optional[Union[str, Iterable[str]]], require_https: bool = ... -) -> bool: ... -def is_safe_url( - url: Optional[str], allowed_hosts: Optional[Union[str, Iterable[str]]], require_https: bool = ... + url: str | None, allowed_hosts: str | Iterable[str] | None, require_https: bool = ... ) -> bool: ... +def is_safe_url(url: str | None, allowed_hosts: str | Iterable[str] | None, require_https: bool = ...) -> bool: ... def parse_qsl( qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ..., - max_num_fields: Optional[int] = ..., + max_num_fields: int | None = ..., separator: str = ..., ) -> List[Tuple[str, str]]: ... def escape_leading_slashes(url: str) -> str: ... diff --git a/django-stubs/utils/inspect.pyi b/django-stubs/utils/inspect.pyi index 79fe0a9f9..9f9509124 100644 --- a/django-stubs/utils/inspect.pyi +++ b/django-stubs/utils/inspect.pyi @@ -1,7 +1,7 @@ -from typing import Any, Callable, List, Tuple, Union +from typing import Any, Callable, List, Tuple def get_func_args(func: Callable[..., Any]) -> List[str]: ... -def get_func_full_args(func: Callable[..., Any]) -> List[Union[Tuple[str, str], Tuple[str]]]: ... +def get_func_full_args(func: Callable[..., Any]) -> List[Tuple[str, str] | Tuple[str]]: ... def func_accepts_kwargs(func: Callable[..., Any]) -> bool: ... def func_accepts_var_args(func: Callable[..., Any]) -> bool: ... def method_has_no_args(meth: Callable[..., Any]) -> bool: ... diff --git a/django-stubs/utils/jslex.pyi b/django-stubs/utils/jslex.pyi index 77b67f3b0..db7834481 100644 --- a/django-stubs/utils/jslex.pyi +++ b/django-stubs/utils/jslex.pyi @@ -1,12 +1,12 @@ -from typing import Any, Dict, Iterator, List, Optional, Tuple +from typing import Any, Dict, Iterator, List, Tuple class Tok: num: int = ... id: int = ... name: str = ... regex: str = ... - next: Optional[str] = ... - def __init__(self, name: str, regex: str, next: Optional[str] = ...) -> None: ... + next: str | None = ... + def __init__(self, name: str, regex: str, next: str | None = ...) -> None: ... def literals(choices: str, prefix: str = ..., suffix: str = ...) -> str: ... diff --git a/django-stubs/utils/log.pyi b/django-stubs/utils/log.pyi index 8dbd20218..745cb3e16 100644 --- a/django-stubs/utils/log.pyi +++ b/django-stubs/utils/log.pyi @@ -1,6 +1,6 @@ import logging.config from logging import Logger, LogRecord -from typing import Any, Callable, Dict, Optional, Union +from typing import Any, Callable, Dict from django.core.management.color import Style from django.http import HttpRequest, HttpResponse @@ -12,12 +12,12 @@ def configure_logging(logging_config: str, logging_settings: Dict[str, Any]) -> class AdminEmailHandler(logging.Handler): include_html: bool = ... - email_backend: Optional[str] = ... + email_backend: str | None = ... def __init__( self, include_html: bool = ..., - email_backend: Optional[str] = ..., - reporter_class: Optional[str] = ..., + email_backend: str | None = ..., + reporter_class: str | None = ..., ) -> None: ... def send_mail(self, subject: str, message: str, *args: Any, **kwargs: Any) -> None: ... def connection(self) -> Any: ... @@ -26,13 +26,13 @@ class AdminEmailHandler(logging.Handler): class CallbackFilter(logging.Filter): callback: Callable = ... def __init__(self, callback: Callable) -> None: ... - def filter(self, record: Union[str, LogRecord]) -> bool: ... + def filter(self, record: str | LogRecord) -> bool: ... class RequireDebugFalse(logging.Filter): - def filter(self, record: Union[str, LogRecord]) -> bool: ... + def filter(self, record: str | LogRecord) -> bool: ... class RequireDebugTrue(logging.Filter): - def filter(self, record: Union[str, LogRecord]) -> bool: ... + def filter(self, record: str | LogRecord) -> bool: ... class ServerFormatter(logging.Formatter): default_time_format: str = ... @@ -43,9 +43,9 @@ class ServerFormatter(logging.Formatter): def log_response( message: str, *args: Any, - response: Optional[HttpResponse] = ..., - request: Optional[HttpRequest] = ..., + response: HttpResponse | None = ..., + request: HttpRequest | None = ..., logger: Logger = ..., - level: Optional[str] = ..., - exception: Optional[BaseException] = ... + level: str | None = ..., + exception: BaseException | None = ... ) -> None: ... diff --git a/django-stubs/utils/numberformat.pyi b/django-stubs/utils/numberformat.pyi index a0e43c92b..18959df5b 100644 --- a/django-stubs/utils/numberformat.pyi +++ b/django-stubs/utils/numberformat.pyi @@ -1,12 +1,12 @@ from decimal import Decimal -from typing import Iterable, Optional, Union +from typing import Iterable def format( - number: Union[Decimal, float, str], + number: Decimal | float | str, decimal_sep: str, - decimal_pos: Optional[int] = ..., - grouping: Union[int, Iterable[int]] = ..., + decimal_pos: int | None = ..., + grouping: int | Iterable[int] = ..., thousand_sep: str = ..., force_grouping: bool = ..., - use_l10n: Optional[bool] = ..., + use_l10n: bool | None = ..., ) -> str: ... diff --git a/django-stubs/utils/regex_helper.pyi b/django-stubs/utils/regex_helper.pyi index d52eeb40e..f529d2a71 100644 --- a/django-stubs/utils/regex_helper.pyi +++ b/django-stubs/utils/regex_helper.pyi @@ -1,6 +1,6 @@ -from typing import Iterator, List, Mapping, Optional, Pattern, Tuple, Type, TypeVar, Union +from typing import Iterator, List, Mapping, Pattern, Tuple, Type, TypeVar -ESCAPE_MAPPINGS: Mapping[str, Union[str, None]] +ESCAPE_MAPPINGS: Mapping[str, str | None] class Choice(list): ... class Group(list): ... @@ -9,13 +9,13 @@ class NonCapture(list): ... def normalize(pattern: str) -> List[Tuple[str, List[str]]]: ... def next_char(input_iter: Iterator[str]) -> Iterator[Tuple[str, bool]]: ... def walk_to_end(ch: str, input_iter: Iterator[Tuple[str, bool]]) -> None: ... -def get_quantifier(ch: str, input_iter: Iterator[Tuple[str, bool]]) -> Tuple[int, Optional[str]]: ... -def contains(source: Union[Group, NonCapture, str], inst: Type[Group]) -> bool: ... +def get_quantifier(ch: str, input_iter: Iterator[Tuple[str, bool]]) -> Tuple[int, str | None]: ... +def contains(source: Group | NonCapture | str, inst: Type[Group]) -> bool: ... def flatten_result( - source: Optional[Union[List[Union[Choice, Group, str]], Group, NonCapture]] + source: List[Choice | Group | str] | Group | NonCapture | None, ) -> Tuple[List[str], List[List[str]]]: ... # Returns SimpleLazyObject, but we can safely ignore it _P = TypeVar("_P", str, bytes) -def _lazy_re_compile(regex: Union[_P, Pattern[_P]], flags: int = ...) -> Pattern[_P]: ... +def _lazy_re_compile(regex: _P | Pattern[_P], flags: int = ...) -> Pattern[_P]: ... diff --git a/django-stubs/utils/termcolors.pyi b/django-stubs/utils/termcolors.pyi index b28922997..3a5b74efb 100644 --- a/django-stubs/utils/termcolors.pyi +++ b/django-stubs/utils/termcolors.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, Union +from typing import Any, Callable, Dict, Mapping, Sequence, Tuple color_names: Sequence foreground: Mapping[str, str] @@ -6,7 +6,7 @@ background: Mapping[str, str] RESET: str opt_dict: Mapping[str, str] -def colorize(text: Optional[str] = ..., opts: Sequence[str] = ..., **kwargs: Any) -> str: ... +def colorize(text: str | None = ..., opts: Sequence[str] = ..., **kwargs: Any) -> str: ... def make_style(opts: Tuple = ..., **kwargs: Any) -> Callable: ... NOCOLOR_PALETTE: str @@ -15,4 +15,4 @@ LIGHT_PALETTE: str PALETTES: Any DEFAULT_PALETTE: str = ... -def parse_color_setting(config_string: str) -> Optional[Dict[str, Dict[str, Union[Tuple[str, ...], str]]]]: ... +def parse_color_setting(config_string: str) -> Dict[str, Dict[str, Tuple[str, ...] | str]] | None: ... diff --git a/django-stubs/utils/text.pyi b/django-stubs/utils/text.pyi index 2474ab79e..5548186de 100644 --- a/django-stubs/utils/text.pyi +++ b/django-stubs/utils/text.pyi @@ -1,11 +1,11 @@ from io import BytesIO -from typing import Callable, Iterable, Iterator, List, Optional, Pattern, Union +from typing import Callable, Iterable, Iterator, List, Pattern from django.db.models.base import Model from django.utils.functional import SimpleLazyObject from django.utils.safestring import SafeString -def capfirst(x: Optional[str]) -> Optional[str]: ... +def capfirst(x: str | None) -> str | None: ... re_words: Pattern[str] re_chars: Pattern[str] @@ -16,10 +16,10 @@ re_camel_case: Pattern[str] def wrap(text: str, width: int) -> str: ... class Truncator(SimpleLazyObject): - def __init__(self, text: Union[Model, str]) -> None: ... - def add_truncation_text(self, text: str, truncate: Optional[str] = ...) -> str: ... - def chars(self, num: int, truncate: Optional[str] = ..., html: bool = ...) -> str: ... - def words(self, num: int, truncate: Optional[str] = ..., html: bool = ...) -> str: ... + def __init__(self, text: Model | str) -> None: ... + def add_truncation_text(self, text: str, truncate: str | None = ...) -> str: ... + def chars(self, num: int, truncate: str | None = ..., html: bool = ...) -> str: ... + def words(self, num: int, truncate: str | None = ..., html: bool = ...) -> str: ... def get_valid_filename(name: str) -> str: ... def get_text_list(list_: List[str], last_word: str = ...) -> str: ... diff --git a/django-stubs/utils/timesince.pyi b/django-stubs/utils/timesince.pyi index ae0891f55..a04afe54f 100644 --- a/django-stubs/utils/timesince.pyi +++ b/django-stubs/utils/timesince.pyi @@ -1,16 +1,14 @@ from datetime import date -from typing import Any, Dict, Optional +from typing import Any, Dict TIME_STRINGS: Dict[str, str] TIMESINCE_CHUNKS: Any def timesince( d: date, - now: Optional[date] = ..., + now: date | None = ..., reversed: bool = ..., - time_strings: Optional[Dict[str, str]] = ..., + time_strings: Dict[str, str] | None = ..., depth: int = ..., ) -> str: ... -def timeuntil( - d: date, now: Optional[date] = ..., time_strings: Optional[Dict[str, str]] = ..., depth: int = ... -) -> str: ... +def timeuntil(d: date, now: date | None = ..., time_strings: Dict[str, str] | None = ..., depth: int = ...) -> str: ... diff --git a/django-stubs/utils/timezone.pyi b/django-stubs/utils/timezone.pyi index 9856ee2c0..5f2cf6ce8 100644 --- a/django-stubs/utils/timezone.pyi +++ b/django-stubs/utils/timezone.pyi @@ -6,18 +6,18 @@ from datetime import timedelta as timedelta from datetime import timezone from datetime import tzinfo as tzinfo from types import TracebackType -from typing import Any, Optional, Type, Union, overload +from typing import Any, Type, overload import pytz from pytz import BaseTzInfo from typing_extensions import Literal, TypeGuard -_PytzTzInfoT = Union[pytz.tzinfo.BaseTzInfo, pytz._FixedOffset] -_TzInfoT = Union[_PytzTzInfoT, tzinfo] +_PytzTzInfoT = pytz.tzinfo.BaseTzInfo | pytz._FixedOffset +_TzInfoT = _PytzTzInfoT | tzinfo utc: Any = ... -def get_fixed_timezone(offset: Union[timedelta, int]) -> timezone: ... +def get_fixed_timezone(offset: timedelta | int) -> timezone: ... def get_default_timezone() -> BaseTzInfo: ... def get_default_timezone_name() -> str: ... @@ -26,23 +26,23 @@ def get_default_timezone_name() -> str: ... # so we use it anyway, to keep things ergonomic for most users. def get_current_timezone() -> BaseTzInfo: ... def get_current_timezone_name() -> str: ... -def activate(timezone: Union[_TzInfoT, str]) -> None: ... +def activate(timezone: _TzInfoT | str) -> None: ... def deactivate() -> None: ... class override(ContextDecorator): - timezone: Optional[Union[str, _TzInfoT]] = ... - old_timezone: Optional[_TzInfoT] = ... - def __init__(self, timezone: Optional[Union[str, _TzInfoT]]) -> None: ... + timezone: str | _TzInfoT | None = ... + old_timezone: _TzInfoT | None = ... + def __init__(self, timezone: str | _TzInfoT | None) -> None: ... def __enter__(self) -> None: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... -def localtime(value: Optional[datetime] = ..., timezone: Optional[_TzInfoT] = ...) -> datetime: ... -def localdate(value: Optional[datetime] = ..., timezone: Optional[_TzInfoT] = ...) -> date: ... +def localtime(value: datetime | None = ..., timezone: _TzInfoT | None = ...) -> datetime: ... +def localdate(value: datetime | None = ..., timezone: _TzInfoT | None = ...) -> date: ... def now() -> datetime: ... @overload def is_aware(value: time) -> Literal[False]: ... @@ -52,6 +52,6 @@ def is_aware(value: datetime) -> bool: ... def is_naive(value: time) -> Literal[True]: ... @overload def is_naive(value: datetime) -> bool: ... -def make_aware(value: datetime, timezone: Optional[_TzInfoT] = ..., is_dst: Optional[bool] = ...) -> datetime: ... -def make_naive(value: datetime, timezone: Optional[_TzInfoT] = ...) -> datetime: ... +def make_aware(value: datetime, timezone: _TzInfoT | None = ..., is_dst: bool | None = ...) -> datetime: ... +def make_naive(value: datetime, timezone: _TzInfoT | None = ...) -> datetime: ... def _is_pytz_zone(tz: _TzInfoT) -> TypeGuard[_PytzTzInfoT]: ... diff --git a/django-stubs/utils/translation/__init__.pyi b/django-stubs/utils/translation/__init__.pyi index fbdc87201..e1e20642e 100644 --- a/django-stubs/utils/translation/__init__.pyi +++ b/django-stubs/utils/translation/__init__.pyi @@ -1,7 +1,7 @@ import functools from contextlib import ContextDecorator from types import TracebackType -from typing import Any, Callable, Optional, Type, Union +from typing import Any, Callable, Type from django.http.request import HttpRequest from django.utils.functional import _StrPromise @@ -35,8 +35,8 @@ def npgettext(context: str, singular: str, plural: str, number: int) -> str: ... # lazy evaluated translation functions def gettext_lazy(message: str) -> _StrPromise: ... def pgettext_lazy(context: str, message: str) -> _StrPromise: ... -def ngettext_lazy(singular: str, plural: str, number: Union[int, str, None] = ...) -> _StrPromise: ... -def npgettext_lazy(context: str, singular: str, plural: str, number: Union[int, str, None] = ...) -> _StrPromise: ... +def ngettext_lazy(singular: str, plural: str, number: int | str | None = ...) -> _StrPromise: ... +def npgettext_lazy(context: str, singular: str, plural: str, number: int | str | None = ...) -> _StrPromise: ... # NOTE: These translation functions are deprecated and removed in Django 4.0. We should remove them when we drop # support for 3.2 @@ -51,22 +51,22 @@ def activate(language: str) -> None: ... def deactivate() -> None: ... class override(ContextDecorator): - language: Optional[str] = ... + language: str | None = ... deactivate: bool = ... - def __init__(self, language: Optional[str], deactivate: bool = ...) -> None: ... - old_language: Optional[str] = ... + def __init__(self, language: str | None, deactivate: bool = ...) -> None: ... + old_language: str | None = ... def __enter__(self) -> None: ... def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + exc_tb: TracebackType | None, ) -> None: ... def get_language() -> str: ... -def get_language_from_path(path: str) -> Optional[str]: ... +def get_language_from_path(path: str) -> str | None: ... def get_language_bidi() -> bool: ... -def check_for_language(lang_code: Optional[str]) -> bool: ... +def check_for_language(lang_code: str | None) -> bool: ... def to_language(locale: str) -> str: ... def to_locale(language: str) -> str: ... def get_language_from_request(request: HttpRequest, check_path: bool = ...) -> str: ... diff --git a/django-stubs/utils/translation/reloader.pyi b/django-stubs/utils/translation/reloader.pyi index f10515283..190c7b6a3 100644 --- a/django-stubs/utils/translation/reloader.pyi +++ b/django-stubs/utils/translation/reloader.pyi @@ -1,7 +1,7 @@ from pathlib import Path -from typing import Any, Optional +from typing import Any from django.utils.autoreload import BaseReloader def watch_for_translation_changes(sender: BaseReloader, **kwargs: Any) -> None: ... -def translation_file_changed(sender: Optional[BaseReloader], file_path: Path, **kwargs: Any) -> bool: ... +def translation_file_changed(sender: BaseReloader | None, file_path: Path, **kwargs: Any) -> bool: ... diff --git a/django-stubs/utils/translation/trans_real.pyi b/django-stubs/utils/translation/trans_real.pyi index 411f25713..626be60a7 100644 --- a/django-stubs/utils/translation/trans_real.pyi +++ b/django-stubs/utils/translation/trans_real.pyi @@ -1,6 +1,6 @@ import gettext as gettext_module from gettext import NullTranslations -from typing import Any, Dict, Iterator, List, Optional, Pattern, Protocol, Tuple, TypeVar, Union +from typing import Any, Dict, Iterator, List, Pattern, Protocol, Tuple, TypeVar from django.http.request import HttpRequest from typing_extensions import Literal @@ -15,25 +15,25 @@ class _PluralCallable(Protocol): def reset_cache(**kwargs: Any) -> None: ... -_KeyT = Union[str, Tuple[str, int]] +_KeyT = str | Tuple[str, int] _Z = TypeVar("_Z") class TranslationCatalog: _catalogs: List[Dict[_KeyT, str]] - def __init__(self, trans: Optional[gettext_module.NullTranslations] = ...) -> None: ... + def __init__(self, trans: gettext_module.NullTranslations | None = ...) -> None: ... def __getitem__(self, key: _KeyT) -> str: ... def __setitem__(self, key: _KeyT, value: str) -> None: ... def __contains__(self, key: _KeyT) -> bool: ... def items(self) -> Iterator[Tuple[_KeyT, str]]: ... def keys(self) -> Iterator[_KeyT]: ... def update(self, trans: gettext_module.NullTranslations) -> None: ... - def get(self, key: _KeyT, default: _Z = ...) -> Union[str, _Z]: ... + def get(self, key: _KeyT, default: _Z = ...) -> str | _Z: ... def plural(self, msgid: str, num: int) -> str: ... class DjangoTranslation(gettext_module.GNUTranslations): domain: str = ... plural: _PluralCallable = ... - def __init__(self, language: str, domain: Optional[str] = ..., localedirs: Optional[List[str]] = ...) -> None: ... + def __init__(self, language: str, domain: str | None = ..., localedirs: List[str] | None = ...) -> None: ... def merge(self, other: NullTranslations) -> None: ... def language(self) -> str: ... def to_language(self) -> str: ... @@ -53,9 +53,9 @@ def do_ntranslate(singular: str, plural: str, number: float, translation_functio def ngettext(singular: str, plural: str, number: float) -> str: ... def npgettext(context: str, singular: str, plural: str, number: int) -> str: ... def all_locale_paths() -> List[str]: ... -def check_for_language(lang_code: Optional[str]) -> bool: ... +def check_for_language(lang_code: str | None) -> bool: ... def get_languages() -> Dict[str, str]: ... -def get_supported_language_variant(lang_code: Optional[str], strict: bool = ...) -> str: ... -def get_language_from_path(path: str, strict: bool = ...) -> Optional[str]: ... +def get_supported_language_variant(lang_code: str | None, strict: bool = ...) -> str: ... +def get_language_from_path(path: str, strict: bool = ...) -> str | None: ... def get_language_from_request(request: HttpRequest, check_path: bool = ...) -> str: ... def parse_accept_lang_header(lang_string: str) -> Tuple[Tuple[str, float], ...]: ... diff --git a/django-stubs/utils/tree.pyi b/django-stubs/utils/tree.pyi index 38ead9a31..57abdfed9 100644 --- a/django-stubs/utils/tree.pyi +++ b/django-stubs/utils/tree.pyi @@ -1,8 +1,8 @@ -from typing import Any, Dict, List, Optional, Sequence, Tuple, Union +from typing import Any, Dict, List, Sequence, Tuple from django.db.models.sql.where import NothingNode -_NodeChildren = List[Union["Node", NothingNode, Sequence[Any]]] +_NodeChildren = List["Node" | NothingNode | Sequence[Any]] class Node: children: _NodeChildren @@ -10,7 +10,7 @@ class Node: connector: str = ... negated: bool = ... def __init__( - self, children: Optional[_NodeChildren] = ..., connector: Optional[str] = ..., negated: bool = ... + self, children: _NodeChildren | None = ..., connector: str | None = ..., negated: bool = ... ) -> None: ... def __deepcopy__(self, memodict: Dict[Any, Any]) -> Node: ... def __len__(self) -> int: ... diff --git a/django-stubs/utils/version.pyi b/django-stubs/utils/version.pyi index 1501e84f0..d62a636cd 100644 --- a/django-stubs/utils/version.pyi +++ b/django-stubs/utils/version.pyi @@ -1,4 +1,4 @@ -from typing import Optional, Tuple +from typing import Tuple PY36: bool PY37: bool @@ -9,9 +9,9 @@ PY311: bool _VT = Tuple[int, int, int, str, int] -def get_version(version: Optional[_VT] = ...) -> str: ... +def get_version(version: _VT | None = ...) -> str: ... def get_main_version(version: _VT = ...) -> str: ... -def get_complete_version(version: Optional[_VT] = ...) -> _VT: ... -def get_docs_version(version: Optional[_VT] = ...) -> str: ... -def get_git_changeset() -> Optional[str]: ... +def get_complete_version(version: _VT | None = ...) -> _VT: ... +def get_docs_version(version: _VT | None = ...) -> str: ... +def get_git_changeset() -> str | None: ... def get_version_tuple(version: str) -> Tuple[int, int, int]: ... diff --git a/django-stubs/utils/xmlutils.pyi b/django-stubs/utils/xmlutils.pyi index 45d8c4c3a..e4ef29279 100644 --- a/django-stubs/utils/xmlutils.pyi +++ b/django-stubs/utils/xmlutils.pyi @@ -1,11 +1,9 @@ -from typing import Dict, Optional +from typing import Dict from xml.sax.saxutils import XMLGenerator class UnserializableContentError(ValueError): ... class SimplerXMLGenerator(XMLGenerator): - def addQuickElement( - self, name: str, contents: Optional[str] = ..., attrs: Optional[Dict[str, str]] = ... - ) -> None: ... + def addQuickElement(self, name: str, contents: str | None = ..., attrs: Dict[str, str] | None = ...) -> None: ... def characters(self, content: str) -> None: ... def startElement(self, name: str, attrs: Dict[str, str]) -> None: ... diff --git a/django-stubs/views/debug.pyi b/django-stubs/views/debug.pyi index 03c9ba44f..bdd2f1f40 100644 --- a/django-stubs/views/debug.pyi +++ b/django-stubs/views/debug.pyi @@ -1,7 +1,7 @@ from importlib.abc import SourceLoader from pathlib import Path from types import TracebackType -from typing import Any, Callable, Dict, ItemsView, Iterator, List, Optional, Type, Union +from typing import Any, Callable, Dict, ItemsView, Iterator, List, Type from django.http.request import HttpRequest, QueryDict from django.http.response import Http404, HttpResponse @@ -11,47 +11,47 @@ CLEANSED_SUBSTITUTE: str CURRENT_DIR: Path class CallableSettingWrapper: - def __init__(self, callable_setting: Union[Callable, Type[Any]]) -> None: ... + def __init__(self, callable_setting: Callable | Type[Any]) -> None: ... def technical_500_response( request: HttpRequest, - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - tb: Optional[TracebackType], + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + tb: TracebackType | None, status_code: int = ..., ) -> HttpResponse: ... def get_default_exception_reporter_filter() -> SafeExceptionReporterFilter: ... -def get_exception_reporter_filter(request: Optional[HttpRequest]) -> SafeExceptionReporterFilter: ... +def get_exception_reporter_filter(request: HttpRequest | None) -> SafeExceptionReporterFilter: ... class SafeExceptionReporterFilter: - def cleanse_setting(self, key: Union[int, str], value: Any) -> Any: ... + def cleanse_setting(self, key: int | str, value: Any) -> Any: ... def get_safe_settings(self) -> Dict[str, Any]: ... - def is_active(self, request: Optional[HttpRequest]) -> bool: ... + def is_active(self, request: HttpRequest | None) -> bool: ... def get_cleansed_multivaluedict(self, request: HttpRequest, multivaluedict: QueryDict) -> QueryDict: ... - def get_post_parameters(self, request: Optional[HttpRequest]) -> Dict[str, Any]: ... - def cleanse_special_types(self, request: Optional[HttpRequest], value: Any) -> Any: ... + def get_post_parameters(self, request: HttpRequest | None) -> Dict[str, Any]: ... + def cleanse_special_types(self, request: HttpRequest | None, value: Any) -> Any: ... def get_traceback_frame_variables(self, request: Any, tb_frame: Any) -> ItemsView[str, Any]: ... class ExceptionReporter: - request: Optional[HttpRequest] = ... + request: HttpRequest | None = ... filter: SafeExceptionReporterFilter = ... - exc_type: Optional[Type[BaseException]] = ... - exc_value: Optional[BaseException] = ... - tb: Optional[TracebackType] = ... + exc_type: Type[BaseException] | None = ... + exc_value: BaseException | None = ... + tb: TracebackType | None = ... is_email: bool = ... - template_info: Optional[Any] = ... + template_info: Any | None = ... template_does_not_exist: bool = ... - postmortem: Optional[Any] = ... + postmortem: Any | None = ... @property def html_template_path(self) -> Path: ... @property def text_template_path(self) -> Path: ... def __init__( self, - request: Optional[HttpRequest], - exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - tb: Optional[TracebackType], + request: HttpRequest | None, + exc_type: Type[BaseException] | None, + exc_value: BaseException | None, + tb: TracebackType | None, is_email: bool = ..., ) -> None: ... def get_traceback_data(self) -> Dict[str, Any]: ... @@ -59,8 +59,8 @@ class ExceptionReporter: def get_traceback_text(self) -> SafeString: ... def get_traceback_frames(self) -> List[Any]: ... def get_exception_traceback_frames( - self, exc_value: Optional[BaseException], tb: Optional[TracebackType] + self, exc_value: BaseException | None, tb: TracebackType | None ) -> Iterator[Dict[str, Any]]: ... def technical_404_response(request: HttpRequest, exception: Http404) -> HttpResponse: ... -def default_urlconf(request: Optional[HttpResponse]) -> HttpResponse: ... +def default_urlconf(request: HttpResponse | None) -> HttpResponse: ... diff --git a/django-stubs/views/decorators/cache.pyi b/django-stubs/views/decorators/cache.pyi index 7aaf3e7fe..b61c70aaa 100644 --- a/django-stubs/views/decorators/cache.pyi +++ b/django-stubs/views/decorators/cache.pyi @@ -1,9 +1,7 @@ -from typing import Any, Callable, Optional, TypeVar +from typing import Any, Callable, TypeVar _F = TypeVar("_F", bound=Callable[..., Any]) -def cache_page( - timeout: Optional[float], *, cache: Optional[Any] = ..., key_prefix: Optional[Any] = ... -) -> Callable: ... +def cache_page(timeout: float | None, *, cache: Any | None = ..., key_prefix: Any | None = ...) -> Callable: ... def cache_control(**kwargs: Any) -> Callable: ... def never_cache(view_func: _F) -> _F: ... diff --git a/django-stubs/views/decorators/http.pyi b/django-stubs/views/decorators/http.pyi index 17ea23226..f215916c1 100644 --- a/django-stubs/views/decorators/http.pyi +++ b/django-stubs/views/decorators/http.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Container, Optional, TypeVar +from typing import Any, Callable, Container, TypeVar _F = TypeVar("_F", bound=Callable[..., Any]) @@ -10,6 +10,6 @@ require_GET: Callable[[_F], _F] = ... require_POST: Callable[[_F], _F] = ... require_safe: Callable[[_F], _F] = ... -def condition(etag_func: Optional[Callable] = ..., last_modified_func: Optional[Callable] = ...) -> Callable: ... +def condition(etag_func: Callable | None = ..., last_modified_func: Callable | None = ...) -> Callable: ... def etag(etag_func: Callable[..., Any]) -> Callable[[_F], _F]: ... def last_modified(last_modified_func: Callable[..., Any]) -> Callable[[_F], _F]: ... diff --git a/django-stubs/views/defaults.pyi b/django-stubs/views/defaults.pyi index 3241eb8fd..83b181cb4 100644 --- a/django-stubs/views/defaults.pyi +++ b/django-stubs/views/defaults.pyi @@ -1,5 +1,3 @@ -from typing import Optional - from django.http.request import HttpRequest from django.http.response import ( HttpResponseBadRequest, @@ -14,7 +12,7 @@ ERROR_400_TEMPLATE_NAME: str ERROR_500_TEMPLATE_NAME: str def page_not_found( - request: HttpRequest, exception: Optional[Exception], template_name: str = ... + request: HttpRequest, exception: Exception | None, template_name: str = ... ) -> HttpResponseNotFound: ... def server_error(request: HttpRequest, template_name: str = ...) -> HttpResponseServerError: ... def bad_request(request: HttpRequest, exception: Exception, template_name: str = ...) -> HttpResponseBadRequest: ... diff --git a/django-stubs/views/generic/base.pyi b/django-stubs/views/generic/base.pyi index cccb551bc..8cdd4ce3d 100644 --- a/django-stubs/views/generic/base.pyi +++ b/django-stubs/views/generic/base.pyi @@ -1,10 +1,10 @@ -from typing import Any, Callable, Dict, List, Optional, Type +from typing import Any, Callable, Dict, List, Type from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponseBase class ContextMixin: - extra_context: Optional[Dict[str, Any]] + extra_context: Dict[str, Any] | None def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... class View: @@ -22,9 +22,9 @@ class View: class TemplateResponseMixin: template_name: str = ... - template_engine: Optional[str] = ... + template_engine: str | None = ... response_class: Type[HttpResponse] = ... - content_type: Optional[str] = ... + content_type: str | None = ... request: HttpRequest = ... def render_to_response(self, context: Dict[str, Any], **response_kwargs: Any) -> HttpResponse: ... def get_template_names(self) -> List[str]: ... @@ -34,10 +34,10 @@ class TemplateView(TemplateResponseMixin, ContextMixin, View): class RedirectView(View): permanent: bool = ... - url: Optional[str] = ... - pattern_name: Optional[str] = ... + url: str | None = ... + pattern_name: str | None = ... query_string: bool = ... - def get_redirect_url(self, *args: Any, **kwargs: Any) -> Optional[str]: ... + def get_redirect_url(self, *args: Any, **kwargs: Any) -> str | None: ... def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ... def head(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ... def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ... diff --git a/django-stubs/views/generic/dates.pyi b/django-stubs/views/generic/dates.pyi index 3790372d9..befcba0ab 100644 --- a/django-stubs/views/generic/dates.pyi +++ b/django-stubs/views/generic/dates.pyi @@ -1,5 +1,5 @@ import datetime -from typing import Any, Dict, Optional, Sequence, Tuple, TypeVar, Union +from typing import Any, Dict, Sequence, Tuple, TypeVar from django.db import models from django.db.models.query import QuerySet @@ -13,55 +13,55 @@ _M = TypeVar("_M", bound=models.Model) class YearMixin: year_format: str = ... - year: Optional[str] = ... + year: str | None = ... def get_year_format(self) -> str: ... def get_year(self) -> str: ... - def get_next_year(self, date: datetime.date) -> Optional[datetime.date]: ... - def get_previous_year(self, date: datetime.date) -> Optional[datetime.date]: ... + def get_next_year(self, date: datetime.date) -> datetime.date | None: ... + def get_previous_year(self, date: datetime.date) -> datetime.date | None: ... class MonthMixin: month_format: str = ... - month: Optional[str] = ... + month: str | None = ... def get_month_format(self) -> str: ... def get_month(self) -> str: ... - def get_next_month(self, date: datetime.date) -> Optional[datetime.date]: ... - def get_previous_month(self, date: datetime.date) -> Optional[datetime.date]: ... + def get_next_month(self, date: datetime.date) -> datetime.date | None: ... + def get_previous_month(self, date: datetime.date) -> datetime.date | None: ... class DayMixin: day_format: str = ... - day: Optional[str] = ... + day: str | None = ... def get_day_format(self) -> str: ... def get_day(self) -> str: ... - def get_next_day(self, date: datetime.date) -> Optional[datetime.date]: ... - def get_previous_day(self, date: datetime.date) -> Optional[datetime.date]: ... + def get_next_day(self, date: datetime.date) -> datetime.date | None: ... + def get_previous_day(self, date: datetime.date) -> datetime.date | None: ... class WeekMixin: week_format: str = ... - week: Optional[str] = ... + week: str | None = ... def get_week_format(self) -> str: ... def get_week(self) -> str: ... - def get_next_week(self, date: datetime.date) -> Optional[datetime.date]: ... - def get_previous_week(self, date: datetime.date) -> Optional[datetime.date]: ... + def get_next_week(self, date: datetime.date) -> datetime.date | None: ... + def get_previous_week(self, date: datetime.date) -> datetime.date | None: ... class DateMixin: - date_field: Optional[str] = ... + date_field: str | None = ... allow_future: bool = ... def get_date_field(self) -> str: ... def get_allow_future(self) -> bool: ... @property def uses_datetime_field(self) -> bool: ... -DatedItems = Tuple[Optional[_IndexableCollection[datetime.date]], _IndexableCollection[_M], Dict[str, Any]] +DatedItems = Tuple[_IndexableCollection[datetime.date] | None, _IndexableCollection[_M], Dict[str, Any]] class BaseDateListView(MultipleObjectMixin[_M], DateMixin, View): date_list_period: str = ... def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def get_dated_items(self) -> DatedItems: ... - def get_ordering(self) -> Union[str, Sequence[str]]: ... + def get_ordering(self) -> str | Sequence[str]: ... def get_dated_queryset(self, **lookup: Any) -> models.query.QuerySet[_M]: ... def get_date_list_period(self) -> str: ... def get_date_list( - self, queryset: models.query.QuerySet, date_type: Optional[str] = ..., ordering: str = ... + self, queryset: models.query.QuerySet, date_type: str | None = ..., ordering: str = ... ) -> models.query.QuerySet: ... class BaseArchiveIndexView(BaseDateListView[_M]): @@ -106,7 +106,7 @@ class TodayArchiveView(MultipleObjectTemplateResponseMixin, BaseTodayArchiveView template_name_suffix: str = ... class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailView[_M]): - def get_object(self, queryset: Optional[QuerySet[_M]] = ...) -> _M: ... + def get_object(self, queryset: QuerySet[_M] | None = ...) -> _M: ... class DateDetailView(SingleObjectTemplateResponseMixin, BaseDateDetailView): template_name_suffix: str = ... diff --git a/django-stubs/views/generic/detail.pyi b/django-stubs/views/generic/detail.pyi index 9b9b08dad..79c2d4535 100644 --- a/django-stubs/views/generic/detail.pyi +++ b/django-stubs/views/generic/detail.pyi @@ -1,4 +1,4 @@ -from typing import Any, Generic, Optional, Type, TypeVar +from typing import Any, Generic, Type, TypeVar from django.db import models from django.http import HttpRequest, HttpResponse @@ -8,23 +8,23 @@ _M = TypeVar("_M", bound=models.Model) class SingleObjectMixin(Generic[_M], ContextMixin): model: Type[_M] = ... - queryset: Optional[models.query.QuerySet[_M]] = ... + queryset: models.query.QuerySet[_M] | None = ... slug_field: str = ... - context_object_name: Optional[str] = ... + context_object_name: str | None = ... slug_url_kwarg: str = ... pk_url_kwarg: str = ... query_pk_and_slug: bool = ... - def get_object(self, queryset: Optional[models.query.QuerySet[_M]] = ...) -> _M: ... + def get_object(self, queryset: models.query.QuerySet[_M] | None = ...) -> _M: ... def get_queryset(self) -> models.query.QuerySet[_M]: ... def get_slug_field(self) -> str: ... - def get_context_object_name(self, obj: _M) -> Optional[str]: ... + def get_context_object_name(self, obj: _M) -> str | None: ... class BaseDetailView(SingleObjectMixin[_M], View): object: _M def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... class SingleObjectTemplateResponseMixin(TemplateResponseMixin): - template_name_field: Optional[str] = ... + template_name_field: str | None = ... template_name_suffix: str = ... class DetailView(SingleObjectTemplateResponseMixin, BaseDetailView[_M]): ... diff --git a/django-stubs/views/generic/edit.pyi b/django-stubs/views/generic/edit.pyi index 1138df73a..3f09b403f 100644 --- a/django-stubs/views/generic/edit.pyi +++ b/django-stubs/views/generic/edit.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Generic, Optional, Type, TypeVar, Union +from typing import Any, Dict, Generic, Type, TypeVar from django.db import models from django.forms.forms import BaseForm @@ -15,13 +15,13 @@ _M = TypeVar("_M", bound=models.Model) class FormMixin(Generic[_FormT], ContextMixin): initial: Dict[str, Any] = ... - form_class: Optional[Type[_FormT]] = ... - success_url: Optional[str] = ... - prefix: Optional[str] = ... + form_class: Type[_FormT] | None = ... + success_url: str | None = ... + prefix: str | None = ... def get_initial(self) -> Dict[str, Any]: ... - def get_prefix(self) -> Optional[str]: ... + def get_prefix(self) -> str | None: ... def get_form_class(self) -> Type[_FormT]: ... - def get_form(self, form_class: Optional[Type[_FormT]] = ...) -> _FormT: ... + def get_form(self, form_class: Type[_FormT] | None = ...) -> _FormT: ... def get_form_kwargs(self) -> Dict[str, Any]: ... def get_success_url(self) -> str: ... def form_valid(self, form: _FormT) -> HttpResponse: ... @@ -29,7 +29,7 @@ class FormMixin(Generic[_FormT], ContextMixin): def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... class ModelFormMixin(Generic[_M, _ModelFormT], FormMixin[_ModelFormT], SingleObjectMixin[_M]): - fields: Optional[Union[_ListOrTuple[str], Literal["__all__"]]] = ... + fields: _ListOrTuple[str] | Literal["__all__"] | None = ... def get_form_class(self) -> Type[_ModelFormT]: ... def get_form_kwargs(self) -> Dict[str, Any]: ... def get_success_url(self) -> str: ... @@ -60,7 +60,7 @@ class UpdateView(SingleObjectTemplateResponseMixin, BaseUpdateView[_M, _ModelFor template_name_suffix: str = ... class DeletionMixin(Generic[_M]): - success_url: Optional[str] = ... + success_url: str | None = ... object: _M def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def delete(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... diff --git a/django-stubs/views/generic/list.pyi b/django-stubs/views/generic/list.pyi index 1a2d06715..2c9f92fe0 100644 --- a/django-stubs/views/generic/list.pyi +++ b/django-stubs/views/generic/list.pyi @@ -1,4 +1,4 @@ -from typing import Any, Generic, Optional, Sequence, Tuple, Type, TypeVar, Union +from typing import Any, Generic, Sequence, Tuple, Type, TypeVar from django.core.paginator import Page, Paginator, _SupportsPagination from django.db.models import Model @@ -9,20 +9,20 @@ _M = TypeVar("_M", bound=Model, covariant=True) class MultipleObjectMixin(Generic[_M], ContextMixin): allow_empty: bool = ... - queryset: Optional[_SupportsPagination[_M]] = ... - model: Optional[Type[_M]] = ... + queryset: _SupportsPagination[_M] | None = ... + model: Type[_M] | None = ... paginate_by: int = ... paginate_orphans: int = ... - context_object_name: Optional[str] = ... + context_object_name: str | None = ... paginator_class: Type[Paginator] = ... page_kwarg: str = ... - ordering: Optional[Union[str, Sequence[str]]] = ... + ordering: str | Sequence[str] | None = ... def get_queryset(self) -> _SupportsPagination[_M]: ... - def get_ordering(self) -> Optional[Union[str, Sequence[str]]]: ... + def get_ordering(self) -> str | Sequence[str] | None: ... def paginate_queryset( self, queryset: _SupportsPagination[_M], page_size: int ) -> Tuple[Paginator, Page, _SupportsPagination[_M], bool]: ... - def get_paginate_by(self, queryset: _SupportsPagination[_M]) -> Optional[int]: ... + def get_paginate_by(self, queryset: _SupportsPagination[_M]) -> int | None: ... def get_paginator( self, queryset: _SupportsPagination[_M], @@ -33,7 +33,7 @@ class MultipleObjectMixin(Generic[_M], ContextMixin): ) -> Paginator: ... def get_paginate_orphans(self) -> int: ... def get_allow_empty(self) -> bool: ... - def get_context_object_name(self, object_list: _SupportsPagination[_M]) -> Optional[str]: ... + def get_context_object_name(self, object_list: _SupportsPagination[_M]) -> str | None: ... class BaseListView(MultipleObjectMixin[_M], View): object_list: _SupportsPagination[_M] diff --git a/django-stubs/views/i18n.pyi b/django-stubs/views/i18n.pyi index 8495ec351..6fed6203f 100644 --- a/django-stubs/views/i18n.pyi +++ b/django-stubs/views/i18n.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, Optional, Union +from typing import Any, Callable, Dict, List from django.http.request import HttpRequest from django.http.response import HttpResponse @@ -8,7 +8,7 @@ from django.views.generic import View LANGUAGE_QUERY_PARAMETER: str def set_language(request: HttpRequest) -> HttpResponse: ... -def get_formats() -> Dict[str, Union[List[str], int, str]]: ... +def get_formats() -> Dict[str, List[str] | int | str]: ... js_catalog_template: str @@ -19,8 +19,8 @@ class JavaScriptCatalog(View): translation: DjangoTranslation = ... def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def get_paths(self, packages: List[str]) -> List[str]: ... - def get_plural(self) -> Optional[List[str]]: ... - def get_catalog(self) -> Dict[str, Union[List[str], str]]: ... + def get_plural(self) -> List[str] | None: ... + def get_catalog(self) -> Dict[str, List[str] | str]: ... def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... def render_to_response(self, context: Dict[str, Any], **response_kwargs: Any) -> HttpResponse: ... diff --git a/django-stubs/views/static.pyi b/django-stubs/views/static.pyi index f27674a0b..2c9f5b8d7 100644 --- a/django-stubs/views/static.pyi +++ b/django-stubs/views/static.pyi @@ -1,14 +1,14 @@ -from typing import Any, Optional +from typing import Any from django.http import FileResponse, HttpResponse from django.http.request import HttpRequest def serve( - request: HttpRequest, path: str, document_root: Optional[str] = ..., show_indexes: bool = ... + request: HttpRequest, path: str, document_root: str | None = ..., show_indexes: bool = ... ) -> FileResponse: ... DEFAULT_DIRECTORY_INDEX_TEMPLATE: str template_translatable: Any def directory_index(path: Any, fullpath: Any) -> HttpResponse: ... -def was_modified_since(header: Optional[str] = ..., mtime: float = ..., size: int = ...) -> bool: ... +def was_modified_since(header: str | None = ..., mtime: float = ..., size: int = ...) -> bool: ... From f06c8d0b4f26b6c748291650ed443b385f6d4931 Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sat, 12 Nov 2022 18:36:37 +0100 Subject: [PATCH 07/13] fix Y015 Signed-off-by: Oleg Hoefling --- django-stubs/apps/config.pyi | 16 +- django-stubs/apps/registry.pyi | 16 +- django-stubs/conf/__init__.pyi | 10 +- django-stubs/conf/global_settings.pyi | 278 +++++++++--------- django-stubs/conf/locale/__init__.pyi | 2 +- django-stubs/conf/urls/__init__.pyi | 8 +- django-stubs/contrib/admin/apps.pyi | 2 +- django-stubs/contrib/admin/filters.pyi | 76 ++--- django-stubs/contrib/admin/forms.pyi | 4 +- django-stubs/contrib/admin/helpers.pyi | 82 +++--- django-stubs/contrib/admin/models.pyi | 16 +- django-stubs/contrib/admin/options.pyi | 134 ++++----- django-stubs/contrib/admin/sites.pyi | 32 +- .../contrib/admin/templatetags/admin_list.pyi | 2 +- .../contrib/admin/templatetags/base.pyi | 2 +- django-stubs/contrib/admin/utils.pyi | 6 +- .../contrib/admin/views/autocomplete.pyi | 4 +- django-stubs/contrib/admin/views/main.pyi | 66 ++--- django-stubs/contrib/admin/widgets.pyi | 48 +-- django-stubs/contrib/admindocs/apps.pyi | 4 +- django-stubs/contrib/admindocs/urls.pyi | 2 +- django-stubs/contrib/auth/admin.pyi | 8 +- django-stubs/contrib/auth/backends.pyi | 2 +- django-stubs/contrib/auth/base_user.pyi | 4 +- .../contrib/auth/context_processors.pyi | 2 +- django-stubs/contrib/auth/forms.pyi | 50 ++-- django-stubs/contrib/auth/hashers.pyi | 16 +- django-stubs/contrib/auth/middleware.pyi | 6 +- django-stubs/contrib/auth/mixins.pyi | 10 +- django-stubs/contrib/auth/models.pyi | 18 +- .../contrib/auth/password_validation.pyi | 12 +- django-stubs/contrib/auth/tokens.pyi | 6 +- django-stubs/contrib/auth/urls.pyi | 2 +- django-stubs/contrib/auth/views.pyi | 54 ++-- django-stubs/contrib/contenttypes/admin.pyi | 2 +- django-stubs/contrib/contenttypes/fields.pyi | 48 +-- django-stubs/contrib/contenttypes/forms.pyi | 6 +- .../contenttypes/management/__init__.pyi | 6 +- django-stubs/contrib/contenttypes/models.pyi | 6 +- django-stubs/contrib/flatpages/admin.pyi | 10 +- django-stubs/contrib/flatpages/apps.pyi | 4 +- django-stubs/contrib/flatpages/forms.pyi | 2 +- django-stubs/contrib/flatpages/models.pyi | 14 +- .../flatpages/templatetags/flatpages.pyi | 6 +- django-stubs/contrib/flatpages/urls.pyi | 2 +- django-stubs/contrib/gis/admin/options.pyi | 72 ++--- django-stubs/contrib/gis/apps.pyi | 4 +- .../contrib/gis/db/backends/base/adapter.pyi | 4 +- .../contrib/gis/db/backends/base/features.pyi | 36 +-- .../gis/db/backends/base/operations.pyi | 28 +- .../contrib/gis/db/backends/mysql/base.pyi | 8 +- .../gis/db/backends/mysql/features.pyi | 16 +- .../gis/db/backends/mysql/introspection.pyi | 2 +- .../gis/db/backends/mysql/operations.pyi | 8 +- .../contrib/gis/db/backends/mysql/schema.pyi | 6 +- .../gis/db/backends/oracle/adapter.pyi | 6 +- .../contrib/gis/db/backends/oracle/base.pyi | 8 +- .../gis/db/backends/oracle/features.pyi | 10 +- .../contrib/gis/db/backends/oracle/models.pyi | 30 +- .../gis/db/backends/oracle/operations.pyi | 28 +- .../contrib/gis/db/backends/oracle/schema.pyi | 12 +- .../gis/db/backends/postgis/adapter.pyi | 8 +- .../contrib/gis/db/backends/postgis/base.pyi | 8 +- .../gis/db/backends/postgis/features.pyi | 10 +- .../gis/db/backends/postgis/introspection.pyi | 4 +- .../gis/db/backends/postgis/models.pyi | 36 +-- .../gis/db/backends/postgis/operations.pyi | 38 +-- .../gis/db/backends/postgis/schema.pyi | 10 +- .../gis/db/backends/spatialite/base.pyi | 12 +- .../gis/db/backends/spatialite/client.pyi | 2 +- .../gis/db/backends/spatialite/features.pyi | 2 +- .../db/backends/spatialite/introspection.pyi | 4 +- .../gis/db/backends/spatialite/models.pyi | 36 +-- .../gis/db/backends/spatialite/operations.pyi | 22 +- .../gis/db/backends/spatialite/schema.pyi | 18 +- .../contrib/gis/db/backends/utils.pyi | 6 +- .../contrib/gis/db/models/aggregates.pyi | 20 +- django-stubs/contrib/gis/db/models/fields.pyi | 76 ++--- .../contrib/gis/db/models/functions.pyi | 100 +++---- .../contrib/gis/db/models/lookups.pyi | 90 +++--- .../contrib/gis/db/models/sql/conversion.pyi | 4 +- django-stubs/contrib/gis/feeds.pyi | 2 +- django-stubs/contrib/gis/forms/fields.pyi | 22 +- django-stubs/contrib/gis/forms/widgets.pyi | 32 +- django-stubs/contrib/gis/gdal/base.pyi | 2 +- django-stubs/contrib/gis/gdal/datasource.pyi | 8 +- django-stubs/contrib/gis/gdal/driver.pyi | 2 +- django-stubs/contrib/gis/gdal/feature.pyi | 4 +- django-stubs/contrib/gis/gdal/field.pyi | 2 +- django-stubs/contrib/gis/gdal/geometries.pyi | 22 +- django-stubs/contrib/gis/gdal/geomtype.pyi | 4 +- django-stubs/contrib/gis/gdal/layer.pyi | 4 +- django-stubs/contrib/gis/gdal/raster/band.pyi | 4 +- .../contrib/gis/gdal/raster/source.pyi | 4 +- django-stubs/contrib/gis/gdal/srs.pyi | 14 +- django-stubs/contrib/gis/geoip2/base.pyi | 12 +- django-stubs/contrib/gis/geos/base.pyi | 2 +- django-stubs/contrib/gis/geos/collections.pyi | 2 +- django-stubs/contrib/gis/geos/coordseq.pyi | 2 +- django-stubs/contrib/gis/geos/geometry.pyi | 12 +- django-stubs/contrib/gis/geos/libgeos.pyi | 8 +- django-stubs/contrib/gis/geos/linestring.pyi | 4 +- django-stubs/contrib/gis/geos/point.pyi | 4 +- django-stubs/contrib/gis/geos/polygon.pyi | 6 +- django-stubs/contrib/gis/geos/prepared.pyi | 6 +- .../contrib/gis/geos/prototypes/coordseq.pyi | 10 +- .../contrib/gis/geos/prototypes/geom.pyi | 16 +- .../contrib/gis/geos/prototypes/io.pyi | 50 ++-- .../contrib/gis/geos/prototypes/misc.pyi | 4 +- .../gis/geos/prototypes/predicates.pyi | 8 +- .../contrib/gis/geos/prototypes/prepared.pyi | 6 +- .../gis/geos/prototypes/threadsafe.pyi | 18 +- .../contrib/gis/geos/prototypes/topology.pyi | 6 +- django-stubs/contrib/gis/measure.pyi | 26 +- django-stubs/contrib/gis/ptr.pyi | 6 +- .../contrib/gis/serializers/geojson.pyi | 2 +- django-stubs/contrib/gis/sitemaps/kml.pyi | 6 +- .../contrib/gis/utils/layermapping.pyi | 36 +-- django-stubs/contrib/humanize/apps.pyi | 4 +- django-stubs/contrib/messages/__init__.pyi | 2 +- django-stubs/contrib/messages/apps.pyi | 4 +- django-stubs/contrib/messages/constants.pyi | 14 +- .../contrib/messages/storage/base.pyi | 14 +- .../contrib/messages/storage/cookie.pyi | 8 +- .../contrib/messages/storage/fallback.pyi | 4 +- .../contrib/messages/storage/session.pyi | 2 +- django-stubs/contrib/messages/views.pyi | 2 +- django-stubs/contrib/postgres/apps.pyi | 4 +- .../contrib/postgres/fields/array.pyi | 12 +- .../contrib/postgres/fields/ranges.pyi | 74 ++--- django-stubs/contrib/postgres/forms/array.pyi | 4 +- .../contrib/postgres/forms/hstore.pyi | 2 +- django-stubs/contrib/postgres/operations.pyi | 8 +- django-stubs/contrib/postgres/search.pyi | 22 +- django-stubs/contrib/postgres/validators.pyi | 4 +- django-stubs/contrib/redirects/admin.pyi | 8 +- django-stubs/contrib/redirects/apps.pyi | 4 +- django-stubs/contrib/redirects/middleware.pyi | 4 +- django-stubs/contrib/redirects/models.pyi | 6 +- django-stubs/contrib/sessions/apps.pyi | 4 +- .../contrib/sessions/backends/base.pyi | 10 +- .../contrib/sessions/backends/cache.pyi | 2 +- .../contrib/sessions/backends/cached_db.pyi | 2 +- .../contrib/sessions/backends/file.pyi | 4 +- .../contrib/sessions/base_session.pyi | 2 +- django-stubs/contrib/sessions/middleware.pyi | 2 +- django-stubs/contrib/sitemaps/__init__.pyi | 22 +- django-stubs/contrib/sitemaps/apps.pyi | 4 +- django-stubs/contrib/sites/admin.pyi | 4 +- django-stubs/contrib/sites/requests.pyi | 2 +- django-stubs/contrib/staticfiles/apps.pyi | 2 +- django-stubs/contrib/staticfiles/finders.pyi | 16 +- django-stubs/contrib/staticfiles/handlers.pyi | 2 +- .../management/commands/collectstatic.pyi | 24 +- django-stubs/contrib/staticfiles/storage.pyi | 18 +- django-stubs/contrib/staticfiles/urls.pyi | 2 +- django-stubs/contrib/syndication/apps.pyi | 4 +- django-stubs/contrib/syndication/views.pyi | 8 +- django-stubs/core/cache/__init__.pyi | 4 +- django-stubs/core/cache/backends/base.pyi | 12 +- django-stubs/core/cache/backends/db.pyi | 22 +- .../core/cache/backends/filebased.pyi | 2 +- django-stubs/core/checks/messages.pyi | 10 +- django-stubs/core/checks/registry.pyi | 36 +-- django-stubs/core/checks/translation.pyi | 8 +- django-stubs/core/exceptions.pyi | 14 +- django-stubs/core/files/base.pyi | 10 +- django-stubs/core/files/locks.pyi | 4 +- django-stubs/core/files/storage.pyi | 2 +- django-stubs/core/files/uploadedfile.pyi | 8 +- django-stubs/core/files/uploadhandler.pyi | 24 +- django-stubs/core/files/utils.pyi | 28 +- django-stubs/core/handlers/asgi.pyi | 24 +- django-stubs/core/handlers/wsgi.pyi | 14 +- django-stubs/core/mail/__init__.pyi | 2 +- django-stubs/core/mail/backends/console.pyi | 4 +- django-stubs/core/mail/backends/smtp.pyi | 22 +- django-stubs/core/mail/message.pyi | 34 +-- django-stubs/core/management/__init__.pyi | 6 +- django-stubs/core/management/base.pyi | 32 +- .../management/commands/compilemessages.pyi | 8 +- .../management/commands/createcachetable.pyi | 2 +- .../core/management/commands/flush.pyi | 4 +- .../core/management/commands/inspectdb.pyi | 4 +- .../core/management/commands/loaddata.pyi | 18 +- .../core/management/commands/makemessages.pyi | 18 +- .../management/commands/makemigrations.pyi | 14 +- .../core/management/commands/migrate.pyi | 6 +- .../core/management/commands/runserver.pyi | 10 +- .../management/commands/sendtestemail.pyi | 2 +- .../core/management/commands/shell.pyi | 2 +- .../management/commands/showmigrations.pyi | 2 +- .../core/management/commands/sqlflush.pyi | 2 +- .../core/management/commands/sqlmigrate.pyi | 2 +- .../management/commands/squashmigrations.pyi | 4 +- .../core/management/commands/startapp.pyi | 2 +- .../core/management/commands/startproject.pyi | 2 +- .../core/management/commands/test.pyi | 2 +- django-stubs/core/management/templates.pyi | 6 +- django-stubs/core/paginator.pyi | 14 +- django-stubs/core/serializers/__init__.pyi | 4 +- django-stubs/core/serializers/base.pyi | 40 +-- django-stubs/core/serializers/python.pyi | 2 +- django-stubs/core/serializers/pyyaml.pyi | 2 +- .../core/serializers/xml_serializer.pyi | 36 +-- django-stubs/core/servers/basehttp.pyi | 14 +- django-stubs/core/signals.pyi | 8 +- django-stubs/core/signing.pyi | 8 +- django-stubs/core/validators.pyi | 88 +++--- django-stubs/db/backends/base/base.pyi | 74 ++--- django-stubs/db/backends/base/client.pyi | 2 +- .../db/backends/base/introspection.pyi | 2 +- django-stubs/db/backends/base/operations.pyi | 24 +- django-stubs/db/backends/base/schema.pyi | 66 ++--- django-stubs/db/backends/base/validation.pyi | 2 +- django-stubs/db/backends/ddl_references.pyi | 28 +- django-stubs/db/backends/dummy/base.pyi | 20 +- django-stubs/db/backends/dummy/features.pyi | 4 +- django-stubs/db/backends/mysql/base.pyi | 24 +- django-stubs/db/backends/mysql/client.pyi | 2 +- django-stubs/db/backends/mysql/features.pyi | 68 ++--- .../db/backends/mysql/introspection.pyi | 2 +- django-stubs/db/backends/mysql/operations.pyi | 10 +- django-stubs/db/backends/mysql/schema.pyi | 24 +- django-stubs/db/backends/oracle/base.pyi | 28 +- django-stubs/db/backends/oracle/client.pyi | 4 +- django-stubs/db/backends/oracle/features.pyi | 88 +++--- django-stubs/db/backends/oracle/functions.pyi | 8 +- .../db/backends/oracle/introspection.pyi | 2 +- .../db/backends/oracle/operations.pyi | 8 +- django-stubs/db/backends/oracle/schema.pyi | 20 +- django-stubs/db/backends/oracle/utils.pyi | 22 +- django-stubs/db/backends/postgresql/base.pyi | 10 +- .../db/backends/postgresql/client.pyi | 2 +- .../db/backends/postgresql/features.pyi | 90 +++--- .../db/backends/postgresql/introspection.pyi | 4 +- .../db/backends/postgresql/schema.pyi | 22 +- django-stubs/db/backends/signals.pyi | 2 +- django-stubs/db/backends/sqlite3/client.pyi | 2 +- .../db/backends/sqlite3/introspection.pyi | 2 +- django-stubs/db/backends/utils.pyi | 6 +- django-stubs/db/migrations/autodetector.pyi | 14 +- django-stubs/db/migrations/exceptions.pyi | 6 +- django-stubs/db/migrations/executor.pyi | 8 +- django-stubs/db/migrations/graph.pyi | 16 +- django-stubs/db/migrations/loader.pyi | 16 +- django-stubs/db/migrations/migration.pyi | 18 +- .../db/migrations/operations/base.pyi | 10 +- .../db/migrations/operations/fields.pyi | 16 +- .../db/migrations/operations/models.pyi | 44 +-- .../db/migrations/operations/special.pyi | 20 +- django-stubs/db/migrations/questioner.pyi | 6 +- django-stubs/db/migrations/recorder.pyi | 8 +- django-stubs/db/migrations/serializer.pyi | 2 +- django-stubs/db/migrations/state.pyi | 6 +- django-stubs/db/migrations/utils.pyi | 4 +- django-stubs/db/migrations/writer.pyi | 14 +- django-stubs/db/models/aggregates.pyi | 6 +- django-stubs/db/models/base.pyi | 8 +- django-stubs/db/models/constants.pyi | 2 +- django-stubs/db/models/enums.pyi | 24 +- django-stubs/db/models/expressions.pyi | 98 +++--- django-stubs/db/models/fields/__init__.pyi | 38 +-- django-stubs/db/models/fields/files.pyi | 14 +- django-stubs/db/models/fields/json.pyi | 24 +- django-stubs/db/models/fields/related.pyi | 18 +- .../db/models/fields/related_descriptors.pyi | 8 +- .../db/models/fields/related_lookups.pyi | 8 +- .../db/models/fields/reverse_related.pyi | 36 +-- django-stubs/db/models/functions/datetime.pyi | 6 +- django-stubs/db/models/functions/text.pyi | 14 +- django-stubs/db/models/functions/window.pyi | 12 +- django-stubs/db/models/indexes.pyi | 20 +- django-stubs/db/models/lookups.pyi | 26 +- django-stubs/db/models/manager.pyi | 12 +- django-stubs/db/models/options.pyi | 86 +++--- django-stubs/db/models/query.pyi | 4 +- django-stubs/db/models/query_utils.pyi | 16 +- django-stubs/db/models/sql/compiler.pyi | 26 +- django-stubs/db/models/sql/constants.pyi | 18 +- django-stubs/db/models/sql/datastructures.pyi | 30 +- django-stubs/db/models/sql/query.pyi | 100 +++---- django-stubs/db/models/sql/subqueries.pyi | 10 +- django-stubs/db/models/sql/where.pyi | 24 +- django-stubs/db/transaction.pyi | 4 +- django-stubs/dispatch/dispatcher.pyi | 10 +- django-stubs/forms/boundfield.pyi | 22 +- django-stubs/forms/fields.pyi | 74 ++--- django-stubs/forms/forms.pyi | 32 +- django-stubs/forms/formsets.pyi | 32 +- django-stubs/forms/models.pyi | 74 ++--- django-stubs/forms/renderers.pyi | 2 +- django-stubs/forms/utils.pyi | 2 +- django-stubs/forms/widgets.pyi | 162 +++++----- django-stubs/http/multipartparser.pyi | 8 +- django-stubs/http/request.pyi | 36 +-- django-stubs/http/response.pyi | 18 +- django-stubs/middleware/cache.pyi | 22 +- django-stubs/middleware/common.pyi | 2 +- django-stubs/middleware/locale.pyi | 2 +- django-stubs/middleware/security.pyi | 16 +- django-stubs/template/backends/base.pyi | 6 +- django-stubs/template/backends/django.pyi | 2 +- django-stubs/template/backends/jinja2.pyi | 8 +- django-stubs/template/base.pyi | 76 ++--- django-stubs/template/context.pyi | 20 +- django-stubs/template/defaulttags.pyi | 68 ++--- django-stubs/template/engine.pyi | 26 +- django-stubs/template/exceptions.pyi | 6 +- django-stubs/template/library.pyi | 16 +- django-stubs/template/loader_tags.pyi | 22 +- django-stubs/template/loaders/base.pyi | 4 +- django-stubs/template/loaders/cached.pyi | 4 +- django-stubs/template/loaders/filesystem.pyi | 2 +- django-stubs/template/loaders/locmem.pyi | 2 +- django-stubs/template/response.pyi | 12 +- django-stubs/template/smartif.pyi | 24 +- django-stubs/templatetags/cache.pyi | 10 +- django-stubs/templatetags/i18n.pyi | 42 +-- django-stubs/templatetags/l10n.pyi | 4 +- django-stubs/templatetags/static.pyi | 8 +- django-stubs/templatetags/tz.pyi | 10 +- django-stubs/test/client.pyi | 18 +- django-stubs/test/html.pyi | 14 +- django-stubs/test/runner.pyi | 84 +++--- django-stubs/test/selenium.pyi | 6 +- django-stubs/test/testcases.pyi | 66 ++--- django-stubs/test/utils.pyi | 56 ++-- django-stubs/urls/converters.pyi | 6 +- django-stubs/urls/resolvers.pyi | 58 ++-- django-stubs/utils/baseconv.pyi | 6 +- django-stubs/utils/connection.pyi | 6 +- django-stubs/utils/datastructures.pyi | 8 +- django-stubs/utils/dateformat.pyi | 6 +- django-stubs/utils/deprecation.pyi | 12 +- django-stubs/utils/encoding.pyi | 2 +- django-stubs/utils/feedgenerator.pyi | 12 +- django-stubs/utils/functional.pyi | 30 +- django-stubs/utils/html.pyi | 2 +- django-stubs/utils/jslex.pyi | 22 +- django-stubs/utils/log.pyi | 10 +- django-stubs/utils/termcolors.pyi | 2 +- django-stubs/utils/text.pyi | 2 +- django-stubs/utils/timezone.pyi | 6 +- django-stubs/utils/translation/__init__.pyi | 6 +- django-stubs/utils/translation/trans_real.pyi | 4 +- django-stubs/utils/tree.pyi | 6 +- django-stubs/views/debug.pyi | 18 +- django-stubs/views/decorators/gzip.pyi | 2 +- django-stubs/views/decorators/http.pyi | 8 +- django-stubs/views/generic/base.pyi | 26 +- django-stubs/views/generic/dates.pyi | 44 +-- django-stubs/views/generic/detail.pyi | 18 +- django-stubs/views/generic/edit.pyi | 18 +- django-stubs/views/generic/list.pyi | 20 +- django-stubs/views/i18n.pyi | 6 +- 356 files changed, 3162 insertions(+), 3162 deletions(-) diff --git a/django-stubs/apps/config.pyi b/django-stubs/apps/config.pyi index ba477f4a0..b453a1f94 100644 --- a/django-stubs/apps/config.pyi +++ b/django-stubs/apps/config.pyi @@ -8,14 +8,14 @@ from django.utils.functional import _StrOrPromise MODELS_MODULE_NAME: str class AppConfig: - name: str = ... - module: types.ModuleType | None = ... - apps: Apps | None = ... - label: str = ... - verbose_name: _StrOrPromise = ... - path: str = ... - models_module: str | None = ... - models: Dict[str, Type[Model]] = ... + name: str + module: types.ModuleType | None + apps: Apps | None + label: str + verbose_name: _StrOrPromise + path: str + models_module: str | None + models: Dict[str, Type[Model]] def __init__(self, app_name: str, app_module: types.ModuleType | None) -> None: ... @classmethod def create(cls, entry: str) -> AppConfig: ... diff --git a/django-stubs/apps/registry.pyi b/django-stubs/apps/registry.pyi index 468a679b4..2091bd264 100644 --- a/django-stubs/apps/registry.pyi +++ b/django-stubs/apps/registry.pyi @@ -6,15 +6,15 @@ from django.db.models.base import Model from .config import AppConfig class Apps: - all_models: Dict[str, Dict[str, Type[Model]]] = ... - app_configs: Dict[str, AppConfig] = ... - stored_app_configs: List[Any] = ... - apps_ready: bool = ... - ready_event: threading.Event = ... - loading: bool = ... + all_models: Dict[str, Dict[str, Type[Model]]] + app_configs: Dict[str, AppConfig] + stored_app_configs: List[Any] + apps_ready: bool + ready_event: threading.Event + loading: bool _pending_operations: Dict[Tuple[str, str], List] - models_ready: bool = ... - ready: bool = ... + models_ready: bool + ready: bool 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: ... diff --git a/django-stubs/conf/__init__.pyi b/django-stubs/conf/__init__.pyi index c48da17f3..4e21cca18 100644 --- a/django-stubs/conf/__init__.pyi +++ b/django-stubs/conf/__init__.pyi @@ -5,9 +5,9 @@ from django.utils.functional import LazyObject # explicit dependency on standard settings to make it loaded from . import global_settings -ENVIRONMENT_VARIABLE: str = ... -PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSG: str = ... -DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSG: str = ... +ENVIRONMENT_VARIABLE: str +PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSG: str +DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSG: str # required for plugin to be able to distinguish this specific instance of LazySettings from others class _DjangoConfLazyObject(LazyObject): @@ -19,7 +19,7 @@ class LazySettings(_DjangoConfLazyObject): def configured(self) -> bool: ... def configure(self, default_settings: Any = ..., **options: Any) -> None: ... -settings: LazySettings = ... +settings: LazySettings class Settings: SETTINGS_MODULE: str @@ -27,7 +27,7 @@ class Settings: def is_overridden(self, setting: str) -> bool: ... class UserSettingsHolder: - SETTINGS_MODULE: None = ... + SETTINGS_MODULE: None def __init__(self, default_settings: Any) -> None: ... def __getattr__(self, name: str) -> Any: ... def __setattr__(self, name: str, value: Any) -> None: ... diff --git a/django-stubs/conf/global_settings.pyi b/django-stubs/conf/global_settings.pyi index 9f71ba6cb..72adc7611 100644 --- a/django-stubs/conf/global_settings.pyi +++ b/django-stubs/conf/global_settings.pyi @@ -12,61 +12,61 @@ from typing_extensions import Literal #################### # CORE # #################### -DEBUG: bool = ... +DEBUG: bool # Whether the framework should propagate raw exceptions rather than catching # them. This is useful under some testing situations and should never be used # on a live site. -DEBUG_PROPAGATE_EXCEPTIONS: bool = ... +DEBUG_PROPAGATE_EXCEPTIONS: bool # People who get code error notifications. # In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')] -ADMINS: List[Tuple[str, str]] = ... +ADMINS: List[Tuple[str, str]] # List of IP addresses, as strings, that: # * See debug comments, when DEBUG is true # * Receive x-headers -INTERNAL_IPS: List[str] = ... +INTERNAL_IPS: List[str] # Hosts/domain names that are valid for this site. # "*" matches anything, ".example.com" matches example.com and all subdomains -ALLOWED_HOSTS: List[str] = ... +ALLOWED_HOSTS: List[str] # Local time zone for this installation. All choices can be found here: # https://en.wikipedia.org/wiki/List_of_tz_zones_by_name (although not all # systems may support all possibilities). When USE_TZ is True, this is # interpreted as the default user time zone. -TIME_ZONE: str = ... +TIME_ZONE: str # If you set this to True, Django will use timezone-aware datetimes. -USE_TZ: bool = ... +USE_TZ: bool # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html -LANGUAGE_CODE: str = ... +LANGUAGE_CODE: str # Languages we provide translations for, out of the box. -LANGUAGES: List[Tuple[str, str]] = ... +LANGUAGES: List[Tuple[str, str]] # Languages using BiDi (right-to-left) layout -LANGUAGES_BIDI: List[str] = ... +LANGUAGES_BIDI: List[str] # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. -USE_I18N: bool = ... -LOCALE_PATHS: List[str] = ... +USE_I18N: bool +LOCALE_PATHS: List[str] # Settings for language cookie -LANGUAGE_COOKIE_NAME: str = ... -LANGUAGE_COOKIE_AGE: int | None = ... -LANGUAGE_COOKIE_DOMAIN: str | None = ... -LANGUAGE_COOKIE_PATH: str = ... -LANGUAGE_COOKIE_HTTPONLY: bool = ... -LANGUAGE_COOKIE_SAMESITE: Literal["Lax", "Strict", "None", False] | None = ... +LANGUAGE_COOKIE_NAME: str +LANGUAGE_COOKIE_AGE: int | None +LANGUAGE_COOKIE_DOMAIN: str | None +LANGUAGE_COOKIE_PATH: str +LANGUAGE_COOKIE_HTTPONLY: bool +LANGUAGE_COOKIE_SAMESITE: Literal["Lax", "Strict", "None", False] | None # If you set this to True, Django will format dates, numbers and calendars # according to user current locale. -USE_L10N: bool = ... +USE_L10N: bool # Not-necessarily-technical managers of the site. They get broken link # notifications and other various emails. @@ -75,68 +75,68 @@ MANAGERS = ADMINS # Default charset to use for all HttpResponse objects, if a # MIME type isn't manually specified. These are used to construct the # Content-Type header. -DEFAULT_CHARSET: str = ... +DEFAULT_CHARSET: str # Email address that error messages come from. -SERVER_EMAIL: str = ... +SERVER_EMAIL: str # Database connection info. If left empty, will default to the dummy backend. -DATABASES: Dict[str, Dict[str, Any]] = ... +DATABASES: Dict[str, Dict[str, Any]] # Classes used to implement DB routing behavior. class Router(Protocol): def allow_migrate(self, db: str, app_label: str, **hints: Any) -> bool | None: ... -DATABASE_ROUTERS: List[str | Router] = ... +DATABASE_ROUTERS: List[str | Router] # The email backend to use. For possible shortcuts see django.core.mail. # The default is to use the SMTP backend. # Third-party backends can be specified by providing a Python path # to a module that defines an EmailBackend class. -EMAIL_BACKEND: str = ... +EMAIL_BACKEND: str # Host for sending email. -EMAIL_HOST: str = ... +EMAIL_HOST: str # Port for sending email. -EMAIL_PORT: int = ... +EMAIL_PORT: int # Whether to send SMTP 'Date' header in the local time zone or in UTC. -EMAIL_USE_LOCALTIME: bool = ... +EMAIL_USE_LOCALTIME: bool # Optional SMTP authentication information for EMAIL_HOST. -EMAIL_HOST_USER: str = ... -EMAIL_HOST_PASSWORD: str = ... -EMAIL_USE_TLS: bool = ... -EMAIL_USE_SSL: bool = ... -EMAIL_SSL_CERTFILE: str | None = ... -EMAIL_SSL_KEYFILE: str | None = ... -EMAIL_TIMEOUT: int | None = ... +EMAIL_HOST_USER: str +EMAIL_HOST_PASSWORD: str +EMAIL_USE_TLS: bool +EMAIL_USE_SSL: bool +EMAIL_SSL_CERTFILE: str | None +EMAIL_SSL_KEYFILE: str | None +EMAIL_TIMEOUT: int | None # List of strings representing installed apps. -INSTALLED_APPS: List[str] = ... +INSTALLED_APPS: List[str] -TEMPLATES: List[Dict[str, Any]] = ... +TEMPLATES: List[Dict[str, Any]] # Default form rendering class. -FORM_RENDERER: str = ... +FORM_RENDERER: str # Default email address to use for various automated correspondence from # the site managers. -DEFAULT_FROM_EMAIL: str = ... +DEFAULT_FROM_EMAIL: str # Subject-line prefix for email messages send with django.core.mail.mail_admins # or ...mail_managers. Make sure to include the trailing space. -EMAIL_SUBJECT_PREFIX: str = ... +EMAIL_SUBJECT_PREFIX: str # Whether to append trailing slashes to URLs. -APPEND_SLASH: bool = ... +APPEND_SLASH: bool # Whether to prepend the "www." subdomain to URLs that don't have it. -PREPEND_WWW: bool = ... +PREPEND_WWW: bool # Override the server-derived value of SCRIPT_NAME -FORCE_SCRIPT_NAME: str | None = ... +FORCE_SCRIPT_NAME: str | None # List of compiled regular expression objects representing User-Agent strings # that are not allowed to visit any page, systemwide. Use this for bad @@ -148,9 +148,9 @@ FORCE_SCRIPT_NAME: str | None = ... # re.compile(r'^SiteSucker.*'), # re.compile(r'^sohu-search'), # ] -DISALLOWED_USER_AGENTS: List[Pattern[str]] = ... +DISALLOWED_USER_AGENTS: List[Pattern[str]] -ABSOLUTE_URL_OVERRIDES: Dict[str, Any] = ... +ABSOLUTE_URL_OVERRIDES: Dict[str, Any] # List of compiled regular expression objects representing URLs that need not # be reported by BrokenLinkEmailsMiddleware. Here are a few examples: @@ -162,150 +162,150 @@ ABSOLUTE_URL_OVERRIDES: Dict[str, Any] = ... # re.compile(r'^/phpmyadmin/'), # re.compile(r'\.(cgi|php|pl)$'), # ] -IGNORABLE_404_URLS: List[Pattern[str]] = ... +IGNORABLE_404_URLS: List[Pattern[str]] # A secret key for this particular Django installation. Used in secret-key # hashing algorithms. Set this in your settings, or Django will complain # loudly. -SECRET_KEY: str = ... +SECRET_KEY: str # Default file storage mechanism that holds media. -DEFAULT_FILE_STORAGE: str = ... +DEFAULT_FILE_STORAGE: str # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/var/www/example.com/media/" -MEDIA_ROOT: str = ... +MEDIA_ROOT: str # URL that handles the media served from MEDIA_ROOT. # Examples: "http://example.com/media/", "http://media.example.com/" -MEDIA_URL: str = ... +MEDIA_URL: str # Absolute path to the directory static files should be collected to. # Example: "/var/www/example.com/static/" -STATIC_ROOT: str | None = ... +STATIC_ROOT: str | None # URL that handles the static files served from STATIC_ROOT. # Example: "http://example.com/static/", "http://static.example.com/" -STATIC_URL: str | None = ... +STATIC_URL: str | None # List of upload handler classes to be applied in order. -FILE_UPLOAD_HANDLERS: List[str] = ... +FILE_UPLOAD_HANDLERS: List[str] # Maximum size, in bytes, of a request before it will be streamed to the # file system instead of into memory. -FILE_UPLOAD_MAX_MEMORY_SIZE: int = ... # i.e. 2.5 MB +FILE_UPLOAD_MAX_MEMORY_SIZE: int # i.e. 2.5 MB # Maximum size in bytes of request data (excluding file uploads) that will be # read before a SuspiciousOperation (RequestDataTooBig) is raised. -DATA_UPLOAD_MAX_MEMORY_SIZE: int = ... # i.e. 2.5 MB +DATA_UPLOAD_MAX_MEMORY_SIZE: int # i.e. 2.5 MB # Maximum number of GET/POST parameters that will be read before a # SuspiciousOperation (TooManyFieldsSent) is raised. -DATA_UPLOAD_MAX_NUMBER_FIELDS: int = ... +DATA_UPLOAD_MAX_NUMBER_FIELDS: int # Directory in which upload streamed files will be temporarily saved. A value of # `None` will make Django use the operating system's default temporary directory # (i.e. "/tmp" on *nix systems). -FILE_UPLOAD_TEMP_DIR: str | None = ... +FILE_UPLOAD_TEMP_DIR: str | None # The numeric mode to set newly-uploaded files to. The value should be a mode # you'd pass directly to os.chmod; see https://docs.python.org/library/os.html#files-and-directories. -FILE_UPLOAD_PERMISSIONS: int = ... +FILE_UPLOAD_PERMISSIONS: int # The numeric mode to assign to newly-created directories, when uploading files. # The value should be a mode as you'd pass to os.chmod; # see https://docs.python.org/library/os.html#files-and-directories. -FILE_UPLOAD_DIRECTORY_PERMISSIONS: int | None = ... +FILE_UPLOAD_DIRECTORY_PERMISSIONS: int | None # Python module path where user will place custom format definition. # The directory where this setting is pointing should contain subdirectories # named as the locales, containing a formats.py file # (i.e. "myproject.locale" for myproject/locale/en/formats.py etc. use) -FORMAT_MODULE_PATH: str | None = ... +FORMAT_MODULE_PATH: str | None # Default formatting for date objects. See all available format strings here: # https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date -DATE_FORMAT: str = ... +DATE_FORMAT: str # Default formatting for datetime objects. See all available format strings here: # https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date -DATETIME_FORMAT: str = ... +DATETIME_FORMAT: str # Default formatting for time objects. See all available format strings here: # https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date -TIME_FORMAT: str = ... +TIME_FORMAT: str # Default formatting for date objects when only the year and month are relevant. # See all available format strings here: # https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date -YEAR_MONTH_FORMAT: str = ... +YEAR_MONTH_FORMAT: str # Default formatting for date objects when only the month and day are relevant. # See all available format strings here: # https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date -MONTH_DAY_FORMAT: str = ... +MONTH_DAY_FORMAT: str # Default short formatting for date objects. See all available format strings here: # https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date -SHORT_DATE_FORMAT: str = ... +SHORT_DATE_FORMAT: str # Default short formatting for datetime objects. # See all available format strings here: # https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date -SHORT_DATETIME_FORMAT: str = ... +SHORT_DATETIME_FORMAT: str # Default formats to be used when parsing dates from input boxes, in order # See all available format string here: # https://docs.python.org/library/datetime.html#strftime-behavior # * Note that these format strings are different from the ones to display dates -DATE_INPUT_FORMATS: List[str] = ... +DATE_INPUT_FORMATS: List[str] # Default formats to be used when parsing times from input boxes, in order # See all available format string here: # https://docs.python.org/library/datetime.html#strftime-behavior # * Note that these format strings are different from the ones to display dates -TIME_INPUT_FORMATS: List[str] = ... # '14:30:59' # '14:30:59.000200' # '14:30' +TIME_INPUT_FORMATS: List[str] # '14:30:59' # '14:30:59.000200' # '14:30' # Default formats to be used when parsing dates and times from input boxes, # in order # See all available format string here: # https://docs.python.org/library/datetime.html#strftime-behavior # * Note that these format strings are different from the ones to display dates -DATETIME_INPUT_FORMATS: List[str] = ... +DATETIME_INPUT_FORMATS: List[str] # First day of week, to be used on calendars # 0 means Sunday, 1 means Monday... -FIRST_DAY_OF_WEEK: int = ... +FIRST_DAY_OF_WEEK: int # Decimal separator symbol -DECIMAL_SEPARATOR: str = ... +DECIMAL_SEPARATOR: str # Boolean that sets whether to add thousand separator when formatting numbers -USE_THOUSAND_SEPARATOR: bool = ... +USE_THOUSAND_SEPARATOR: bool # Number of digits that will be together, when splitting them by # THOUSAND_SEPARATOR. 0 means no grouping, 3 means splitting by thousands... -NUMBER_GROUPING: int = ... +NUMBER_GROUPING: int # Thousand separator symbol -THOUSAND_SEPARATOR: str = ... +THOUSAND_SEPARATOR: str # The tablespaces to use for each model when not specified otherwise. -DEFAULT_TABLESPACE: str = ... -DEFAULT_INDEX_TABLESPACE: str = ... +DEFAULT_TABLESPACE: str +DEFAULT_INDEX_TABLESPACE: str # Default X-Frame-Options header value -X_FRAME_OPTIONS: str = ... +X_FRAME_OPTIONS: str -USE_X_FORWARDED_HOST: bool = ... -USE_X_FORWARDED_PORT: bool = ... +USE_X_FORWARDED_HOST: bool +USE_X_FORWARDED_PORT: bool # The Python dotted path to the WSGI application that Django's internal server # (runserver) will use. If `None`, the return value of # 'django.core.wsgi.get_wsgi_application' is used, thus preserving the same # behavior as previous versions of Django. Otherwise this should point to an # actual WSGI application object. -WSGI_APPLICATION: str | None = ... +WSGI_APPLICATION: str | None # If your Django app is behind a proxy that sets a header to specify secure # connections, AND that proxy ensures that user-submitted headers with the @@ -314,7 +314,7 @@ WSGI_APPLICATION: str | None = ... # that header/value, request.is_secure() will return True. # WARNING! Only set this if you fully understand what you're doing. Otherwise, # you may be opening yourself up to a security risk. -SECURE_PROXY_SSL_HEADER: Tuple[str, str] | None = ... +SECURE_PROXY_SSL_HEADER: Tuple[str, str] | None ############## # MIDDLEWARE # @@ -323,80 +323,80 @@ SECURE_PROXY_SSL_HEADER: Tuple[str, str] | None = ... # List of middleware to use. Order is important; in the request phase, these # middleware will be applied in the order given, and in the response # phase the middleware will be applied in reverse order. -MIDDLEWARE: List[str] = ... +MIDDLEWARE: List[str] ############ # SESSIONS # ############ # Cache to store session data if using the cache session backend. -SESSION_CACHE_ALIAS: str = ... +SESSION_CACHE_ALIAS: str # Cookie name. This can be whatever you want. -SESSION_COOKIE_NAME: str = ... +SESSION_COOKIE_NAME: str # Age of cookie, in seconds (default: 2 weeks). -SESSION_COOKIE_AGE: int = ... +SESSION_COOKIE_AGE: int # A string like "example.com", or None for standard domain cookie. -SESSION_COOKIE_DOMAIN: str | None = ... +SESSION_COOKIE_DOMAIN: str | None # Whether the session cookie should be secure (https:// only). -SESSION_COOKIE_SECURE: bool = ... +SESSION_COOKIE_SECURE: bool # The path of the session cookie. -SESSION_COOKIE_PATH: str = ... +SESSION_COOKIE_PATH: str # Whether to use the non-RFC standard httpOnly flag (IE, FF3+, others) -SESSION_COOKIE_HTTPONLY: bool = ... +SESSION_COOKIE_HTTPONLY: bool # Whether to set the flag restricting cookie leaks on cross-site requests. # This can be 'Lax', 'Strict', 'None', or False to disable the flag. -SESSION_COOKIE_SAMESITE: Literal["Lax", "Strict", "None", False] = ... +SESSION_COOKIE_SAMESITE: Literal["Lax", "Strict", "None", False] # Whether to save the session data on every request. -SESSION_SAVE_EVERY_REQUEST: bool = ... +SESSION_SAVE_EVERY_REQUEST: bool # Whether a user's session cookie expires when the Web browser is closed. -SESSION_EXPIRE_AT_BROWSER_CLOSE: bool = ... +SESSION_EXPIRE_AT_BROWSER_CLOSE: bool # The module to store session data -SESSION_ENGINE: str = ... +SESSION_ENGINE: str # 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 = ... +SESSION_FILE_PATH: str | None # class to serialize session data -SESSION_SERIALIZER: str = ... +SESSION_SERIALIZER: str ######### # CACHE # ######### # The cache backends to use. -CACHES: Dict[str, Dict[str, Any]] = ... -CACHE_MIDDLEWARE_KEY_PREFIX: str = ... -CACHE_MIDDLEWARE_SECONDS: int = ... -CACHE_MIDDLEWARE_ALIAS: str = ... +CACHES: Dict[str, Dict[str, Any]] +CACHE_MIDDLEWARE_KEY_PREFIX: str +CACHE_MIDDLEWARE_SECONDS: int +CACHE_MIDDLEWARE_ALIAS: str ################## # AUTHENTICATION # ################## -AUTH_USER_MODEL: str = ... +AUTH_USER_MODEL: str -AUTHENTICATION_BACKENDS: Sequence[str] = ... +AUTHENTICATION_BACKENDS: Sequence[str] -LOGIN_URL: str = ... +LOGIN_URL: str -LOGIN_REDIRECT_URL: str = ... +LOGIN_REDIRECT_URL: str -LOGOUT_REDIRECT_URL: str | None = ... +LOGOUT_REDIRECT_URL: str | None # The number of days a password reset link is valid for -PASSWORD_RESET_TIMEOUT_DAYS: int = ... +PASSWORD_RESET_TIMEOUT_DAYS: int # the first hasher in this list is the preferred algorithm. any # password using different algorithms will be converted automatically # upon login -PASSWORD_HASHERS: List[str] = ... +PASSWORD_HASHERS: List[str] -AUTH_PASSWORD_VALIDATORS: List[Dict[str, str]] = ... +AUTH_PASSWORD_VALIDATORS: List[Dict[str, str]] ########### # SIGNING # ########### -SIGNING_BACKEND: str = ... +SIGNING_BACKEND: str ######## # CSRF # @@ -404,26 +404,26 @@ SIGNING_BACKEND: str = ... # Dotted path to callable to be used as view when a request is # rejected by the CSRF middleware. -CSRF_FAILURE_VIEW: str = ... +CSRF_FAILURE_VIEW: str # Settings for CSRF cookie. -CSRF_COOKIE_NAME: str = ... -CSRF_COOKIE_AGE: int = ... -CSRF_COOKIE_DOMAIN: str | None = ... -CSRF_COOKIE_PATH: str = ... -CSRF_COOKIE_SECURE: bool = ... -CSRF_COOKIE_HTTPONLY: bool = ... -CSRF_COOKIE_SAMESITE: Literal["Lax", "Strict", "None", False] = ... -CSRF_HEADER_NAME: str = ... -CSRF_TRUSTED_ORIGINS: List[str] = ... -CSRF_USE_SESSIONS: bool = ... +CSRF_COOKIE_NAME: str +CSRF_COOKIE_AGE: int +CSRF_COOKIE_DOMAIN: str | None +CSRF_COOKIE_PATH: str +CSRF_COOKIE_SECURE: bool +CSRF_COOKIE_HTTPONLY: bool +CSRF_COOKIE_SAMESITE: Literal["Lax", "Strict", "None", False] +CSRF_HEADER_NAME: str +CSRF_TRUSTED_ORIGINS: List[str] +CSRF_USE_SESSIONS: bool ############ # MESSAGES # ############ # Class to use as messages backend -MESSAGE_STORAGE: str = ... +MESSAGE_STORAGE: str # Default values of MESSAGE_LEVEL and MESSAGE_TAGS are defined within # django.contrib.messages to avoid imports in this settings file. @@ -433,53 +433,53 @@ MESSAGE_STORAGE: str = ... ########### # The callable to use to configure logging -LOGGING_CONFIG: str = ... +LOGGING_CONFIG: str # Custom logging configuration. -LOGGING: Dict[str, Any] = ... +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: str = ... +DEFAULT_EXCEPTION_REPORTER_FILTER: str ########### # TESTING # ########### # The name of the class to use to run the test suite -TEST_RUNNER: str = ... +TEST_RUNNER: str # Apps that don't need to be serialized at test database creation time # (only apps with migrations are to start with) -TEST_NON_SERIALIZED_APPS: List[str] = ... +TEST_NON_SERIALIZED_APPS: List[str] ############ # FIXTURES # ############ # The list of directories to search for fixtures -FIXTURE_DIRS: List[str] = ... +FIXTURE_DIRS: List[str] ############### # STATICFILES # ############### # A list of locations of additional static files -STATICFILES_DIRS: List[str] = ... +STATICFILES_DIRS: List[str] # The default file storage backend used during the build process -STATICFILES_STORAGE: str = ... +STATICFILES_STORAGE: str # List of finder classes that know how to find static files in # various locations. -STATICFILES_FINDERS: List[str] = ... +STATICFILES_FINDERS: List[str] ############## # MIGRATIONS # ############## # Migration module overrides for apps, by app label. -MIGRATION_MODULES: Dict[str, str] = ... +MIGRATION_MODULES: Dict[str, str] ################# # SYSTEM CHECKS # @@ -489,16 +489,16 @@ MIGRATION_MODULES: Dict[str, str] = ... # issues like warnings, infos or debugs will not generate a message. Silencing # serious issues like errors and criticals does not result in hiding the # message, but Django will not stop you from e.g. running server. -SILENCED_SYSTEM_CHECKS: List[str] = ... +SILENCED_SYSTEM_CHECKS: List[str] ####################### # SECURITY MIDDLEWARE # ####################### -SECURE_BROWSER_XSS_FILTER: bool = ... -SECURE_CONTENT_TYPE_NOSNIFF: bool = ... -SECURE_HSTS_INCLUDE_SUBDOMAINS: bool = ... -SECURE_HSTS_PRELOAD: bool = ... -SECURE_HSTS_SECONDS: int = ... -SECURE_REDIRECT_EXEMPT: List[str] = ... -SECURE_SSL_HOST: str | None = ... -SECURE_SSL_REDIRECT: bool = ... +SECURE_BROWSER_XSS_FILTER: bool +SECURE_CONTENT_TYPE_NOSNIFF: bool +SECURE_HSTS_INCLUDE_SUBDOMAINS: bool +SECURE_HSTS_PRELOAD: bool +SECURE_HSTS_SECONDS: int +SECURE_REDIRECT_EXEMPT: List[str] +SECURE_SSL_HOST: str | None +SECURE_SSL_REDIRECT: bool diff --git a/django-stubs/conf/locale/__init__.pyi b/django-stubs/conf/locale/__init__.pyi index b7629af2b..c5ecead17 100644 --- a/django-stubs/conf/locale/__init__.pyi +++ b/django-stubs/conf/locale/__init__.pyi @@ -1,3 +1,3 @@ from typing import Any, Dict -LANG_INFO: Dict[str, Any] = ... +LANG_INFO: Dict[str, Any] diff --git a/django-stubs/conf/urls/__init__.pyi b/django-stubs/conf/urls/__init__.pyi index 6d58d9a41..f8197f8a6 100644 --- a/django-stubs/conf/urls/__init__.pyi +++ b/django-stubs/conf/urls/__init__.pyi @@ -5,10 +5,10 @@ from django.http.response import HttpResponse, HttpResponseBase from django.urls import URLPattern, URLResolver from django.urls import include as include -handler400: str | Callable[..., HttpResponse] = ... -handler403: str | Callable[..., HttpResponse] = ... -handler404: str | Callable[..., HttpResponse] = ... -handler500: str | Callable[..., HttpResponse] = ... +handler400: str | Callable[..., HttpResponse] +handler403: str | Callable[..., HttpResponse] +handler404: str | Callable[..., HttpResponse] +handler500: str | Callable[..., HttpResponse] IncludedURLConf = Tuple[Sequence[URLResolver | URLPattern], str | None, str | None] diff --git a/django-stubs/contrib/admin/apps.pyi b/django-stubs/contrib/admin/apps.pyi index 0fa9e21e8..d23665bd1 100644 --- a/django-stubs/contrib/admin/apps.pyi +++ b/django-stubs/contrib/admin/apps.pyi @@ -1,6 +1,6 @@ from django.apps import AppConfig class SimpleAdminConfig(AppConfig): - default_site: str = ... + default_site: str class AdminConfig(SimpleAdminConfig): ... diff --git a/django-stubs/contrib/admin/filters.pyi b/django-stubs/contrib/admin/filters.pyi index 54456c129..ffe0c0a10 100644 --- a/django-stubs/contrib/admin/filters.pyi +++ b/django-stubs/contrib/admin/filters.pyi @@ -8,9 +8,9 @@ from django.db.models.query import QuerySet from django.http.request import HttpRequest class ListFilter: - title: str = ... - template: str = ... - used_parameters: Any = ... + title: str + template: str + used_parameters: Any def __init__( self, request: HttpRequest, params: Dict[str, str], model: Type[Model], model_admin: ModelAdmin ) -> None: ... @@ -20,16 +20,16 @@ class ListFilter: def expected_parameters(self) -> List[str] | None: ... class SimpleListFilter(ListFilter): - parameter_name: str = ... - lookup_choices: Any = ... + parameter_name: str + lookup_choices: Any def value(self) -> str | None: ... def lookups(self, request: HttpRequest, model_admin: ModelAdmin) -> Iterable[Tuple[Any, str]] | None: ... def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... class FieldListFilter(ListFilter): - field: Field = ... - field_path: str = ... - title: str = ... + field: Field + field_path: str + title: str def __init__( self, field: Field, @@ -54,14 +54,14 @@ class FieldListFilter(ListFilter): class RelatedFieldListFilter(FieldListFilter): used_parameters: Dict[Any, Any] - lookup_kwarg: str = ... - lookup_kwarg_isnull: str = ... - lookup_val: Any = ... - lookup_val_isnull: Any = ... - lookup_choices: Any = ... - lookup_title: str = ... - title: str = ... - empty_value_display: Any = ... + lookup_kwarg: str + lookup_kwarg_isnull: str + lookup_val: Any + lookup_val_isnull: Any + lookup_choices: Any + lookup_title: str + title: str + empty_value_display: Any @property def include_empty_choice(self) -> bool: ... def field_choices( @@ -70,39 +70,39 @@ class RelatedFieldListFilter(FieldListFilter): def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... class BooleanFieldListFilter(FieldListFilter): - lookup_kwarg: str = ... - lookup_kwarg2: str = ... - lookup_val: Any = ... - lookup_val2: Any = ... + lookup_kwarg: str + lookup_kwarg2: str + lookup_val: Any + lookup_val2: Any def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... class ChoicesFieldListFilter(FieldListFilter): title: str used_parameters: Dict[Any, Any] - lookup_kwarg: str = ... - lookup_kwarg_isnull: str = ... - lookup_val: Any = ... - lookup_val_isnull: Any = ... + lookup_kwarg: str + lookup_kwarg_isnull: str + lookup_val: Any + lookup_val_isnull: Any def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... class DateFieldListFilter(FieldListFilter): - field_generic: Any = ... - date_params: Any = ... - lookup_kwarg_since: Any = ... - lookup_kwarg_until: Any = ... - links: Any = ... - lookup_kwarg_isnull: Any = ... + field_generic: Any + date_params: Any + lookup_kwarg_since: Any + lookup_kwarg_until: Any + links: Any + lookup_kwarg_isnull: Any def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... class AllValuesFieldListFilter(FieldListFilter): title: str used_parameters: Dict[Any, Any] - lookup_kwarg: str = ... - lookup_kwarg_isnull: str = ... - lookup_val: Any = ... - lookup_val_isnull: Any = ... - empty_value_display: str = ... - lookup_choices: QuerySet = ... + lookup_kwarg: str + lookup_kwarg_isnull: str + lookup_val: Any + lookup_val_isnull: Any + empty_value_display: str + lookup_choices: QuerySet def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... class RelatedOnlyFieldListFilter(RelatedFieldListFilter): @@ -114,6 +114,6 @@ class RelatedOnlyFieldListFilter(RelatedFieldListFilter): used_parameters: Dict[Any, Any] class EmptyFieldListFilter(FieldListFilter): - lookup_kwarg: str = ... - lookup_val: Any = ... + lookup_kwarg: str + lookup_val: Any def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... diff --git a/django-stubs/contrib/admin/forms.pyi b/django-stubs/contrib/admin/forms.pyi index fdfe7d919..930c5e132 100644 --- a/django-stubs/contrib/admin/forms.pyi +++ b/django-stubs/contrib/admin/forms.pyi @@ -1,7 +1,7 @@ from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm class AdminAuthenticationForm(AuthenticationForm): - required_css_class: str = ... + required_css_class: str class AdminPasswordChangeForm(PasswordChangeForm): - required_css_class: str = ... + required_css_class: str diff --git a/django-stubs/contrib/admin/helpers.pyi b/django-stubs/contrib/admin/helpers.pyi index 64c007d22..5233dbc2d 100644 --- a/django-stubs/contrib/admin/helpers.pyi +++ b/django-stubs/contrib/admin/helpers.pyi @@ -15,8 +15,8 @@ from typing_extensions import TypedDict ACTION_CHECKBOX_NAME: str class ActionForm(forms.Form): - action: Any = ... - select_across: Any = ... + action: Any + select_across: Any checkbox: Any @@ -26,8 +26,8 @@ class _PrepopulatedDict(TypedDict): class AdminForm: prepopulated_fields: List[_PrepopulatedDict] - model_admin: ModelAdmin | None = ... - readonly_fields: Sequence[str] = ... + model_admin: ModelAdmin | None + readonly_fields: Sequence[str] form: ModelForm fieldsets: List[Tuple[Any, Dict[str, List[str]]]] def __init__( @@ -47,11 +47,11 @@ class AdminForm: def media(self) -> Media: ... class Fieldset: - form: ModelForm = ... - classes: str = ... - description: str | None = ... - model_admin: ModelAdmin | None = ... - readonly_fields: Sequence[str] = ... + form: ModelForm + classes: str + description: str | None + model_admin: ModelAdmin | None + readonly_fields: Sequence[str] def __init__( self, form: ModelForm, @@ -67,11 +67,11 @@ class Fieldset: def __iter__(self) -> Iterator[Fieldline]: ... class Fieldline: - form: ModelForm = ... - fields: Sequence[str] = ... - has_visible_field: bool = ... - model_admin: ModelAdmin | None = ... - readonly_fields: Sequence[str] = ... + form: ModelForm + fields: Sequence[str] + has_visible_field: bool + model_admin: ModelAdmin | None + readonly_fields: Sequence[str] def __init__( self, form: ModelForm, @@ -83,10 +83,10 @@ class Fieldline: def errors(self) -> SafeString: ... class AdminField: - field: BoundField = ... - is_first: bool = ... - is_checkbox: bool = ... - is_readonly: bool = ... + field: BoundField + is_first: bool + is_checkbox: bool + is_readonly: bool def __init__(self, form: ModelForm, field: str, is_first: bool) -> None: ... def label_tag(self) -> SafeString: ... def errors(self) -> SafeString: ... @@ -98,13 +98,13 @@ class _FieldDictT(TypedDict): field: Callable[[Model], Any] | str class AdminReadonlyField: - field: _FieldDictT = ... - form: ModelForm = ... - model_admin: ModelAdmin | None = ... - is_first: bool = ... - is_checkbox: bool = ... - is_readonly: bool = ... - empty_value_display: Any = ... + field: _FieldDictT + form: ModelForm + model_admin: ModelAdmin | None + is_first: bool + is_checkbox: bool + is_readonly: bool + empty_value_display: Any def __init__( self, form: ModelForm, @@ -116,17 +116,17 @@ class AdminReadonlyField: def contents(self) -> SafeString: ... class InlineAdminFormSet: - opts: Any = ... - formset: Any = ... - fieldsets: Any = ... - model_admin: ModelAdmin | None = ... - readonly_fields: Sequence[str] = ... - prepopulated_fields: Dict[str, Any] = ... - classes: str = ... - has_add_permission: bool = ... - has_change_permission: bool = ... - has_delete_permission: bool = ... - has_view_permission: bool = ... + opts: Any + formset: Any + fieldsets: Any + model_admin: ModelAdmin | None + readonly_fields: Sequence[str] + prepopulated_fields: Dict[str, Any] + classes: str + has_add_permission: bool + has_change_permission: bool + has_delete_permission: bool + has_view_permission: bool def __init__( self, inline: Any, @@ -151,10 +151,10 @@ class InlineAdminFormSet: def media(self) -> Media: ... class InlineAdminForm(AdminForm): - formset: Any = ... - original: bool | None = ... - show_url: bool = ... - absolute_url: str | None = ... + formset: Any + original: bool | None + show_url: bool + absolute_url: str | None def __init__( self, formset: Any, @@ -173,7 +173,7 @@ class InlineAdminForm(AdminForm): def deletion_field(self) -> AdminField: ... class InlineFieldset(Fieldset): - formset: Any = ... + formset: Any def __init__(self, formset: Any, *args: Any, **kwargs: Any) -> None: ... def __iter__(self) -> Iterator[Fieldline]: ... diff --git a/django-stubs/contrib/admin/models.pyi b/django-stubs/contrib/admin/models.pyi index 6c1a20cee..b0c8a774e 100644 --- a/django-stubs/contrib/admin/models.pyi +++ b/django-stubs/contrib/admin/models.pyi @@ -22,14 +22,14 @@ class LogEntryManager(models.Manager["LogEntry"]): ) -> LogEntry: ... class LogEntry(models.Model): - action_time: models.DateTimeField = ... - user: models.ForeignKey = ... - content_type: models.ForeignKey = models.ForeignKey(ContentType, on_delete=models.CASCADE) - object_id: models.TextField = ... - object_repr: models.CharField = ... - action_flag: models.PositiveSmallIntegerField = ... - change_message: models.TextField = ... - objects: LogEntryManager = ... + action_time: models.DateTimeField + user: models.ForeignKey + content_type: models.ForeignKey + object_id: models.TextField + object_repr: models.CharField + action_flag: models.PositiveSmallIntegerField + change_message: models.TextField + objects: LogEntryManager def is_addition(self) -> bool: ... def is_change(self) -> bool: ... def is_deletion(self) -> bool: ... diff --git a/django-stubs/contrib/admin/options.pyi b/django-stubs/contrib/admin/options.pyi index 548e67876..5414ab324 100644 --- a/django-stubs/contrib/admin/options.pyi +++ b/django-stubs/contrib/admin/options.pyi @@ -53,8 +53,8 @@ from typing_extensions import Literal, TypedDict IS_POPUP_VAR: str TO_FIELD_VAR: str -HORIZONTAL: Literal[1] = ... -VERTICAL: Literal[2] = ... +HORIZONTAL: Literal[1] +VERTICAL: Literal[2] _Direction = Union[Literal[1], Literal[2]] @@ -92,23 +92,23 @@ _ListFilterT = Union[ _ModelT = TypeVar("_ModelT", bound=Model) class BaseModelAdmin(Generic[_ModelT]): - autocomplete_fields: Sequence[str] = ... - raw_id_fields: Sequence[str] = ... - fields: _FieldGroups | None = ... - exclude: Sequence[str] | None = ... - fieldsets: Optional[_FieldsetSpec] = ... - form: Type[forms.ModelForm[_ModelT]] = ... - filter_vertical: Sequence[str] = ... - filter_horizontal: Sequence[str] = ... - radio_fields: Mapping[str, _Direction] = ... - prepopulated_fields: Dict[str, Sequence[str]] = ... - formfield_overrides: Mapping[Type[Field], Mapping[str, Any]] = ... - readonly_fields: Sequence[str] = ... - ordering: Sequence[str] | None = ... - sortable_by: _ListOrTuple[str] | None = ... - view_on_site: bool | Callable[[_ModelT], str] = ... - show_full_result_count: bool = ... - checks_class: Any = ... + autocomplete_fields: Sequence[str] + raw_id_fields: Sequence[str] + fields: _FieldGroups | None + exclude: Sequence[str] | None + fieldsets: Optional[_FieldsetSpec] + form: Type[forms.ModelForm[_ModelT]] + filter_vertical: Sequence[str] + filter_horizontal: Sequence[str] + radio_fields: Mapping[str, _Direction] + prepopulated_fields: Dict[str, Sequence[str]] + formfield_overrides: Mapping[Type[Field], Mapping[str, Any]] + readonly_fields: Sequence[str] + ordering: Sequence[str] | None + sortable_by: _ListOrTuple[str] | None + view_on_site: bool | Callable[[_ModelT], str] + show_full_result_count: bool + checks_class: Any model: Type[_ModelT] opts: Options[_ModelT] admin_site: AdminSite @@ -147,36 +147,36 @@ class BaseModelAdmin(Generic[_ModelT]): _DisplayT = _ListOrTuple[str | Callable[[_ModelT], str]] class ModelAdmin(BaseModelAdmin[_ModelT]): - list_display: _DisplayT = ... - list_display_links: _DisplayT | None = ... - list_filter: _ListOrTuple[_ListFilterT] = ... - list_select_related: bool | Sequence[str] = ... - list_per_page: int = ... - list_max_show_all: int = ... - list_editable: Sequence[str] = ... - search_fields: Sequence[str] = ... - date_hierarchy: str | None = ... - save_as: bool = ... - save_as_continue: bool = ... - save_on_top: bool = ... - paginator: Type = ... - preserve_filters: bool = ... - inlines: Sequence[Type[InlineModelAdmin]] = ... - add_form_template: _TemplateForResponseT | None = ... - change_form_template: _TemplateForResponseT | None = ... - change_list_template: _TemplateForResponseT | None = ... - delete_confirmation_template: _TemplateForResponseT | None = ... - delete_selected_confirmation_template: _TemplateForResponseT | None = ... - object_history_template: _TemplateForResponseT | None = ... - popup_response_template: _TemplateForResponseT | None = ... - actions: Sequence[Callable[[ModelAdmin, HttpRequest, QuerySet], None] | str] | None = ... - action_form: Any = ... - actions_on_top: bool = ... - actions_on_bottom: bool = ... - actions_selection_counter: bool = ... - model: Type[_ModelT] = ... - opts: Options[_ModelT] = ... - admin_site: AdminSite = ... + list_display: _DisplayT + list_display_links: _DisplayT | None + list_filter: _ListOrTuple[_ListFilterT] + list_select_related: bool | Sequence[str] + list_per_page: int + list_max_show_all: int + list_editable: Sequence[str] + search_fields: Sequence[str] + date_hierarchy: str | None + save_as: bool + save_as_continue: bool + save_on_top: bool + paginator: Type + preserve_filters: bool + inlines: Sequence[Type[InlineModelAdmin]] + add_form_template: _TemplateForResponseT | None + change_form_template: _TemplateForResponseT | None + change_list_template: _TemplateForResponseT | None + delete_confirmation_template: _TemplateForResponseT | None + delete_selected_confirmation_template: _TemplateForResponseT | None + object_history_template: _TemplateForResponseT | None + popup_response_template: _TemplateForResponseT | None + actions: Sequence[Callable[[ModelAdmin, HttpRequest, QuerySet], None] | str] | None + action_form: Any + actions_on_top: bool + actions_on_bottom: bool + actions_selection_counter: bool + model: Type[_ModelT] + opts: Options[_ModelT] + admin_site: AdminSite def __init__(self, model: Type[_ModelT], admin_site: AdminSite) -> None: ... def get_inline_instances(self, request: HttpRequest, obj: _ModelT | None = ...) -> List[InlineModelAdmin]: ... def get_urls(self) -> List[URLPattern]: ... @@ -290,22 +290,22 @@ _ChildModelT = TypeVar("_ChildModelT", bound=Model) _ParentModelT = TypeVar("_ParentModelT", bound=Model) class InlineModelAdmin(Generic[_ChildModelT, _ParentModelT], BaseModelAdmin[_ChildModelT]): - model: Type[_ChildModelT] = ... - fk_name: str | None = ... - formset: Type[BaseInlineFormSet[_ChildModelT, _ParentModelT, forms.ModelForm[_ChildModelT]]] = ... - extra: int = ... - min_num: int | None = ... - max_num: int | None = ... - template: str = ... - verbose_name: _StrOrPromise | None = ... - verbose_name_plural: _StrOrPromise | None = ... - can_delete: bool = ... - show_change_link: bool = ... - classes: Sequence[str] | None = ... - admin_site: AdminSite = ... - parent_model: Type[_ParentModelT] = ... - opts: Options[_ChildModelT] = ... - has_registered_model: bool = ... + model: Type[_ChildModelT] + fk_name: str | None + formset: Type[BaseInlineFormSet[_ChildModelT, _ParentModelT, forms.ModelForm[_ChildModelT]]] + extra: int + min_num: int | None + max_num: int | None + template: str + verbose_name: _StrOrPromise | None + verbose_name_plural: _StrOrPromise | None + can_delete: bool + show_change_link: bool + classes: Sequence[str] | None + admin_site: AdminSite + parent_model: Type[_ParentModelT] + opts: Options[_ChildModelT] + has_registered_model: bool def __init__(self, parent_model: Type[_ParentModelT], admin_site: AdminSite) -> None: ... @property def media(self) -> Media: ... @@ -322,7 +322,7 @@ class InlineModelAdmin(Generic[_ChildModelT, _ParentModelT], BaseModelAdmin[_Chi def has_view_permission(self, request: HttpRequest, obj: _ParentModelT | None = ...) -> bool: ... # type: ignore class StackedInline(InlineModelAdmin[_ChildModelT, _ParentModelT]): - template: str = ... + template: str class TabularInline(InlineModelAdmin[_ChildModelT, _ParentModelT]): - template: str = ... + template: str diff --git a/django-stubs/contrib/admin/sites.pyi b/django-stubs/contrib/admin/sites.pyi index 3bd23ea28..774a8f137 100644 --- a/django-stubs/contrib/admin/sites.pyi +++ b/django-stubs/contrib/admin/sites.pyi @@ -28,22 +28,22 @@ class AlreadyRegistered(Exception): ... class NotRegistered(Exception): ... class AdminSite: - site_title: str = ... - site_header: str = ... - index_title: str = ... - site_url: str = ... - login_form: Type[AuthenticationForm] | None = ... - index_template: str | None = ... - app_index_template: str | None = ... - login_template: str | None = ... - logout_template: str | None = ... - password_change_template: str | None = ... - password_change_done_template: str | None = ... - name: str = ... - enable_nav_sidebar: bool = ... - empty_value_display: str = ... - final_catch_all_view: bool = ... - _empty_value_display: str = ... + site_title: str + site_header: str + index_title: str + site_url: str + login_form: Type[AuthenticationForm] | None + index_template: str | None + app_index_template: str | None + login_template: str | None + logout_template: str | None + password_change_template: str | None + password_change_done_template: str | None + name: str + enable_nav_sidebar: bool + empty_value_display: str + final_catch_all_view: bool + _empty_value_display: str _registry: Dict[Type[Model], ModelAdmin] _global_actions: Dict[str, _ActionCallback] _actions: Dict[str, _ActionCallback] diff --git a/django-stubs/contrib/admin/templatetags/admin_list.pyi b/django-stubs/contrib/admin/templatetags/admin_list.pyi index bc290008a..c689cbce4 100644 --- a/django-stubs/contrib/admin/templatetags/admin_list.pyi +++ b/django-stubs/contrib/admin/templatetags/admin_list.pyi @@ -22,7 +22,7 @@ def result_headers(cl: ChangeList) -> Iterator[Dict[str, int | str | None]]: ... def items_for_result(cl: ChangeList, result: Model, form: ModelForm | None) -> Iterator[SafeString]: ... class ResultList(list): - form: ModelForm | None = ... + form: ModelForm | None def __init__(self, form: ModelForm | None, *items: Any) -> None: ... def results(cl: ChangeList) -> Iterator[ResultList]: ... diff --git a/django-stubs/contrib/admin/templatetags/base.pyi b/django-stubs/contrib/admin/templatetags/base.pyi index efb31710f..e822b28df 100644 --- a/django-stubs/contrib/admin/templatetags/base.pyi +++ b/django-stubs/contrib/admin/templatetags/base.pyi @@ -10,7 +10,7 @@ class InclusionAdminNode(InclusionNode): func: Callable kwargs: Dict[str, Any] takes_context: bool - template_name: str = ... + template_name: str def __init__( self, parser: Parser, token: Token, func: Callable, template_name: str, takes_context: bool = ... ) -> None: ... diff --git a/django-stubs/contrib/admin/utils.pyi b/django-stubs/contrib/admin/utils.pyi index 2f5f6d7d9..b0e1d766a 100644 --- a/django-stubs/contrib/admin/utils.pyi +++ b/django-stubs/contrib/admin/utils.pyi @@ -34,9 +34,9 @@ class NestedObjects(Collector): fast_deletes: List[Any] field_updates: Dict[Any, Any] using: str - edges: Any = ... - protected: Any = ... - model_objs: Any = ... + edges: Any + protected: Any + model_objs: Any def __init__(self, *args: Any, **kwargs: Any) -> None: ... def add_edge(self, source: Model | None, target: Model) -> None: ... def related_objects( diff --git a/django-stubs/contrib/admin/views/autocomplete.pyi b/django-stubs/contrib/admin/views/autocomplete.pyi index 102b838ee..fc036b91a 100644 --- a/django-stubs/contrib/admin/views/autocomplete.pyi +++ b/django-stubs/contrib/admin/views/autocomplete.pyi @@ -6,6 +6,6 @@ from django.http.request import HttpRequest from django.views.generic.list import BaseListView class AutocompleteJsonView(BaseListView): - model_admin: ModelAdmin = ... - term: Any = ... + model_admin: ModelAdmin + term: Any def has_perm(self, request: HttpRequest, obj: Model | None = ...) -> bool: ... diff --git a/django-stubs/contrib/admin/views/main.pyi b/django-stubs/contrib/admin/views/main.pyi index a93b31537..003bffe44 100644 --- a/django-stubs/contrib/admin/views/main.pyi +++ b/django-stubs/contrib/admin/views/main.pyi @@ -21,31 +21,31 @@ ERROR_FLAG: str IGNORED_PARAMS: Tuple[str, ...] class ChangeList: - model: Type[Model] = ... - opts: Options = ... - lookup_opts: Options = ... - root_queryset: QuerySet = ... - list_display: _DisplayT = ... - list_display_links: _DisplayT = ... - list_filter: Sequence[_ListFilterT] = ... - date_hierarchy: Any = ... - search_fields: Sequence[str] = ... - list_select_related: bool | Sequence[str] = ... - list_per_page: int = ... - list_max_show_all: int = ... - model_admin: ModelAdmin = ... - preserved_filters: str = ... - sortable_by: Sequence[str] | None = ... - page_num: int = ... - show_all: bool = ... - is_popup: bool = ... - to_field: Any = ... - params: Dict[str, Any] = ... - list_editable: Sequence[str] = ... - query: str = ... - queryset: Any = ... - title: str = ... - pk_attname: str = ... + model: Type[Model] + opts: Options + lookup_opts: Options + root_queryset: QuerySet + list_display: _DisplayT + list_display_links: _DisplayT + list_filter: Sequence[_ListFilterT] + date_hierarchy: Any + search_fields: Sequence[str] + list_select_related: bool | Sequence[str] + list_per_page: int + list_max_show_all: int + model_admin: ModelAdmin + preserved_filters: str + sortable_by: Sequence[str] | None + page_num: int + show_all: bool + is_popup: bool + to_field: Any + params: Dict[str, Any] + list_editable: Sequence[str] + query: str + queryset: Any + title: str + pk_attname: str formset: BaseFormSet | None def __init__( self, @@ -66,14 +66,14 @@ class ChangeList: def get_filters_params(self, params: Dict[str, Any] | None = ...) -> Dict[str, Any]: ... def get_filters(self, request: HttpRequest) -> Tuple[List[ListFilter], bool, Dict[str, bool | str], bool, bool]: ... def get_query_string(self, new_params: Dict[str, Any] | None = ..., remove: Iterable[str] | None = ...) -> str: ... - result_count: int = ... - show_full_result_count: bool = ... - show_admin_actions: bool = ... - full_result_count: int | None = ... - result_list: Any = ... - can_show_all: bool = ... - multi_page: bool = ... - paginator: Any = ... + result_count: int + show_full_result_count: bool + show_admin_actions: bool + full_result_count: int | None + result_list: Any + can_show_all: bool + multi_page: bool + paginator: Any def get_results(self, request: HttpRequest) -> None: ... def get_ordering_field(self, field_name: Callable | str) -> Expression | str | None: ... def get_ordering(self, request: HttpRequest, queryset: QuerySet) -> List[Expression | str]: ... diff --git a/django-stubs/contrib/admin/widgets.pyi b/django-stubs/contrib/admin/widgets.pyi index 1cd346359..41f048ca0 100644 --- a/django-stubs/contrib/admin/widgets.pyi +++ b/django-stubs/contrib/admin/widgets.pyi @@ -10,8 +10,8 @@ from django.forms.widgets import Media, _OptAttrs from django.utils.functional import _StrOrPromise class FilteredSelectMultiple(forms.SelectMultiple): - verbose_name: _StrOrPromise = ... - is_stacked: bool = ... + verbose_name: _StrOrPromise + is_stacked: bool def __init__( self, verbose_name: _StrOrPromise, @@ -37,9 +37,9 @@ class AdminFileWidget(forms.ClearableFileInput): ... def url_params_from_lookup_dict(lookups: Any) -> Dict[str, str]: ... class ForeignKeyRawIdWidget(forms.TextInput): - rel: ManyToOneRel = ... - admin_site: AdminSite = ... - db: str | None = ... + rel: ManyToOneRel + admin_site: AdminSite + db: str | None def __init__( self, rel: ManyToOneRel, admin_site: AdminSite, attrs: _OptAttrs | None = ..., using: str | None = ... ) -> None: ... @@ -49,7 +49,7 @@ class ForeignKeyRawIdWidget(forms.TextInput): def label_and_url_for_value(self, value: Any) -> Tuple[str, str]: ... class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): - rel: ManyToManyRel = ... # type: ignore + rel: ManyToManyRel # type: ignore def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... def url_parameters(self) -> Dict[str, str]: ... def label_and_url_for_value(self, value: Any) -> Tuple[str, str]: ... @@ -57,15 +57,15 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Iterable[File]], name: str) -> Any: ... class RelatedFieldWidgetWrapper(forms.Widget): - template_name: str = ... - choices: ModelChoiceIterator = ... - widget: forms.ChoiceWidget = ... - rel: ManyToOneRel = ... - can_add_related: bool = ... - can_change_related: bool = ... - can_delete_related: bool = ... - can_view_related: bool = ... - admin_site: AdminSite = ... + template_name: str + choices: ModelChoiceIterator + widget: forms.ChoiceWidget + rel: ManyToOneRel + can_add_related: bool + can_change_related: bool + can_delete_related: bool + can_view_related: bool + admin_site: AdminSite def __init__( self, widget: forms.ChoiceWidget, @@ -104,23 +104,23 @@ class AdminURLFieldWidget(forms.URLInput): class AdminIntegerFieldWidget(forms.NumberInput): def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... - class_name: str = ... + class_name: str class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): - class_name: str = ... + class_name: str class AdminUUIDInputWidget(forms.TextInput): def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... -SELECT2_TRANSLATIONS: Dict[str, str] = ... +SELECT2_TRANSLATIONS: Dict[str, str] class AutocompleteMixin: - url_name: str = ... - field: Any = ... - admin_site: AdminSite = ... - db: str | None = ... - choices: Any = ... - attrs: _OptAttrs = ... + url_name: str + field: Any + admin_site: AdminSite + db: str | None + choices: Any + attrs: _OptAttrs def __init__( self, field: Any, diff --git a/django-stubs/contrib/admindocs/apps.pyi b/django-stubs/contrib/admindocs/apps.pyi index 6150ebd38..f758414b0 100644 --- a/django-stubs/contrib/admindocs/apps.pyi +++ b/django-stubs/contrib/admindocs/apps.pyi @@ -3,5 +3,5 @@ from typing import Any from django.apps import AppConfig as AppConfig class AdminDocsConfig(AppConfig): - name: str = ... - verbose_name: Any = ... + name: str + verbose_name: Any diff --git a/django-stubs/contrib/admindocs/urls.pyi b/django-stubs/contrib/admindocs/urls.pyi index 3df94ca6f..14e91f5b3 100644 --- a/django-stubs/contrib/admindocs/urls.pyi +++ b/django-stubs/contrib/admindocs/urls.pyi @@ -2,4 +2,4 @@ from typing import List from django.urls import _AnyURL -urlpatterns: List[_AnyURL] = ... +urlpatterns: List[_AnyURL] diff --git a/django-stubs/contrib/auth/admin.pyi b/django-stubs/contrib/auth/admin.pyi index cd1234209..209779e64 100644 --- a/django-stubs/contrib/auth/admin.pyi +++ b/django-stubs/contrib/auth/admin.pyi @@ -10,8 +10,8 @@ sensitive_post_parameters_m: Any class GroupAdmin(admin.ModelAdmin): ... class UserAdmin(admin.ModelAdmin): - change_user_password_template: Any = ... - add_fieldsets: Any = ... - add_form: Any = ... - change_password_form: Any = ... + change_user_password_template: Any + add_fieldsets: Any + add_form: Any + change_password_form: Any def user_change_password(self, request: HttpRequest, id: str, form_url: str = ...) -> HttpResponse: ... diff --git a/django-stubs/contrib/auth/backends.pyi b/django-stubs/contrib/auth/backends.pyi index 6fe293f30..c306eff61 100644 --- a/django-stubs/contrib/auth/backends.pyi +++ b/django-stubs/contrib/auth/backends.pyi @@ -37,7 +37,7 @@ class AllowAllUsersModelBackend(ModelBackend): ... _U = TypeVar("_U", bound=AbstractBaseUser) class RemoteUserBackend(ModelBackend): - create_unknown_user: bool = ... + create_unknown_user: bool def clean_username(self, username: str) -> str: ... def configure_user(self, request: HttpRequest, user: _U) -> _U: ... diff --git a/django-stubs/contrib/auth/base_user.pyi b/django-stubs/contrib/auth/base_user.pyi index 4f2209634..53b1de2d0 100644 --- a/django-stubs/contrib/auth/base_user.pyi +++ b/django-stubs/contrib/auth/base_user.pyi @@ -15,11 +15,11 @@ class BaseUserManager(models.Manager[_T]): def get_by_natural_key(self, username: str | None) -> _T: ... class AbstractBaseUser(models.Model): - REQUIRED_FIELDS: List[str] = ... + REQUIRED_FIELDS: List[str] password = models.CharField(max_length=128) last_login = models.DateTimeField(blank=True, null=True) - is_active: bool | BooleanField[bool | Combinable, bool] = ... + is_active: bool | BooleanField[bool | Combinable, bool] def get_username(self) -> str: ... def natural_key(self) -> Tuple[str]: ... @property diff --git a/django-stubs/contrib/auth/context_processors.pyi b/django-stubs/contrib/auth/context_processors.pyi index 623e121cc..c9cce2a2b 100644 --- a/django-stubs/contrib/auth/context_processors.pyi +++ b/django-stubs/contrib/auth/context_processors.pyi @@ -11,7 +11,7 @@ class PermLookupDict: def __bool__(self) -> bool: ... class PermWrapper: - user: Any = ... + user: Any def __init__(self, user: Any) -> None: ... def __getitem__(self, app_label: str) -> PermLookupDict: ... def __iter__(self) -> Iterator[Any]: ... diff --git a/django-stubs/contrib/auth/forms.pyi b/django-stubs/contrib/auth/forms.pyi index a7b780824..f125f437d 100644 --- a/django-stubs/contrib/auth/forms.pyi +++ b/django-stubs/contrib/auth/forms.pyi @@ -14,12 +14,12 @@ UserModel: Type[AbstractBaseUser] _User = TypeVar("_User", bound=AbstractBaseUser) class ReadOnlyPasswordHashWidget(forms.Widget): - template_name: str = ... - read_only: bool = ... + template_name: str + read_only: bool def get_context(self, name: str, value: Any, attrs: Dict[str, Any] | None) -> Dict[str, Any]: ... class ReadOnlyPasswordHashField(forms.Field): - widget: _ClassLevelWidgetT = ... + widget: _ClassLevelWidgetT def __init__(self, *args: Any, **kwargs: Any) -> None: ... class UsernameField(forms.CharField): @@ -27,24 +27,24 @@ class UsernameField(forms.CharField): def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... class UserCreationForm(forms.ModelForm[_User]): - error_messages: _ErrorMessagesT = ... - password1: forms.Field = ... - password2: forms.Field = ... + error_messages: _ErrorMessagesT + password1: forms.Field + password2: forms.Field def __init__(self, *args: Any, **kwargs: Any) -> None: ... def clean_password2(self) -> str: ... def save(self, commit: bool = ...) -> _User: ... class UserChangeForm(forms.ModelForm[_User]): - password: forms.Field = ... + password: forms.Field def __init__(self, *args: Any, **kwargs: Any) -> None: ... class AuthenticationForm(forms.Form): - username: forms.Field = ... - password: forms.Field = ... - error_messages: _ErrorMessagesT = ... - request: HttpRequest | None = ... - user_cache: Any = ... - username_field: models.Field = ... + username: forms.Field + password: forms.Field + error_messages: _ErrorMessagesT + request: HttpRequest | None + user_cache: Any + username_field: models.Field def __init__(self, request: HttpRequest | None = ..., *args: Any, **kwargs: Any) -> None: ... def confirm_login_allowed(self, user: AbstractBaseUser) -> None: ... def get_user(self) -> AbstractBaseUser: ... @@ -52,7 +52,7 @@ class AuthenticationForm(forms.Form): def clean(self) -> Dict[str, Any]: ... class PasswordResetForm(forms.Form): - email: forms.Field = ... + email: forms.Field def send_mail( self, subject_template_name: str, @@ -77,25 +77,25 @@ class PasswordResetForm(forms.Form): ) -> None: ... class SetPasswordForm(forms.Form): - error_messages: _ErrorMessagesT = ... - new_password1: forms.Field = ... - new_password2: forms.Field = ... - user: AbstractBaseUser = ... + error_messages: _ErrorMessagesT + new_password1: forms.Field + new_password2: forms.Field + user: AbstractBaseUser def __init__(self, user: AbstractBaseUser, *args: Any, **kwargs: Any) -> None: ... def clean_new_password2(self) -> str: ... def save(self, commit: bool = ...) -> AbstractBaseUser: ... class PasswordChangeForm(SetPasswordForm): - error_messages: _ErrorMessagesT = ... - old_password: forms.Field = ... + error_messages: _ErrorMessagesT + old_password: forms.Field def clean_old_password(self) -> str: ... class AdminPasswordChangeForm(forms.Form): - error_messages: _ErrorMessagesT = ... - required_css_class: str = ... - password1: forms.Field = ... - password2: forms.Field = ... - user: AbstractBaseUser = ... + error_messages: _ErrorMessagesT + required_css_class: str + password1: forms.Field + password2: forms.Field + user: AbstractBaseUser def __init__(self, user: AbstractBaseUser, *args: Any, **kwargs: Any) -> None: ... def clean_password2(self) -> str: ... def save(self, commit: bool = ...) -> AbstractBaseUser: ... diff --git a/django-stubs/contrib/auth/hashers.pyi b/django-stubs/contrib/auth/hashers.pyi index f0d1b2fbb..b0f31bf21 100644 --- a/django-stubs/contrib/auth/hashers.pyi +++ b/django-stubs/contrib/auth/hashers.pyi @@ -14,14 +14,14 @@ def identify_hasher(encoded: str) -> BasePasswordHasher: ... def mask_hash(hash: str, show: int = ..., char: str = ...) -> str: ... class BasePasswordHasher: - algorithm: str = ... - library: str | Tuple[str, str] = ... - rounds: int = ... - time_cost: int = ... - memory_cost: int = ... - parallelism: int = ... - digest: Any = ... - iterations: int = ... + algorithm: str + library: str | Tuple[str, str] + rounds: int + time_cost: int + memory_cost: int + parallelism: int + digest: Any + iterations: int def salt(self) -> str: ... def verify(self, password: str, encoded: str) -> bool: ... def encode(self, password: str, salt: str) -> Any: ... diff --git a/django-stubs/contrib/auth/middleware.pyi b/django-stubs/contrib/auth/middleware.pyi index 52cc8ae35..4d25b66d0 100644 --- a/django-stubs/contrib/auth/middleware.pyi +++ b/django-stubs/contrib/auth/middleware.pyi @@ -9,10 +9,10 @@ class AuthenticationMiddleware(MiddlewareMixin): def process_request(self, request: HttpRequest) -> None: ... class RemoteUserMiddleware(MiddlewareMixin): - header: str = ... - force_logout_if_no_header: bool = ... + header: str + force_logout_if_no_header: bool def process_request(self, request: HttpRequest) -> None: ... def clean_username(self, username: str, request: HttpRequest) -> str: ... class PersistentRemoteUserMiddleware(RemoteUserMiddleware): - force_logout_if_no_header: bool = ... + force_logout_if_no_header: bool diff --git a/django-stubs/contrib/auth/mixins.pyi b/django-stubs/contrib/auth/mixins.pyi index d8fc25f9d..5162dfb3f 100644 --- a/django-stubs/contrib/auth/mixins.pyi +++ b/django-stubs/contrib/auth/mixins.pyi @@ -5,10 +5,10 @@ from django.http.response import HttpResponseBase, HttpResponseRedirect from django.utils.functional import _StrOrPromise class AccessMixin: - login_url: Any = ... - permission_denied_message: _StrOrPromise = ... - raise_exception: bool = ... - redirect_field_name: Any = ... + login_url: Any + permission_denied_message: _StrOrPromise + raise_exception: bool + redirect_field_name: Any def get_login_url(self) -> str: ... def get_permission_denied_message(self) -> _StrOrPromise: ... def get_redirect_field_name(self) -> str: ... @@ -18,7 +18,7 @@ class LoginRequiredMixin(AccessMixin): def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ... class PermissionRequiredMixin(AccessMixin): - permission_required: Any = ... + permission_required: Any def get_permission_required(self) -> Sequence[str]: ... def has_permission(self) -> bool: ... def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ... diff --git a/django-stubs/contrib/auth/models.pyi b/django-stubs/contrib/auth/models.pyi index 4c47c21bc..e1c939677 100644 --- a/django-stubs/contrib/auth/models.pyi +++ b/django-stubs/contrib/auth/models.pyi @@ -66,7 +66,7 @@ class PermissionsMixin(models.Model): def has_module_perms(self, app_label: str) -> bool: ... class AbstractUser(AbstractBaseUser, PermissionsMixin): - username_validator: UnicodeUsernameValidator = ... + username_validator: UnicodeUsernameValidator username = models.CharField(max_length=150) first_name = models.CharField(max_length=30, blank=True) @@ -76,8 +76,8 @@ class AbstractUser(AbstractBaseUser, PermissionsMixin): is_active = models.BooleanField() date_joined = models.DateTimeField() - EMAIL_FIELD: str = ... - USERNAME_FIELD: str = ... + EMAIL_FIELD: str + USERNAME_FIELD: str def get_full_name(self) -> str: ... def get_short_name(self) -> str: ... def email_user(self, subject: str, message: str, from_email: str = ..., **kwargs: Any) -> None: ... @@ -85,12 +85,12 @@ class AbstractUser(AbstractBaseUser, PermissionsMixin): class User(AbstractUser): ... class AnonymousUser: - id: Any = ... - pk: Any = ... - username: Literal[""] = ... - is_staff: Literal[False] = ... - is_active: Literal[False] = ... - is_superuser: Literal[False] = ... + id: Any + pk: Any + username: Literal[""] + is_staff: Literal[False] + is_active: Literal[False] + is_superuser: Literal[False] def save(self) -> None: ... def delete(self) -> None: ... def set_password(self, raw_password: str) -> None: ... diff --git a/django-stubs/contrib/auth/password_validation.pyi b/django-stubs/contrib/auth/password_validation.pyi index 63ced0844..a6b68a987 100644 --- a/django-stubs/contrib/auth/password_validation.pyi +++ b/django-stubs/contrib/auth/password_validation.pyi @@ -22,22 +22,22 @@ def password_validators_help_texts(password_validators: Sequence[PasswordValidat password_validators_help_text_html: Any class MinimumLengthValidator: - min_length: int = ... + min_length: int def __init__(self, min_length: int = ...) -> None: ... def validate(self, password: str, user: _UserModel | None = ...) -> None: ... def get_help_text(self) -> str: ... class UserAttributeSimilarityValidator: - DEFAULT_USER_ATTRIBUTES: Sequence[str] = ... - user_attributes: Sequence[str] = ... - max_similarity: float = ... + DEFAULT_USER_ATTRIBUTES: Sequence[str] + user_attributes: Sequence[str] + max_similarity: float def __init__(self, user_attributes: Sequence[str] = ..., max_similarity: float = ...) -> None: ... def validate(self, password: str, user: _UserModel | None = ...) -> None: ... def get_help_text(self) -> str: ... class CommonPasswordValidator: - DEFAULT_PASSWORD_LIST_PATH: Path = ... - passwords: Set[str] = ... + DEFAULT_PASSWORD_LIST_PATH: Path + passwords: Set[str] def __init__(self, password_list_path: Path | PosixPath | str = ...) -> None: ... def validate(self, password: str, user: _UserModel | None = ...) -> None: ... def get_help_text(self) -> str: ... diff --git a/django-stubs/contrib/auth/tokens.pyi b/django-stubs/contrib/auth/tokens.pyi index fe4939ecc..c0c8d830f 100644 --- a/django-stubs/contrib/auth/tokens.pyi +++ b/django-stubs/contrib/auth/tokens.pyi @@ -4,9 +4,9 @@ from typing import Any from django.contrib.auth.base_user import AbstractBaseUser class PasswordResetTokenGenerator: - key_salt: str = ... - secret: Any = ... - algorithm: str = ... + key_salt: str + secret: Any + algorithm: str def make_token(self, user: AbstractBaseUser) -> str: ... def check_token(self, user: AbstractBaseUser | None, token: str | None) -> bool: ... def _make_token_with_timestamp(self, user: AbstractBaseUser, timestamp: int, legacy: bool = ...) -> str: ... diff --git a/django-stubs/contrib/auth/urls.pyi b/django-stubs/contrib/auth/urls.pyi index 3df94ca6f..14e91f5b3 100644 --- a/django-stubs/contrib/auth/urls.pyi +++ b/django-stubs/contrib/auth/urls.pyi @@ -2,4 +2,4 @@ from typing import List from django.urls import _AnyURL -urlpatterns: List[_AnyURL] = ... +urlpatterns: List[_AnyURL] diff --git a/django-stubs/contrib/auth/views.pyi b/django-stubs/contrib/auth/views.pyi index a25b484ad..2048d0ebc 100644 --- a/django-stubs/contrib/auth/views.pyi +++ b/django-stubs/contrib/auth/views.pyi @@ -10,20 +10,20 @@ from django.views.generic.edit import FormView UserModel: Any class SuccessURLAllowedHostsMixin: - success_url_allowed_hosts: Any = ... + success_url_allowed_hosts: Any def get_success_url_allowed_hosts(self) -> Set[str]: ... class LoginView(SuccessURLAllowedHostsMixin, FormView[AuthenticationForm]): - authentication_form: Any = ... - redirect_field_name: Any = ... - redirect_authenticated_user: bool = ... - extra_context: Any = ... + authentication_form: Any + redirect_field_name: Any + redirect_authenticated_user: bool + extra_context: Any def get_redirect_url(self) -> str: ... class LogoutView(SuccessURLAllowedHostsMixin, TemplateView): - next_page: str | None = ... - redirect_field_name: str = ... - extra_context: Any = ... + next_page: str | None + redirect_field_name: str + extra_context: Any def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def get_next_page(self) -> str | None: ... @@ -34,39 +34,39 @@ def redirect_to_login( ) -> HttpResponseRedirect: ... class PasswordContextMixin: - extra_context: Any = ... + extra_context: Any def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... class PasswordResetView(PasswordContextMixin, FormView): - email_template_name: str = ... - extra_email_context: Any = ... - from_email: Any = ... - html_email_template_name: Any = ... - subject_template_name: str = ... - title: Any = ... - token_generator: Any = ... + email_template_name: str + extra_email_context: Any + from_email: Any + html_email_template_name: Any + subject_template_name: str + title: Any + token_generator: Any INTERNAL_RESET_URL_TOKEN: str INTERNAL_RESET_SESSION_TOKEN: str class PasswordResetDoneView(PasswordContextMixin, TemplateView): - title: Any = ... + title: Any class PasswordResetConfirmView(PasswordContextMixin, FormView): - post_reset_login: bool = ... - post_reset_login_backend: Any = ... - reset_url_token: str = ... - title: Any = ... - token_generator: Any = ... - validlink: bool = ... - user: Any = ... + post_reset_login: bool + post_reset_login_backend: Any + reset_url_token: str + title: Any + token_generator: Any + validlink: bool + user: Any def get_user(self, uidb64: str) -> AbstractBaseUser | None: ... class PasswordResetCompleteView(PasswordContextMixin, TemplateView): - title: Any = ... + title: Any class PasswordChangeView(PasswordContextMixin, FormView): - title: Any = ... + title: Any class PasswordChangeDoneView(PasswordContextMixin, TemplateView): - title: Any = ... + title: Any diff --git a/django-stubs/contrib/contenttypes/admin.pyi b/django-stubs/contrib/contenttypes/admin.pyi index df2578baa..fafbfff71 100644 --- a/django-stubs/contrib/contenttypes/admin.pyi +++ b/django-stubs/contrib/contenttypes/admin.pyi @@ -9,7 +9,7 @@ class GenericInlineModelAdminChecks(InlineModelAdminChecks): def _check_relation(self, obj: GenericInlineModelAdmin, parent_model: Type[Model]) -> List[Any]: ... class GenericInlineModelAdmin(InlineModelAdmin): - template: str = ... + template: str class GenericStackedInline(GenericInlineModelAdmin): ... class GenericTabularInline(GenericInlineModelAdmin): ... diff --git a/django-stubs/contrib/contenttypes/fields.pyi b/django-stubs/contrib/contenttypes/fields.pyi index a99835a1c..845c543f5 100644 --- a/django-stubs/contrib/contenttypes/fields.pyi +++ b/django-stubs/contrib/contenttypes/fields.pyi @@ -18,25 +18,25 @@ class GenericForeignKey(FieldCacheMixin): _pyi_private_set_type: Any | Combinable _pyi_private_get_type: Any # attributes - auto_created: bool = ... - concrete: bool = ... - editable: bool = ... - hidden: bool = ... - is_relation: bool = ... - many_to_many: bool = ... - many_to_one: bool = ... - one_to_many: bool = ... - one_to_one: bool = ... - related_model: Any = ... - remote_field: Any = ... - ct_field: str = ... - fk_field: str = ... - for_concrete_model: bool = ... - rel: None = ... - column: None = ... + auto_created: bool + concrete: bool + editable: bool + hidden: bool + is_relation: bool + many_to_many: bool + many_to_one: bool + one_to_many: bool + one_to_one: bool + related_model: Any + remote_field: Any + ct_field: str + fk_field: str + for_concrete_model: bool + rel: None + column: None def __init__(self, ct_field: str = ..., fk_field: str = ..., for_concrete_model: bool = ...) -> None: ... - name: Any = ... - model: Any = ... + name: Any + model: Any def contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ... def get_filter_kwargs_for_object(self, obj: Model) -> Dict[str, ContentType | None]: ... def get_forward_related_filter(self, obj: Model) -> Dict[str, int]: ... @@ -63,12 +63,12 @@ class GenericRel(ForeignObjectRel): ) -> None: ... class GenericRelation(ForeignObject): - rel_class: Any = ... - mti_inherited: bool = ... - object_id_field_name: str = ... - content_type_field_name: str = ... - for_concrete_model: bool = ... - to_fields: Any = ... + rel_class: Any + mti_inherited: bool + object_id_field_name: str + content_type_field_name: str + for_concrete_model: bool + to_fields: Any def __init__( self, to: Type[Model] | str, diff --git a/django-stubs/contrib/contenttypes/forms.pyi b/django-stubs/contrib/contenttypes/forms.pyi index ffe20b4f9..18e5070e4 100644 --- a/django-stubs/contrib/contenttypes/forms.pyi +++ b/django-stubs/contrib/contenttypes/forms.pyi @@ -7,9 +7,9 @@ _M = TypeVar("_M", bound=Model) _ModelFormT = TypeVar("_ModelFormT", bound=ModelForm) class BaseGenericInlineFormSet(BaseModelFormSet[_M, _ModelFormT]): - instance: Any = ... - rel_name: Any = ... - save_as_new: Any = ... + instance: Any + rel_name: Any + save_as_new: Any def __init__( self, data: Any | None = ..., diff --git a/django-stubs/contrib/contenttypes/management/__init__.pyi b/django-stubs/contrib/contenttypes/management/__init__.pyi index 06f5a27ce..489a527cc 100644 --- a/django-stubs/contrib/contenttypes/management/__init__.pyi +++ b/django-stubs/contrib/contenttypes/management/__init__.pyi @@ -10,9 +10,9 @@ from django.db.migrations.state import StateApps from django.db.models.base import Model class RenameContentType(migrations.RunPython): - app_label: Any = ... - old_model: Any = ... - new_model: Any = ... + app_label: Any + old_model: Any + new_model: Any def __init__(self, app_label: str, old_model: str, new_model: str) -> None: ... def rename_forward(self, apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: ... def rename_backward(self, apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: ... diff --git a/django-stubs/contrib/contenttypes/models.pyi b/django-stubs/contrib/contenttypes/models.pyi index 1daecc677..7485c68e2 100644 --- a/django-stubs/contrib/contenttypes/models.pyi +++ b/django-stubs/contrib/contenttypes/models.pyi @@ -13,9 +13,9 @@ class ContentTypeManager(models.Manager["ContentType"]): class ContentType(models.Model): id: int - app_label: models.CharField = ... - model: models.CharField = ... - objects: ContentTypeManager = ... + app_label: models.CharField + model: models.CharField + objects: ContentTypeManager @property def name(self) -> str: ... def model_class(self) -> Type[Model] | None: ... diff --git a/django-stubs/contrib/flatpages/admin.pyi b/django-stubs/contrib/flatpages/admin.pyi index 90b045fc2..f17bd6190 100644 --- a/django-stubs/contrib/flatpages/admin.pyi +++ b/django-stubs/contrib/flatpages/admin.pyi @@ -3,8 +3,8 @@ from typing import Any from django.contrib import admin class FlatPageAdmin(admin.ModelAdmin): - form: Any = ... - fieldsets: Any = ... - list_display: Any = ... - list_filter: Any = ... - search_fields: Any = ... + form: Any + fieldsets: Any + list_display: Any + list_filter: Any + search_fields: Any diff --git a/django-stubs/contrib/flatpages/apps.pyi b/django-stubs/contrib/flatpages/apps.pyi index e3cd708bf..f809fe3f0 100644 --- a/django-stubs/contrib/flatpages/apps.pyi +++ b/django-stubs/contrib/flatpages/apps.pyi @@ -3,5 +3,5 @@ from typing import Any from django.apps import AppConfig as AppConfig class FlatPagesConfig(AppConfig): - name: str = ... - verbose_name: Any = ... + name: str + verbose_name: Any diff --git a/django-stubs/contrib/flatpages/forms.pyi b/django-stubs/contrib/flatpages/forms.pyi index 5146154d5..a33fa2309 100644 --- a/django-stubs/contrib/flatpages/forms.pyi +++ b/django-stubs/contrib/flatpages/forms.pyi @@ -3,5 +3,5 @@ from typing import Any from django import forms class FlatpageForm(forms.ModelForm): - url: Any = ... + url: Any def clean_url(self) -> str: ... diff --git a/django-stubs/contrib/flatpages/models.pyi b/django-stubs/contrib/flatpages/models.pyi index d44cc9a63..4b578fe03 100644 --- a/django-stubs/contrib/flatpages/models.pyi +++ b/django-stubs/contrib/flatpages/models.pyi @@ -2,11 +2,11 @@ from django.contrib.sites.models import Site from django.db import models class FlatPage(models.Model): - url: models.CharField = ... - title: models.CharField = ... - content: models.TextField = ... - enable_comments: models.BooleanField = ... - template_name: models.CharField = ... - registration_required: models.BooleanField = ... - sites: models.ManyToManyField[Site, Site] = ... + url: models.CharField + title: models.CharField + content: models.TextField + enable_comments: models.BooleanField + template_name: models.CharField + registration_required: models.BooleanField + sites: models.ManyToManyField[Site, Site] def get_absolute_url(self) -> str: ... diff --git a/django-stubs/contrib/flatpages/templatetags/flatpages.pyi b/django-stubs/contrib/flatpages/templatetags/flatpages.pyi index 89951ea0a..32b45b0ef 100644 --- a/django-stubs/contrib/flatpages/templatetags/flatpages.pyi +++ b/django-stubs/contrib/flatpages/templatetags/flatpages.pyi @@ -7,9 +7,9 @@ from django.template.context import Context register: Any class FlatpageNode(template.Node): - context_name: str = ... - starts_with: None = ... - user: None = ... + context_name: str + starts_with: None + user: None def __init__(self, context_name: str, starts_with: str | None = ..., user: str | None = ...) -> None: ... def render(self, context: Context) -> str: ... diff --git a/django-stubs/contrib/flatpages/urls.pyi b/django-stubs/contrib/flatpages/urls.pyi index 3df94ca6f..14e91f5b3 100644 --- a/django-stubs/contrib/flatpages/urls.pyi +++ b/django-stubs/contrib/flatpages/urls.pyi @@ -2,4 +2,4 @@ from typing import List from django.urls import _AnyURL -urlpatterns: List[_AnyURL] = ... +urlpatterns: List[_AnyURL] diff --git a/django-stubs/contrib/gis/admin/options.pyi b/django-stubs/contrib/gis/admin/options.pyi index 1e5200ffe..f343ff678 100644 --- a/django-stubs/contrib/gis/admin/options.pyi +++ b/django-stubs/contrib/gis/admin/options.pyi @@ -5,44 +5,44 @@ from django.contrib.admin import ModelAdmin as ModelAdmin spherical_mercator_srid: int class GeoModelAdmin(ModelAdmin): - default_lon: int = ... - default_lat: int = ... - default_zoom: int = ... - display_wkt: bool = ... - display_srid: bool = ... - extra_js: Any = ... - num_zoom: int = ... - max_zoom: bool = ... - min_zoom: bool = ... - units: str | bool = ... - max_resolution: str | bool = ... - max_extent: str | bool = ... - modifiable: bool = ... - mouse_position: bool = ... - scale_text: bool = ... - layerswitcher: bool = ... - scrollable: bool = ... - map_width: int = ... - map_height: int = ... - map_srid: int = ... - map_template: str = ... - openlayers_url: str = ... - point_zoom: Any = ... - wms_url: str = ... - wms_layer: str = ... - wms_name: str = ... - wms_options: Any = ... - debug: bool = ... - widget: Any = ... + default_lon: int + default_lat: int + default_zoom: int + display_wkt: bool + display_srid: bool + extra_js: Any + num_zoom: int + max_zoom: bool + min_zoom: bool + units: str | bool + max_resolution: str | bool + max_extent: str | bool + modifiable: bool + mouse_position: bool + scale_text: bool + layerswitcher: bool + scrollable: bool + map_width: int + map_height: int + map_srid: int + map_template: str + openlayers_url: str + point_zoom: Any + wms_url: str + wms_layer: str + wms_name: str + wms_options: Any + debug: bool + widget: Any @property def media(self) -> Any: ... def get_map_widget(self, db_field: Any) -> Any: ... class OSMGeoAdmin(GeoModelAdmin): - map_template: str = ... - num_zoom: int = ... - map_srid: Any = ... - max_extent: str = ... - max_resolution: str = ... - point_zoom: int = ... - units: str = ... + map_template: str + num_zoom: int + map_srid: Any + max_extent: str + max_resolution: str + point_zoom: int + units: str diff --git a/django-stubs/contrib/gis/apps.pyi b/django-stubs/contrib/gis/apps.pyi index 04ebc989a..95b1afb4a 100644 --- a/django-stubs/contrib/gis/apps.pyi +++ b/django-stubs/contrib/gis/apps.pyi @@ -3,6 +3,6 @@ from typing import Any from django.apps import AppConfig as AppConfig class GISConfig(AppConfig): - name: str = ... - verbose_name: Any = ... + name: str + verbose_name: Any def ready(self) -> None: ... diff --git a/django-stubs/contrib/gis/db/backends/base/adapter.pyi b/django-stubs/contrib/gis/db/backends/base/adapter.pyi index fd5ed0b3a..c87981245 100644 --- a/django-stubs/contrib/gis/db/backends/base/adapter.pyi +++ b/django-stubs/contrib/gis/db/backends/base/adapter.pyi @@ -1,8 +1,8 @@ from typing import Any class WKTAdapter: - wkt: Any = ... - srid: Any = ... + wkt: Any + srid: Any def __init__(self, geom: Any) -> None: ... def __eq__(self, other: Any) -> bool: ... def __hash__(self) -> int: ... diff --git a/django-stubs/contrib/gis/db/backends/base/features.pyi b/django-stubs/contrib/gis/db/backends/base/features.pyi index 6bb87ced5..d51f9488c 100644 --- a/django-stubs/contrib/gis/db/backends/base/features.pyi +++ b/django-stubs/contrib/gis/db/backends/base/features.pyi @@ -1,24 +1,24 @@ from typing import Any class BaseSpatialFeatures: - gis_enabled: bool = ... - has_spatialrefsys_table: bool = ... - supports_add_srs_entry: bool = ... - supports_geometry_field_introspection: bool = ... - supports_3d_storage: bool = ... - supports_3d_functions: bool = ... - supports_transform: bool = ... - supports_null_geometries: bool = ... - supports_empty_geometries: bool = ... - supports_distance_geodetic: bool = ... - supports_length_geodetic: bool = ... - supports_perimeter_geodetic: bool = ... - supports_area_geodetic: bool = ... - supports_num_points_poly: bool = ... - supports_left_right_lookups: bool = ... - supports_dwithin_distance_expr: bool = ... - supports_raster: bool = ... - supports_geometry_field_unique_index: bool = ... + gis_enabled: bool + has_spatialrefsys_table: bool + supports_add_srs_entry: bool + supports_geometry_field_introspection: bool + supports_3d_storage: bool + supports_3d_functions: bool + supports_transform: bool + supports_null_geometries: bool + supports_empty_geometries: bool + supports_distance_geodetic: bool + supports_length_geodetic: bool + supports_perimeter_geodetic: bool + supports_area_geodetic: bool + supports_num_points_poly: bool + supports_left_right_lookups: bool + supports_dwithin_distance_expr: bool + supports_raster: bool + supports_geometry_field_unique_index: bool @property def supports_bbcontains_lookup(self) -> bool: ... @property diff --git a/django-stubs/contrib/gis/db/backends/base/operations.pyi b/django-stubs/contrib/gis/db/backends/base/operations.pyi index 015b63670..e57f1bf91 100644 --- a/django-stubs/contrib/gis/db/backends/base/operations.pyi +++ b/django-stubs/contrib/gis/db/backends/base/operations.pyi @@ -1,21 +1,21 @@ from typing import Any, Set class BaseSpatialOperations: - postgis: bool = ... - spatialite: bool = ... - mysql: bool = ... - oracle: bool = ... - spatial_version: Any = ... - select: str = ... + postgis: bool + spatialite: bool + mysql: bool + oracle: bool + spatial_version: Any + select: str @property def select_extent(self) -> str: ... - geography: bool = ... - geometry: bool = ... - disallowed_aggregates: Any = ... - geom_func_prefix: str = ... - function_names: Any = ... - unsupported_functions: Set[str] = ... - from_text: bool = ... + geography: bool + geometry: bool + disallowed_aggregates: Any + geom_func_prefix: str + function_names: Any + unsupported_functions: Set[str] + from_text: bool def convert_extent(self, box: Any, srid: Any) -> Any: ... def convert_extent3d(self, box: Any, srid: Any) -> Any: ... def geo_quote_name(self, name: Any) -> Any: ... @@ -27,7 +27,7 @@ class BaseSpatialOperations: def spatial_function_name(self, func_name: Any) -> Any: ... def geometry_columns(self) -> Any: ... def spatial_ref_sys(self) -> Any: ... - distance_expr_for_lookup: Any = ... + distance_expr_for_lookup: Any def get_db_converters(self, expression: Any) -> Any: ... def get_geometry_converter(self, expression: Any) -> Any: ... def get_area_att_for_field(self, field: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/mysql/base.pyi b/django-stubs/contrib/gis/db/backends/mysql/base.pyi index 0bbd97a18..a33fce329 100644 --- a/django-stubs/contrib/gis/db/backends/mysql/base.pyi +++ b/django-stubs/contrib/gis/db/backends/mysql/base.pyi @@ -3,7 +3,7 @@ from typing import Any from django.db.backends.mysql.base import DatabaseWrapper as MySQLDatabaseWrapper class DatabaseWrapper(MySQLDatabaseWrapper): - SchemaEditorClass: Any = ... - features_class: Any = ... - introspection_class: Any = ... - ops_class: Any = ... + SchemaEditorClass: Any + features_class: Any + introspection_class: Any + ops_class: Any diff --git a/django-stubs/contrib/gis/db/backends/mysql/features.pyi b/django-stubs/contrib/gis/db/backends/mysql/features.pyi index 23fe5f2aa..cb1bf2c05 100644 --- a/django-stubs/contrib/gis/db/backends/mysql/features.pyi +++ b/django-stubs/contrib/gis/db/backends/mysql/features.pyi @@ -4,14 +4,14 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as from django.db.backends.mysql.features import DatabaseFeatures as MySQLDatabaseFeatures class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures): - has_spatialrefsys_table: bool = ... - supports_add_srs_entry: bool = ... - supports_distance_geodetic: bool = ... - supports_length_geodetic: bool = ... - supports_area_geodetic: bool = ... - supports_transform: bool = ... - supports_null_geometries: bool = ... - supports_num_points_poly: bool = ... + has_spatialrefsys_table: bool + supports_add_srs_entry: bool + supports_distance_geodetic: bool + supports_length_geodetic: bool + supports_area_geodetic: bool + supports_transform: bool + supports_null_geometries: bool + supports_num_points_poly: bool @property def empty_intersection_returns_none(self) -> bool: ... @property diff --git a/django-stubs/contrib/gis/db/backends/mysql/introspection.pyi b/django-stubs/contrib/gis/db/backends/mysql/introspection.pyi index fe05ddc4d..4460a0e71 100644 --- a/django-stubs/contrib/gis/db/backends/mysql/introspection.pyi +++ b/django-stubs/contrib/gis/db/backends/mysql/introspection.pyi @@ -3,6 +3,6 @@ from typing import Any from django.db.backends.mysql.introspection import DatabaseIntrospection as DatabaseIntrospection class MySQLIntrospection(DatabaseIntrospection): - data_types_reverse: Any = ... + data_types_reverse: Any def get_geometry_type(self, table_name: Any, description: Any) -> Any: ... def supports_spatial_index(self, cursor: Any, table_name: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/mysql/operations.pyi b/django-stubs/contrib/gis/db/backends/mysql/operations.pyi index 890fbe06d..84ab086a5 100644 --- a/django-stubs/contrib/gis/db/backends/mysql/operations.pyi +++ b/django-stubs/contrib/gis/db/backends/mysql/operations.pyi @@ -6,9 +6,9 @@ from django.contrib.gis.geos.geometry import GEOSGeometryBase from django.db.backends.mysql.operations import DatabaseOperations as DatabaseOperations class MySQLOperations(BaseSpatialOperations, DatabaseOperations): - name: str = ... - geom_func_prefix: str = ... - Adapter: Any = ... + name: str + geom_func_prefix: str + Adapter: Any @property def mariadb(self) -> bool: ... @property @@ -19,7 +19,7 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations): def from_text(self) -> str: ... # type: ignore @property def gis_operators(self) -> Dict[str, SpatialOperator]: ... - disallowed_aggregates: Any = ... + disallowed_aggregates: Any @property def unsupported_functions(self) -> Set[str]: ... # type: ignore def geo_db_type(self, f: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/mysql/schema.pyi b/django-stubs/contrib/gis/db/backends/mysql/schema.pyi index 97aa99fbe..121238ec3 100644 --- a/django-stubs/contrib/gis/db/backends/mysql/schema.pyi +++ b/django-stubs/contrib/gis/db/backends/mysql/schema.pyi @@ -6,9 +6,9 @@ from django.db.backends.mysql.schema import DatabaseSchemaEditor as DatabaseSche logger: Logger class MySQLGISSchemaEditor(DatabaseSchemaEditor): - sql_add_spatial_index: str = ... - sql_drop_spatial_index: str = ... - geometry_sql: Any = ... + sql_add_spatial_index: str + sql_drop_spatial_index: str + geometry_sql: Any def __init__(self, *args: Any, **kwargs: Any) -> None: ... def skip_default(self, field: Any) -> Any: ... def column_sql(self, model: Any, field: Any, include_default: bool = ...) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/oracle/adapter.pyi b/django-stubs/contrib/gis/db/backends/oracle/adapter.pyi index 86ebca7b6..1a0c905ae 100644 --- a/django-stubs/contrib/gis/db/backends/oracle/adapter.pyi +++ b/django-stubs/contrib/gis/db/backends/oracle/adapter.pyi @@ -3,7 +3,7 @@ from typing import Any from django.contrib.gis.db.backends.base.adapter import WKTAdapter class OracleSpatialAdapter(WKTAdapter): - input_size: Any = ... - wkt: Any = ... - srid: Any = ... + input_size: Any + wkt: Any + srid: Any def __init__(self, geom: Any) -> None: ... diff --git a/django-stubs/contrib/gis/db/backends/oracle/base.pyi b/django-stubs/contrib/gis/db/backends/oracle/base.pyi index cc1e35428..80e58f618 100644 --- a/django-stubs/contrib/gis/db/backends/oracle/base.pyi +++ b/django-stubs/contrib/gis/db/backends/oracle/base.pyi @@ -3,7 +3,7 @@ from typing import Any from django.db.backends.oracle.base import DatabaseWrapper as OracleDatabaseWrapper class DatabaseWrapper(OracleDatabaseWrapper): - SchemaEditorClass: Any = ... - features_class: Any = ... - introspection_class: Any = ... - ops_class: Any = ... + SchemaEditorClass: Any + features_class: Any + introspection_class: Any + ops_class: Any diff --git a/django-stubs/contrib/gis/db/backends/oracle/features.pyi b/django-stubs/contrib/gis/db/backends/oracle/features.pyi index 4e290c11d..3f4efc5ca 100644 --- a/django-stubs/contrib/gis/db/backends/oracle/features.pyi +++ b/django-stubs/contrib/gis/db/backends/oracle/features.pyi @@ -2,8 +2,8 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as from django.db.backends.oracle.features import DatabaseFeatures as OracleDatabaseFeatures class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures): - supports_add_srs_entry: bool = ... - supports_geometry_field_introspection: bool = ... - supports_geometry_field_unique_index: bool = ... - supports_perimeter_geodetic: bool = ... - supports_dwithin_distance_expr: bool = ... + supports_add_srs_entry: bool + supports_geometry_field_introspection: bool + supports_geometry_field_unique_index: bool + supports_perimeter_geodetic: bool + supports_dwithin_distance_expr: bool diff --git a/django-stubs/contrib/gis/db/backends/oracle/models.pyi b/django-stubs/contrib/gis/db/backends/oracle/models.pyi index 060fe553b..e9a803705 100644 --- a/django-stubs/contrib/gis/db/backends/oracle/models.pyi +++ b/django-stubs/contrib/gis/db/backends/oracle/models.pyi @@ -4,30 +4,30 @@ from django.contrib.gis.db import models from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin class OracleGeometryColumns(models.Model): - table_name: Any = ... - column_name: Any = ... - srid: Any = ... + table_name: Any + column_name: Any + srid: Any class Meta: - app_label: str = ... - db_table: str = ... - managed: bool = ... + app_label: str + db_table: str + managed: bool @classmethod def table_name_col(cls) -> Any: ... @classmethod def geom_col_name(cls) -> Any: ... class OracleSpatialRefSys(models.Model, SpatialRefSysMixin): - cs_name: Any = ... - srid: Any = ... - auth_srid: Any = ... - auth_name: Any = ... - wktext: Any = ... - cs_bounds: Any = ... + cs_name: Any + srid: Any + auth_srid: Any + auth_name: Any + wktext: Any + cs_bounds: Any class Meta: - app_label: str = ... - db_table: str = ... - managed: bool = ... + app_label: str + db_table: str + managed: bool @property def wkt(self) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/oracle/operations.pyi b/django-stubs/contrib/gis/db/backends/oracle/operations.pyi index 425a5a468..316767ac8 100644 --- a/django-stubs/contrib/gis/db/backends/oracle/operations.pyi +++ b/django-stubs/contrib/gis/db/backends/oracle/operations.pyi @@ -7,29 +7,29 @@ from django.db.backends.oracle.operations import DatabaseOperations as DatabaseO DEFAULT_TOLERANCE: str class SDOOperator(SpatialOperator): - sql_template: str = ... + sql_template: str class SDODWithin(SpatialOperator): - sql_template: str = ... + sql_template: str class SDODisjoint(SpatialOperator): - sql_template: Any = ... + sql_template: Any class SDORelate(SpatialOperator): - sql_template: str = ... + sql_template: str def check_relate_argument(self, arg: Any) -> None: ... class OracleOperations(BaseSpatialOperations, DatabaseOperations): - name: str = ... - oracle: bool = ... - disallowed_aggregates: Any = ... - Adapter: Any = ... - extent: str = ... - unionagg: str = ... - function_names: Any = ... - select: str = ... - gis_operators: Any = ... - unsupported_functions: Any = ... + name: str + oracle: bool + disallowed_aggregates: Any + Adapter: Any + extent: str + unionagg: str + function_names: Any + select: str + gis_operators: Any + unsupported_functions: Any def geo_quote_name(self, name: Any) -> Any: ... def geo_db_type(self, f: Any) -> Any: ... def get_distance(self, f: Any, value: Any, lookup_type: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/oracle/schema.pyi b/django-stubs/contrib/gis/db/backends/oracle/schema.pyi index aab3e8b2f..7e5ffdb27 100644 --- a/django-stubs/contrib/gis/db/backends/oracle/schema.pyi +++ b/django-stubs/contrib/gis/db/backends/oracle/schema.pyi @@ -3,12 +3,12 @@ from typing import Any from django.db.backends.oracle.schema import DatabaseSchemaEditor class OracleGISSchemaEditor(DatabaseSchemaEditor): - sql_add_geometry_metadata: str = ... - sql_add_spatial_index: str = ... - sql_drop_spatial_index: str = ... - sql_clear_geometry_table_metadata: str = ... - sql_clear_geometry_field_metadata: str = ... - geometry_sql: Any = ... + sql_add_geometry_metadata: str + sql_add_spatial_index: str + sql_drop_spatial_index: str + sql_clear_geometry_table_metadata: str + sql_clear_geometry_field_metadata: str + geometry_sql: Any def __init__(self, *args: Any, **kwargs: Any) -> None: ... def geo_quote_name(self, name: Any) -> Any: ... def column_sql(self, model: Any, field: Any, include_default: bool = ...) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/postgis/adapter.pyi b/django-stubs/contrib/gis/db/backends/postgis/adapter.pyi index 3f7bcdc4c..999ff5978 100644 --- a/django-stubs/contrib/gis/db/backends/postgis/adapter.pyi +++ b/django-stubs/contrib/gis/db/backends/postgis/adapter.pyi @@ -1,10 +1,10 @@ from typing import Any class PostGISAdapter: - is_geometry: Any = ... - ewkb: Any = ... - srid: Any = ... - geography: Any = ... + is_geometry: Any + ewkb: Any + srid: Any + geography: Any def __init__(self, obj: Any, geography: bool = ...) -> None: ... def __conform__(self, proto: Any) -> Any: ... def __eq__(self, other: Any) -> bool: ... diff --git a/django-stubs/contrib/gis/db/backends/postgis/base.pyi b/django-stubs/contrib/gis/db/backends/postgis/base.pyi index 65110da76..3456b4547 100644 --- a/django-stubs/contrib/gis/db/backends/postgis/base.pyi +++ b/django-stubs/contrib/gis/db/backends/postgis/base.pyi @@ -3,9 +3,9 @@ from typing import Any from django.db.backends.postgresql.base import DatabaseWrapper as Psycopg2DatabaseWrapper class DatabaseWrapper(Psycopg2DatabaseWrapper): - SchemaEditorClass: Any = ... - features: Any = ... - ops: Any = ... - introspection: Any = ... + SchemaEditorClass: Any + features: Any + ops: Any + introspection: Any def __init__(self, *args: Any, **kwargs: Any) -> None: ... def prepare_database(self) -> None: ... diff --git a/django-stubs/contrib/gis/db/backends/postgis/features.pyi b/django-stubs/contrib/gis/db/backends/postgis/features.pyi index 0daef2259..eba6857d2 100644 --- a/django-stubs/contrib/gis/db/backends/postgis/features.pyi +++ b/django-stubs/contrib/gis/db/backends/postgis/features.pyi @@ -2,8 +2,8 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as from django.db.backends.postgresql.features import DatabaseFeatures as Psycopg2DatabaseFeatures class DatabaseFeatures(BaseSpatialFeatures, Psycopg2DatabaseFeatures): - supports_3d_storage: bool = ... - supports_3d_functions: bool = ... - supports_left_right_lookups: bool = ... - supports_raster: bool = ... - supports_empty_geometries: bool = ... + supports_3d_storage: bool + supports_3d_functions: bool + supports_left_right_lookups: bool + supports_raster: bool + supports_empty_geometries: bool diff --git a/django-stubs/contrib/gis/db/backends/postgis/introspection.pyi b/django-stubs/contrib/gis/db/backends/postgis/introspection.pyi index 59c6842b3..ce3d3a92e 100644 --- a/django-stubs/contrib/gis/db/backends/postgis/introspection.pyi +++ b/django-stubs/contrib/gis/db/backends/postgis/introspection.pyi @@ -3,7 +3,7 @@ from typing import Any from django.db.backends.postgresql.introspection import DatabaseIntrospection as DatabaseIntrospection class PostGISIntrospection(DatabaseIntrospection): - postgis_oid_lookup: Any = ... - ignored_tables: Any = ... + postgis_oid_lookup: Any + ignored_tables: Any def get_field_type(self, data_type: Any, description: Any) -> Any: ... def get_geometry_type(self, table_name: Any, description: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/postgis/models.pyi b/django-stubs/contrib/gis/db/backends/postgis/models.pyi index 1779e645e..a478242d2 100644 --- a/django-stubs/contrib/gis/db/backends/postgis/models.pyi +++ b/django-stubs/contrib/gis/db/backends/postgis/models.pyi @@ -4,33 +4,33 @@ from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin as Spa from django.db import models as models class PostGISGeometryColumns(models.Model): - f_table_catalog: Any = ... - f_table_schema: Any = ... - f_table_name: Any = ... - f_geometry_column: Any = ... - coord_dimension: Any = ... - srid: Any = ... - type: Any = ... + f_table_catalog: Any + f_table_schema: Any + f_table_name: Any + f_geometry_column: Any + coord_dimension: Any + srid: Any + type: Any class Meta: - app_label: str = ... - db_table: str = ... - managed: bool = ... + app_label: str + db_table: str + managed: bool @classmethod def table_name_col(cls) -> Any: ... @classmethod def geom_col_name(cls) -> Any: ... class PostGISSpatialRefSys(models.Model, SpatialRefSysMixin): - srid: Any = ... - auth_name: Any = ... - auth_srid: Any = ... - srtext: Any = ... - proj4text: Any = ... + srid: Any + auth_name: Any + auth_srid: Any + srtext: Any + proj4text: Any class Meta: - app_label: str = ... - db_table: str = ... - managed: bool = ... + app_label: str + db_table: str + managed: bool @property def wkt(self) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/postgis/operations.pyi b/django-stubs/contrib/gis/db/backends/postgis/operations.pyi index 021995aa6..9f138e373 100644 --- a/django-stubs/contrib/gis/db/backends/postgis/operations.pyi +++ b/django-stubs/contrib/gis/db/backends/postgis/operations.pyi @@ -9,34 +9,34 @@ from typing_extensions import Literal BILATERAL: Literal["bilateral"] class PostGISOperator(SpatialOperator): - geography: Any = ... - raster: bool | Literal["bilateral"] = ... + geography: Any + raster: bool | Literal["bilateral"] def __init__(self, geography: bool = ..., raster: bool | Literal["bilateral"] = ..., **kwargs: Any) -> None: ... def check_raster(self, lookup: Any, template_params: Any) -> Any: ... class ST_Polygon(Func): - function: str = ... + function: str def __init__(self, expr: Any) -> None: ... @property def output_field(self) -> Any: ... class PostGISOperations(BaseSpatialOperations, DatabaseOperations): - name: str = ... - postgis: bool = ... - geography: bool = ... - geom_func_prefix: str = ... - Adapter: Any = ... - collect: Any = ... - extent: Any = ... - extent3d: Any = ... - length3d: Any = ... - makeline: Any = ... - perimeter3d: Any = ... - unionagg: Any = ... - gis_operators: Any = ... - unsupported_functions: Any = ... - select: str = ... - select_extent: Any = ... + name: str + postgis: bool + geography: bool + geom_func_prefix: str + Adapter: Any + collect: Any + extent: Any + extent3d: Any + length3d: Any + makeline: Any + perimeter3d: Any + unionagg: Any + gis_operators: Any + unsupported_functions: Any + select: str + select_extent: Any @property def function_names(self) -> Any: ... @property diff --git a/django-stubs/contrib/gis/db/backends/postgis/schema.pyi b/django-stubs/contrib/gis/db/backends/postgis/schema.pyi index 7946eb45f..7fc85d73d 100644 --- a/django-stubs/contrib/gis/db/backends/postgis/schema.pyi +++ b/django-stubs/contrib/gis/db/backends/postgis/schema.pyi @@ -3,9 +3,9 @@ from typing import Any from django.db.backends.postgresql.schema import DatabaseSchemaEditor class PostGISSchemaEditor(DatabaseSchemaEditor): - geom_index_type: str = ... - geom_index_ops_nd: str = ... - rast_index_wrapper: str = ... - sql_alter_column_to_3d: str = ... - sql_alter_column_to_2d: str = ... + geom_index_type: str + geom_index_ops_nd: str + rast_index_wrapper: str + sql_alter_column_to_3d: str + sql_alter_column_to_2d: str def geo_quote_name(self, name: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/spatialite/base.pyi b/django-stubs/contrib/gis/db/backends/spatialite/base.pyi index 22b2f8cd0..f8af7061f 100644 --- a/django-stubs/contrib/gis/db/backends/spatialite/base.pyi +++ b/django-stubs/contrib/gis/db/backends/spatialite/base.pyi @@ -3,12 +3,12 @@ from typing import Any from django.db.backends.sqlite3.base import DatabaseWrapper as SQLiteDatabaseWrapper class DatabaseWrapper(SQLiteDatabaseWrapper): - SchemaEditorClass: Any = ... - client_class: Any = ... - features_class: Any = ... - introspection_class: Any = ... - ops_class: Any = ... - lib_spatialite_paths: Any = ... + SchemaEditorClass: Any + client_class: Any + features_class: Any + introspection_class: Any + ops_class: Any + lib_spatialite_paths: Any def __init__(self, *args: Any, **kwargs: Any) -> None: ... def get_new_connection(self, conn_params: Any) -> Any: ... def prepare_database(self) -> None: ... diff --git a/django-stubs/contrib/gis/db/backends/spatialite/client.pyi b/django-stubs/contrib/gis/db/backends/spatialite/client.pyi index f97121016..bfee3fc41 100644 --- a/django-stubs/contrib/gis/db/backends/spatialite/client.pyi +++ b/django-stubs/contrib/gis/db/backends/spatialite/client.pyi @@ -1,4 +1,4 @@ from django.db.backends.sqlite3.client import DatabaseClient as DatabaseClient class SpatiaLiteClient(DatabaseClient): - executable_name: str = ... + executable_name: str diff --git a/django-stubs/contrib/gis/db/backends/spatialite/features.pyi b/django-stubs/contrib/gis/db/backends/spatialite/features.pyi index e4680b14c..5d33d8fa8 100644 --- a/django-stubs/contrib/gis/db/backends/spatialite/features.pyi +++ b/django-stubs/contrib/gis/db/backends/spatialite/features.pyi @@ -2,6 +2,6 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as from django.db.backends.sqlite3.features import DatabaseFeatures as SQLiteDatabaseFeatures class DatabaseFeatures(BaseSpatialFeatures, SQLiteDatabaseFeatures): - supports_3d_storage: bool = ... + supports_3d_storage: bool @property def supports_area_geodetic(self) -> bool: ... # type: ignore[override] diff --git a/django-stubs/contrib/gis/db/backends/spatialite/introspection.pyi b/django-stubs/contrib/gis/db/backends/spatialite/introspection.pyi index 7ce59fbdd..e05f67757 100644 --- a/django-stubs/contrib/gis/db/backends/spatialite/introspection.pyi +++ b/django-stubs/contrib/gis/db/backends/spatialite/introspection.pyi @@ -4,9 +4,9 @@ from django.db.backends.sqlite3.introspection import DatabaseIntrospection as Da from django.db.backends.sqlite3.introspection import FlexibleFieldLookupDict as FlexibleFieldLookupDict class GeoFlexibleFieldLookupDict(FlexibleFieldLookupDict): - base_data_types_reverse: Any = ... + base_data_types_reverse: Any class SpatiaLiteIntrospection(DatabaseIntrospection): - data_types_reverse: Any = ... + data_types_reverse: Any def get_geometry_type(self, table_name: Any, description: Any) -> Any: ... def get_constraints(self, cursor: Any, table_name: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/spatialite/models.pyi b/django-stubs/contrib/gis/db/backends/spatialite/models.pyi index 8a33516a9..108290c2a 100644 --- a/django-stubs/contrib/gis/db/backends/spatialite/models.pyi +++ b/django-stubs/contrib/gis/db/backends/spatialite/models.pyi @@ -4,33 +4,33 @@ from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin as Spa from django.db import models as models class SpatialiteGeometryColumns(models.Model): - f_table_name: Any = ... - f_geometry_column: Any = ... - coord_dimension: Any = ... - srid: Any = ... - spatial_index_enabled: Any = ... - type: Any = ... + f_table_name: Any + f_geometry_column: Any + coord_dimension: Any + srid: Any + spatial_index_enabled: Any + type: Any class Meta: - app_label: str = ... - db_table: str = ... - managed: bool = ... + app_label: str + db_table: str + managed: bool @classmethod def table_name_col(cls) -> Any: ... @classmethod def geom_col_name(cls) -> Any: ... class SpatialiteSpatialRefSys(models.Model, SpatialRefSysMixin): - srid: Any = ... - auth_name: Any = ... - auth_srid: Any = ... - ref_sys_name: Any = ... - proj4text: Any = ... - srtext: Any = ... + srid: Any + auth_name: Any + auth_srid: Any + ref_sys_name: Any + proj4text: Any + srtext: Any class Meta: - app_label: str = ... - db_table: str = ... - managed: bool = ... + app_label: str + db_table: str + managed: bool @property def wkt(self) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/spatialite/operations.pyi b/django-stubs/contrib/gis/db/backends/spatialite/operations.pyi index 11a07c67b..dab62a916 100644 --- a/django-stubs/contrib/gis/db/backends/spatialite/operations.pyi +++ b/django-stubs/contrib/gis/db/backends/spatialite/operations.pyi @@ -7,17 +7,17 @@ from django.db.backends.sqlite3.operations import DatabaseOperations class SpatialiteNullCheckOperator(SpatialOperator): ... class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations): - name: str = ... - spatialite: bool = ... - Adapter: Any = ... - collect: str = ... - extent: str = ... - makeline: str = ... - unionagg: str = ... - gis_operators: Any = ... - disallowed_aggregates: Any = ... - select: str = ... - function_names: Any = ... + name: str + spatialite: bool + Adapter: Any + collect: str + extent: str + makeline: str + unionagg: str + gis_operators: Any + disallowed_aggregates: Any + select: str + function_names: Any @property def unsupported_functions(self) -> Set[str]: ... # type: ignore[override] @property diff --git a/django-stubs/contrib/gis/db/backends/spatialite/schema.pyi b/django-stubs/contrib/gis/db/backends/spatialite/schema.pyi index 3aea269db..8cc590859 100644 --- a/django-stubs/contrib/gis/db/backends/spatialite/schema.pyi +++ b/django-stubs/contrib/gis/db/backends/spatialite/schema.pyi @@ -3,15 +3,15 @@ from typing import Any from django.db.backends.sqlite3.schema import DatabaseSchemaEditor as DatabaseSchemaEditor class SpatialiteSchemaEditor(DatabaseSchemaEditor): - sql_add_geometry_column: str = ... - sql_add_spatial_index: str = ... - sql_drop_spatial_index: str = ... - sql_recover_geometry_metadata: str = ... - sql_remove_geometry_metadata: str = ... - sql_discard_geometry_columns: str = ... - sql_update_geometry_columns: str = ... - geometry_tables: Any = ... - geometry_sql: Any = ... + sql_add_geometry_column: str + sql_add_spatial_index: str + sql_drop_spatial_index: str + sql_recover_geometry_metadata: str + sql_remove_geometry_metadata: str + sql_discard_geometry_columns: str + sql_update_geometry_columns: str + geometry_tables: Any + geometry_sql: Any def __init__(self, *args: Any, **kwargs: Any) -> None: ... def geo_quote_name(self, name: Any) -> Any: ... def column_sql(self, model: Any, field: Any, include_default: bool = ...) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/utils.pyi b/django-stubs/contrib/gis/db/backends/utils.pyi index a3d2ed3dd..23a977074 100644 --- a/django-stubs/contrib/gis/db/backends/utils.pyi +++ b/django-stubs/contrib/gis/db/backends/utils.pyi @@ -3,9 +3,9 @@ from typing import Any from django.db.models.sql.compiler import _AsSqlType class SpatialOperator: - sql_template: Any = ... - op: Any = ... - func: Any = ... + sql_template: Any + op: Any + func: Any def __init__(self, op: Any | None = ..., func: Any | None = ...) -> None: ... @property def default_template(self) -> Any: ... diff --git a/django-stubs/contrib/gis/db/models/aggregates.pyi b/django-stubs/contrib/gis/db/models/aggregates.pyi index ea178930e..d42cad7bb 100644 --- a/django-stubs/contrib/gis/db/models/aggregates.pyi +++ b/django-stubs/contrib/gis/db/models/aggregates.pyi @@ -4,8 +4,8 @@ from django.db.models import Aggregate from django.db.models.sql.compiler import _AsSqlType class GeoAggregate(Aggregate): - function: Any = ... - is_extent: bool = ... + function: Any + is_extent: bool @property def output_field(self) -> Any: ... def as_sql( @@ -22,21 +22,21 @@ class GeoAggregate(Aggregate): ) -> Any: ... class Collect(GeoAggregate): - name: str = ... - output_field_class: Any = ... + name: str + output_field_class: Any class Extent(GeoAggregate): - name: str = ... + name: str def __init__(self, expression: Any, **extra: Any) -> None: ... class Extent3D(GeoAggregate): - name: str = ... + name: str def __init__(self, expression: Any, **extra: Any) -> None: ... class MakeLine(GeoAggregate): - name: str = ... - output_field_class: Any = ... + name: str + output_field_class: Any class Union(GeoAggregate): - name: str = ... - output_field_class: Any = ... + name: str + output_field_class: Any diff --git a/django-stubs/contrib/gis/db/models/fields.pyi b/django-stubs/contrib/gis/db/models/fields.pyi index 284156de1..d6c98e496 100644 --- a/django-stubs/contrib/gis/db/models/fields.pyi +++ b/django-stubs/contrib/gis/db/models/fields.pyi @@ -58,12 +58,12 @@ class BaseSpatialField(Field[_ST, _GT]): def get_prep_value(self, value: Any) -> Any: ... class GeometryField(BaseSpatialField): - description: Any = ... - form_class: Any = ... - geom_type: str = ... - geom_class: Any = ... - dim: Any = ... - geography: Any = ... + description: Any + form_class: Any + geom_type: str + geom_class: Any + dim: Any + geography: Any def __init__( self, verbose_name: _StrOrPromise | None = ..., @@ -100,56 +100,56 @@ class GeometryField(BaseSpatialField): def select_format(self, compiler: Any, sql: Any, params: Any) -> Any: ... class PointField(GeometryField): - geom_type: str = ... - geom_class: Any = ... - form_class: Any = ... - description: Any = ... + geom_type: str + geom_class: Any + form_class: Any + description: Any class LineStringField(GeometryField): - geom_type: str = ... - geom_class: Any = ... - form_class: Any = ... - description: Any = ... + geom_type: str + geom_class: Any + form_class: Any + description: Any class PolygonField(GeometryField): - geom_type: str = ... - geom_class: Any = ... - form_class: Any = ... - description: Any = ... + geom_type: str + geom_class: Any + form_class: Any + description: Any class MultiPointField(GeometryField): - geom_type: str = ... - geom_class: Any = ... - form_class: Any = ... - description: Any = ... + geom_type: str + geom_class: Any + form_class: Any + description: Any class MultiLineStringField(GeometryField): - geom_type: str = ... - geom_class: Any = ... - form_class: Any = ... - description: Any = ... + geom_type: str + geom_class: Any + form_class: Any + description: Any class MultiPolygonField(GeometryField): - geom_type: str = ... - geom_class: Any = ... - form_class: Any = ... - description: Any = ... + geom_type: str + geom_class: Any + form_class: Any + description: Any class GeometryCollectionField(GeometryField): - geom_type: str = ... - geom_class: Any = ... - form_class: Any = ... - description: Any = ... + geom_type: str + geom_class: Any + form_class: Any + description: Any class ExtentField(Field): - description: Any = ... + description: Any def get_internal_type(self) -> Any: ... def select_format(self, compiler: Any, sql: Any, params: Any) -> Any: ... class RasterField(BaseSpatialField): - description: Any = ... - geom_type: str = ... - geography: bool = ... + description: Any + geom_type: str + geography: bool def db_type(self, connection: Any) -> Any: ... def from_db_value(self, value: Any, expression: Any, connection: Any) -> Any: ... def get_transform(self, name: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/db/models/functions.pyi b/django-stubs/contrib/gis/db/models/functions.pyi index 806417f63..bc5b88d7f 100644 --- a/django-stubs/contrib/gis/db/models/functions.pyi +++ b/django-stubs/contrib/gis/db/models/functions.pyi @@ -7,8 +7,8 @@ from django.db.models.sql.compiler import _AsSqlType NUMERIC_TYPES: Any class GeoFuncMixin: - function: Any = ... - geom_param_pos: Any = ... + function: Any + geom_param_pos: Any def __init__(self, *expressions: Any, **extra: Any) -> None: ... @property def geo_field(self) -> Any: ... @@ -27,59 +27,59 @@ class SQLiteDecimalToFloatMixin: def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class OracleToleranceMixin: - tolerance: float = ... + tolerance: float def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class Area(OracleToleranceMixin, GeoFunc): - arity: int = ... + arity: int @property def output_field(self) -> Any: ... def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class Azimuth(GeoFunc): - output_field: Any = ... - arity: int = ... - geom_param_pos: Any = ... + output_field: Any + arity: int + geom_param_pos: Any class AsGeoJSON(GeoFunc): - output_field: Any = ... + output_field: Any def __init__( self, expression: Any, bbox: bool = ..., crs: bool = ..., precision: int = ..., **extra: Any ) -> None: ... def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class AsGML(GeoFunc): - geom_param_pos: Any = ... - output_field: Any = ... + geom_param_pos: Any + output_field: Any def __init__(self, expression: Any, version: int = ..., precision: int = ..., **extra: Any) -> None: ... def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class AsKML(GeoFunc): - output_field: Any = ... + output_field: Any def __init__(self, expression: Any, precision: int = ..., **extra: Any) -> None: ... class AsSVG(GeoFunc): - output_field: Any = ... + output_field: Any def __init__(self, expression: Any, relative: bool = ..., precision: int = ..., **extra: Any) -> None: ... class AsWKB(GeoFunc): - output_field: Any = ... - arity: int = ... + output_field: Any + arity: int class AsWKT(GeoFunc): - output_field: Any = ... - arity: int = ... + output_field: Any + arity: int class BoundingCircle(OracleToleranceMixin, GeomOutputGeoFunc): def __init__(self, expression: Any, num_seg: int = ..., **extra: Any) -> None: ... def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class Centroid(OracleToleranceMixin, GeomOutputGeoFunc): - arity: int = ... + arity: int class Difference(OracleToleranceMixin, GeomOutputGeoFunc): - arity: int = ... - geom_param_pos: Any = ... + arity: int + geom_param_pos: Any class DistanceResultMixin: @property @@ -87,74 +87,74 @@ class DistanceResultMixin: def source_is_geography(self) -> Any: ... class Distance(DistanceResultMixin, OracleToleranceMixin, GeoFunc): - geom_param_pos: Any = ... - spheroid: Any = ... + geom_param_pos: Any + spheroid: Any def __init__(self, expr1: Any, expr2: Any, spheroid: Any | None = ..., **extra: Any) -> None: ... def as_postgresql(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class Envelope(GeomOutputGeoFunc): - arity: int = ... + arity: int class ForcePolygonCW(GeomOutputGeoFunc): - arity: int = ... + arity: int class GeoHash(GeoFunc): - output_field: Any = ... + output_field: Any def __init__(self, expression: Any, precision: Any | None = ..., **extra: Any) -> None: ... def as_mysql(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class GeometryDistance(GeoFunc): - output_field: Any = ... - arity: int = ... - function: str = ... - arg_joiner: str = ... - geom_param_pos: Any = ... + output_field: Any + arity: int + function: str + arg_joiner: str + geom_param_pos: Any class Intersection(OracleToleranceMixin, GeomOutputGeoFunc): - arity: int = ... - geom_param_pos: Any = ... + arity: int + geom_param_pos: Any class IsValid(OracleToleranceMixin, GeoFuncMixin, StandardTransform): - lookup_name: str = ... - output_field: Any = ... + lookup_name: str + output_field: Any def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class Length(DistanceResultMixin, OracleToleranceMixin, GeoFunc): - spheroid: Any = ... + spheroid: Any def __init__(self, expr1: Any, spheroid: bool = ..., **extra: Any) -> None: ... def as_postgresql(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class LineLocatePoint(GeoFunc): - output_field: Any = ... - arity: int = ... - geom_param_pos: Any = ... + output_field: Any + arity: int + geom_param_pos: Any class MakeValid(GeomOutputGeoFunc): ... class MemSize(GeoFunc): - output_field: Any = ... - arity: int = ... + output_field: Any + arity: int class NumGeometries(GeoFunc): - output_field: Any = ... - arity: int = ... + output_field: Any + arity: int class NumPoints(GeoFunc): - output_field: Any = ... - arity: int = ... + output_field: Any + arity: int class Perimeter(DistanceResultMixin, OracleToleranceMixin, GeoFunc): - arity: int = ... + arity: int def as_postgresql(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class PointOnSurface(OracleToleranceMixin, GeomOutputGeoFunc): - arity: int = ... + arity: int class Reverse(GeoFunc): - arity: int = ... + arity: int class Scale(SQLiteDecimalToFloatMixin, GeomOutputGeoFunc): def __init__(self, expression: Any, x: Any, y: Any, z: float = ..., **extra: Any) -> None: ... @@ -163,8 +163,8 @@ class SnapToGrid(SQLiteDecimalToFloatMixin, GeomOutputGeoFunc): def __init__(self, expression: Any, *args: Any, **extra: Any) -> None: ... class SymDifference(OracleToleranceMixin, GeomOutputGeoFunc): - arity: int = ... - geom_param_pos: Any = ... + arity: int + geom_param_pos: Any class Transform(GeomOutputGeoFunc): def __init__(self, expression: Any, srid: Any, **extra: Any) -> None: ... @@ -173,5 +173,5 @@ class Translate(Scale): def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... class Union(OracleToleranceMixin, GeomOutputGeoFunc): - arity: int = ... - geom_param_pos: Any = ... + arity: int + geom_param_pos: Any diff --git a/django-stubs/contrib/gis/db/models/lookups.pyi b/django-stubs/contrib/gis/db/models/lookups.pyi index 82530af7a..6929e6e08 100644 --- a/django-stubs/contrib/gis/db/models/lookups.pyi +++ b/django-stubs/contrib/gis/db/models/lookups.pyi @@ -5,121 +5,121 @@ from django.db.models import Lookup, Transform class RasterBandTransform(Transform): ... class GISLookup(Lookup): - sql_template: Any = ... - transform_func: Any = ... - distance: bool = ... - band_rhs: Any = ... - band_lhs: Any = ... - template_params: Any = ... + sql_template: Any + transform_func: Any + distance: bool + band_rhs: Any + band_lhs: Any + template_params: Any def __init__(self, lhs: Any, rhs: Any) -> None: ... def process_rhs_params(self) -> None: ... def process_band_indices(self, only_lhs: bool = ...) -> None: ... def get_db_prep_lookup(self, value: Any, connection: Any) -> Any: ... - rhs: Any = ... + rhs: Any def process_rhs(self, compiler: Any, connection: Any) -> Any: ... def get_rhs_op(self, connection: Any, rhs: Any) -> Any: ... class OverlapsLeftLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class OverlapsRightLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class OverlapsBelowLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class OverlapsAboveLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class LeftLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class RightLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class StrictlyBelowLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class StrictlyAboveLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class SameAsLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class BBContainsLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class BBOverlapsLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class ContainedLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class ContainsLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class ContainsProperlyLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class CoveredByLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class CoversLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class CrossesLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class DisjointLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class EqualsLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class IntersectsLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class OverlapsLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class RelateLookup(GISLookup): - lookup_name: str = ... - sql_template: str = ... - pattern_regex: Any = ... + lookup_name: str + sql_template: str + pattern_regex: Any def process_rhs(self, compiler: Any, connection: Any) -> Any: ... class TouchesLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class WithinLookup(GISLookup): - lookup_name: str = ... + lookup_name: str class DistanceLookupBase(GISLookup): - distance: bool = ... - sql_template: str = ... + distance: bool + sql_template: str def process_rhs_params(self) -> None: ... def process_distance(self, compiler: Any, connection: Any) -> Any: ... class DWithinLookup(DistanceLookupBase): - lookup_name: str = ... - sql_template: str = ... + lookup_name: str + sql_template: str def process_distance(self, compiler: Any, connection: Any) -> Any: ... def process_rhs(self, compiler: Any, connection: Any) -> Any: ... class DistanceLookupFromFunction(DistanceLookupBase): ... class DistanceGTLookup(DistanceLookupFromFunction): - lookup_name: str = ... - op: str = ... + lookup_name: str + op: str class DistanceGTELookup(DistanceLookupFromFunction): - lookup_name: str = ... - op: str = ... + lookup_name: str + op: str class DistanceLTLookup(DistanceLookupFromFunction): - lookup_name: str = ... - op: str = ... + lookup_name: str + op: str class DistanceLTELookup(DistanceLookupFromFunction): - lookup_name: str = ... - op: str = ... + lookup_name: str + op: str diff --git a/django-stubs/contrib/gis/db/models/sql/conversion.pyi b/django-stubs/contrib/gis/db/models/sql/conversion.pyi index 60b54b756..50c08f5ee 100644 --- a/django-stubs/contrib/gis/db/models/sql/conversion.pyi +++ b/django-stubs/contrib/gis/db/models/sql/conversion.pyi @@ -3,7 +3,7 @@ from typing import Any from django.db import models as models class AreaField(models.FloatField): - geo_field: Any = ... + geo_field: Any def __init__(self, geo_field: Any) -> None: ... def get_prep_value(self, value: Any) -> Any: ... def get_db_prep_value(self, value: Any, connection: Any, prepared: bool = ...) -> Any: ... @@ -11,7 +11,7 @@ class AreaField(models.FloatField): def get_internal_type(self) -> Any: ... class DistanceField(models.FloatField): - geo_field: Any = ... + geo_field: Any def __init__(self, geo_field: Any) -> None: ... def get_prep_value(self, value: Any) -> Any: ... def get_db_prep_value(self, value: Any, connection: Any, prepared: bool = ...) -> Any: ... diff --git a/django-stubs/contrib/gis/feeds.pyi b/django-stubs/contrib/gis/feeds.pyi index 2e90e79cb..d3ecee6d8 100644 --- a/django-stubs/contrib/gis/feeds.pyi +++ b/django-stubs/contrib/gis/feeds.pyi @@ -24,6 +24,6 @@ class W3CGeoFeed(Rss201rev2Feed, GeoFeedMixin): def add_root_elements(self, handler: Any) -> None: ... class Feed(BaseFeed): - feed_type: Any = ... + feed_type: Any def feed_extra_kwargs(self, obj: Any) -> Any: ... def item_extra_kwargs(self, item: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/forms/fields.pyi b/django-stubs/contrib/gis/forms/fields.pyi index ff7a9e21a..a2a408c6b 100644 --- a/django-stubs/contrib/gis/forms/fields.pyi +++ b/django-stubs/contrib/gis/forms/fields.pyi @@ -3,32 +3,32 @@ from typing import Any from django import forms class GeometryField(forms.Field): - widget: Any = ... - geom_type: str = ... - default_error_messages: Any = ... - srid: Any = ... + widget: Any + geom_type: str + default_error_messages: Any + srid: Any def __init__(self, *, srid: Any | None = ..., geom_type: Any | None = ..., **kwargs: Any) -> None: ... def to_python(self, value: Any) -> Any: ... def clean(self, value: Any) -> Any: ... def has_changed(self, initial: Any, data: Any) -> Any: ... class GeometryCollectionField(GeometryField): - geom_type: str = ... + geom_type: str class PointField(GeometryField): - geom_type: str = ... + geom_type: str class MultiPointField(GeometryField): - geom_type: str = ... + geom_type: str class LineStringField(GeometryField): - geom_type: str = ... + geom_type: str class MultiLineStringField(GeometryField): - geom_type: str = ... + geom_type: str class PolygonField(GeometryField): - geom_type: str = ... + geom_type: str class MultiPolygonField(GeometryField): - geom_type: str = ... + geom_type: str diff --git a/django-stubs/contrib/gis/forms/widgets.pyi b/django-stubs/contrib/gis/forms/widgets.pyi index 703d60990..128fb7bfe 100644 --- a/django-stubs/contrib/gis/forms/widgets.pyi +++ b/django-stubs/contrib/gis/forms/widgets.pyi @@ -6,32 +6,32 @@ from django.forms.widgets import Widget as Widget logger: Logger class BaseGeometryWidget(Widget): - geom_type: str = ... - map_srid: int = ... - map_width: int = ... - map_height: int = ... - display_raw: bool = ... - supports_3d: bool = ... - template_name: str = ... - attrs: Any = ... + geom_type: str + map_srid: int + map_width: int + map_height: int + display_raw: bool + supports_3d: bool + template_name: str + attrs: Any def __init__(self, attrs: Any | None = ...) -> None: ... def serialize(self, value: Any) -> Any: ... def deserialize(self, value: Any) -> Any: ... def get_context(self, name: Any, value: Any, attrs: Any) -> Any: ... class OpenLayersWidget(BaseGeometryWidget): - template_name: str = ... - map_srid: int = ... + template_name: str + map_srid: int class Media: - css: Any = ... - js: Any = ... + css: Any + js: Any def serialize(self, value: Any) -> Any: ... def deserialize(self, value: Any) -> Any: ... class OSMWidget(OpenLayersWidget): - template_name: str = ... - default_lon: int = ... - default_lat: int = ... - default_zoom: int = ... + template_name: str + default_lon: int + default_lat: int + default_zoom: int def __init__(self, attrs: Any | None = ...) -> None: ... diff --git a/django-stubs/contrib/gis/gdal/base.pyi b/django-stubs/contrib/gis/gdal/base.pyi index 7cc886641..600808721 100644 --- a/django-stubs/contrib/gis/gdal/base.pyi +++ b/django-stubs/contrib/gis/gdal/base.pyi @@ -3,4 +3,4 @@ from typing import Any from django.contrib.gis.ptr import CPointerBase as CPointerBase class GDALBase(CPointerBase): - null_ptr_exception_class: Any = ... + null_ptr_exception_class: Any diff --git a/django-stubs/contrib/gis/gdal/datasource.pyi b/django-stubs/contrib/gis/gdal/datasource.pyi index 1ed79da79..105a8ee0d 100644 --- a/django-stubs/contrib/gis/gdal/datasource.pyi +++ b/django-stubs/contrib/gis/gdal/datasource.pyi @@ -3,10 +3,10 @@ from typing import Any from django.contrib.gis.gdal.base import GDALBase as GDALBase class DataSource(GDALBase): - destructor: Any = ... - encoding: Any = ... - ptr: Any = ... - driver: Any = ... + destructor: Any + encoding: Any + ptr: Any + driver: Any def __init__(self, ds_input: Any, ds_driver: bool = ..., write: bool = ..., encoding: str = ...) -> None: ... def __getitem__(self, index: Any) -> Any: ... def __len__(self) -> int: ... diff --git a/django-stubs/contrib/gis/gdal/driver.pyi b/django-stubs/contrib/gis/gdal/driver.pyi index cddf50248..4fb87e647 100644 --- a/django-stubs/contrib/gis/gdal/driver.pyi +++ b/django-stubs/contrib/gis/gdal/driver.pyi @@ -3,7 +3,7 @@ from typing import Any from django.contrib.gis.gdal.base import GDALBase as GDALBase class Driver(GDALBase): - ptr: Any = ... + ptr: Any def __init__(self, dr_input: Any) -> None: ... @classmethod def ensure_registered(cls) -> None: ... diff --git a/django-stubs/contrib/gis/gdal/feature.pyi b/django-stubs/contrib/gis/gdal/feature.pyi index 7a4f512d1..9b296e995 100644 --- a/django-stubs/contrib/gis/gdal/feature.pyi +++ b/django-stubs/contrib/gis/gdal/feature.pyi @@ -3,8 +3,8 @@ from typing import Any from django.contrib.gis.gdal.base import GDALBase as GDALBase class Feature(GDALBase): - destructor: Any = ... - ptr: Any = ... + destructor: Any + ptr: Any def __init__(self, feat: Any, layer: Any) -> None: ... def __getitem__(self, index: Any) -> Any: ... def __len__(self) -> int: ... diff --git a/django-stubs/contrib/gis/gdal/field.pyi b/django-stubs/contrib/gis/gdal/field.pyi index cf1ba52fd..c573efdc1 100644 --- a/django-stubs/contrib/gis/gdal/field.pyi +++ b/django-stubs/contrib/gis/gdal/field.pyi @@ -3,7 +3,7 @@ from typing import Any from django.contrib.gis.gdal.base import GDALBase as GDALBase class Field(GDALBase): - ptr: Any = ... + ptr: Any def __init__(self, feat: Any, index: Any) -> None: ... def as_double(self) -> Any: ... def as_int(self, is_64: bool = ...) -> Any: ... diff --git a/django-stubs/contrib/gis/gdal/geometries.pyi b/django-stubs/contrib/gis/gdal/geometries.pyi index 585a7e5e7..3eb580352 100644 --- a/django-stubs/contrib/gis/gdal/geometries.pyi +++ b/django-stubs/contrib/gis/gdal/geometries.pyi @@ -3,9 +3,9 @@ from typing import Any from django.contrib.gis.gdal.base import GDALBase as GDALBase class OGRGeometry(GDALBase): - destructor: Any = ... - ptr: Any = ... - srs: Any = ... + destructor: Any + ptr: Any + srs: Any def __init__(self, geom_input: Any, srs: Any | None = ...) -> None: ... @classmethod def from_bbox(cls, bbox: Any) -> Any: ... @@ -20,7 +20,7 @@ class OGRGeometry(GDALBase): def __eq__(self, other: Any) -> bool: ... @property def dimension(self) -> Any: ... - coord_dim: Any = ... + coord_dim: Any @property def geom_count(self) -> Any: ... @property @@ -41,7 +41,7 @@ class OGRGeometry(GDALBase): def empty(self) -> Any: ... @property def extent(self) -> Any: ... - srid: Any = ... + srid: Any @property def geos(self) -> Any: ... @property @@ -50,7 +50,7 @@ class OGRGeometry(GDALBase): def hex(self) -> Any: ... @property def json(self) -> Any: ... - geojson: Any = ... + geojson: Any @property def kml(self) -> Any: ... @property @@ -90,14 +90,14 @@ class Point(OGRGeometry): def z(self) -> Any: ... @property def tuple(self) -> Any: ... - coords: Any = ... + coords: Any class LineString(OGRGeometry): def __getitem__(self, index: Any) -> Any: ... def __len__(self) -> int: ... @property def tuple(self) -> Any: ... - coords: Any = ... + coords: Any @property def x(self) -> Any: ... @property @@ -112,10 +112,10 @@ class Polygon(OGRGeometry): def __getitem__(self, index: Any) -> Any: ... @property def shell(self) -> Any: ... - exterior_ring: Any = ... + exterior_ring: Any @property def tuple(self) -> Any: ... - coords: Any = ... + coords: Any @property def point_count(self) -> Any: ... @property @@ -129,7 +129,7 @@ class GeometryCollection(OGRGeometry): def point_count(self) -> Any: ... @property def tuple(self) -> Any: ... - coords: Any = ... + coords: Any class MultiPoint(GeometryCollection): ... class MultiLineString(GeometryCollection): ... diff --git a/django-stubs/contrib/gis/gdal/geomtype.pyi b/django-stubs/contrib/gis/gdal/geomtype.pyi index 04ee0f0a0..3666b594d 100644 --- a/django-stubs/contrib/gis/gdal/geomtype.pyi +++ b/django-stubs/contrib/gis/gdal/geomtype.pyi @@ -1,8 +1,8 @@ from typing import Any class OGRGeomType: - wkb25bit: int = ... - num: Any = ... + wkb25bit: int + num: Any def __init__(self, type_input: Any) -> None: ... def __eq__(self, other: Any) -> bool: ... @property diff --git a/django-stubs/contrib/gis/gdal/layer.pyi b/django-stubs/contrib/gis/gdal/layer.pyi index 5671d9e72..205f4734c 100644 --- a/django-stubs/contrib/gis/gdal/layer.pyi +++ b/django-stubs/contrib/gis/gdal/layer.pyi @@ -3,7 +3,7 @@ from typing import Any, Iterator from django.contrib.gis.gdal.base import GDALBase as GDALBase class Layer(GDALBase): - ptr: Any = ... + ptr: Any def __init__(self, layer_ptr: Any, ds: Any) -> None: ... def __getitem__(self, index: Any) -> Any: ... def __iter__(self) -> Iterator[Any]: ... @@ -26,7 +26,7 @@ class Layer(GDALBase): def field_widths(self) -> Any: ... @property def field_precisions(self) -> Any: ... - spatial_filter: Any = ... + spatial_filter: Any def get_fields(self, field_name: Any) -> Any: ... def get_geoms(self, geos: bool = ...) -> Any: ... def test_capability(self, capability: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/gdal/raster/band.pyi b/django-stubs/contrib/gis/gdal/raster/band.pyi index 50869cf37..113a87500 100644 --- a/django-stubs/contrib/gis/gdal/raster/band.pyi +++ b/django-stubs/contrib/gis/gdal/raster/band.pyi @@ -3,7 +3,7 @@ from typing import Any, Iterator from django.contrib.gis.gdal.raster.base import GDALRasterBase as GDALRasterBase class GDALBand(GDALRasterBase): - source: Any = ... + source: Any def __init__(self, source: Any, index: Any) -> None: ... @property def description(self) -> Any: ... @@ -38,7 +38,7 @@ class GDALBand(GDALRasterBase): ) -> Any: ... class BandList(list): - source: Any = ... + source: Any def __init__(self, source: Any) -> None: ... def __iter__(self) -> Iterator[Any]: ... def __len__(self) -> int: ... diff --git a/django-stubs/contrib/gis/gdal/raster/source.pyi b/django-stubs/contrib/gis/gdal/raster/source.pyi index 781d66160..a46e19b8f 100644 --- a/django-stubs/contrib/gis/gdal/raster/source.pyi +++ b/django-stubs/contrib/gis/gdal/raster/source.pyi @@ -3,7 +3,7 @@ from typing import Any from django.contrib.gis.gdal.raster.base import GDALRasterBase as GDALRasterBase class TransformPoint(list): - indices: Any = ... + indices: Any def __init__(self, raster: Any, prop: Any) -> None: ... @property def x(self) -> Any: ... @@ -15,7 +15,7 @@ class TransformPoint(list): def y(self, value: Any) -> None: ... class GDALRaster(GDALRasterBase): - destructor: Any = ... + destructor: Any def __init__(self, ds_input: Any, write: bool = ...) -> None: ... def __del__(self) -> None: ... @property diff --git a/django-stubs/contrib/gis/gdal/srs.pyi b/django-stubs/contrib/gis/gdal/srs.pyi index a584f9e36..cb298d363 100644 --- a/django-stubs/contrib/gis/gdal/srs.pyi +++ b/django-stubs/contrib/gis/gdal/srs.pyi @@ -4,13 +4,13 @@ from typing import Any from django.contrib.gis.gdal.base import GDALBase as GDALBase class AxisOrder(IntEnum): - TRADITIONAL: int = ... - AUTHORITY: int = ... + TRADITIONAL: int + AUTHORITY: int class SpatialReference(GDALBase): - destructor: Any = ... - axis_order: Any = ... - ptr: Any = ... + destructor: Any + axis_order: Any + ptr: Any def __init__(self, srs_input: str = ..., srs_type: str = ..., axis_order: Any | None = ...) -> None: ... def __getitem__(self, target: Any) -> Any: ... def attr_value(self, target: Any, index: int = ...) -> Any: ... @@ -62,6 +62,6 @@ class SpatialReference(GDALBase): def proj4(self) -> Any: ... class CoordTransform(GDALBase): - destructor: Any = ... - ptr: Any = ... + destructor: Any + ptr: Any def __init__(self, source: Any, target: Any) -> None: ... diff --git a/django-stubs/contrib/gis/geoip2/base.pyi b/django-stubs/contrib/gis/geoip2/base.pyi index ae9faea5a..5dc5869d5 100644 --- a/django-stubs/contrib/gis/geoip2/base.pyi +++ b/django-stubs/contrib/gis/geoip2/base.pyi @@ -5,12 +5,12 @@ GEOIP_SETTINGS: Any class GeoIP2Exception(Exception): ... class GeoIP2: - MODE_AUTO: int = ... - MODE_MMAP_EXT: int = ... - MODE_MMAP: int = ... - MODE_FILE: int = ... - MODE_MEMORY: int = ... - cache_options: Any = ... + MODE_AUTO: int + MODE_MMAP_EXT: int + MODE_MMAP: int + MODE_FILE: int + MODE_MEMORY: int + cache_options: Any def __init__( self, path: Any | None = ..., cache: int = ..., country: Any | None = ..., city: Any | None = ... ) -> None: ... diff --git a/django-stubs/contrib/gis/geos/base.pyi b/django-stubs/contrib/gis/geos/base.pyi index 97b08ada1..63b092dc6 100644 --- a/django-stubs/contrib/gis/geos/base.pyi +++ b/django-stubs/contrib/gis/geos/base.pyi @@ -3,4 +3,4 @@ from typing import Any from django.contrib.gis.ptr import CPointerBase as CPointerBase class GEOSBase(CPointerBase): - null_ptr_exception_class: Any = ... + null_ptr_exception_class: Any diff --git a/django-stubs/contrib/gis/geos/collections.pyi b/django-stubs/contrib/gis/geos/collections.pyi index f1f3b18a1..b7209c5f4 100644 --- a/django-stubs/contrib/gis/geos/collections.pyi +++ b/django-stubs/contrib/gis/geos/collections.pyi @@ -11,7 +11,7 @@ class GeometryCollection(GEOSGeometry): def kml(self) -> Any: ... @property def tuple(self) -> Any: ... - coords: Any = ... + coords: Any class MultiPoint(GeometryCollection): ... class MultiLineString(LinearGeometryMixin, GeometryCollection): ... diff --git a/django-stubs/contrib/gis/geos/coordseq.pyi b/django-stubs/contrib/gis/geos/coordseq.pyi index 0a63ce4f5..3ac53f42c 100644 --- a/django-stubs/contrib/gis/geos/coordseq.pyi +++ b/django-stubs/contrib/gis/geos/coordseq.pyi @@ -3,7 +3,7 @@ from typing import Any, Iterator from django.contrib.gis.geos.base import GEOSBase as GEOSBase class GEOSCoordSeq(GEOSBase): - ptr_type: Any = ... + ptr_type: Any def __init__(self, ptr: Any, z: bool = ...) -> None: ... def __iter__(self) -> Iterator[Any]: ... def __len__(self) -> int: ... diff --git a/django-stubs/contrib/gis/geos/geometry.pyi b/django-stubs/contrib/gis/geos/geometry.pyi index 4f4370a95..4f3742fe1 100644 --- a/django-stubs/contrib/gis/geos/geometry.pyi +++ b/django-stubs/contrib/gis/geos/geometry.pyi @@ -9,9 +9,9 @@ from django.contrib.gis.geos.mutable_list import ListMixin as ListMixin _T = TypeVar("_T") class GEOSGeometryBase(GEOSBase): - ptr_type: Any = ... - destructor: Any = ... - has_cs: bool = ... + ptr_type: Any + destructor: Any + has_cs: bool def __init__(self, ptr: Any, cls: Any) -> None: ... def __copy__(self: _T) -> _T: ... def __deepcopy__(self: _T, memodict: Any) -> _T: ... @@ -77,7 +77,7 @@ class GEOSGeometryBase(GEOSBase): def hexewkb(self) -> Any: ... @property def json(self) -> Any: ... - geojson: Any = ... + geojson: Any @property def wkb(self) -> Any: ... @property @@ -92,7 +92,7 @@ class GEOSGeometryBase(GEOSBase): def srs(self) -> Any: ... @property def crs(self) -> Any: ... - ptr: Any = ... + ptr: Any def transform(self, ct: Any, clone: bool = ...) -> Any: ... @property def boundary(self) -> Any: ... @@ -136,5 +136,5 @@ class LinearGeometryMixin: def closed(self) -> Any: ... class GEOSGeometry(GEOSGeometryBase, ListMixin): - srid: Any = ... + srid: Any def __init__(self, geo_input: Any, srid: Any | None = ...) -> None: ... diff --git a/django-stubs/contrib/gis/geos/libgeos.pyi b/django-stubs/contrib/gis/geos/libgeos.pyi index 4e72a74d8..1b4c9725d 100644 --- a/django-stubs/contrib/gis/geos/libgeos.pyi +++ b/django-stubs/contrib/gis/geos/libgeos.pyi @@ -26,10 +26,10 @@ CONTEXT_PTR: Any lgeos: Any class GEOSFuncFactory: - argtypes: Any = ... - restype: Any = ... - errcheck: Any = ... - func_name: Any = ... + argtypes: Any + restype: Any + errcheck: Any + func_name: Any def __init__( self, func_name: Any, *, restype: Any | None = ..., errcheck: Any | None = ..., argtypes: Any | None = ... ) -> None: ... diff --git a/django-stubs/contrib/gis/geos/linestring.pyi b/django-stubs/contrib/gis/geos/linestring.pyi index ab3ffb2c2..c53212762 100644 --- a/django-stubs/contrib/gis/geos/linestring.pyi +++ b/django-stubs/contrib/gis/geos/linestring.pyi @@ -4,13 +4,13 @@ from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry from django.contrib.gis.geos.geometry import LinearGeometryMixin as LinearGeometryMixin class LineString(LinearGeometryMixin, GEOSGeometry): - has_cs: bool = ... + has_cs: bool def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __iter__(self) -> Iterator[Any]: ... def __len__(self) -> int: ... @property def tuple(self) -> Any: ... - coords: Any = ... + coords: Any @property def array(self) -> Any: ... @property diff --git a/django-stubs/contrib/gis/geos/point.pyi b/django-stubs/contrib/gis/geos/point.pyi index 9821686c1..b67bf27c1 100644 --- a/django-stubs/contrib/gis/geos/point.pyi +++ b/django-stubs/contrib/gis/geos/point.pyi @@ -3,7 +3,7 @@ from typing import Any, Iterator from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry class Point(GEOSGeometry): - has_cs: bool = ... + has_cs: bool def __init__( self, x: Any | None = ..., y: Any | None = ..., z: Any | None = ..., srid: Any | None = ... ) -> None: ... @@ -25,4 +25,4 @@ class Point(GEOSGeometry): def tuple(self) -> Any: ... @tuple.setter def tuple(self, tup: Any) -> None: ... - coords: Any = ... + coords: Any diff --git a/django-stubs/contrib/gis/geos/polygon.pyi b/django-stubs/contrib/gis/geos/polygon.pyi index e02d2b78f..0d0e8bf71 100644 --- a/django-stubs/contrib/gis/geos/polygon.pyi +++ b/django-stubs/contrib/gis/geos/polygon.pyi @@ -10,10 +10,10 @@ class Polygon(GEOSGeometry): def from_bbox(cls, bbox: Any) -> Any: ... @property def num_interior_rings(self) -> Any: ... - exterior_ring: Any = ... - shell: Any = ... + exterior_ring: Any + shell: Any @property def tuple(self) -> Any: ... - coords: Any = ... + coords: Any @property def kml(self) -> Any: ... diff --git a/django-stubs/contrib/gis/geos/prepared.pyi b/django-stubs/contrib/gis/geos/prepared.pyi index 731332e3c..a0aa425ce 100644 --- a/django-stubs/contrib/gis/geos/prepared.pyi +++ b/django-stubs/contrib/gis/geos/prepared.pyi @@ -3,9 +3,9 @@ from typing import Any from .base import GEOSBase as GEOSBase class PreparedGeometry(GEOSBase): - ptr_type: Any = ... - destructor: Any = ... - ptr: Any = ... + ptr_type: Any + destructor: Any + ptr: Any def __init__(self, geom: Any) -> None: ... def contains(self, other: Any) -> Any: ... def contains_properly(self, other: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/geos/prototypes/coordseq.pyi b/django-stubs/contrib/gis/geos/prototypes/coordseq.pyi index b31cbea3a..09fe2c4f6 100644 --- a/django-stubs/contrib/gis/geos/prototypes/coordseq.pyi +++ b/django-stubs/contrib/gis/geos/prototypes/coordseq.pyi @@ -6,16 +6,16 @@ def check_cs_op(result: Any, func: Any, cargs: Any) -> Any: ... def check_cs_get(result: Any, func: Any, cargs: Any) -> Any: ... class CsInt(GEOSFuncFactory): - argtypes: Any = ... - restype: Any = ... - errcheck: Any = ... + argtypes: Any + restype: Any + errcheck: Any class CsOperation(GEOSFuncFactory): - restype: Any = ... + restype: Any def __init__(self, *args: Any, ordinate: bool = ..., get: bool = ..., **kwargs: Any) -> None: ... class CsOutput(GEOSFuncFactory): - restype: Any = ... + restype: Any @staticmethod def errcheck(result: Any, func: Any, cargs: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/geos/prototypes/geom.pyi b/django-stubs/contrib/gis/geos/prototypes/geom.pyi index 969af76d6..0ac454877 100644 --- a/django-stubs/contrib/gis/geos/prototypes/geom.pyi +++ b/django-stubs/contrib/gis/geos/prototypes/geom.pyi @@ -8,18 +8,18 @@ c_uchar_p: Any class geos_char_p(c_char_p): ... class GeomOutput(GEOSFuncFactory): - restype: Any = ... - errcheck: Any = ... + restype: Any + errcheck: Any class IntFromGeom(GEOSFuncFactory): - argtypes: Any = ... - restype: Any = ... - errcheck: Any = ... + argtypes: Any + restype: Any + errcheck: Any class StringFromGeom(GEOSFuncFactory): - argtypes: Any = ... - restype: Any = ... - errcheck: Any = ... + argtypes: Any + restype: Any + errcheck: Any geos_normalize: Any geos_type: Any diff --git a/django-stubs/contrib/gis/geos/prototypes/io.pyi b/django-stubs/contrib/gis/geos/prototypes/io.pyi index 5fc105fbf..12c1b9531 100644 --- a/django-stubs/contrib/gis/geos/prototypes/io.pyi +++ b/django-stubs/contrib/gis/geos/prototypes/io.pyi @@ -28,9 +28,9 @@ wkb_reader_create: Any wkb_reader_destroy: Any class WKBReadFunc(GEOSFuncFactory): - argtypes: Any = ... - restype: Any = ... - errcheck: Any = ... + argtypes: Any + restype: Any + errcheck: Any wkb_reader_read: Any wkb_reader_read_hex: Any @@ -38,19 +38,19 @@ wkb_writer_create: Any wkb_writer_destroy: Any class WKBWriteFunc(GEOSFuncFactory): - argtypes: Any = ... - restype: Any = ... - errcheck: Any = ... + argtypes: Any + restype: Any + errcheck: Any wkb_writer_write: Any wkb_writer_write_hex: Any class WKBWriterGet(GEOSFuncFactory): - argtypes: Any = ... - restype: Any = ... + argtypes: Any + restype: Any class WKBWriterSet(GEOSFuncFactory): - argtypes: Any = ... + argtypes: Any wkb_writer_get_byteorder: Any wkb_writer_set_byteorder: Any @@ -60,22 +60,22 @@ wkb_writer_get_include_srid: Any wkb_writer_set_include_srid: Any class IOBase(GEOSBase): - ptr: Any = ... + ptr: Any def __init__(self) -> None: ... class _WKTReader(IOBase): - ptr_type: Any = ... - destructor: Any = ... + ptr_type: Any + destructor: Any def read(self, wkt: Any) -> Any: ... class _WKBReader(IOBase): - ptr_type: Any = ... - destructor: Any = ... + ptr_type: Any + destructor: Any def read(self, wkb: Any) -> Any: ... class WKTWriter(IOBase): - ptr_type: Any = ... - destructor: Any = ... + ptr_type: Any + destructor: Any def __init__(self, dim: int = ..., trim: bool = ..., precision: Any | None = ...) -> None: ... def write(self, geom: Any) -> Any: ... @property @@ -92,13 +92,13 @@ class WKTWriter(IOBase): def precision(self, precision: Any) -> None: ... class WKBWriter(IOBase): - ptr_type: Any = ... - destructor: Any = ... - geos_version: Any = ... + ptr_type: Any + destructor: Any + geos_version: Any def __init__(self, dim: int = ...) -> None: ... def write(self, geom: Any) -> Any: ... def write_hex(self, geom: Any) -> Any: ... - byteorder: Any = ... + byteorder: Any @property def outdim(self) -> Any: ... @outdim.setter @@ -109,11 +109,11 @@ class WKBWriter(IOBase): def srid(self, include: Any) -> None: ... class ThreadLocalIO(threading.local): - wkt_r: Any = ... - wkt_w: Any = ... - wkb_r: Any = ... - wkb_w: Any = ... - ewkb_w: Any = ... + wkt_r: Any + wkt_w: Any + wkb_r: Any + wkb_w: Any + ewkb_w: Any thread_context: Any diff --git a/django-stubs/contrib/gis/geos/prototypes/misc.pyi b/django-stubs/contrib/gis/geos/prototypes/misc.pyi index 64feec2f5..30c97c461 100644 --- a/django-stubs/contrib/gis/geos/prototypes/misc.pyi +++ b/django-stubs/contrib/gis/geos/prototypes/misc.pyi @@ -3,8 +3,8 @@ from typing import Any from django.contrib.gis.geos.libgeos import GEOSFuncFactory class DblFromGeom(GEOSFuncFactory): - restype: Any = ... - errcheck: Any = ... + restype: Any + errcheck: Any geos_area: Any geos_distance: Any diff --git a/django-stubs/contrib/gis/geos/prototypes/predicates.pyi b/django-stubs/contrib/gis/geos/prototypes/predicates.pyi index 494f93ba7..c912e6fb4 100644 --- a/django-stubs/contrib/gis/geos/prototypes/predicates.pyi +++ b/django-stubs/contrib/gis/geos/prototypes/predicates.pyi @@ -3,12 +3,12 @@ from typing import Any from django.contrib.gis.geos.libgeos import GEOSFuncFactory as GEOSFuncFactory class UnaryPredicate(GEOSFuncFactory): - argtypes: Any = ... - restype: Any = ... - errcheck: Any = ... + argtypes: Any + restype: Any + errcheck: Any class BinaryPredicate(UnaryPredicate): - argtypes: Any = ... + argtypes: Any geos_hasz: Any geos_isclosed: Any diff --git a/django-stubs/contrib/gis/geos/prototypes/prepared.pyi b/django-stubs/contrib/gis/geos/prototypes/prepared.pyi index 413f8daaf..3b2bb2380 100644 --- a/django-stubs/contrib/gis/geos/prototypes/prepared.pyi +++ b/django-stubs/contrib/gis/geos/prototypes/prepared.pyi @@ -6,9 +6,9 @@ geos_prepare: Any prepared_destroy: Any class PreparedPredicate(GEOSFuncFactory): - argtypes: Any = ... - restype: Any = ... - errcheck: Any = ... + argtypes: Any + restype: Any + errcheck: Any prepared_contains: Any prepared_contains_properly: Any diff --git a/django-stubs/contrib/gis/geos/prototypes/threadsafe.pyi b/django-stubs/contrib/gis/geos/prototypes/threadsafe.pyi index f916b0cbc..281c9f902 100644 --- a/django-stubs/contrib/gis/geos/prototypes/threadsafe.pyi +++ b/django-stubs/contrib/gis/geos/prototypes/threadsafe.pyi @@ -4,21 +4,21 @@ from typing import Any from django.contrib.gis.geos.base import GEOSBase as GEOSBase class GEOSContextHandle(GEOSBase): - ptr_type: Any = ... - destructor: Any = ... - ptr: Any = ... + ptr_type: Any + destructor: Any + ptr: Any def __init__(self) -> None: ... class GEOSContext(threading.local): - handle: Any = ... + handle: Any thread_context: Any class GEOSFunc: - cfunc: Any = ... - thread_context: Any = ... + cfunc: Any + thread_context: Any def __init__(self, func_name: Any) -> None: ... def __call__(self, *args: Any) -> Any: ... - argtypes: Any = ... - restype: Any = ... - errcheck: Any = ... + argtypes: Any + restype: Any + errcheck: Any diff --git a/django-stubs/contrib/gis/geos/prototypes/topology.pyi b/django-stubs/contrib/gis/geos/prototypes/topology.pyi index 9b3c005c0..ba4d27787 100644 --- a/django-stubs/contrib/gis/geos/prototypes/topology.pyi +++ b/django-stubs/contrib/gis/geos/prototypes/topology.pyi @@ -3,9 +3,9 @@ from typing import Any from django.contrib.gis.geos.libgeos import GEOSFuncFactory as GEOSFuncFactory class Topology(GEOSFuncFactory): - argtypes: Any = ... - restype: Any = ... - errcheck: Any = ... + argtypes: Any + restype: Any + errcheck: Any geos_boundary: Any geos_buffer: Any diff --git a/django-stubs/contrib/gis/measure.pyi b/django-stubs/contrib/gis/measure.pyi index e5b2bf202..2db984648 100644 --- a/django-stubs/contrib/gis/measure.pyi +++ b/django-stubs/contrib/gis/measure.pyi @@ -1,12 +1,12 @@ from typing import Any class MeasureBase: - STANDARD_UNIT: Any = ... - ALIAS: Any = ... - UNITS: Any = ... - LALIAS: Any = ... + STANDARD_UNIT: Any + ALIAS: Any + UNITS: Any + LALIAS: Any def __init__(self, default_unit: Any | None = ..., **kwargs: Any) -> None: ... - standard: Any = ... + standard: Any def __getattr__(self, name: Any) -> Any: ... def __eq__(self, other: Any) -> bool: ... def __lt__(self, other: Any) -> Any: ... @@ -25,17 +25,17 @@ class MeasureBase: def unit_attname(cls, unit_str: Any) -> Any: ... class Distance(MeasureBase): - STANDARD_UNIT: str = ... - UNITS: Any = ... - ALIAS: Any = ... - LALIAS: Any = ... + STANDARD_UNIT: str + UNITS: Any + ALIAS: Any + LALIAS: Any def __mul__(self, other: Any) -> Any: ... class Area(MeasureBase): - STANDARD_UNIT: Any = ... - UNITS: Any = ... - ALIAS: Any = ... - LALIAS: Any = ... + STANDARD_UNIT: Any + UNITS: Any + ALIAS: Any + LALIAS: Any def __truediv__(self, other: Any) -> Any: ... D = Distance diff --git a/django-stubs/contrib/gis/ptr.pyi b/django-stubs/contrib/gis/ptr.pyi index 10de23b5f..93d740b42 100644 --- a/django-stubs/contrib/gis/ptr.pyi +++ b/django-stubs/contrib/gis/ptr.pyi @@ -1,9 +1,9 @@ from typing import Any class CPointerBase: - ptr_type: Any = ... - destructor: Any = ... - null_ptr_exception_class: Any = ... + ptr_type: Any + destructor: Any + null_ptr_exception_class: Any @property def ptr(self) -> Any: ... @ptr.setter diff --git a/django-stubs/contrib/gis/serializers/geojson.pyi b/django-stubs/contrib/gis/serializers/geojson.pyi index 936ae7a03..757bc606d 100644 --- a/django-stubs/contrib/gis/serializers/geojson.pyi +++ b/django-stubs/contrib/gis/serializers/geojson.pyi @@ -5,7 +5,7 @@ from django.core.serializers.json import Serializer as JSONSerializer class Serializer(JSONSerializer): def start_serialization(self) -> None: ... def end_serialization(self) -> None: ... - geometry_field: Any = ... + geometry_field: Any def start_object(self, obj: Any) -> None: ... def get_dump_object(self, obj: Any) -> Any: ... def handle_field(self, obj: Any, field: Any) -> None: ... diff --git a/django-stubs/contrib/gis/sitemaps/kml.pyi b/django-stubs/contrib/gis/sitemaps/kml.pyi index f2ece2388..3b65b9262 100644 --- a/django-stubs/contrib/gis/sitemaps/kml.pyi +++ b/django-stubs/contrib/gis/sitemaps/kml.pyi @@ -3,11 +3,11 @@ from typing import Any from django.contrib.sitemaps import Sitemap as Sitemap class KMLSitemap(Sitemap): - geo_format: str = ... - locations: Any = ... + geo_format: str + locations: Any def __init__(self, locations: Any | None = ...) -> None: ... def items(self) -> Any: ... def location(self, obj: Any) -> Any: ... class KMZSitemap(KMLSitemap): - geo_format: str = ... + geo_format: str diff --git a/django-stubs/contrib/gis/utils/layermapping.pyi b/django-stubs/contrib/gis/utils/layermapping.pyi index 7fad74512..032883824 100644 --- a/django-stubs/contrib/gis/utils/layermapping.pyi +++ b/django-stubs/contrib/gis/utils/layermapping.pyi @@ -7,21 +7,21 @@ class InvalidInteger(LayerMapError): ... class MissingForeignKey(LayerMapError): ... class LayerMapping: - MULTI_TYPES: Any = ... - FIELD_TYPES: Any = ... - ds: Any = ... - layer: Any = ... - using: Any = ... - spatial_backend: Any = ... - mapping: Any = ... - model: Any = ... - geo_field: Any = ... - source_srs: Any = ... - transform: Any = ... - encoding: Any = ... - unique: Any = ... - transaction_mode: Any = ... - transaction_decorator: Any = ... + MULTI_TYPES: Any + FIELD_TYPES: Any + ds: Any + layer: Any + using: Any + spatial_backend: Any + mapping: Any + model: Any + geo_field: Any + source_srs: Any + transform: Any + encoding: Any + unique: Any + transaction_mode: Any + transaction_decorator: Any def __init__( self, model: Any, @@ -36,9 +36,9 @@ class LayerMapping: using: Any | None = ..., ) -> None: ... def check_fid_range(self, fid_range: Any) -> Any: ... - geom_field: str = ... - fields: Any = ... - coord_dim: Any = ... + geom_field: str + fields: Any + coord_dim: Any def check_layer(self) -> Any: ... def check_srs(self, source_srs: Any) -> Any: ... def check_unique(self, unique: Any) -> None: ... diff --git a/django-stubs/contrib/humanize/apps.pyi b/django-stubs/contrib/humanize/apps.pyi index ccc481bd9..caf829d7f 100644 --- a/django-stubs/contrib/humanize/apps.pyi +++ b/django-stubs/contrib/humanize/apps.pyi @@ -3,5 +3,5 @@ from typing import Any from django.apps import AppConfig as AppConfig class HumanizeConfig(AppConfig): - name: str = ... - verbose_name: Any = ... + name: str + verbose_name: Any diff --git a/django-stubs/contrib/messages/__init__.pyi b/django-stubs/contrib/messages/__init__.pyi index e45e467ec..dad44759f 100644 --- a/django-stubs/contrib/messages/__init__.pyi +++ b/django-stubs/contrib/messages/__init__.pyi @@ -16,4 +16,4 @@ from .constants import INFO as INFO from .constants import SUCCESS as SUCCESS from .constants import WARNING as WARNING -default_app_config: str = ... +default_app_config: str diff --git a/django-stubs/contrib/messages/apps.pyi b/django-stubs/contrib/messages/apps.pyi index 38cafb25c..221c05510 100644 --- a/django-stubs/contrib/messages/apps.pyi +++ b/django-stubs/contrib/messages/apps.pyi @@ -3,5 +3,5 @@ from typing import Any from django.apps import AppConfig as AppConfig class MessagesConfig(AppConfig): - name: str = ... - verbose_name: Any = ... + name: str + verbose_name: Any diff --git a/django-stubs/contrib/messages/constants.pyi b/django-stubs/contrib/messages/constants.pyi index c0246de5a..6b1eaa8c3 100644 --- a/django-stubs/contrib/messages/constants.pyi +++ b/django-stubs/contrib/messages/constants.pyi @@ -1,11 +1,11 @@ from typing import Dict -DEBUG: int = ... -INFO: int = ... -SUCCESS: int = ... -WARNING: int = ... -ERROR: int = ... +DEBUG: int +INFO: int +SUCCESS: int +WARNING: int +ERROR: int -DEFAULT_TAGS: Dict[int, str] = ... +DEFAULT_TAGS: Dict[int, str] -DEFAULT_LEVELS: Dict[str, int] = ... +DEFAULT_LEVELS: Dict[str, int] diff --git a/django-stubs/contrib/messages/storage/base.pyi b/django-stubs/contrib/messages/storage/base.pyi index 9ffad6065..9f1ebbe3a 100644 --- a/django-stubs/contrib/messages/storage/base.pyi +++ b/django-stubs/contrib/messages/storage/base.pyi @@ -6,9 +6,9 @@ from django.http.response import HttpResponseBase LEVEL_TAGS: Any class Message: - level: int = ... - message: str = ... - extra_tags: str = ... + level: int + message: str + extra_tags: str def __init__(self, level: int, message: str, extra_tags: str | None = ...) -> None: ... @property def tags(self) -> str: ... @@ -16,13 +16,13 @@ class Message: def level_tag(self) -> str: ... class BaseStorage: - request: HttpRequest = ... - used: bool = ... - added_new: bool = ... + request: HttpRequest + used: bool + added_new: bool def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[Message]: ... def __contains__(self, item: Any) -> bool: ... def update(self, response: HttpResponseBase) -> List[Message] | None: ... def add(self, level: int, message: str, extra_tags: str | None = ...) -> None: ... - level: Any = ... + level: Any diff --git a/django-stubs/contrib/messages/storage/cookie.pyi b/django-stubs/contrib/messages/storage/cookie.pyi index 8f267389f..39f4fe2cb 100644 --- a/django-stubs/contrib/messages/storage/cookie.pyi +++ b/django-stubs/contrib/messages/storage/cookie.pyi @@ -9,12 +9,12 @@ class MessageEncoder(json.JSONEncoder): ensure_ascii: bool skipkeys: bool sort_keys: bool - message_key: str = ... + message_key: str class MessageDecoder(json.JSONDecoder): def process_messages(self, obj: Any) -> Any: ... class CookieStorage(BaseStorage): - cookie_name: str = ... - max_cookie_size: int = ... - not_finished: str = ... + cookie_name: str + max_cookie_size: int + not_finished: str diff --git a/django-stubs/contrib/messages/storage/fallback.pyi b/django-stubs/contrib/messages/storage/fallback.pyi index b6e0d49b9..cfea1f37e 100644 --- a/django-stubs/contrib/messages/storage/fallback.pyi +++ b/django-stubs/contrib/messages/storage/fallback.pyi @@ -3,6 +3,6 @@ from typing import Any from django.contrib.messages.storage.base import BaseStorage class FallbackStorage(BaseStorage): - storage_classes: Any = ... - storages: Any = ... + storage_classes: Any + storages: Any def __init__(self, *args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/contrib/messages/storage/session.pyi b/django-stubs/contrib/messages/storage/session.pyi index 5f0179fe8..d14ee1fd0 100644 --- a/django-stubs/contrib/messages/storage/session.pyi +++ b/django-stubs/contrib/messages/storage/session.pyi @@ -4,7 +4,7 @@ from django.contrib.messages.storage.base import BaseStorage from django.http.request import HttpRequest class SessionStorage(BaseStorage): - session_key: str = ... + session_key: str def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ... def serialize_messages(self, messages: Sequence[Any]) -> str: ... def deserialize_messages(self, data: List[Any] | str | None) -> List[Any] | None: ... diff --git a/django-stubs/contrib/messages/views.pyi b/django-stubs/contrib/messages/views.pyi index c22c640bc..56458dcbe 100644 --- a/django-stubs/contrib/messages/views.pyi +++ b/django-stubs/contrib/messages/views.pyi @@ -5,6 +5,6 @@ from django.http.response import HttpResponse from django.utils.functional import _StrOrPromise class SuccessMessageMixin: - success_message: _StrOrPromise = ... + success_message: _StrOrPromise def form_valid(self, form: BaseForm) -> HttpResponse: ... def get_success_message(self, cleaned_data: Dict[str, str]) -> _StrOrPromise: ... diff --git a/django-stubs/contrib/postgres/apps.pyi b/django-stubs/contrib/postgres/apps.pyi index 11a06a9a3..d01d21187 100644 --- a/django-stubs/contrib/postgres/apps.pyi +++ b/django-stubs/contrib/postgres/apps.pyi @@ -7,6 +7,6 @@ RANGE_TYPES: Any def uninstall_if_needed(setting: Any, value: Any, enter: Any, **kwargs: Any) -> None: ... class PostgresConfig(AppConfig): - name: str = ... - verbose_name: Any = ... + name: str + verbose_name: Any def ready(self) -> None: ... diff --git a/django-stubs/contrib/postgres/fields/array.pyi b/django-stubs/contrib/postgres/fields/array.pyi index 06d64d9f2..0d78cc51d 100644 --- a/django-stubs/contrib/postgres/fields/array.pyi +++ b/django-stubs/contrib/postgres/fields/array.pyi @@ -16,12 +16,12 @@ class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]): _pyi_private_set_type: Sequence[Any] | Combinable _pyi_private_get_type: List[Any] - empty_strings_allowed: bool = ... - default_error_messages: _ErrorMessagesT = ... - base_field: Field = ... - size: int | None = ... - default_validators: Sequence[_ValidatorCallable] = ... - from_db_value: Any = ... + empty_strings_allowed: bool + default_error_messages: _ErrorMessagesT + base_field: Field + size: int | None + default_validators: Sequence[_ValidatorCallable] + from_db_value: Any def __init__( self, base_field: Field, diff --git a/django-stubs/contrib/postgres/fields/ranges.pyi b/django-stubs/contrib/postgres/fields/ranges.pyi index 86d0e6890..4ee89a363 100644 --- a/django-stubs/contrib/postgres/fields/ranges.pyi +++ b/django-stubs/contrib/postgres/fields/ranges.pyi @@ -23,9 +23,9 @@ class RangeOperators: ADJACENT_TO: Literal["-|-"] class RangeField(models.Field): - empty_strings_allowed: bool = ... - base_field: models.Field = ... - range_type: Type[Range] = ... + empty_strings_allowed: bool + base_field: models.Field + range_type: Type[Range] def get_prep_value(self, value: Any) -> Any | None: ... def to_python(self, value: Any) -> Any: ... @@ -45,67 +45,67 @@ class DateRangeField(RangeField): def __get__(self, instance: Any, owner: Any) -> DateRange: ... class DateTimeRangeContains(PostgresOperatorLookup): - lookup_name: str = ... - postgres_operator: str = ... + lookup_name: str + postgres_operator: str class RangeContainedBy(PostgresOperatorLookup): - lookup_name: str = ... - type_mapping: Dict[str, str] = ... - postgres_operator: str = ... + lookup_name: str + type_mapping: Dict[str, str] + postgres_operator: str class FullyLessThan(PostgresOperatorLookup): - lookup_name: str = ... - postgres_operator: str = ... + lookup_name: str + postgres_operator: str class FullGreaterThan(PostgresOperatorLookup): - lookup_name: str = ... - postgres_operator: str = ... + lookup_name: str + postgres_operator: str class NotLessThan(PostgresOperatorLookup): - lookup_name: str = ... - postgres_operator: str = ... + lookup_name: str + postgres_operator: str class NotGreaterThan(PostgresOperatorLookup): - lookup_name: str = ... - postgres_operator: str = ... + lookup_name: str + postgres_operator: str class AdjacentToLookup(PostgresOperatorLookup): - lookup_name: str = ... - postgres_operator: str = ... + lookup_name: str + postgres_operator: str class RangeStartsWith(models.Transform): - lookup_name: str = ... - function: str = ... + lookup_name: str + function: str @property def output_field(self) -> models.Field: ... class RangeEndsWith(models.Transform): - lookup_name: str = ... - function: str = ... + lookup_name: str + function: str @property def output_field(self) -> models.Field: ... class IsEmpty(models.Transform): - lookup_name: str = ... - function: str = ... - output_field: models.BooleanField = ... + lookup_name: str + function: str + output_field: models.BooleanField class LowerInclusive(models.Transform): - lookup_name: str = ... - function: str = ... - output_field: models.BooleanField = ... + lookup_name: str + function: str + output_field: models.BooleanField class LowerInfinite(models.Transform): - lookup_name: str = ... - function: str = ... - output_field: models.BooleanField = ... + lookup_name: str + function: str + output_field: models.BooleanField class UpperInclusive(models.Transform): - lookup_name: str = ... - function: str = ... - output_field: models.BooleanField = ... + lookup_name: str + function: str + output_field: models.BooleanField class UpperInfinite(models.Transform): - lookup_name: str = ... - function: str = ... - output_field: models.BooleanField = ... + lookup_name: str + function: str + output_field: models.BooleanField diff --git a/django-stubs/contrib/postgres/forms/array.pyi b/django-stubs/contrib/postgres/forms/array.pyi index 7a2122aaa..031953dfa 100644 --- a/django-stubs/contrib/postgres/forms/array.pyi +++ b/django-stubs/contrib/postgres/forms/array.pyi @@ -12,7 +12,7 @@ from django.forms.widgets import Media, _OptAttrs from ..utils import prefix_validation_error as prefix_validation_error class SimpleArrayField(forms.CharField): - default_error_messages: _ErrorMessagesT = ... + default_error_messages: _ErrorMessagesT base_field: forms.Field delimiter: str min_length: int | None @@ -50,7 +50,7 @@ class SplitArrayWidget(forms.Widget): def needs_multipart_form(self) -> bool: ... # type: ignore class SplitArrayField(forms.Field): - default_error_messages: _ErrorMessagesT = ... + default_error_messages: _ErrorMessagesT base_field: forms.Field size: int remove_trailing_nulls: bool diff --git a/django-stubs/contrib/postgres/forms/hstore.pyi b/django-stubs/contrib/postgres/forms/hstore.pyi index 5041186dc..4778560ef 100644 --- a/django-stubs/contrib/postgres/forms/hstore.pyi +++ b/django-stubs/contrib/postgres/forms/hstore.pyi @@ -6,7 +6,7 @@ from django.forms.fields import _ClassLevelWidgetT class HStoreField(forms.CharField): widget: _ClassLevelWidgetT - default_error_messages: _ErrorMessagesT = ... + default_error_messages: _ErrorMessagesT def prepare_value(self, value: Any) -> Any: ... def to_python(self, value: Any) -> Dict[str, str | None]: ... # type: ignore def has_changed(self, initial: Any, data: Any) -> bool: ... diff --git a/django-stubs/contrib/postgres/operations.pyi b/django-stubs/contrib/postgres/operations.pyi index 11e5261cd..c6c658509 100644 --- a/django-stubs/contrib/postgres/operations.pyi +++ b/django-stubs/contrib/postgres/operations.pyi @@ -4,8 +4,8 @@ from django.db.migrations.operations.base import Operation from typing_extensions import Literal class CreateExtension(Operation): - reversible: bool = ... - name: str = ... + reversible: bool + name: str def __init__(self, name: str) -> None: ... def extension_exists(self, schema_editor: BaseDatabaseSchemaEditor, extension: str) -> bool: ... @@ -37,10 +37,10 @@ class NotInTransactionMixin: def _ensure_not_in_transaction(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ... class AddIndexConcurrently(NotInTransactionMixin, AddIndex): - atomic: Literal[False] = ... + atomic: Literal[False] class RemoveIndexConcurrently(NotInTransactionMixin, RemoveIndex): - atomic: Literal[False] = ... + atomic: Literal[False] class CollationOperation(Operation): name: str diff --git a/django-stubs/contrib/postgres/search.pyi b/django-stubs/contrib/postgres/search.pyi index 47ba6e5bc..f3721de09 100644 --- a/django-stubs/contrib/postgres/search.pyi +++ b/django-stubs/contrib/postgres/search.pyi @@ -11,18 +11,18 @@ class SearchVectorField(Field): ... class SearchQueryField(Field): ... class SearchConfig(Expression): - config: _Expression | None = ... + config: _Expression | None def __init__(self, config: _Expression) -> None: ... @classmethod def from_parameter(cls, config: _Expression | None) -> SearchConfig: ... class SearchVectorCombinable: - ADD: str = ... + ADD: str class SearchVector(SearchVectorCombinable, Func): - config: _Expression | None = ... - function: str = ... - arg_joiner: str = ... + config: _Expression | None + function: str + arg_joiner: str output_field: Field def __init__( self, *expressions: _Expression, config: _Expression | None = ..., weight: Any | None = ... @@ -41,15 +41,15 @@ class CombinedSearchVector(SearchVectorCombinable, CombinedExpression): _T = TypeVar("_T", bound="SearchQueryCombinable") class SearchQueryCombinable: - BITAND: str = ... - BITOR: str = ... + BITAND: str + BITOR: str def __or__(self: _T, other: SearchQueryCombinable) -> _T: ... def __ror__(self: _T, other: SearchQueryCombinable) -> _T: ... def __and__(self: _T, other: SearchQueryCombinable) -> _T: ... def __rand__(self: _T, other: SearchQueryCombinable) -> _T: ... class SearchQuery(SearchQueryCombinable, Func): # type: ignore - SEARCH_TYPES: Dict[str, str] = ... + SEARCH_TYPES: Dict[str, str] def __init__( self, value: _Expression, @@ -82,9 +82,9 @@ class SearchRank(Func): ) -> None: ... class SearchHeadline(Func): - function: str = ... - template: str = ... - output_field: Field = ... + function: str + template: str + output_field: Field def __init__( self, expression: _Expression, diff --git a/django-stubs/contrib/postgres/validators.pyi b/django-stubs/contrib/postgres/validators.pyi index 24c2b0fe6..b7b42badb 100644 --- a/django-stubs/contrib/postgres/validators.pyi +++ b/django-stubs/contrib/postgres/validators.pyi @@ -6,8 +6,8 @@ class ArrayMaxLengthValidator(MaxLengthValidator): ... class ArrayMinLengthValidator(MinLengthValidator): ... class KeysValidator: - messages: Dict[str, str] = ... - strict: bool = ... + messages: Dict[str, str] + strict: bool def __init__(self, keys: Iterable[str], strict: bool = ..., messages: Mapping[str, str] | None = ...) -> None: ... def __call__(self, value: Any) -> None: ... diff --git a/django-stubs/contrib/redirects/admin.pyi b/django-stubs/contrib/redirects/admin.pyi index e4dbdbd2b..295fb8786 100644 --- a/django-stubs/contrib/redirects/admin.pyi +++ b/django-stubs/contrib/redirects/admin.pyi @@ -3,7 +3,7 @@ from typing import Any from django.contrib import admin class RedirectAdmin(admin.ModelAdmin): - list_display: Any = ... - list_filter: Any = ... - search_fields: Any = ... - radio_fields: Any = ... + list_display: Any + list_filter: Any + search_fields: Any + radio_fields: Any diff --git a/django-stubs/contrib/redirects/apps.pyi b/django-stubs/contrib/redirects/apps.pyi index bb3a68dc5..59f130060 100644 --- a/django-stubs/contrib/redirects/apps.pyi +++ b/django-stubs/contrib/redirects/apps.pyi @@ -3,5 +3,5 @@ from typing import Any from django.apps import AppConfig as AppConfig class RedirectsConfig(AppConfig): - name: str = ... - verbose_name: Any = ... + name: str + verbose_name: Any diff --git a/django-stubs/contrib/redirects/middleware.pyi b/django-stubs/contrib/redirects/middleware.pyi index 10b830470..69d99de02 100644 --- a/django-stubs/contrib/redirects/middleware.pyi +++ b/django-stubs/contrib/redirects/middleware.pyi @@ -5,6 +5,6 @@ from django.http.response import HttpResponse from django.utils.deprecation import MiddlewareMixin class RedirectFallbackMiddleware(MiddlewareMixin): - response_gone_class: Any = ... - response_redirect_class: Any = ... + response_gone_class: Any + response_redirect_class: Any def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ... diff --git a/django-stubs/contrib/redirects/models.pyi b/django-stubs/contrib/redirects/models.pyi index b732632d9..444960881 100644 --- a/django-stubs/contrib/redirects/models.pyi +++ b/django-stubs/contrib/redirects/models.pyi @@ -1,6 +1,6 @@ from django.db import models class Redirect(models.Model): - site: models.ForeignKey = ... - old_path: models.CharField = ... - new_path: models.CharField = ... + site: models.ForeignKey + old_path: models.CharField + new_path: models.CharField diff --git a/django-stubs/contrib/sessions/apps.pyi b/django-stubs/contrib/sessions/apps.pyi index c65086ac0..bd173b2e7 100644 --- a/django-stubs/contrib/sessions/apps.pyi +++ b/django-stubs/contrib/sessions/apps.pyi @@ -3,5 +3,5 @@ from typing import Any from django.apps import AppConfig as AppConfig class SessionsConfig(AppConfig): - name: str = ... - verbose_name: Any = ... + name: str + verbose_name: Any diff --git a/django-stubs/contrib/sessions/backends/base.pyi b/django-stubs/contrib/sessions/backends/base.pyi index ad711da13..049d08b27 100644 --- a/django-stubs/contrib/sessions/backends/base.pyi +++ b/django-stubs/contrib/sessions/backends/base.pyi @@ -7,11 +7,11 @@ class CreateError(Exception): ... class UpdateError(Exception): ... class SessionBase(Dict[str, Any]): - TEST_COOKIE_NAME: str = ... - TEST_COOKIE_VALUE: str = ... - accessed: bool = ... - modified: bool = ... - serializer: Any = ... + TEST_COOKIE_NAME: str + TEST_COOKIE_VALUE: str + accessed: bool + modified: bool + serializer: Any def __init__(self, session_key: str | None = ...) -> None: ... def set_test_cookie(self) -> None: ... def test_cookie_worked(self) -> bool: ... diff --git a/django-stubs/contrib/sessions/backends/cache.pyi b/django-stubs/contrib/sessions/backends/cache.pyi index 59d440f05..9fcdf4d36 100644 --- a/django-stubs/contrib/sessions/backends/cache.pyi +++ b/django-stubs/contrib/sessions/backends/cache.pyi @@ -5,7 +5,7 @@ from django.contrib.sessions.backends.base import SessionBase KEY_PREFIX: str class SessionStore(SessionBase): - cache_key_prefix: Any = ... + cache_key_prefix: Any def __init__(self, session_key: str | None = ...) -> None: ... @property def cache_key(self) -> str: ... diff --git a/django-stubs/contrib/sessions/backends/cached_db.pyi b/django-stubs/contrib/sessions/backends/cached_db.pyi index 9b48dc1fd..11995d0e8 100644 --- a/django-stubs/contrib/sessions/backends/cached_db.pyi +++ b/django-stubs/contrib/sessions/backends/cached_db.pyi @@ -5,7 +5,7 @@ from django.contrib.sessions.backends.db import SessionStore as DBStore KEY_PREFIX: str class SessionStore(DBStore): - cache_key_prefix: Any = ... + cache_key_prefix: Any def __init__(self, session_key: str | None = ...) -> None: ... @property def cache_key(self) -> str: ... diff --git a/django-stubs/contrib/sessions/backends/file.pyi b/django-stubs/contrib/sessions/backends/file.pyi index 84af0d3ec..6e72a95bf 100644 --- a/django-stubs/contrib/sessions/backends/file.pyi +++ b/django-stubs/contrib/sessions/backends/file.pyi @@ -1,7 +1,7 @@ from django.contrib.sessions.backends.base import SessionBase class SessionStore(SessionBase): - storage_path: str = ... - file_prefix: str = ... + storage_path: str + file_prefix: str def __init__(self, session_key: str | None = ...) -> None: ... def clean(self) -> None: ... diff --git a/django-stubs/contrib/sessions/base_session.pyi b/django-stubs/contrib/sessions/base_session.pyi index aedebe638..d26133853 100644 --- a/django-stubs/contrib/sessions/base_session.pyi +++ b/django-stubs/contrib/sessions/base_session.pyi @@ -14,7 +14,7 @@ class AbstractBaseSession(models.Model): expire_date: datetime session_data: str session_key: str - objects: Any = ... + objects: Any @classmethod def get_session_store_class(cls) -> Type[SessionBase] | None: ... def get_decoded(self) -> Dict[str, Any]: ... diff --git a/django-stubs/contrib/sessions/middleware.pyi b/django-stubs/contrib/sessions/middleware.pyi index 0e29b8d22..864e51dfd 100644 --- a/django-stubs/contrib/sessions/middleware.pyi +++ b/django-stubs/contrib/sessions/middleware.pyi @@ -6,6 +6,6 @@ from django.http.response import HttpResponse from django.utils.deprecation import MiddlewareMixin class SessionMiddleware(MiddlewareMixin): - SessionStore: Type[SessionBase] = ... + SessionStore: Type[SessionBase] def process_request(self, request: HttpRequest) -> None: ... def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ... diff --git a/django-stubs/contrib/sitemaps/__init__.pyi b/django-stubs/contrib/sitemaps/__init__.pyi index eb2e5ba2b..5118a95f1 100644 --- a/django-stubs/contrib/sitemaps/__init__.pyi +++ b/django-stubs/contrib/sitemaps/__init__.pyi @@ -16,12 +16,12 @@ def ping_google(sitemap_url: str | None = ..., ping_url: str = ..., sitemap_uses _ItemT = TypeVar("_ItemT") class Sitemap(Generic[_ItemT]): - limit: int = ... - protocol: str | None = ... - i18n: bool = ... - languages: Sequence[str] | None = ... - alternates: bool = ... - x_default: bool = ... + limit: int + protocol: str | None + i18n: bool + languages: Sequence[str] | None + alternates: bool + x_default: bool def items(self) -> Iterable[_ItemT]: ... def location(self, item: _ItemT) -> str: ... @property @@ -34,11 +34,11 @@ class Sitemap(Generic[_ItemT]): _ModelT = TypeVar("_ModelT", bound=Model) class GenericSitemap(Sitemap[_ModelT]): - priority: float | None = ... - changefreq: str | None = ... - queryset: QuerySet[_ModelT] = ... - date_field: str | None = ... - protocol: str | None = ... + priority: float | None + changefreq: str | None + queryset: QuerySet[_ModelT] + date_field: str | None + protocol: str | None def __init__( self, info_dict: Mapping[str, datetime | QuerySet[_ModelT] | str], diff --git a/django-stubs/contrib/sitemaps/apps.pyi b/django-stubs/contrib/sitemaps/apps.pyi index 72ab919eb..8821366e0 100644 --- a/django-stubs/contrib/sitemaps/apps.pyi +++ b/django-stubs/contrib/sitemaps/apps.pyi @@ -3,5 +3,5 @@ from typing import Any from django.apps import AppConfig as AppConfig class SiteMapsConfig(AppConfig): - name: str = ... - verbose_name: Any = ... + name: str + verbose_name: Any diff --git a/django-stubs/contrib/sites/admin.pyi b/django-stubs/contrib/sites/admin.pyi index 0f8db71ba..5891cce4f 100644 --- a/django-stubs/contrib/sites/admin.pyi +++ b/django-stubs/contrib/sites/admin.pyi @@ -3,5 +3,5 @@ from typing import Any from django.contrib import admin class SiteAdmin(admin.ModelAdmin): - list_display: Any = ... - search_fields: Any = ... + list_display: Any + search_fields: Any diff --git a/django-stubs/contrib/sites/requests.pyi b/django-stubs/contrib/sites/requests.pyi index 6a638b600..d32d2b254 100644 --- a/django-stubs/contrib/sites/requests.pyi +++ b/django-stubs/contrib/sites/requests.pyi @@ -4,7 +4,7 @@ from django.http.request import HttpRequest class RequestSite: name: str - domain: str = ... + domain: str def __init__(self, request: HttpRequest) -> None: ... def save(self, force_insert: bool = ..., force_update: bool = ...) -> Any: ... def delete(self) -> Any: ... diff --git a/django-stubs/contrib/staticfiles/apps.pyi b/django-stubs/contrib/staticfiles/apps.pyi index e2787b848..69fc831fe 100644 --- a/django-stubs/contrib/staticfiles/apps.pyi +++ b/django-stubs/contrib/staticfiles/apps.pyi @@ -3,4 +3,4 @@ from typing import Any from django.apps import AppConfig class StaticFilesConfig(AppConfig): - ignore_patterns: Any = ... + ignore_patterns: Any diff --git a/django-stubs/contrib/staticfiles/finders.pyi b/django-stubs/contrib/staticfiles/finders.pyi index edeedd397..5e9ab5c2f 100644 --- a/django-stubs/contrib/staticfiles/finders.pyi +++ b/django-stubs/contrib/staticfiles/finders.pyi @@ -15,8 +15,8 @@ class BaseFinder: def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... class FileSystemFinder(BaseFinder): - locations: List[Tuple[str, str]] = ... - storages: Dict[str, Any] = ... + locations: List[Tuple[str, str]] + storages: Dict[str, Any] def __init__(self, app_names: Sequence[str] = ..., *args: Any, **kwargs: Any) -> None: ... def find_location(self, root: str, path: str, prefix: str | None = ...) -> str | None: ... @overload @@ -26,10 +26,10 @@ class FileSystemFinder(BaseFinder): def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... class AppDirectoriesFinder(BaseFinder): - storage_class: Type[FileSystemStorage] = ... - source_dir: str = ... - apps: List[str] = ... - storages: Dict[str, FileSystemStorage] = ... + storage_class: Type[FileSystemStorage] + source_dir: str + apps: List[str] + storages: Dict[str, FileSystemStorage] def __init__(self, app_names: Iterable[str] | None = ..., *args: Any, **kwargs: Any) -> None: ... def find_in_app(self, app: str, path: str) -> str | None: ... @overload @@ -39,7 +39,7 @@ class AppDirectoriesFinder(BaseFinder): def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... class BaseStorageFinder(BaseFinder): - storage: Storage = ... + storage: Storage def __init__(self, storage: Storage | None = ..., *args: Any, **kwargs: Any) -> None: ... @overload def find(self, path: str, all: Literal[False] = ...) -> str | None: ... @@ -48,7 +48,7 @@ class BaseStorageFinder(BaseFinder): def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... class DefaultStorageFinder(BaseStorageFinder): - storage: Storage = ... + storage: Storage def __init__(self, *args: Any, **kwargs: Any) -> None: ... @overload diff --git a/django-stubs/contrib/staticfiles/handlers.pyi b/django-stubs/contrib/staticfiles/handlers.pyi index 370098132..519b4efbc 100644 --- a/django-stubs/contrib/staticfiles/handlers.pyi +++ b/django-stubs/contrib/staticfiles/handlers.pyi @@ -8,7 +8,7 @@ from django.http import HttpRequest from django.http.response import FileResponse, HttpResponseBase class StaticFilesHandlerMixin: - handles_files: bool = ... + handles_files: bool application: BaseHandler base_url: ParseResult def load_middleware(self) -> None: ... diff --git a/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi b/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi index aca78077a..d0a4901f5 100644 --- a/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi +++ b/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi @@ -4,21 +4,21 @@ from django.core.files.storage import Storage from django.core.management.base import BaseCommand class Command(BaseCommand): - copied_files: Any = ... - symlinked_files: Any = ... - unmodified_files: Any = ... - post_processed_files: Any = ... - storage: Any = ... + copied_files: Any + symlinked_files: Any + unmodified_files: Any + post_processed_files: Any + storage: Any def __init__(self, *args: Any, **kwargs: Any) -> None: ... @property def local(self) -> bool: ... - interactive: Any = ... - verbosity: Any = ... - symlink: Any = ... - clear: Any = ... - dry_run: Any = ... - ignore_patterns: Any = ... - post_process: Any = ... + interactive: Any + verbosity: Any + symlink: Any + clear: Any + dry_run: Any + ignore_patterns: Any + post_process: Any def set_options(self, **options: Any) -> None: ... def collect(self) -> Dict[str, List[str]]: ... def log(self, msg: str, level: int = ...) -> None: ... diff --git a/django-stubs/contrib/staticfiles/storage.pyi b/django-stubs/contrib/staticfiles/storage.pyi index 67c438f3b..b12fff8e8 100644 --- a/django-stubs/contrib/staticfiles/storage.pyi +++ b/django-stubs/contrib/staticfiles/storage.pyi @@ -16,11 +16,11 @@ class StaticFilesStorage(FileSystemStorage): def path(self, name: _PathCompatible) -> str: ... class HashedFilesMixin: - default_template: str = ... - max_post_process_passes: int = ... - patterns: Any = ... - hashed_files: Any = ... - keep_intermediate_files: bool = ... + default_template: str + max_post_process_passes: int + patterns: Any + 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 hashed_name(self, name: str, content: File | None = ..., filename: str | None = ...) -> str: ... @@ -32,10 +32,10 @@ class HashedFilesMixin: def stored_name(self, name: str) -> str: ... class ManifestFilesMixin(HashedFilesMixin): - manifest_version: str = ... - manifest_name: str = ... - manifest_strict: bool = ... - keep_intermediate_files: bool = ... + manifest_version: str + manifest_name: str + manifest_strict: bool + keep_intermediate_files: bool def __init__(self, *args: Any, **kwargs: Any) -> None: ... def read_manifest(self) -> str: ... def load_manifest(self) -> Dict[str, Any]: ... diff --git a/django-stubs/contrib/staticfiles/urls.pyi b/django-stubs/contrib/staticfiles/urls.pyi index cb5a2415f..c8344e9ec 100644 --- a/django-stubs/contrib/staticfiles/urls.pyi +++ b/django-stubs/contrib/staticfiles/urls.pyi @@ -2,6 +2,6 @@ from typing import List from django.urls import URLPattern, _AnyURL -urlpatterns: List[_AnyURL] = ... +urlpatterns: List[_AnyURL] def staticfiles_urlpatterns(prefix: str | None = ...) -> List[URLPattern]: ... diff --git a/django-stubs/contrib/syndication/apps.pyi b/django-stubs/contrib/syndication/apps.pyi index 029571178..cb727bd92 100644 --- a/django-stubs/contrib/syndication/apps.pyi +++ b/django-stubs/contrib/syndication/apps.pyi @@ -3,5 +3,5 @@ from typing import Any from django.apps import AppConfig as AppConfig class SyndicationConfig(AppConfig): - name: str = ... - verbose_name: Any = ... + name: str + verbose_name: Any diff --git a/django-stubs/contrib/syndication/views.pyi b/django-stubs/contrib/syndication/views.pyi index 5a84dcce1..f8c7bc7fb 100644 --- a/django-stubs/contrib/syndication/views.pyi +++ b/django-stubs/contrib/syndication/views.pyi @@ -14,10 +14,10 @@ _Item = TypeVar("_Item", bound=Model) _Object = TypeVar("_Object") class Feed(Generic[_Item, _Object]): - feed_type: Type[SyndicationFeed] = ... - title_template: str | None = ... - description_template: str | None = ... - language: str | None = ... + feed_type: Type[SyndicationFeed] + title_template: str | None + description_template: str | None + language: str | None # Dynamic attributes: title: Any diff --git a/django-stubs/core/cache/__init__.pyi b/django-stubs/core/cache/__init__.pyi index fe327d75f..8a0e9d608 100644 --- a/django-stubs/core/cache/__init__.pyi +++ b/django-stubs/core/cache/__init__.pyi @@ -9,8 +9,8 @@ from .backends.base import InvalidCacheBackendError as InvalidCacheBackendError DEFAULT_CACHE_ALIAS: str class CacheHandler(BaseConnectionHandler): - settings_name: str = ... - exception_class: Type[Exception] = ... + settings_name: str + exception_class: Type[Exception] def create_connection(self, alias: str) -> BaseCache: ... def all(self, initialized_only: bool = ...) -> List[BaseCache]: ... diff --git a/django-stubs/core/cache/backends/base.pyi b/django-stubs/core/cache/backends/base.pyi index 4998eeabd..63f3b0a5f 100644 --- a/django-stubs/core/cache/backends/base.pyi +++ b/django-stubs/core/cache/backends/base.pyi @@ -14,12 +14,12 @@ def get_key_func(key_func: Callable | str | None) -> Callable: ... class BaseCache: _missing_key: object - default_timeout: float | None = ... - _max_entries: int = ... - _cull_frequency: int = ... - key_prefix: str = ... - version: int = ... - key_func: Callable = ... + default_timeout: float | None + _max_entries: int + _cull_frequency: int + key_prefix: str + version: int + key_func: Callable def __init__(self, params: Dict[str, Any]) -> None: ... def get_backend_timeout(self, timeout: float | None = ...) -> float | None: ... def make_key(self, key: Any, version: int | None = ...) -> str: ... diff --git a/django-stubs/core/cache/backends/db.pyi b/django-stubs/core/cache/backends/db.pyi index e82bf502d..f88bd7c10 100644 --- a/django-stubs/core/cache/backends/db.pyi +++ b/django-stubs/core/cache/backends/db.pyi @@ -4,20 +4,20 @@ from django.core.cache.backends.base import BaseCache from django.utils.functional import _StrOrPromise class Options: - db_table: str = ... - app_label: str = ... - model_name: str = ... - verbose_name: _StrOrPromise = ... - verbose_name_plural: _StrOrPromise = ... - object_name: str = ... - abstract: bool = ... - managed: bool = ... - proxy: bool = ... - swapped: bool = ... + db_table: str + app_label: str + model_name: str + verbose_name: _StrOrPromise + verbose_name_plural: _StrOrPromise + object_name: str + abstract: bool + managed: bool + proxy: bool + swapped: bool def __init__(self, table: str) -> None: ... class BaseDatabaseCache(BaseCache): - cache_model_class: Any = ... + cache_model_class: Any def __init__(self, table: str, params: Dict[str, Any]) -> None: ... class DatabaseCache(BaseDatabaseCache): ... diff --git a/django-stubs/core/cache/backends/filebased.pyi b/django-stubs/core/cache/backends/filebased.pyi index f8e0e156a..8a0bb424e 100644 --- a/django-stubs/core/cache/backends/filebased.pyi +++ b/django-stubs/core/cache/backends/filebased.pyi @@ -3,5 +3,5 @@ from typing import Any, Dict from django.core.cache.backends.base import BaseCache class FileBasedCache(BaseCache): - cache_suffix: str = ... + cache_suffix: str def __init__(self, dir: str, params: Dict[str, Any]) -> None: ... diff --git a/django-stubs/core/checks/messages.pyi b/django-stubs/core/checks/messages.pyi index 2d8dd7d41..e5d57e0fb 100644 --- a/django-stubs/core/checks/messages.pyi +++ b/django-stubs/core/checks/messages.pyi @@ -7,11 +7,11 @@ ERROR: int CRITICAL: int class CheckMessage: - level: int = ... - msg: str = ... - hint: str | None = ... - obj: Any = ... - id: str | None = ... + level: int + msg: str + hint: str | None + obj: Any + id: str | None def __init__(self, level: int, msg: str, hint: str | None = ..., obj: Any = ..., id: str | None = ...) -> None: ... def is_serious(self, level: int = ...) -> bool: ... def is_silenced(self) -> bool: ... diff --git a/django-stubs/core/checks/registry.pyi b/django-stubs/core/checks/registry.pyi index 9d3c71acd..74951a427 100644 --- a/django-stubs/core/checks/registry.pyi +++ b/django-stubs/core/checks/registry.pyi @@ -5,18 +5,18 @@ from django.core.checks.messages import CheckMessage from typing_extensions import Protocol class Tags: - admin: str = ... - caches: str = ... - compatibility: str = ... - database: str = ... - models: str = ... - security: str = ... - signals: str = ... - sites: str = ... - staticfiles: str = ... - templates: str = ... - translation: str = ... - urls: str = ... + admin: str + caches: str + compatibility: str + database: str + models: str + security: str + signals: str + sites: str + staticfiles: str + templates: str + translation: str + urls: str _CheckCallable = Callable[..., Sequence[CheckMessage]] _C = TypeVar("_C", bound=_CheckCallable) @@ -26,8 +26,8 @@ class _ProcessedCheckCallable(Protocol[_C]): __call__: _C class CheckRegistry: - registered_checks: Set[_ProcessedCheckCallable] = ... - deployment_checks: Set[_ProcessedCheckCallable] = ... + registered_checks: Set[_ProcessedCheckCallable] + deployment_checks: Set[_ProcessedCheckCallable] def __init__(self) -> None: ... def register( self, check: _CheckCallable | str | None = ..., *tags: str, **kwargs: Any @@ -43,7 +43,7 @@ class CheckRegistry: def tags_available(self, deployment_checks: bool = ...) -> Set[str]: ... def get_checks(self, include_deployment_checks: bool = ...) -> List[_ProcessedCheckCallable]: ... -registry: CheckRegistry = ... -register: Any = ... -run_checks: Any = ... -tag_exists: Any = ... +registry: CheckRegistry +register: Any +run_checks: Any +tag_exists: Any diff --git a/django-stubs/core/checks/translation.pyi b/django-stubs/core/checks/translation.pyi index ede597f06..e46691a58 100644 --- a/django-stubs/core/checks/translation.pyi +++ b/django-stubs/core/checks/translation.pyi @@ -4,10 +4,10 @@ from django.apps.config import AppConfig from . import Error -E001: Error = ... -E002: Error = ... -E003: Error = ... -E004: Error = ... +E001: Error +E002: Error +E003: Error +E004: Error def check_setting_language_code(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... def check_setting_languages(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> Sequence[Error]: ... diff --git a/django-stubs/core/exceptions.pyi b/django-stubs/core/exceptions.pyi index 52c7d21d0..7552effe0 100644 --- a/django-stubs/core/exceptions.pyi +++ b/django-stubs/core/exceptions.pyi @@ -7,7 +7,7 @@ class FieldDoesNotExist(Exception): ... class AppRegistryNotReady(Exception): ... class ObjectDoesNotExist(Exception): - silent_variable_failure: bool = ... + silent_variable_failure: bool class MultipleObjectsReturned(Exception): ... class SuspiciousOperation(Exception): ... @@ -25,14 +25,14 @@ class MiddlewareNotUsed(Exception): ... class ImproperlyConfigured(Exception): ... class FieldError(Exception): ... -NON_FIELD_ERRORS: Literal["__all__"] = ... +NON_FIELD_ERRORS: Literal["__all__"] class ValidationError(Exception): - error_dict: Dict[str, List[ValidationError]] = ... - error_list: List[ValidationError] = ... - message: str = ... - code: str | None = ... - params: Dict[str, Any] | None = ... + error_dict: Dict[str, List[ValidationError]] + error_list: List[ValidationError] + message: str + code: str | None + params: Dict[str, Any] | None def __init__( self, # Accepts arbitrarily nested data structure, mypy doesn't allow describing it accurately. diff --git a/django-stubs/core/files/base.pyi b/django-stubs/core/files/base.pyi index 5a2b8aa31..d10c51452 100644 --- a/django-stubs/core/files/base.pyi +++ b/django-stubs/core/files/base.pyi @@ -6,10 +6,10 @@ from django.core.files.utils import FileProxyMixin _T = TypeVar("_T", bound="File") class File(FileProxyMixin[AnyStr], IO[AnyStr]): - DEFAULT_CHUNK_SIZE: int = ... - file: IO[AnyStr] | None = ... - name: str | None = ... # type: ignore[assignment] - mode: str = ... + DEFAULT_CHUNK_SIZE: int + file: IO[AnyStr] | None + name: str | None # type: ignore[assignment] + mode: str def __init__(self, file: IO[AnyStr] | None, name: str | None = ...) -> None: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... @@ -34,7 +34,7 @@ class File(FileProxyMixin[AnyStr], IO[AnyStr]): class ContentFile(File[AnyStr]): file: IO[AnyStr] - size: int = ... + size: int def __init__(self, content: AnyStr, name: str | None = ...) -> None: ... def __str__(self) -> str: ... def __bool__(self) -> bool: ... diff --git a/django-stubs/core/files/locks.pyi b/django-stubs/core/files/locks.pyi index 768114f50..cc44d811f 100644 --- a/django-stubs/core/files/locks.pyi +++ b/django-stubs/core/files/locks.pyi @@ -4,8 +4,8 @@ from typing import Any LOCK_SH: int LOCK_NB: int LOCK_EX: int -ULONG_PTR: Any = ... -PVOID: Any = ... +ULONG_PTR: Any +PVOID: Any class _OFFSET(Structure): ... class _OFFSET_UNION(Union): ... diff --git a/django-stubs/core/files/storage.pyi b/django-stubs/core/files/storage.pyi index 3adf10d98..5d64f10d1 100644 --- a/django-stubs/core/files/storage.pyi +++ b/django-stubs/core/files/storage.pyi @@ -23,7 +23,7 @@ class Storage: def get_modified_time(self, name: str) -> datetime: ... class FileSystemStorage(Storage): - OS_OPEN_FLAGS: int = ... + OS_OPEN_FLAGS: int def __init__( self, location: _PathCompatible | None = ..., diff --git a/django-stubs/core/files/uploadedfile.pyi b/django-stubs/core/files/uploadedfile.pyi index 9330e203e..35e11cade 100644 --- a/django-stubs/core/files/uploadedfile.pyi +++ b/django-stubs/core/files/uploadedfile.pyi @@ -3,9 +3,9 @@ from typing import IO, Dict, Type, TypeVar from django.core.files.base import File class UploadedFile(File): - content_type: str | None = ... - charset: str | None = ... - content_type_extra: Dict[str, str] | None = ... + content_type: str | None + charset: str | None + content_type_extra: Dict[str, str] | None size: int | None # type: ignore[assignment] name: str | None def __init__( @@ -30,7 +30,7 @@ class TemporaryUploadedFile(UploadedFile): def temporary_file_path(self) -> str: ... class InMemoryUploadedFile(UploadedFile): - field_name: str | None = ... + field_name: str | None def __init__( self, file: IO, diff --git a/django-stubs/core/files/uploadhandler.pyi b/django-stubs/core/files/uploadhandler.pyi index a024d13f1..3a01fbeb2 100644 --- a/django-stubs/core/files/uploadhandler.pyi +++ b/django-stubs/core/files/uploadhandler.pyi @@ -9,7 +9,7 @@ from django.utils.datastructures import MultiValueDict class UploadFileException(Exception): ... class StopUpload(UploadFileException): - connection_reset: bool = ... + connection_reset: bool def __init__(self, connection_reset: bool = ...) -> None: ... def __str__(self) -> str: ... @@ -17,14 +17,14 @@ class SkipFile(UploadFileException): ... class StopFutureHandlers(UploadFileException): ... class FileUploadHandler: - chunk_size: int = ... - file_name: str | None = ... - content_type: str | None = ... - content_length: int | None = ... - charset: str | None = ... - content_type_extra: Dict[str, str] | None = ... - request: HttpRequest | None = ... - field_name: str = ... + chunk_size: int + file_name: str | None + content_type: str | None + content_length: int | None + charset: str | None + content_type_extra: Dict[str, str] | None + request: HttpRequest | None + field_name: str def __init__(self, request: HttpRequest | None = ...) -> None: ... def handle_raw_input( self, @@ -49,7 +49,7 @@ class FileUploadHandler: def upload_interrupted(self) -> None: ... class TemporaryFileUploadHandler(FileUploadHandler): - file: TemporaryUploadedFile = ... + file: TemporaryUploadedFile def new_file( self, field_name: str, @@ -64,8 +64,8 @@ class TemporaryFileUploadHandler(FileUploadHandler): def upload_interrupted(self) -> None: ... class MemoryFileUploadHandler(FileUploadHandler): - activated: bool = ... - file: IO[bytes] = ... + activated: bool + file: IO[bytes] def handle_raw_input( self, input_data: IO[bytes], diff --git a/django-stubs/core/files/utils.pyi b/django-stubs/core/files/utils.pyi index 0d26ff9e5..aa6f70279 100644 --- a/django-stubs/core/files/utils.pyi +++ b/django-stubs/core/files/utils.pyi @@ -6,20 +6,20 @@ def validate_file_name(name: _PathCompatible, allow_relative_path: bool = ...) - class FileProxyMixin(Generic[AnyStr]): file: IO[AnyStr] | None - encoding: Any = ... - fileno: Any = ... - flush: Any = ... - isatty: Any = ... - newlines: Any = ... - read: Any = ... - readinto: Any = ... - readline: Any = ... - readlines: Any = ... - seek: Any = ... - tell: Any = ... - truncate: Any = ... - write: Any = ... - writelines: Any = ... + encoding: Any + fileno: Any + flush: Any + isatty: Any + newlines: Any + read: Any + readinto: Any + readline: Any + readlines: Any + seek: Any + tell: Any + truncate: Any + write: Any + writelines: Any @property def closed(self) -> bool: ... def readable(self) -> bool: ... diff --git a/django-stubs/core/handlers/asgi.pyi b/django-stubs/core/handlers/asgi.pyi index dbac67cc2..6a606fd0b 100644 --- a/django-stubs/core/handlers/asgi.pyi +++ b/django-stubs/core/handlers/asgi.pyi @@ -10,27 +10,27 @@ _ReceiveCallback = Callable[[], Awaitable[Mapping[str, Any]]] _SendCallback = Callable[[Mapping[str, Any]], Awaitable[None]] class ASGIRequest(HttpRequest): - body_receive_timeout: int = ... - scope: Mapping[str, Any] = ... - resolver_match: ResolverMatch | None = ... - script_name: str | None = ... - path_info: str = ... - path: str = ... - method: str = ... - META: Dict[str, Any] = ... + body_receive_timeout: int + scope: Mapping[str, Any] + resolver_match: ResolverMatch | None + script_name: str | None + path_info: str + path: str + method: str + META: Dict[str, Any] def __init__(self, scope: Mapping[str, Any], body_file: IO[bytes]) -> None: ... @property def GET(self) -> _ImmutableQueryDict: ... # type: ignore - POST: _ImmutableQueryDict = ... - FILES: MultiValueDict = ... + POST: _ImmutableQueryDict + FILES: MultiValueDict @property def COOKIES(self) -> Dict[str, str]: ... # type: ignore _T = TypeVar("_T") class ASGIHandler(base.BaseHandler): - request_class: Type[ASGIRequest] = ... - chunk_size: int = ... + request_class: Type[ASGIRequest] + chunk_size: int def __init__(self) -> None: ... async def __call__( self, diff --git a/django-stubs/core/handlers/wsgi.pyi b/django-stubs/core/handlers/wsgi.pyi index 0effda4df..b4b0117f8 100644 --- a/django-stubs/core/handlers/wsgi.pyi +++ b/django-stubs/core/handlers/wsgi.pyi @@ -9,22 +9,22 @@ from django.http.response import HttpResponseBase _WSGIEnviron = Dict[str, Any] class LimitedStream: - stream: BytesIO = ... - remaining: int = ... - buffer: bytes = ... - buf_size: int = ... + stream: BytesIO + remaining: int + buffer: bytes + buf_size: int def __init__(self, stream: BytesIO, limit: int, buf_size: int = ...) -> None: ... def read(self, size: int | None = ...) -> bytes: ... def readline(self, size: int | None = ...) -> bytes: ... class WSGIRequest(HttpRequest): - environ: _WSGIEnviron = ... + environ: _WSGIEnviron session: SessionBase - encoding: Any = ... + encoding: Any def __init__(self, environ: _WSGIEnviron) -> None: ... class WSGIHandler(base.BaseHandler): - request_class: Type[WSGIRequest] = ... + request_class: Type[WSGIRequest] def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __call__( self, diff --git a/django-stubs/core/mail/__init__.pyi b/django-stubs/core/mail/__init__.pyi index c36bbbc99..6a103cc50 100644 --- a/django-stubs/core/mail/__init__.pyi +++ b/django-stubs/core/mail/__init__.pyi @@ -44,4 +44,4 @@ def mail_managers( html_message: str | None = ..., ) -> None: ... -outbox: List[EmailMessage] = ... +outbox: List[EmailMessage] diff --git a/django-stubs/core/mail/backends/console.pyi b/django-stubs/core/mail/backends/console.pyi index 04d859720..7b340ac34 100644 --- a/django-stubs/core/mail/backends/console.pyi +++ b/django-stubs/core/mail/backends/console.pyi @@ -4,5 +4,5 @@ from typing import TextIO from django.core.mail.backends.base import BaseEmailBackend class EmailBackend(BaseEmailBackend): - stream: TextIO = ... - _lock: threading.RLock = ... + stream: TextIO + _lock: threading.RLock diff --git a/django-stubs/core/mail/backends/smtp.pyi b/django-stubs/core/mail/backends/smtp.pyi index 3fae00f57..dad2f29cf 100644 --- a/django-stubs/core/mail/backends/smtp.pyi +++ b/django-stubs/core/mail/backends/smtp.pyi @@ -4,14 +4,14 @@ import threading from django.core.mail.backends.base import BaseEmailBackend class EmailBackend(BaseEmailBackend): - host: str = ... - port: int = ... - username: str = ... - password: str = ... - use_tls: bool = ... - use_ssl: bool = ... - timeout: int | None = ... - ssl_keyfile: str | None = ... - ssl_certfile: str | None = ... - connection: smtplib.SMTP_SSL | smtplib.SMTP | None = ... - _lock: threading.RLock = ... + host: str + port: int + username: str + password: str + use_tls: bool + use_ssl: bool + timeout: int | None + ssl_keyfile: str | None + ssl_certfile: str | None + connection: smtplib.SMTP_SSL | smtplib.SMTP | None + _lock: threading.RLock diff --git a/django-stubs/core/mail/message.pyi b/django-stubs/core/mail/message.pyi index 7013596cd..6de2c7dce 100644 --- a/django-stubs/core/mail/message.pyi +++ b/django-stubs/core/mail/message.pyi @@ -35,7 +35,7 @@ class SafeMIMEText(MIMEMixin, MIMEText): # type: ignore epilogue: None policy: Policy preamble: None - encoding: str = ... + encoding: str def __init__(self, _text: str, _subtype: str = ..., _charset: str = ...) -> None: ... def __setitem__(self, name: str, val: str) -> None: ... def set_payload( @@ -47,7 +47,7 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): # type: ignore epilogue: None policy: Policy preamble: None - encoding: str = ... + encoding: str def __init__( self, _subtype: str = ..., @@ -64,19 +64,19 @@ _AttachmentTuple = ( ) class EmailMessage: - content_subtype: str = ... - mixed_subtype: str = ... - encoding: Any = ... - to: List[str] = ... - cc: List[Any] = ... - bcc: List[Any] = ... - reply_to: List[Any] = ... - from_email: str = ... - subject: str = ... - body: str = ... - attachments: List[Any] = ... - extra_headers: Dict[Any, Any] = ... - connection: Any = ... + content_subtype: str + mixed_subtype: str + encoding: Any + to: List[str] + cc: List[Any] + bcc: List[Any] + reply_to: List[Any] + from_email: str + subject: str + body: str + attachments: List[Any] + extra_headers: Dict[Any, Any] + connection: Any def __init__( self, subject: str = ..., @@ -104,8 +104,8 @@ class EmailMessage: def attach_file(self, path: str, mimetype: str | None = ...) -> None: ... class EmailMultiAlternatives(EmailMessage): - alternative_subtype: str = ... - alternatives: List[Tuple[_AttachmentContent, str]] = ... + alternative_subtype: str + alternatives: List[Tuple[_AttachmentContent, str]] def __init__( self, subject: str = ..., diff --git a/django-stubs/core/management/__init__.pyi b/django-stubs/core/management/__init__.pyi index e3890d1ac..d0a67f955 100644 --- a/django-stubs/core/management/__init__.pyi +++ b/django-stubs/core/management/__init__.pyi @@ -9,9 +9,9 @@ def get_commands() -> Dict[str, str]: ... def call_command(command_name: BaseCommand | str, *args: Any, **options: Any) -> str: ... class ManagementUtility: - argv: List[str] = ... - prog_name: str = ... - settings_exception: Exception | None = ... + argv: List[str] + prog_name: str + settings_exception: Exception | None def __init__(self, argv: List[str] | None = ...) -> None: ... def main_help_text(self, commands_only: bool = ...) -> str: ... def fetch_command(self, subcommand: str) -> BaseCommand: ... diff --git a/django-stubs/core/management/base.pyi b/django-stubs/core/management/base.pyi index c84ee5961..b27fc54cd 100644 --- a/django-stubs/core/management/base.pyi +++ b/django-stubs/core/management/base.pyi @@ -13,8 +13,8 @@ class CommandError(Exception): class SystemCheckError(CommandError): ... class CommandParser(ArgumentParser): - missing_args_message: str | None = ... - called_from_command_line: bool | None = ... + missing_args_message: str | None + called_from_command_line: bool | None def __init__( self, *, missing_args_message: str | None = ..., called_from_command_line: bool | None = ..., **kwargs: Any ) -> None: ... @@ -24,7 +24,7 @@ def handle_default_options(options: Namespace) -> None: ... def no_translations(handle_func: Callable) -> Callable: ... class DjangoHelpFormatter(HelpFormatter): - show_last: Set[str] = ... + show_last: Set[str] def add_usage(self, usage: str | None, actions: Iterable[Any], *args: Any, **kwargs: Any) -> Any: ... def add_arguments(self, actions: Any) -> Any: ... @@ -33,7 +33,7 @@ class OutputWrapper(TextIOBase): def style_func(self) -> Callable[[str], str]: ... @style_func.setter def style_func(self, style_func: Callable[[str], str] | None) -> None: ... - ending: str = ... + ending: str def __init__(self, out: TextIO, ending: str = ...) -> None: ... def __getattr__(self, name: str) -> Callable: ... def flush(self) -> None: ... @@ -43,15 +43,15 @@ class OutputWrapper(TextIOBase): ) -> None: ... class BaseCommand: - help: str = ... - output_transaction: bool = ... - requires_migrations_checks: bool = ... - requires_system_checks: _ListOrTuple[str] | Literal["__all__"] = ... - base_stealth_options: Tuple[str, ...] = ... - stealth_options: Tuple[str, ...] = ... - stdout: OutputWrapper = ... - stderr: OutputWrapper = ... - style: Style = ... + help: str + output_transaction: bool + requires_migrations_checks: bool + requires_system_checks: _ListOrTuple[str] | Literal["__all__"] + base_stealth_options: Tuple[str, ...] + stealth_options: Tuple[str, ...] + stdout: OutputWrapper + stderr: OutputWrapper + style: Style def __init__( self, stdout: TextIO | None = ..., @@ -78,14 +78,14 @@ class BaseCommand: def handle(self, *args: Any, **options: Any) -> str | None: ... class AppCommand(BaseCommand): - missing_args_message: str = ... + missing_args_message: str def add_arguments(self, parser: CommandParser) -> None: ... def handle(self, *app_labels: str, **options: Any) -> str | None: ... def handle_app_config(self, app_config: Any, **options: Any) -> str | None: ... class LabelCommand(BaseCommand): - label: str = ... - missing_args_message: Any = ... + label: str + missing_args_message: Any def add_arguments(self, parser: CommandParser) -> None: ... def handle(self, *labels: str, **options: Any) -> str | None: ... def handle_label(self, label: str, **options: Any) -> str | None: ... diff --git a/django-stubs/core/management/commands/compilemessages.pyi b/django-stubs/core/management/commands/compilemessages.pyi index 78c71c6c7..d702ff230 100644 --- a/django-stubs/core/management/commands/compilemessages.pyi +++ b/django-stubs/core/management/commands/compilemessages.pyi @@ -13,8 +13,8 @@ def has_bom(fn: Path) -> bool: ... def is_writable(path: _PathCompatible) -> bool: ... class Command(BaseCommand): - program: str = ... - program_options: List[str] = ... - verbosity: int = ... - has_errors: bool = ... + program: str + program_options: List[str] + verbosity: int + has_errors: bool def compile_messages(self, locations: List[Tuple[_PathCompatible, _PathCompatible]]) -> None: ... diff --git a/django-stubs/core/management/commands/createcachetable.pyi b/django-stubs/core/management/commands/createcachetable.pyi index 4c64f1099..3304498fc 100644 --- a/django-stubs/core/management/commands/createcachetable.pyi +++ b/django-stubs/core/management/commands/createcachetable.pyi @@ -13,6 +13,6 @@ from django.db import router as router from django.db import transaction as transaction class Command(BaseCommand): - verbosity: int = ... + verbosity: int def handle(self, *tablenames: List[str], **options: Any) -> None: ... def create_table(self, database: str, tablename: str, dry_run: bool) -> None: ... diff --git a/django-stubs/core/management/commands/flush.pyi b/django-stubs/core/management/commands/flush.pyi index d72f612e0..b7127209b 100644 --- a/django-stubs/core/management/commands/flush.pyi +++ b/django-stubs/core/management/commands/flush.pyi @@ -11,5 +11,5 @@ from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS from django.db import connections as connections class Command(BaseCommand): - stealth_options: Tuple[str] = ... - style: Style = ... + stealth_options: Tuple[str] + style: Style diff --git a/django-stubs/core/management/commands/inspectdb.pyi b/django-stubs/core/management/commands/inspectdb.pyi index db555bd92..50d988df7 100644 --- a/django-stubs/core/management/commands/inspectdb.pyi +++ b/django-stubs/core/management/commands/inspectdb.pyi @@ -8,8 +8,8 @@ from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.constants import LOOKUP_SEP as LOOKUP_SEP class Command(BaseCommand): - stealth_options: Tuple[str] = ... - db_module: str = ... + stealth_options: Tuple[str] + db_module: str def handle_inspection(self, options: Dict[str, Any]) -> Iterable[str]: ... def normalize_col_name( self, col_name: str, used_column_names: List[str], is_relation: bool diff --git a/django-stubs/core/management/commands/loaddata.pyi b/django-stubs/core/management/commands/loaddata.pyi index ad7d40adc..a0852b1be 100644 --- a/django-stubs/core/management/commands/loaddata.pyi +++ b/django-stubs/core/management/commands/loaddata.pyi @@ -5,17 +5,17 @@ from django.apps.config import AppConfig from django.core.management.base import BaseCommand from django.db.models.base import Model -READ_STDIN: str = ... +READ_STDIN: str class Command(BaseCommand): - ignore: bool = ... - using: str = ... - app_label: str = ... - verbosity: int = ... - excluded_models: Set[Type[Model]] = ... - excluded_apps: Set[AppConfig] = ... - format: str = ... - missing_args_message: str = ... + ignore: bool + using: str + app_label: str + verbosity: int + excluded_models: Set[Type[Model]] + excluded_apps: Set[AppConfig] + format: str + missing_args_message: str def loaddata(self, fixture_labels: Sequence[str]) -> None: ... def load_label(self, fixture_label: str) -> None: ... def find_fixtures(self, fixture_label: str) -> List[Tuple[str, str | None, str | None]]: ... diff --git a/django-stubs/core/management/commands/makemessages.pyi b/django-stubs/core/management/commands/makemessages.pyi index bfaa30aa5..77775d596 100644 --- a/django-stubs/core/management/commands/makemessages.pyi +++ b/django-stubs/core/management/commands/makemessages.pyi @@ -2,9 +2,9 @@ from typing import Any, List, Pattern, Type from django.core.management.base import BaseCommand -plural_forms_re: Pattern = ... -STATUS_OK: int = ... -NO_LOCALE_DIR: Any = ... +plural_forms_re: Pattern +STATUS_OK: int +NO_LOCALE_DIR: Any def check_programs(*programs: str) -> None: ... @@ -34,9 +34,9 @@ def normalize_eols(raw_contents: str) -> str: ... def write_pot_file(potfile: str, msgs: str) -> None: ... class Command(BaseCommand): - translatable_file_class: Type[TranslatableFile] = ... - build_file_class: Type[BuildFile] = ... - msgmerge_options: List[str] = ... - msguniq_options: List[str] = ... - msgattrib_options: List[str] = ... - xgettext_options: List[str] = ... + translatable_file_class: Type[TranslatableFile] + build_file_class: Type[BuildFile] + msgmerge_options: List[str] + msguniq_options: List[str] + msgattrib_options: List[str] + xgettext_options: List[str] diff --git a/django-stubs/core/management/commands/makemigrations.pyi b/django-stubs/core/management/commands/makemigrations.pyi index 46fbabe98..3e5ffa56d 100644 --- a/django-stubs/core/management/commands/makemigrations.pyi +++ b/django-stubs/core/management/commands/makemigrations.pyi @@ -20,12 +20,12 @@ from django.db.migrations.utils import get_migration_name_timestamp as get_migra from django.db.migrations.writer import MigrationWriter as MigrationWriter class Command(BaseCommand): - verbosity: int = ... - interactive: bool = ... - dry_run: bool = ... - merge: bool = ... - empty: bool = ... - migration_name: str = ... - include_header: bool = ... + verbosity: int + interactive: bool + dry_run: bool + merge: bool + empty: bool + migration_name: str + include_header: bool def write_migration_files(self, changes: Dict[str, Any]) -> None: ... def handle_merge(self, loader: MigrationLoader, conflicts: Dict[str, Any]) -> None: ... diff --git a/django-stubs/core/management/commands/migrate.pyi b/django-stubs/core/management/commands/migrate.pyi index f757457a4..319ca5214 100644 --- a/django-stubs/core/management/commands/migrate.pyi +++ b/django-stubs/core/management/commands/migrate.pyi @@ -20,9 +20,9 @@ from django.utils.module_loading import module_has_submodule as module_has_submo from django.utils.text import Truncator as Truncator class Command(BaseCommand): - verbosity: int = ... - interactive: bool = ... - start: float = ... + verbosity: int + interactive: bool + start: float def migration_progress_callback(self, action: str, migration: Any | None = ..., fake: bool = ...) -> None: ... def sync_apps(self, connection: BaseDatabaseWrapper, app_labels: Container[str]) -> None: ... @staticmethod diff --git a/django-stubs/core/management/commands/runserver.pyi b/django-stubs/core/management/commands/runserver.pyi index d60ec3acc..90f167336 100644 --- a/django-stubs/core/management/commands/runserver.pyi +++ b/django-stubs/core/management/commands/runserver.pyi @@ -5,11 +5,11 @@ from django.core.management.base import BaseCommand from django.core.servers.basehttp import WSGIServer class Command(BaseCommand): - default_addr: str = ... - default_addr_ipv6: str = ... - default_port: str = ... - protocol: str = ... - server_cls: Type[WSGIServer] = ... + default_addr: str + default_addr_ipv6: str + default_port: str + protocol: str + server_cls: Type[WSGIServer] def run(self, **options: Any) -> None: ... def get_handler(self, *args: Any, **options: Any) -> WSGIHandler: ... def inner_run(self, *args: Any, **options: Any) -> None: ... diff --git a/django-stubs/core/management/commands/sendtestemail.pyi b/django-stubs/core/management/commands/sendtestemail.pyi index 6cda8b1fb..298564136 100644 --- a/django-stubs/core/management/commands/sendtestemail.pyi +++ b/django-stubs/core/management/commands/sendtestemail.pyi @@ -5,4 +5,4 @@ from django.core.management.base import BaseCommand as BaseCommand from django.utils import timezone as timezone class Command(BaseCommand): - missing_args_message: str = ... + missing_args_message: str diff --git a/django-stubs/core/management/commands/shell.pyi b/django-stubs/core/management/commands/shell.pyi index 73cced3ad..fe9bde31f 100644 --- a/django-stubs/core/management/commands/shell.pyi +++ b/django-stubs/core/management/commands/shell.pyi @@ -5,7 +5,7 @@ from django.core.management import CommandError as CommandError from django.utils.datastructures import OrderedSet as OrderedSet class Command(BaseCommand): - shells: List[str] = ... + shells: List[str] def ipython(self, options: Any) -> None: ... def bpython(self, options: Any) -> None: ... def python(self, options: Any) -> None: ... diff --git a/django-stubs/core/management/commands/showmigrations.pyi b/django-stubs/core/management/commands/showmigrations.pyi index 8bc981926..d5594c621 100644 --- a/django-stubs/core/management/commands/showmigrations.pyi +++ b/django-stubs/core/management/commands/showmigrations.pyi @@ -8,6 +8,6 @@ from django.db.backends.base.base import BaseDatabaseWrapper from django.db.migrations.loader import MigrationLoader as MigrationLoader class Command(BaseCommand): - verbosity: int = ... + verbosity: int def show_list(self, connection: BaseDatabaseWrapper, app_names: List[str] | None = ...) -> None: ... def show_plan(self, connection: BaseDatabaseWrapper, app_names: List[str] | None = ...) -> None: ... diff --git a/django-stubs/core/management/commands/sqlflush.pyi b/django-stubs/core/management/commands/sqlflush.pyi index 74bbc7c2a..3625b9801 100644 --- a/django-stubs/core/management/commands/sqlflush.pyi +++ b/django-stubs/core/management/commands/sqlflush.pyi @@ -4,4 +4,4 @@ from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS from django.db import connections as connections class Command(BaseCommand): - output_transaction: bool = ... + output_transaction: bool diff --git a/django-stubs/core/management/commands/sqlmigrate.pyi b/django-stubs/core/management/commands/sqlmigrate.pyi index 509ec6ce8..03bad538d 100644 --- a/django-stubs/core/management/commands/sqlmigrate.pyi +++ b/django-stubs/core/management/commands/sqlmigrate.pyi @@ -9,5 +9,5 @@ from django.db.migrations.loader import AmbiguityError as AmbiguityError from django.db.migrations.loader import MigrationLoader as MigrationLoader class Command(BaseCommand): - output_transaction: bool = ... + output_transaction: bool def execute(self, *args: Any, **options: Any) -> str | None: ... diff --git a/django-stubs/core/management/commands/squashmigrations.pyi b/django-stubs/core/management/commands/squashmigrations.pyi index b4b5157c3..77e81e96a 100644 --- a/django-stubs/core/management/commands/squashmigrations.pyi +++ b/django-stubs/core/management/commands/squashmigrations.pyi @@ -14,6 +14,6 @@ from django.db.migrations.writer import MigrationWriter as MigrationWriter from django.utils.version import get_docs_version as get_docs_version class Command(BaseCommand): - verbosity: int = ... - interactive: bool = ... + verbosity: int + interactive: bool def find_migration(self, loader: MigrationLoader, app_label: str, name: str) -> Migration: ... diff --git a/django-stubs/core/management/commands/startapp.pyi b/django-stubs/core/management/commands/startapp.pyi index 0bd549a50..e3ace8601 100644 --- a/django-stubs/core/management/commands/startapp.pyi +++ b/django-stubs/core/management/commands/startapp.pyi @@ -3,4 +3,4 @@ from typing import Any from django.core.management.templates import TemplateCommand as TemplateCommand class Command(TemplateCommand): - missing_args_message: str = ... + missing_args_message: str diff --git a/django-stubs/core/management/commands/startproject.pyi b/django-stubs/core/management/commands/startproject.pyi index 9111c5e84..34bbfdd34 100644 --- a/django-stubs/core/management/commands/startproject.pyi +++ b/django-stubs/core/management/commands/startproject.pyi @@ -3,4 +3,4 @@ from django.core.management.templates import TemplateCommand as TemplateCommand from ..utils import get_random_secret_key as get_random_secret_key class Command(TemplateCommand): - missing_args_message: str = ... + missing_args_message: str diff --git a/django-stubs/core/management/commands/test.pyi b/django-stubs/core/management/commands/test.pyi index 3849926cc..46a90cef8 100644 --- a/django-stubs/core/management/commands/test.pyi +++ b/django-stubs/core/management/commands/test.pyi @@ -6,6 +6,6 @@ from django.core.management.utils import get_command_line_option as get_command_ from django.test.utils import get_runner as get_runner class Command(BaseCommand): - test_runner: Any = ... + test_runner: Any def run_from_argv(self, argv: Any) -> None: ... def add_arguments(self, parser: Any) -> None: ... diff --git a/django-stubs/core/management/templates.pyi b/django-stubs/core/management/templates.pyi index 21dd8d6c3..d0c392128 100644 --- a/django-stubs/core/management/templates.pyi +++ b/django-stubs/core/management/templates.pyi @@ -4,12 +4,12 @@ from typing import Any, Sequence, Tuple from django.core.management.base import BaseCommand class TemplateCommand(BaseCommand): - url_schemes: Sequence[str] = ... - rewrite_template_suffixes: Sequence[Tuple[str, str]] = ... + url_schemes: Sequence[str] + rewrite_template_suffixes: Sequence[Tuple[str, str]] app_or_project: str a_or_an: str paths_to_remove: Sequence[Any] - verbosity: Any = ... + verbosity: Any def add_arguments(self, parser: ArgumentParser) -> None: ... def handle(self, app_or_project: str, name: str, target: str | None = ..., **options: Any) -> None: ... def handle_template(self, template: str | None, subdir: str | None) -> str: ... diff --git a/django-stubs/core/paginator.pyi b/django-stubs/core/paginator.pyi index 5b20bee7e..500161db5 100644 --- a/django-stubs/core/paginator.pyi +++ b/django-stubs/core/paginator.pyi @@ -17,10 +17,10 @@ class _SupportsPagination(Protocol[_T], Sized, Iterable): def __getitem__(self, __index: slice) -> _SupportsPagination[_T]: ... class Paginator(Generic[_T]): - object_list: _SupportsPagination[_T] = ... - per_page: int = ... - orphans: int = ... - allow_empty_first_page: bool = ... + object_list: _SupportsPagination[_T] + per_page: int + orphans: int + allow_empty_first_page: bool def __init__( self, object_list: _SupportsPagination[_T], @@ -45,9 +45,9 @@ class Paginator(Generic[_T]): QuerySetPaginator = Paginator class Page(Sequence[_T]): - object_list: _SupportsPagination[_T] = ... - number: int = ... - paginator: Paginator = ... + object_list: _SupportsPagination[_T] + number: int + paginator: Paginator def __init__( self, object_list: _SupportsPagination[_T], diff --git a/django-stubs/core/serializers/__init__.pyi b/django-stubs/core/serializers/__init__.pyi index 9c1cdd353..ec603cb6f 100644 --- a/django-stubs/core/serializers/__init__.pyi +++ b/django-stubs/core/serializers/__init__.pyi @@ -13,8 +13,8 @@ from .base import SerializerDoesNotExist as SerializerDoesNotExist BUILTIN_SERIALIZERS: Any class BadSerializer: - internal_use_only: bool = ... - exception: BaseException = ... + internal_use_only: bool + exception: BaseException def __init__(self, exception: BaseException) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... diff --git a/django-stubs/core/serializers/base.pyi b/django-stubs/core/serializers/base.pyi index aa3aec795..88d4c6bce 100644 --- a/django-stubs/core/serializers/base.pyi +++ b/django-stubs/core/serializers/base.pyi @@ -4,7 +4,7 @@ from django.db.models.base import Model from django.db.models.fields import Field from django.db.models.fields.related import ForeignKey, ManyToManyField -DEFER_FIELD: object = ... +DEFER_FIELD: object class SerializerDoesNotExist(KeyError): ... class SerializationError(Exception): ... @@ -16,28 +16,28 @@ class DeserializationError(Exception): ) -> DeserializationError: ... class M2MDeserializationError(Exception): - original_exc: Exception = ... - pk: Any = ... + original_exc: Exception + pk: Any def __init__(self, original_exc: Exception, pk: Any) -> None: ... class ProgressBar: - progress_width: int = ... - output: IO[str] | None = ... - total_count: int = ... - prev_done: int = ... + progress_width: int + output: IO[str] | None + total_count: int + prev_done: int def __init__(self, output: IO[str] | None, total_count: int) -> None: ... def update(self, count: int) -> None: ... class Serializer: - internal_use_only: bool = ... - progress_class: Type[ProgressBar] = ... - stream_class: Type[IO[str]] = ... - options: Dict[str, Any] = ... - stream: IO[str] = ... - selected_fields: Collection[str] | None = ... - use_natural_foreign_keys: bool = ... - use_natural_primary_keys: bool = ... - first: bool = ... + internal_use_only: bool + progress_class: Type[ProgressBar] + stream_class: Type[IO[str]] + options: Dict[str, Any] + stream: IO[str] + selected_fields: Collection[str] | None + use_natural_foreign_keys: bool + use_natural_primary_keys: bool + first: bool def serialize( self, queryset: Iterable[Model], @@ -60,15 +60,15 @@ class Serializer: def getvalue(self) -> bytes | str | None: ... class Deserializer: - options: Dict[str, Any] = ... - stream: IO[str] | IO[bytes] = ... + options: Dict[str, Any] + stream: IO[str] | IO[bytes] def __init__(self, stream_or_string: bytes | str | IO[bytes] | IO[str], **options: Any) -> None: ... def __iter__(self) -> Deserializer: ... def __next__(self) -> Any: ... class DeserializedObject: - object: Any = ... - m2m_data: Dict[str, Sequence[Any]] | None = ... + object: Any + m2m_data: Dict[str, Sequence[Any]] | None deferred_fields: Dict[Field, Any] def __init__( self, diff --git a/django-stubs/core/serializers/python.pyi b/django-stubs/core/serializers/python.pyi index 2c02c41a2..b8e9d1e42 100644 --- a/django-stubs/core/serializers/python.pyi +++ b/django-stubs/core/serializers/python.pyi @@ -5,7 +5,7 @@ from django.core.serializers.base import DeserializedObject from django.db.models.base import Model class Serializer(base.Serializer): - objects: List[Any] = ... + objects: List[Any] def get_dump_object(self, obj: Model) -> Dict[str, Any]: ... def Deserializer( diff --git a/django-stubs/core/serializers/pyyaml.pyi b/django-stubs/core/serializers/pyyaml.pyi index f37b90eb9..9c97d2485 100644 --- a/django-stubs/core/serializers/pyyaml.pyi +++ b/django-stubs/core/serializers/pyyaml.pyi @@ -11,7 +11,7 @@ class DjangoSafeDumper(SafeDumper): def represent_ordered_dict(self, data: Any) -> MappingNode: ... class Serializer(PythonSerializer): - internal_use_only: bool = ... + internal_use_only: bool def handle_field(self, obj: Any, field: Field) -> None: ... def end_serialization(self) -> None: ... def getvalue(self) -> Any: ... diff --git a/django-stubs/core/serializers/xml_serializer.pyi b/django-stubs/core/serializers/xml_serializer.pyi index 46a73e84f..f21496aa7 100644 --- a/django-stubs/core/serializers/xml_serializer.pyi +++ b/django-stubs/core/serializers/xml_serializer.pyi @@ -5,7 +5,7 @@ from django.core.serializers import base as base class Serializer(base.Serializer): def indent(self, level: int) -> None: ... - xml: Any = ... + xml: Any def start_serialization(self) -> None: ... def end_serialization(self) -> None: ... def start_object(self, obj: Any) -> None: ... @@ -15,10 +15,10 @@ class Serializer(base.Serializer): def handle_m2m_field(self, obj: Any, field: Any) -> None: ... class Deserializer(base.Deserializer): - handle_forward_references: bool = ... - event_stream: Any = ... - db: str = ... - ignore: bool = ... + handle_forward_references: bool + event_stream: Any + db: str + ignore: bool def __init__( self, stream_or_string: bytes | str | IO[bytes] | IO[str], @@ -44,23 +44,23 @@ class DefusedExpatParser(_ExpatParser): class DefusedXmlException(ValueError): ... class DTDForbidden(DefusedXmlException): - name: Any = ... - sysid: Any = ... - pubid: Any = ... + name: Any + sysid: Any + pubid: Any def __init__(self, name: Any, sysid: Any, pubid: Any) -> None: ... class EntitiesForbidden(DefusedXmlException): - name: Any = ... - value: Any = ... - base: Any = ... - sysid: Any = ... - pubid: Any = ... - notation_name: Any = ... + name: Any + value: Any + base: Any + sysid: Any + pubid: Any + notation_name: Any def __init__(self, name: Any, value: Any, base: Any, sysid: Any, pubid: Any, notation_name: Any) -> None: ... class ExternalReferenceForbidden(DefusedXmlException): - context: Any = ... - base: Any = ... - sysid: Any = ... - pubid: Any = ... + context: Any + base: Any + sysid: Any + pubid: Any def __init__(self, context: Any, base: Any, sysid: Any, pubid: Any) -> None: ... diff --git a/django-stubs/core/servers/basehttp.pyi b/django-stubs/core/servers/basehttp.pyi index 15a0cae27..82a1f68f9 100644 --- a/django-stubs/core/servers/basehttp.pyi +++ b/django-stubs/core/servers/basehttp.pyi @@ -7,9 +7,9 @@ from django.core.handlers.wsgi import WSGIHandler, WSGIRequest from django.core.wsgi import get_wsgi_application as get_wsgi_application # noqa: F401 class WSGIServer(simple_server.WSGIServer): - request_queue_size: int = ... - address_family: Any = ... - allow_reuse_address: Any = ... + request_queue_size: int + address_family: Any + allow_reuse_address: Any def __init__(self, *args: Any, ipv6: bool = ..., allow_reuse_address: bool = ..., **kwargs: Any) -> None: ... def handle_error(self, request: Any, client_address: Any) -> None: ... @@ -24,13 +24,13 @@ class WSGIRequestHandler(simple_server.WSGIRequestHandler): request: WSGIRequest rfile: BytesIO wfile: BytesIO - protocol_version: str = ... + protocol_version: str def address_string(self) -> str: ... def log_message(self, format: str, *args: Any) -> None: ... def get_environ(self) -> Dict[str, str]: ... - raw_requestline: bytes = ... - requestline: str = ... - request_version: str = ... + raw_requestline: bytes + requestline: str + request_version: str def handle(self) -> None: ... def get_internal_wsgi_application() -> WSGIHandler: ... diff --git a/django-stubs/core/signals.pyi b/django-stubs/core/signals.pyi index edd2b3089..ff59bd05a 100644 --- a/django-stubs/core/signals.pyi +++ b/django-stubs/core/signals.pyi @@ -1,6 +1,6 @@ from django.dispatch import Signal -request_started: Signal = ... -request_finished: Signal = ... -got_request_exception: Signal = ... -setting_changed: Signal = ... +request_started: Signal +request_finished: Signal +got_request_exception: Signal +setting_changed: Signal diff --git a/django-stubs/core/signing.pyi b/django-stubs/core/signing.pyi index 605ba49b4..0b607cdfc 100644 --- a/django-stubs/core/signing.pyi +++ b/django-stubs/core/signing.pyi @@ -33,10 +33,10 @@ def loads( ) -> Any: ... class Signer: - key: str = ... - sep: str = ... - salt: str = ... - algorithm: str = ... + key: str + sep: str + salt: str + algorithm: str def __init__( self, key: bytes | str | None = ..., diff --git a/django-stubs/core/validators.pyi b/django-stubs/core/validators.pyi index 404ab32f2..90d362ad8 100644 --- a/django-stubs/core/validators.pyi +++ b/django-stubs/core/validators.pyi @@ -11,11 +11,11 @@ _Regex = str | Pattern[str] _ValidatorCallable = Callable[[Any], None] class RegexValidator: - regex: _Regex = ... # Pattern[str] on instance, but may be str on class definition - message: str | _StrPromise = ... - code: str = ... - inverse_match: bool = ... - flags: int = ... + regex: _Regex # Pattern[str] on instance, but may be str on class definition + message: str | _StrPromise + code: str + inverse_match: bool + flags: int def __init__( self, regex: _Regex | None = ..., @@ -27,28 +27,28 @@ class RegexValidator: def __call__(self, value: Any) -> None: ... class URLValidator(RegexValidator): - ul: str = ... - ipv4_re: str = ... - ipv6_re: str = ... - hostname_re: str = ... - domain_re: str = ... - tld_re: str = ... - host_re: str = ... - schemes: Sequence[str] = ... + ul: str + ipv4_re: str + ipv6_re: str + hostname_re: str + domain_re: str + tld_re: str + host_re: str + schemes: Sequence[str] def __init__(self, schemes: Sequence[str] | None = ..., **kwargs: Any) -> None: ... def __call__(self, value: str) -> None: ... -integer_validator: RegexValidator = ... +integer_validator: RegexValidator def validate_integer(value: float | str | None) -> None: ... class EmailValidator: - message: str = ... - code: str = ... - user_regex: Pattern[str] = ... - domain_regex: Pattern[str] = ... - literal_regex: Pattern[str] = ... - domain_allowlist: Sequence[str] = ... + message: str + code: str + user_regex: Pattern[str] + domain_regex: Pattern[str] + literal_regex: Pattern[str] + domain_allowlist: Sequence[str] def __init__( self, message: str | None = ..., @@ -65,11 +65,11 @@ class EmailValidator: def validate_domain_part(self, domain_part: str) -> bool: ... def __eq__(self, other: Any) -> bool: ... -validate_email: EmailValidator = ... -slug_re: Pattern[str] = ... -validate_slug: RegexValidator = ... -slug_unicode_re: Pattern[str] = ... -validate_unicode_slug: RegexValidator = ... +validate_email: EmailValidator +slug_re: Pattern[str] +validate_slug: RegexValidator +slug_unicode_re: Pattern[str] +validate_unicode_slug: RegexValidator def validate_ipv4_address(value: str) -> None: ... def validate_ipv6_address(value: str) -> None: ... @@ -86,9 +86,9 @@ def int_list_validator( validate_comma_separated_integer_list: RegexValidator class BaseValidator: - message: str = ... - code: str = ... - limit_value: Any = ... + message: str + code: str + limit_value: Any def __init__(self, limit_value: Any, message: str | None = ...) -> None: ... def __call__(self, value: Any) -> None: ... def compare(self, a: Any, b: Any) -> bool: ... @@ -96,39 +96,39 @@ class BaseValidator: def __eq__(self, other: Any) -> bool: ... class MaxValueValidator(BaseValidator): - message: str = ... - code: str = ... + message: str + code: str def compare(self, a: Any, b: Any) -> bool: ... class MinValueValidator(BaseValidator): - message: str = ... - code: str = ... + message: str + code: str def compare(self, a: Any, b: Any) -> bool: ... class MinLengthValidator(BaseValidator): - message: str = ... - code: str = ... + message: str + code: str def compare(self, a: Any, b: Any) -> bool: ... def clean(self, x: Sized) -> int: ... class MaxLengthValidator(BaseValidator): - message: str = ... - code: str = ... + message: str + code: str def compare(self, a: Any, b: Any) -> bool: ... def clean(self, x: Sized) -> int: ... class DecimalValidator: - messages: Dict[str, str] = ... - max_digits: int | None = ... - decimal_places: int | None = ... + messages: Dict[str, str] + max_digits: int | None + decimal_places: int | None def __init__(self, max_digits: int | None, decimal_places: int | None) -> None: ... def __call__(self, value: Decimal) -> None: ... def __eq__(self, other: Any) -> bool: ... class FileExtensionValidator: - message: str = ... - code: str = ... - allowed_extensions: Collection[str] | None = ... + message: str + code: str + allowed_extensions: Collection[str] | None def __init__( self, allowed_extensions: Collection[str] | None = ..., @@ -141,7 +141,7 @@ def get_available_image_extensions() -> Sequence[str]: ... def validate_image_file_extension(value: File) -> None: ... class ProhibitNullCharactersValidator: - message: str = ... - code: str = ... + message: str + code: str def __init__(self, message: str | None = ..., code: str | None = ...) -> None: ... def __call__(self, value: Any) -> None: ... diff --git a/django-stubs/db/backends/base/base.pyi b/django-stubs/db/backends/base/base.pyi index 04ae26b22..639ba1460 100644 --- a/django-stubs/db/backends/base/base.pyi +++ b/django-stubs/db/backends/base/base.pyi @@ -18,43 +18,43 @@ _T = TypeVar("_T", bound="BaseDatabaseWrapper") _ExecuteWrapper = Callable[[Callable[[str, Any, bool, Dict[str, Any]], Any], str, Any, bool, Dict[str, Any]], Any] class BaseDatabaseWrapper: - data_types: Dict[str, str] = ... - data_types_suffix: Dict[str, str] = ... - data_type_check_constraints: Dict[str, str] = ... - vendor: str = ... - display_name: str = ... - SchemaEditorClass: Type[BaseDatabaseSchemaEditor] = ... - client_class: Type[BaseDatabaseClient] = ... - creation_class: Type[BaseDatabaseCreation] = ... - features_class: Type[BaseDatabaseFeatures] = ... - introspection_class: Type[BaseDatabaseIntrospection] = ... - ops_class: Type[BaseDatabaseOperations] = ... - validation_class: Type[BaseDatabaseValidation] = ... - queries_limit: int = ... - connection: Any = ... - settings_dict: Dict[str, Any] = ... - alias: str = ... - queries_log: Any = ... - force_debug_cursor: bool = ... - autocommit: bool = ... - in_atomic_block: bool = ... - savepoint_state: int = ... - savepoint_ids: List[str] = ... - commit_on_exit: bool = ... - needs_rollback: bool = ... - close_at: float | None = ... - closed_in_transaction: bool = ... - errors_occurred: bool = ... - run_on_commit: List[Tuple[Set[str], Callable[[], None]]] = ... - run_commit_hooks_on_set_autocommit_on: bool = ... - execute_wrappers: List[_ExecuteWrapper] = ... - client: BaseDatabaseClient = ... - creation: BaseDatabaseCreation = ... - features: BaseDatabaseFeatures = ... - introspection: BaseDatabaseIntrospection = ... - ops: BaseDatabaseOperations = ... - validation: BaseDatabaseValidation = ... - operators: MutableMapping[str, str] = ... + data_types: Dict[str, str] + data_types_suffix: Dict[str, str] + data_type_check_constraints: Dict[str, str] + vendor: str + display_name: str + SchemaEditorClass: Type[BaseDatabaseSchemaEditor] + client_class: Type[BaseDatabaseClient] + creation_class: Type[BaseDatabaseCreation] + features_class: Type[BaseDatabaseFeatures] + introspection_class: Type[BaseDatabaseIntrospection] + ops_class: Type[BaseDatabaseOperations] + validation_class: Type[BaseDatabaseValidation] + queries_limit: int + connection: Any + settings_dict: Dict[str, Any] + alias: str + queries_log: Any + force_debug_cursor: bool + autocommit: bool + in_atomic_block: bool + savepoint_state: int + savepoint_ids: List[str] + commit_on_exit: bool + needs_rollback: bool + close_at: float | None + closed_in_transaction: bool + errors_occurred: bool + run_on_commit: List[Tuple[Set[str], Callable[[], None]]] + run_commit_hooks_on_set_autocommit_on: bool + execute_wrappers: List[_ExecuteWrapper] + client: BaseDatabaseClient + creation: BaseDatabaseCreation + features: BaseDatabaseFeatures + introspection: BaseDatabaseIntrospection + ops: BaseDatabaseOperations + validation: BaseDatabaseValidation + operators: MutableMapping[str, str] def __init__(self, settings_dict: Dict[str, Any], alias: str = ...) -> None: ... def ensure_timezone(self) -> bool: ... @property diff --git a/django-stubs/db/backends/base/client.pyi b/django-stubs/db/backends/base/client.pyi index bdf313778..7ea1692d2 100644 --- a/django-stubs/db/backends/base/client.pyi +++ b/django-stubs/db/backends/base/client.pyi @@ -3,7 +3,7 @@ from typing import Any, Dict, Iterable, Sequence, Tuple from django.db.backends.base.base import BaseDatabaseWrapper class BaseDatabaseClient: - executable_name: str | None = ... + executable_name: str | None connection: BaseDatabaseWrapper def __init__(self, connection: BaseDatabaseWrapper) -> None: ... @classmethod diff --git a/django-stubs/db/backends/base/introspection.pyi b/django-stubs/db/backends/base/introspection.pyi index fe9706abd..a383630fe 100644 --- a/django-stubs/db/backends/base/introspection.pyi +++ b/django-stubs/db/backends/base/introspection.pyi @@ -12,7 +12,7 @@ FieldInfo = namedtuple( ) class BaseDatabaseIntrospection: - data_types_reverse: Any = ... + data_types_reverse: Any connection: BaseDatabaseWrapper def __init__(self, connection: BaseDatabaseWrapper) -> None: ... def get_field_type(self, data_type: str, description: FieldInfo) -> str: ... diff --git a/django-stubs/db/backends/base/operations.pyi b/django-stubs/db/backends/base/operations.pyi index 9fad1b069..a5d10cbea 100644 --- a/django-stubs/db/backends/base/operations.pyi +++ b/django-stubs/db/backends/base/operations.pyi @@ -13,17 +13,17 @@ from django.db.models.fields import Field from django.db.models.sql.compiler import SQLCompiler class BaseDatabaseOperations: - compiler_module: str = ... - integer_field_ranges: Dict[str, Tuple[int, int]] = ... - set_operators: Dict[str, str] = ... - cast_data_types: Dict[Any, Any] = ... - cast_char_field_without_max_length: Any = ... - PRECEDING: str = ... - FOLLOWING: str = ... - UNBOUNDED_PRECEDING: str = ... - UNBOUNDED_FOLLOWING: str = ... - CURRENT_ROW: str = ... - explain_prefix: str | None = ... + compiler_module: str + integer_field_ranges: Dict[str, Tuple[int, int]] + set_operators: Dict[str, str] + cast_data_types: Dict[Any, Any] + cast_char_field_without_max_length: Any + PRECEDING: str + FOLLOWING: str + UNBOUNDED_PRECEDING: str + UNBOUNDED_FOLLOWING: str + CURRENT_ROW: str + explain_prefix: str | None connection: BaseDatabaseWrapper def __init__(self, connection: BaseDatabaseWrapper) -> None: ... def autoinc_sql(self, table: str, column: str) -> str | None: ... @@ -73,7 +73,7 @@ class BaseDatabaseOperations: def end_transaction_sql(self, success: bool = ...) -> str: ... def tablespace_sql(self, tablespace: str | None, inline: bool = ...) -> str: ... def prep_for_like_query(self, x: str) -> str: ... - prep_for_iexact_query: Any = ... + prep_for_iexact_query: Any def validate_autopk_value(self, value: int) -> int: ... def adapt_unknown_value(self, value: Any) -> Any: ... def adapt_datefield_value(self, value: date | None) -> str | None: ... diff --git a/django-stubs/db/backends/base/schema.pyi b/django-stubs/db/backends/base/schema.pyi index 292faaa49..3d35b31a9 100644 --- a/django-stubs/db/backends/base/schema.pyi +++ b/django-stubs/db/backends/base/schema.pyi @@ -11,42 +11,42 @@ from django.db.models.indexes import Index logger: Logger class BaseDatabaseSchemaEditor(ContextManager[Any]): - sql_create_table: str = ... - sql_rename_table: str = ... - sql_retablespace_table: str = ... - sql_delete_table: str = ... - sql_create_column: str = ... - sql_alter_column: str = ... - sql_alter_column_type: str = ... - sql_alter_column_null: str = ... - sql_alter_column_not_null: str = ... - sql_alter_column_default: str = ... - sql_alter_column_no_default: str = ... - sql_delete_column: str = ... - sql_rename_column: str = ... - sql_update_with_default: str = ... - sql_create_check: str = ... - sql_delete_check: str = ... - sql_create_unique: str = ... - sql_delete_unique: str = ... + sql_create_table: str + sql_rename_table: str + sql_retablespace_table: str + sql_delete_table: str + sql_create_column: str + sql_alter_column: str + sql_alter_column_type: str + sql_alter_column_null: str + sql_alter_column_not_null: str + sql_alter_column_default: str + sql_alter_column_no_default: str + sql_delete_column: str + sql_rename_column: str + sql_update_with_default: str + sql_create_check: str + sql_delete_check: str + sql_create_unique: str + sql_delete_unique: str - sql_create_fk: str = ... - sql_create_inline_fk: str | None = ... - sql_create_column_inline_fk: str | None = ... - sql_delete_fk: str = ... + sql_create_fk: str + sql_create_inline_fk: str | None + sql_create_column_inline_fk: str | None + sql_delete_fk: str - sql_create_index: str = ... - sql_delete_index: str = ... - sql_create_pk: str = ... - sql_delete_pk: str = ... - sql_delete_procedure: str = ... - connection: BaseDatabaseWrapper = ... - collect_sql: bool = ... - collected_sql: Any = ... - atomic_migration: Any = ... + sql_create_index: str + sql_delete_index: str + sql_create_pk: str + sql_delete_pk: str + sql_delete_procedure: str + connection: BaseDatabaseWrapper + collect_sql: bool + collected_sql: Any + atomic_migration: Any def __init__(self, connection: BaseDatabaseWrapper, collect_sql: bool = ..., atomic: bool = ...) -> None: ... - deferred_sql: Any = ... - atomic: Any = ... + deferred_sql: Any + atomic: Any def __enter__(self) -> BaseDatabaseSchemaEditor: ... def __exit__( self, diff --git a/django-stubs/db/backends/base/validation.pyi b/django-stubs/db/backends/base/validation.pyi index 27fdd627d..db1a4a6de 100644 --- a/django-stubs/db/backends/base/validation.pyi +++ b/django-stubs/db/backends/base/validation.pyi @@ -4,7 +4,7 @@ from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.fields import Field class BaseDatabaseValidation: - connection: BaseDatabaseWrapper = ... + connection: BaseDatabaseWrapper def __init__(self, connection: BaseDatabaseWrapper) -> None: ... def check(self, **kwargs: Any) -> List[Any]: ... def check_field(self, field: Field, **kwargs: Any) -> List[Any]: ... diff --git a/django-stubs/db/backends/ddl_references.pyi b/django-stubs/db/backends/ddl_references.pyi index 91a32d70c..469bbb898 100644 --- a/django-stubs/db/backends/ddl_references.pyi +++ b/django-stubs/db/backends/ddl_references.pyi @@ -14,15 +14,15 @@ class Reference: def rename_column_references(self, table: Any, old_column: Any, new_column: Any) -> None: ... class Table(Reference): - table: str = ... - quote_name: _QuoteCallable = ... + table: str + quote_name: _QuoteCallable def __init__(self, table: str, quote_name: _QuoteCallable) -> None: ... def references_table(self, table: str) -> bool: ... def rename_table_references(self, old_table: str, new_table: str) -> None: ... class TableColumns(Table): - table: str = ... - columns: List[str] = ... + table: str + columns: List[str] def __init__(self, table: str, columns: List[str]) -> None: ... def references_column(self, table: str, column: str) -> bool: ... def rename_column_references(self, table: str, old_column: str, new_column: str) -> None: ... @@ -30,8 +30,8 @@ class TableColumns(Table): class Columns(TableColumns): columns: List[str] table: str - quote_name: _QuoteCallable = ... - col_suffixes: Sequence[str] = ... + quote_name: _QuoteCallable + col_suffixes: Sequence[str] def __init__( self, table: str, columns: List[str], quote_name: _QuoteCallable, col_suffixes: Sequence[str] = ... ) -> None: ... @@ -44,12 +44,12 @@ class _NameCallable(Protocol): class IndexName(TableColumns): columns: List[str] table: str - suffix: str = ... - create_index_name: _NameCallable = ... + suffix: str + create_index_name: _NameCallable def __init__(self, table: str, columns: List[str], suffix: str, create_index_name: _NameCallable) -> None: ... class IndexColumns(Columns): - opclasses: Any = ... + opclasses: Any def __init__( self, table: Any, columns: Any, quote_name: Any, col_suffixes: Any = ..., opclasses: Any = ... ) -> None: ... @@ -57,9 +57,9 @@ class IndexColumns(Columns): class ForeignKeyName(TableColumns): columns: List[str] table: str - to_reference: TableColumns = ... - suffix_template: str = ... - create_fk_name: _NameCallable = ... + to_reference: TableColumns + suffix_template: str + create_fk_name: _NameCallable def __init__( self, from_table: str, @@ -75,8 +75,8 @@ class ForeignKeyName(TableColumns): def rename_column_references(self, table: str, old_column: str, new_column: str) -> None: ... class Statement(Reference): - template: str = ... - parts: Dict[str, Table] = ... + template: str + parts: Dict[str, Table] def __init__(self, template: str, **parts: Any) -> None: ... def references_table(self, table: str) -> bool: ... def references_column(self, table: str, column: str) -> bool: ... diff --git a/django-stubs/db/backends/dummy/base.pyi b/django-stubs/db/backends/dummy/base.pyi index 3f969d819..b74c9cbdc 100644 --- a/django-stubs/db/backends/dummy/base.pyi +++ b/django-stubs/db/backends/dummy/base.pyi @@ -10,21 +10,21 @@ def complain(*args: Any, **kwargs: Any) -> Any: ... def ignore(*args: Any, **kwargs: Any) -> None: ... class DatabaseOperations(BaseDatabaseOperations): - quote_name: Any = ... + quote_name: Any class DatabaseClient(BaseDatabaseClient): ... class DatabaseCreation(BaseDatabaseCreation): - create_test_db: Any = ... - destroy_test_db: Any = ... + create_test_db: Any + destroy_test_db: Any class DatabaseIntrospection(BaseDatabaseIntrospection): - get_table_list: Any = ... - get_table_description: Any = ... - get_relations: Any = ... - get_indexes: Any = ... - get_key_columns: Any = ... + get_table_list: Any + get_table_description: Any + get_relations: Any + get_indexes: Any + get_key_columns: Any class DatabaseWrapper(BaseDatabaseWrapper): - operators: Any = ... - ensure_connection: Any = ... + operators: Any + ensure_connection: Any diff --git a/django-stubs/db/backends/dummy/features.pyi b/django-stubs/db/backends/dummy/features.pyi index 7e05ffdd0..61142f424 100644 --- a/django-stubs/db/backends/dummy/features.pyi +++ b/django-stubs/db/backends/dummy/features.pyi @@ -1,5 +1,5 @@ from django.db.backends.base.features import BaseDatabaseFeatures as BaseDatabaseFeatures class DummyDatabaseFeatures(BaseDatabaseFeatures): - supports_transactions: bool = ... - uses_savepoints: bool = ... + supports_transactions: bool + uses_savepoints: bool diff --git a/django-stubs/db/backends/mysql/base.pyi b/django-stubs/db/backends/mysql/base.pyi index 0da5925f6..fb8bc2e8f 100644 --- a/django-stubs/db/backends/mysql/base.pyi +++ b/django-stubs/db/backends/mysql/base.pyi @@ -15,8 +15,8 @@ django_conversions: Any server_version_re: Any class CursorWrapper: - codes_for_integrityerror: Any = ... - cursor: Any = ... + codes_for_integrityerror: Any + cursor: Any def __init__(self, cursor: Any) -> None: ... def execute(self, query: Any, args: Any | None = ...) -> Any: ... def executemany(self, query: Any, args: Any) -> Any: ... @@ -38,21 +38,21 @@ class DatabaseWrapper(BaseDatabaseWrapper): ops_class: Type[DatabaseOperations] validation_class: Type[DatabaseValidation] - vendor: str = ... - data_types: Any = ... - operators: Any = ... - pattern_esc: str = ... - pattern_ops: Any = ... - isolation_levels: Any = ... - Database: Any = ... - SchemaEditorClass: Any = ... - isolation_level: Any = ... + vendor: str + data_types: Any + operators: Any + pattern_esc: str + pattern_ops: Any + isolation_levels: Any + Database: Any + SchemaEditorClass: Any + isolation_level: Any def get_connection_params(self) -> Dict[str, Any]: ... def get_new_connection(self, conn_params: Any) -> Any: ... def init_connection_state(self) -> None: ... def create_cursor(self, name: Any | None = ...) -> CursorWrapper: ... def disable_constraint_checking(self) -> Literal[True]: ... - needs_rollback: Any = ... + needs_rollback: Any def enable_constraint_checking(self) -> None: ... def check_constraints(self, table_names: Any | None = ...) -> None: ... def is_usable(self) -> bool: ... diff --git a/django-stubs/db/backends/mysql/client.pyi b/django-stubs/db/backends/mysql/client.pyi index df2d36a4b..893189a0b 100644 --- a/django-stubs/db/backends/mysql/client.pyi +++ b/django-stubs/db/backends/mysql/client.pyi @@ -5,7 +5,7 @@ from django.db.backends.mysql.base import DatabaseWrapper class DatabaseClient(BaseDatabaseClient): connection: DatabaseWrapper - executable_name: str = ... + executable_name: str @classmethod def settings_to_cmd_args_env( cls, diff --git a/django-stubs/db/backends/mysql/features.pyi b/django-stubs/db/backends/mysql/features.pyi index e66b6a0be..b38deb4ba 100644 --- a/django-stubs/db/backends/mysql/features.pyi +++ b/django-stubs/db/backends/mysql/features.pyi @@ -5,42 +5,42 @@ from django.db.backends.mysql.base import DatabaseWrapper class DatabaseFeatures(BaseDatabaseFeatures): connection: DatabaseWrapper - empty_fetchmany_value: Any = ... - allows_group_by_pk: bool = ... - related_fields_match_type: bool = ... - allow_sliced_subqueries_with_in: bool = ... - has_select_for_update: bool = ... - supports_forward_references: bool = ... - supports_regex_backreferencing: bool = ... - supports_date_lookup_using_string: bool = ... - can_introspect_autofield: bool = ... - can_introspect_binary_field: bool = ... - can_introspect_duration_field: bool = ... - can_introspect_small_integer_field: bool = ... - can_introspect_positive_integer_field: bool = ... - introspected_boolean_field_type: str = ... - supports_timezones: bool = ... - requires_explicit_null_ordering_when_grouping: bool = ... - can_release_savepoints: bool = ... - atomic_transactions: bool = ... - can_clone_databases: bool = ... - supports_temporal_subtraction: bool = ... - supports_select_intersection: bool = ... - supports_select_difference: bool = ... - supports_slicing_ordering_in_compound: bool = ... - supports_index_on_text_field: bool = ... - has_case_insensitive_like: bool = ... - create_test_procedure_without_params_sql: str = ... - create_test_procedure_with_int_param_sql: str = ... - db_functions_convert_bytes_to_str: bool = ... - supports_partial_indexes: bool = ... - supports_order_by_nulls_modifier: bool = ... - order_by_nulls_first: bool = ... + empty_fetchmany_value: Any + allows_group_by_pk: bool + related_fields_match_type: bool + allow_sliced_subqueries_with_in: bool + has_select_for_update: bool + supports_forward_references: bool + supports_regex_backreferencing: bool + supports_date_lookup_using_string: bool + can_introspect_autofield: bool + can_introspect_binary_field: bool + can_introspect_duration_field: bool + can_introspect_small_integer_field: bool + can_introspect_positive_integer_field: bool + introspected_boolean_field_type: str + supports_timezones: bool + requires_explicit_null_ordering_when_grouping: bool + can_release_savepoints: bool + atomic_transactions: bool + can_clone_databases: bool + supports_temporal_subtraction: bool + supports_select_intersection: bool + supports_select_difference: bool + supports_slicing_ordering_in_compound: bool + supports_index_on_text_field: bool + has_case_insensitive_like: bool + create_test_procedure_without_params_sql: str + create_test_procedure_with_int_param_sql: str + db_functions_convert_bytes_to_str: bool + supports_partial_indexes: bool + supports_order_by_nulls_modifier: bool + order_by_nulls_first: bool # fake properties (until `property` is generic) - supports_frame_range_fixed_distance: bool = ... - supports_table_check_constraints: bool = ... - can_return_rows_from_bulk_insert: bool = ... + supports_frame_range_fixed_distance: bool + supports_table_check_constraints: bool + can_return_rows_from_bulk_insert: bool @property def allows_auto_pk_0(self) -> bool: ... # type: ignore @property diff --git a/django-stubs/db/backends/mysql/introspection.pyi b/django-stubs/db/backends/mysql/introspection.pyi index e39af165d..97ca492d0 100644 --- a/django-stubs/db/backends/mysql/introspection.pyi +++ b/django-stubs/db/backends/mysql/introspection.pyi @@ -22,7 +22,7 @@ InfoLine = namedtuple( class DatabaseIntrospection(BaseDatabaseIntrospection): connection: DatabaseWrapper - data_types_reverse: Any = ... + data_types_reverse: Any def get_field_type(self, data_type: Any, description: Any) -> Any: ... def get_table_list(self, cursor: Any) -> Any: ... def get_table_description(self, cursor: Any, table_name: Any) -> Any: ... diff --git a/django-stubs/db/backends/mysql/operations.pyi b/django-stubs/db/backends/mysql/operations.pyi index 457639c09..8dbba2472 100644 --- a/django-stubs/db/backends/mysql/operations.pyi +++ b/django-stubs/db/backends/mysql/operations.pyi @@ -5,11 +5,11 @@ from django.db.backends.mysql.base import DatabaseWrapper class DatabaseOperations(BaseDatabaseOperations): connection: DatabaseWrapper - compiler_module: str = ... - integer_field_ranges: Dict[str, Tuple[int, int]] = ... - cast_data_types: Dict[str, str] = ... - cast_char_field_without_max_length: str = ... - explain_prefix: str = ... + compiler_module: str + integer_field_ranges: Dict[str, Tuple[int, int]] + cast_data_types: Dict[str, str] + cast_char_field_without_max_length: str + explain_prefix: str def date_extract_sql(self, lookup_type: str, field_name: str) -> Any: ... def date_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None = ...) -> Any: ... def datetime_cast_date_sql(self, field_name: str, tzname: str | None) -> Any: ... diff --git a/django-stubs/db/backends/mysql/schema.pyi b/django-stubs/db/backends/mysql/schema.pyi index 474d0168d..bc372a08a 100644 --- a/django-stubs/db/backends/mysql/schema.pyi +++ b/django-stubs/db/backends/mysql/schema.pyi @@ -5,18 +5,18 @@ from django.db.backends.mysql.base import DatabaseWrapper class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): connection: DatabaseWrapper - sql_rename_table: str = ... - sql_alter_column_null: str = ... - sql_alter_column_not_null: str = ... - sql_alter_column_type: str = ... - sql_delete_column: str = ... - sql_delete_unique: str = ... - sql_create_column_inline_fk: str = ... - sql_delete_fk: str = ... - sql_delete_index: str = ... - sql_create_pk: str = ... - sql_delete_pk: str = ... - sql_create_index: str = ... + sql_rename_table: str + sql_alter_column_null: str + sql_alter_column_not_null: str + sql_alter_column_type: str + sql_delete_column: str + sql_delete_unique: str + sql_create_column_inline_fk: str + sql_delete_fk: str + sql_delete_index: str + sql_create_pk: str + sql_delete_pk: str + sql_create_index: str @property def sql_delete_check(self) -> str: ... # type: ignore[override] @property diff --git a/django-stubs/db/backends/oracle/base.pyi b/django-stubs/db/backends/oracle/base.pyi index db72bbfc0..3ce823f75 100644 --- a/django-stubs/db/backends/oracle/base.pyi +++ b/django-stubs/db/backends/oracle/base.pyi @@ -31,18 +31,18 @@ class DatabaseWrapper(BaseDatabaseWrapper): ops_class: Type[DatabaseOperations] validation_class: Type[DatabaseValidation] - vendor: str = ... - display_name: str = ... - data_types: Any = ... - data_type_check_constraints: Any = ... - operators: Any = ... - pattern_esc: str = ... - Database: Any = ... - SchemaEditorClass: Any = ... + vendor: str + display_name: str + data_types: Any + data_type_check_constraints: Any + operators: Any + pattern_esc: str + Database: Any + SchemaEditorClass: Any def __init__(self, *args: Any, **kwargs: Any) -> None: ... def get_connection_params(self) -> Any: ... def get_new_connection(self, conn_params: Any) -> Any: ... - pattern_ops: Any = ... + pattern_ops: Any def init_connection_state(self) -> None: ... def create_cursor(self, name: Any | None = ...) -> Any: ... def check_constraints(self, table_names: Any | None = ...) -> None: ... @@ -53,20 +53,20 @@ class DatabaseWrapper(BaseDatabaseWrapper): def oracle_version(self) -> Any: ... class OracleParam: - force_bytes: Any = ... - input_size: Any = ... + force_bytes: Any + input_size: Any def __init__(self, param: Any, cursor: Any, strings_only: bool = ...) -> None: ... class VariableWrapper: - var: Any = ... + var: Any def __init__(self, var: Any) -> None: ... def bind_parameter(self, cursor: Any) -> Any: ... def __getattr__(self, key: Any) -> Any: ... def __setattr__(self, key: Any, value: Any) -> None: ... class FormatStylePlaceholderCursor: - charset: str = ... - cursor: Any = ... + charset: str + cursor: Any def __init__(self, connection: Any) -> None: ... def execute(self, query: Any, params: Any | None = ...) -> Any: ... def executemany(self, query: Any, params: Any | None = ...) -> Any: ... diff --git a/django-stubs/db/backends/oracle/client.pyi b/django-stubs/db/backends/oracle/client.pyi index cb97ca4d1..321e0250d 100644 --- a/django-stubs/db/backends/oracle/client.pyi +++ b/django-stubs/db/backends/oracle/client.pyi @@ -5,8 +5,8 @@ from django.db.backends.oracle.base import DatabaseWrapper class DatabaseClient(BaseDatabaseClient): connection: DatabaseWrapper - executable_name: str = ... - wrapper_name: str = ... + executable_name: str + wrapper_name: str @staticmethod def connect_string(settings_dict: Dict[str, Any]) -> str: ... @classmethod diff --git a/django-stubs/db/backends/oracle/features.pyi b/django-stubs/db/backends/oracle/features.pyi index 091e37ab8..540998b44 100644 --- a/django-stubs/db/backends/oracle/features.pyi +++ b/django-stubs/db/backends/oracle/features.pyi @@ -5,47 +5,47 @@ from django.db.backends.oracle.base import DatabaseWrapper class DatabaseFeatures(BaseDatabaseFeatures): connection: DatabaseWrapper - interprets_empty_strings_as_nulls: bool = ... - has_select_for_update: bool = ... - has_select_for_update_nowait: bool = ... - has_select_for_update_skip_locked: bool = ... - has_select_for_update_of: bool = ... - select_for_update_of_column: bool = ... - can_return_columns_from_insert: bool = ... - can_introspect_autofield: bool = ... - supports_subqueries_in_group_by: bool = ... - supports_transactions: bool = ... - supports_timezones: bool = ... - has_native_duration_field: bool = ... - can_defer_constraint_checks: bool = ... - supports_partially_nullable_unique_constraints: bool = ... - supports_deferrable_unique_constraints: bool = ... - truncates_names: bool = ... - supports_tablespaces: bool = ... - supports_sequence_reset: bool = ... - can_introspect_materialized_views: bool = ... - can_introspect_time_field: bool = ... - atomic_transactions: bool = ... - supports_combined_alters: bool = ... - nulls_order_largest: bool = ... - requires_literal_defaults: bool = ... - closed_cursor_error_class: Any = ... - bare_select_suffix: str = ... - supports_select_for_update_with_limit: bool = ... - supports_temporal_subtraction: bool = ... - ignores_table_name_case: bool = ... - supports_index_on_text_field: bool = ... - has_case_insensitive_like: bool = ... - create_test_procedure_without_params_sql: str = ... - create_test_procedure_with_int_param_sql: str = ... - supports_callproc_kwargs: bool = ... - supports_over_clause: bool = ... - supports_frame_range_fixed_distance: bool = ... - supports_ignore_conflicts: bool = ... - max_query_params: Any = ... - supports_partial_indexes: bool = ... - supports_slicing_ordering_in_compound: bool = ... - allows_multiple_constraints_on_same_fields: bool = ... - supports_boolean_expr_in_select_clause: bool = ... - supports_primitives_in_json_field: bool = ... - supports_json_field_contains: bool = ... + interprets_empty_strings_as_nulls: bool + has_select_for_update: bool + has_select_for_update_nowait: bool + has_select_for_update_skip_locked: bool + has_select_for_update_of: bool + select_for_update_of_column: bool + can_return_columns_from_insert: bool + can_introspect_autofield: bool + supports_subqueries_in_group_by: bool + supports_transactions: bool + supports_timezones: bool + has_native_duration_field: bool + can_defer_constraint_checks: bool + supports_partially_nullable_unique_constraints: bool + supports_deferrable_unique_constraints: bool + truncates_names: bool + supports_tablespaces: bool + supports_sequence_reset: bool + can_introspect_materialized_views: bool + can_introspect_time_field: bool + atomic_transactions: bool + supports_combined_alters: bool + nulls_order_largest: bool + requires_literal_defaults: bool + closed_cursor_error_class: Any + bare_select_suffix: str + supports_select_for_update_with_limit: bool + supports_temporal_subtraction: bool + ignores_table_name_case: bool + supports_index_on_text_field: bool + has_case_insensitive_like: bool + create_test_procedure_without_params_sql: str + create_test_procedure_with_int_param_sql: str + supports_callproc_kwargs: bool + supports_over_clause: bool + supports_frame_range_fixed_distance: bool + supports_ignore_conflicts: bool + max_query_params: Any + supports_partial_indexes: bool + supports_slicing_ordering_in_compound: bool + allows_multiple_constraints_on_same_fields: bool + supports_boolean_expr_in_select_clause: bool + supports_primitives_in_json_field: bool + supports_json_field_contains: bool diff --git a/django-stubs/db/backends/oracle/functions.pyi b/django-stubs/db/backends/oracle/functions.pyi index 49d78c25e..828a78488 100644 --- a/django-stubs/db/backends/oracle/functions.pyi +++ b/django-stubs/db/backends/oracle/functions.pyi @@ -3,11 +3,11 @@ from typing import Any from django.db.models import Func as Func class IntervalToSeconds(Func): - function: str = ... - template: str = ... + function: str + template: str def __init__(self, expression: Any, *, output_field: Any | None = ..., **extra: Any) -> None: ... class SecondsToInterval(Func): - function: str = ... - template: str = ... + function: str + template: str def __init__(self, expression: Any, *, output_field: Any | None = ..., **extra: Any) -> None: ... diff --git a/django-stubs/db/backends/oracle/introspection.pyi b/django-stubs/db/backends/oracle/introspection.pyi index 4d70ca374..07f07635c 100644 --- a/django-stubs/db/backends/oracle/introspection.pyi +++ b/django-stubs/db/backends/oracle/introspection.pyi @@ -7,7 +7,7 @@ FieldInfo: Any class DatabaseIntrospection(BaseDatabaseIntrospection): connection: DatabaseWrapper - cache_bust_counter: int = ... + cache_bust_counter: int @property def data_types_reverse(self) -> Any: ... def get_field_type(self, data_type: Any, description: Any) -> Any: ... diff --git a/django-stubs/db/backends/oracle/operations.pyi b/django-stubs/db/backends/oracle/operations.pyi index e7d08d861..23e0da20d 100644 --- a/django-stubs/db/backends/oracle/operations.pyi +++ b/django-stubs/db/backends/oracle/operations.pyi @@ -5,10 +5,10 @@ from django.db.backends.oracle.base import DatabaseWrapper class DatabaseOperations(BaseDatabaseOperations): connection: DatabaseWrapper - integer_field_ranges: Any = ... - set_operators: Any = ... - cast_char_field_without_max_length: str = ... - cast_data_types: Any = ... + integer_field_ranges: Any + set_operators: Any + cast_char_field_without_max_length: str + cast_data_types: Any def cache_key_culling_sql(self) -> str: ... def date_extract_sql(self, lookup_type: str, field_name: str) -> str: ... def date_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None = ...) -> str: ... diff --git a/django-stubs/db/backends/oracle/schema.pyi b/django-stubs/db/backends/oracle/schema.pyi index f022ebead..e8d940942 100644 --- a/django-stubs/db/backends/oracle/schema.pyi +++ b/django-stubs/db/backends/oracle/schema.pyi @@ -5,16 +5,16 @@ from django.db.backends.oracle.base import DatabaseWrapper class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): connection: DatabaseWrapper - sql_create_column: str = ... - sql_alter_column_type: str = ... - sql_alter_column_null: str = ... - sql_alter_column_not_null: str = ... - sql_alter_column_default: str = ... - sql_alter_column_no_default: str = ... - sql_delete_column: str = ... - sql_create_column_inline_fk: str = ... - sql_delete_table: str = ... - sql_create_index: str = ... + sql_create_column: str + sql_alter_column_type: str + sql_alter_column_null: str + sql_alter_column_not_null: str + sql_alter_column_default: str + sql_alter_column_no_default: str + sql_delete_column: str + sql_create_column_inline_fk: str + sql_delete_table: str + sql_create_index: str def quote_value(self, value: Any) -> str: ... def remove_field(self, model: Any, field: Any) -> None: ... def delete_model(self, model: Any) -> None: ... diff --git a/django-stubs/db/backends/oracle/utils.pyi b/django-stubs/db/backends/oracle/utils.pyi index 081b0a743..8aaf0edcd 100644 --- a/django-stubs/db/backends/oracle/utils.pyi +++ b/django-stubs/db/backends/oracle/utils.pyi @@ -2,23 +2,23 @@ import datetime from typing import Any class InsertVar: - types: Any = ... - db_type: Any = ... - bound_param: Any = ... + types: Any + db_type: Any + bound_param: Any def __init__(self, field: Any) -> None: ... def bind_parameter(self, cursor: Any) -> Any: ... def get_value(self) -> Any: ... class Oracle_datetime(datetime.datetime): - input_size: Any = ... + input_size: Any @classmethod def from_datetime(cls, dt: Any) -> Any: ... class BulkInsertMapper: - BLOB: str = ... - CLOB: str = ... - DATE: str = ... - INTERVAL: str = ... - NUMBER: str = ... - TIMESTAMP: str = ... - types: Any = ... + BLOB: str + CLOB: str + DATE: str + INTERVAL: str + NUMBER: str + TIMESTAMP: str + types: Any diff --git a/django-stubs/db/backends/postgresql/base.pyi b/django-stubs/db/backends/postgresql/base.pyi index 78694da9d..8df163e6d 100644 --- a/django-stubs/db/backends/postgresql/base.pyi +++ b/django-stubs/db/backends/postgresql/base.pyi @@ -13,7 +13,7 @@ from .operations import DatabaseOperations def psycopg2_version() -> Tuple[int, ...]: ... -PSYCOPG2_VERSION: Tuple[int, ...] = ... +PSYCOPG2_VERSION: Tuple[int, ...] class DatabaseWrapper(BaseDatabaseWrapper): client: DatabaseClient @@ -28,12 +28,12 @@ class DatabaseWrapper(BaseDatabaseWrapper): introspection_class: Type[DatabaseIntrospection] ops_class: Type[DatabaseOperations] - operators: Dict[str, str] = ... - pattern_esc: str = ... - pattern_ops: Dict[str, str] = ... + operators: Dict[str, str] + pattern_esc: str + pattern_ops: Dict[str, str] # PostgreSQL backend-specific attributes. - _named_cursor_idx: int = ... + _named_cursor_idx: int @property def pg_version(self) -> int: ... diff --git a/django-stubs/db/backends/postgresql/client.pyi b/django-stubs/db/backends/postgresql/client.pyi index f9e8c8a39..29885c8d9 100644 --- a/django-stubs/db/backends/postgresql/client.pyi +++ b/django-stubs/db/backends/postgresql/client.pyi @@ -5,7 +5,7 @@ from django.db.backends.postgresql.base import DatabaseWrapper class DatabaseClient(BaseDatabaseClient): connection: DatabaseWrapper - executable_name: str = ... + executable_name: str @classmethod def settings_to_cmd_args_env( cls, settings_dict: Dict[str, Any], parameters: Iterable[str] diff --git a/django-stubs/db/backends/postgresql/features.pyi b/django-stubs/db/backends/postgresql/features.pyi index 03fbbb092..7b9b7c929 100644 --- a/django-stubs/db/backends/postgresql/features.pyi +++ b/django-stubs/db/backends/postgresql/features.pyi @@ -5,44 +5,44 @@ from django.db.backends.postgresql.base import DatabaseWrapper class DatabaseFeatures(BaseDatabaseFeatures): connection: DatabaseWrapper - allows_group_by_selected_pks: bool = ... - can_return_columns_from_insert: bool = ... - can_return_rows_from_bulk_insert: bool = ... - has_real_datatype: bool = ... - has_native_uuid_field: bool = ... - has_native_duration_field: bool = ... - has_native_json_field: bool = ... - can_defer_constraint_checks: bool = ... - has_select_for_update: bool = ... - has_select_for_update_nowait: bool = ... - has_select_for_update_of: bool = ... - has_select_for_update_skip_locked: bool = ... - has_select_for_no_key_update: bool = ... - can_release_savepoints: bool = ... - supports_tablespaces: bool = ... - supports_transactions: bool = ... - can_introspect_materialized_views: bool = ... - can_distinct_on_fields: bool = ... - can_rollback_ddl: bool = ... - supports_combined_alters: bool = ... - nulls_order_largest: bool = ... - closed_cursor_error_class: Any = ... - has_case_insensitive_like: bool = ... - greatest_least_ignores_nulls: bool = ... - can_clone_databases: bool = ... - supports_temporal_subtraction: bool = ... - supports_slicing_ordering_in_compound: bool = ... - create_test_procedure_without_params_sql: str = ... - create_test_procedure_with_int_param_sql: str = ... - requires_casted_case_in_updates: bool = ... - supports_over_clause: bool = ... - only_supports_unbounded_with_preceding_and_following: bool = ... - supports_aggregate_filter_clause: bool = ... - supported_explain_formats: Any = ... - validates_explain_options: bool = ... - supports_deferrable_unique_constraints: bool = ... - has_json_operators: bool = ... - json_key_contains_list_matching_requires_list: bool = ... + allows_group_by_selected_pks: bool + can_return_columns_from_insert: bool + can_return_rows_from_bulk_insert: bool + has_real_datatype: bool + has_native_uuid_field: bool + has_native_duration_field: bool + has_native_json_field: bool + can_defer_constraint_checks: bool + has_select_for_update: bool + has_select_for_update_nowait: bool + has_select_for_update_of: bool + has_select_for_update_skip_locked: bool + has_select_for_no_key_update: bool + can_release_savepoints: bool + supports_tablespaces: bool + supports_transactions: bool + can_introspect_materialized_views: bool + can_distinct_on_fields: bool + can_rollback_ddl: bool + supports_combined_alters: bool + nulls_order_largest: bool + closed_cursor_error_class: Any + has_case_insensitive_like: bool + greatest_least_ignores_nulls: bool + can_clone_databases: bool + supports_temporal_subtraction: bool + supports_slicing_ordering_in_compound: bool + create_test_procedure_without_params_sql: str + create_test_procedure_with_int_param_sql: str + requires_casted_case_in_updates: bool + supports_over_clause: bool + only_supports_unbounded_with_preceding_and_following: bool + supports_aggregate_filter_clause: bool + supported_explain_formats: Any + validates_explain_options: bool + supports_deferrable_unique_constraints: bool + has_json_operators: bool + json_key_contains_list_matching_requires_list: bool @property def is_postgresql_10(self) -> bool: ... @property @@ -51,10 +51,10 @@ class DatabaseFeatures(BaseDatabaseFeatures): def is_postgresql_12(self) -> bool: ... @property def is_postgresql_13(self) -> bool: ... - has_brin_autosummarize: bool = ... - has_websearch_to_tsquery: bool = ... - supports_table_partitions: bool = ... - supports_covering_indexes: bool = ... - supports_covering_gist_indexes: bool = ... - supports_non_deterministic_collations: bool = ... - supports_alternate_collation_providers: bool = ... + has_brin_autosummarize: bool + has_websearch_to_tsquery: bool + supports_table_partitions: bool + supports_covering_indexes: bool + supports_covering_gist_indexes: bool + supports_non_deterministic_collations: bool + supports_alternate_collation_providers: bool diff --git a/django-stubs/db/backends/postgresql/introspection.pyi b/django-stubs/db/backends/postgresql/introspection.pyi index 74067db50..e6c0aa4c0 100644 --- a/django-stubs/db/backends/postgresql/introspection.pyi +++ b/django-stubs/db/backends/postgresql/introspection.pyi @@ -5,8 +5,8 @@ from django.db.backends.postgresql.base import DatabaseWrapper class DatabaseIntrospection(BaseDatabaseIntrospection): connection: DatabaseWrapper - data_types_reverse: Any = ... - ignored_tables: Any = ... + data_types_reverse: Any + ignored_tables: Any def get_field_type(self, data_type: Any, description: Any) -> Any: ... def get_table_list(self, cursor: Any) -> Any: ... def get_table_description(self, cursor: Any, table_name: Any) -> Any: ... diff --git a/django-stubs/db/backends/postgresql/schema.pyi b/django-stubs/db/backends/postgresql/schema.pyi index 0dc32ef68..105cee75e 100644 --- a/django-stubs/db/backends/postgresql/schema.pyi +++ b/django-stubs/db/backends/postgresql/schema.pyi @@ -5,17 +5,17 @@ from django.db.backends.postgresql.base import DatabaseWrapper class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): connection: DatabaseWrapper - sql_create_sequence: str = ... - sql_delete_sequence: str = ... - sql_set_sequence_max: str = ... - sql_set_sequence_owner: str = ... - sql_create_index: str = ... - sql_create_index_concurrently: str = ... - sql_delete_index: str = ... - sql_delete_index_concurrently: str = ... - sql_create_column_inline_fk: str = ... - sql_delete_fk: str = ... - sql_delete_procedure: str = ... + sql_create_sequence: str + sql_delete_sequence: str + sql_set_sequence_max: str + sql_set_sequence_owner: str + sql_create_index: str + sql_create_index_concurrently: str + sql_delete_index: str + sql_delete_index_concurrently: str + sql_create_column_inline_fk: str + sql_delete_fk: str + sql_delete_procedure: str def quote_value(self, value: Any) -> str: ... def add_index(self, model: Any, index: Any, concurrently: bool = ...) -> None: ... def remove_index(self, model: Any, index: Any, concurrently: bool = ...) -> None: ... diff --git a/django-stubs/db/backends/signals.pyi b/django-stubs/db/backends/signals.pyi index 3586e1319..79c4207c3 100644 --- a/django-stubs/db/backends/signals.pyi +++ b/django-stubs/db/backends/signals.pyi @@ -1,3 +1,3 @@ from django.dispatch import Signal -connection_created: Signal = ... +connection_created: Signal diff --git a/django-stubs/db/backends/sqlite3/client.pyi b/django-stubs/db/backends/sqlite3/client.pyi index d3cc4cb2e..68a480572 100644 --- a/django-stubs/db/backends/sqlite3/client.pyi +++ b/django-stubs/db/backends/sqlite3/client.pyi @@ -5,7 +5,7 @@ from django.db.backends.sqlite3.base import DatabaseWrapper class DatabaseClient(BaseDatabaseClient): connection: DatabaseWrapper - executable_name: str = ... + executable_name: str @classmethod def settings_to_cmd_args_env( cls, settings_dict: Dict[str, Any], parameters: Iterable[str] diff --git a/django-stubs/db/backends/sqlite3/introspection.pyi b/django-stubs/db/backends/sqlite3/introspection.pyi index 7b329f6f4..4a3434b66 100644 --- a/django-stubs/db/backends/sqlite3/introspection.pyi +++ b/django-stubs/db/backends/sqlite3/introspection.pyi @@ -8,7 +8,7 @@ field_size_re: Any def get_field_size(name: str) -> int | None: ... class FlexibleFieldLookupDict: - base_data_types_reverse: Any = ... + base_data_types_reverse: Any def __getitem__(self, key: str) -> Any: ... class DatabaseIntrospection(BaseDatabaseIntrospection): diff --git a/django-stubs/db/backends/utils.pyi b/django-stubs/db/backends/utils.pyi index 17d19f35c..20430bd33 100644 --- a/django-stubs/db/backends/utils.pyi +++ b/django-stubs/db/backends/utils.pyi @@ -36,10 +36,10 @@ _SQLType = ( _ExecuteParameters = Sequence[_SQLType] | Mapping[str, _SQLType] | None class CursorWrapper: - cursor: Any = ... - db: Any = ... + cursor: Any + db: Any def __init__(self, cursor: Any, db: Any) -> None: ... - WRAP_ERROR_ATTRS: Any = ... + WRAP_ERROR_ATTRS: Any def __getattr__(self, attr: str) -> Any: ... def __iter__(self) -> Iterator[Tuple[Any, ...]]: ... def __enter__(self) -> CursorWrapper: ... diff --git a/django-stubs/db/migrations/autodetector.pyi b/django-stubs/db/migrations/autodetector.pyi index 0eaf8edb6..953d41aea 100644 --- a/django-stubs/db/migrations/autodetector.pyi +++ b/django-stubs/db/migrations/autodetector.pyi @@ -8,10 +8,10 @@ from django.db.migrations.state import ProjectState from django.db.models.fields import Field class MigrationAutodetector: - from_state: ProjectState = ... - to_state: ProjectState = ... - questioner: MigrationQuestioner = ... - existing_apps: Set[Any] = ... + from_state: ProjectState + to_state: ProjectState + questioner: MigrationQuestioner + existing_apps: Set[Any] def __init__( self, from_state: ProjectState, to_state: ProjectState, questioner: MigrationQuestioner | None = ... ) -> None: ... @@ -35,14 +35,14 @@ class MigrationAutodetector: beginning: bool = ..., ) -> None: ... def swappable_first_key(self, item: Tuple[str, str]) -> Tuple[str, str]: ... - renamed_models: Any = ... - renamed_models_rel: Any = ... + renamed_models: Any + renamed_models_rel: Any def generate_renamed_models(self) -> None: ... def generate_created_models(self) -> None: ... def generate_created_proxies(self) -> None: ... def generate_deleted_models(self) -> None: ... def generate_deleted_proxies(self) -> None: ... - renamed_fields: Any = ... + renamed_fields: Any def generate_renamed_fields(self) -> None: ... def generate_added_fields(self) -> None: ... def generate_removed_fields(self) -> None: ... diff --git a/django-stubs/db/migrations/exceptions.pyi b/django-stubs/db/migrations/exceptions.pyi index 401afc26d..4590bdfbe 100644 --- a/django-stubs/db/migrations/exceptions.pyi +++ b/django-stubs/db/migrations/exceptions.pyi @@ -11,9 +11,9 @@ class InvalidBasesError(ValueError): ... class IrreversibleError(RuntimeError): ... class NodeNotFoundError(LookupError): - message: str = ... - origin: Migration | None = ... - node: Tuple[str, str] = ... + message: str + origin: Migration | None + node: Tuple[str, str] def __init__(self, message: str, node: Tuple[str, str], origin: Migration | None = ...) -> None: ... class MigrationSchemaMissing(DatabaseError): ... diff --git a/django-stubs/db/migrations/executor.pyi b/django-stubs/db/migrations/executor.pyi index ea7d21ea8..05f2cc192 100644 --- a/django-stubs/db/migrations/executor.pyi +++ b/django-stubs/db/migrations/executor.pyi @@ -12,10 +12,10 @@ class _ProgressCallbackT(Protocol): def __call__(self, __action: str, __migration: Migration | None = ..., __fake: bool | None = ...) -> None: ... class MigrationExecutor: - connection: BaseDatabaseWrapper = ... - loader: MigrationLoader = ... - recorder: MigrationRecorder = ... - progress_callback: _ProgressCallbackT | None = ... + connection: BaseDatabaseWrapper + loader: MigrationLoader + recorder: MigrationRecorder + progress_callback: _ProgressCallbackT | None def __init__( self, connection: BaseDatabaseWrapper | None, diff --git a/django-stubs/db/migrations/graph.pyi b/django-stubs/db/migrations/graph.pyi index acea2ce9d..cdab16d13 100644 --- a/django-stubs/db/migrations/graph.pyi +++ b/django-stubs/db/migrations/graph.pyi @@ -6,9 +6,9 @@ from django.db.migrations.state import ProjectState RECURSION_DEPTH_WARNING: str class Node: - key: Tuple[str, str] = ... - children: Set[Any] = ... - parents: Set[Any] = ... + key: Tuple[str, str] + children: Set[Any] + parents: Set[Any] def __init__(self, key: Tuple[str, str]) -> None: ... def __eq__(self, other: Any) -> bool: ... def __lt__(self, other: Tuple[str, str] | Node) -> bool: ... @@ -18,15 +18,15 @@ class Node: def add_parent(self, parent: Node) -> None: ... class DummyNode(Node): - origin: Any = ... - error_message: Any = ... + origin: Any + error_message: Any def __init__(self, key: Tuple[str, str], origin: Migration | str, error_message: str) -> None: ... def raise_error(self) -> None: ... class MigrationGraph: - node_map: Dict[Tuple[str, str], Node] = ... - nodes: Dict[Tuple[str, str], Migration | None] = ... - cached: bool = ... + node_map: Dict[Tuple[str, str], Node] + nodes: Dict[Tuple[str, str], Migration | None] + cached: bool def __init__(self) -> None: ... def add_node(self, key: Tuple[str, str], migration: Migration | None) -> None: ... def add_dummy_node(self, key: Tuple[str, str], origin: Migration | str, error_message: str) -> None: ... diff --git a/django-stubs/db/migrations/loader.pyi b/django-stubs/db/migrations/loader.pyi index 3925cc6cb..8e4bcc4e2 100644 --- a/django-stubs/db/migrations/loader.pyi +++ b/django-stubs/db/migrations/loader.pyi @@ -12,10 +12,10 @@ from .exceptions import NodeNotFoundError as NodeNotFoundError MIGRATIONS_MODULE_NAME: str class MigrationLoader: - connection: BaseDatabaseWrapper | None = ... - disk_migrations: Dict[Tuple[str, str], Migration] = ... - applied_migrations: Dict[Tuple[str, str], Migration] = ... - ignore_no_migrations: bool = ... + connection: BaseDatabaseWrapper | None + disk_migrations: Dict[Tuple[str, str], Migration] + applied_migrations: Dict[Tuple[str, str], Migration] + ignore_no_migrations: bool def __init__( self, connection: BaseDatabaseWrapper | None, @@ -25,16 +25,16 @@ class MigrationLoader: ) -> None: ... @classmethod def migrations_module(cls, app_label: str) -> Tuple[str | None, bool]: ... - unmigrated_apps: Set[str] = ... - migrated_apps: Set[str] = ... + unmigrated_apps: Set[str] + migrated_apps: Set[str] def load_disk(self) -> None: ... def get_migration(self, app_label: str, name_prefix: str) -> Migration: ... def get_migration_by_prefix(self, app_label: str, name_prefix: str) -> Migration: ... def check_key(self, key: Tuple[str, str], current_app: str) -> Tuple[str, str] | None: ... def add_internal_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ... def add_external_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ... - graph: Any = ... - replacements: Any = ... + graph: Any + replacements: Any def build_graph(self) -> None: ... def check_consistent_history(self, connection: BaseDatabaseWrapper) -> None: ... def detect_conflicts(self) -> Dict[str, List[str]]: ... diff --git a/django-stubs/db/migrations/migration.pyi b/django-stubs/db/migrations/migration.pyi index 4bc2c2bc8..51e3c0e0b 100644 --- a/django-stubs/db/migrations/migration.pyi +++ b/django-stubs/db/migrations/migration.pyi @@ -5,14 +5,14 @@ from django.db.migrations.operations.base import Operation from django.db.migrations.state import ProjectState class Migration: - operations: List[Operation] = ... - dependencies: List[Tuple[str, str]] = ... - run_before: List[Tuple[str, str]] = ... - replaces: List[Tuple[str, str]] = ... - initial: bool | None = ... - atomic: bool = ... - name: str = ... - app_label: str = ... + operations: List[Operation] + dependencies: List[Tuple[str, str]] + run_before: List[Tuple[str, str]] + replaces: List[Tuple[str, str]] + initial: bool | None + atomic: bool + name: str + app_label: str def __init__(self, name: str, app_label: str) -> None: ... def mutate_state(self, project_state: ProjectState, preserve: bool = ...) -> ProjectState: ... def apply( @@ -23,7 +23,7 @@ class Migration: ) -> ProjectState: ... class SwappableTuple(Tuple[str, str]): - setting: str = ... + setting: str def __new__(cls, value: Tuple[str, str], setting: str) -> SwappableTuple: ... def swappable_dependency(value: str) -> SwappableTuple: ... diff --git a/django-stubs/db/migrations/operations/base.pyi b/django-stubs/db/migrations/operations/base.pyi index c963f6252..2f146bba8 100644 --- a/django-stubs/db/migrations/operations/base.pyi +++ b/django-stubs/db/migrations/operations/base.pyi @@ -6,11 +6,11 @@ from django.db.migrations.state import ProjectState from django.db.models import Model class Operation: - reversible: bool = ... - reduces_to_sql: bool = ... - atomic: bool = ... - elidable: bool = ... - serialization_expand_args: List[str] = ... + reversible: bool + reduces_to_sql: bool + atomic: bool + elidable: bool + serialization_expand_args: List[str] _constructor_args: Tuple[Sequence[Any], Dict[str, Any]] def deconstruct(self) -> Tuple[str, Sequence[Any], Dict[str, Any]]: ... def state_forwards(self, app_label: str, state: ProjectState) -> None: ... diff --git a/django-stubs/db/migrations/operations/fields.pyi b/django-stubs/db/migrations/operations/fields.pyi index 7d3f830bc..ea55695d5 100644 --- a/django-stubs/db/migrations/operations/fields.pyi +++ b/django-stubs/db/migrations/operations/fields.pyi @@ -3,8 +3,8 @@ from django.db.models.fields import Field from .base import Operation class FieldOperation(Operation): - model_name: str = ... - name: str = ... + model_name: str + name: str def __init__(self, model_name: str, name: str, field: Field | None = ...) -> None: ... @property def name_lower(self) -> str: ... @@ -14,20 +14,20 @@ class FieldOperation(Operation): def is_same_field_operation(self, operation: FieldOperation) -> bool: ... class AddField(FieldOperation): - field: Field = ... - preserve_default: bool = ... + field: Field + preserve_default: bool def __init__(self, model_name: str, name: str, field: Field, preserve_default: bool = ...) -> None: ... class RemoveField(FieldOperation): ... class AlterField(FieldOperation): - field: Field = ... - preserve_default: bool = ... + field: Field + preserve_default: bool def __init__(self, model_name: str, name: str, field: Field, preserve_default: bool = ...) -> None: ... class RenameField(FieldOperation): - old_name: str = ... - new_name: str = ... + old_name: str + new_name: str def __init__(self, model_name: str, old_name: str, new_name: str) -> None: ... @property def old_name_lower(self) -> str: ... diff --git a/django-stubs/db/migrations/operations/models.pyi b/django-stubs/db/migrations/operations/models.pyi index 509ee6b10..c360e191c 100644 --- a/django-stubs/db/migrations/operations/models.pyi +++ b/django-stubs/db/migrations/operations/models.pyi @@ -10,16 +10,16 @@ from django.db.models.manager import Manager from django.db.models.options import _OptionTogetherT class ModelOperation(Operation): - name: str = ... + name: str def __init__(self, name: str) -> None: ... @property def name_lower(self) -> str: ... class CreateModel(ModelOperation): - fields: List[Tuple[str, Field]] = ... - options: Dict[str, Any] = ... - bases: Sequence[Type[Model] | str] | None = ... - managers: Sequence[Tuple[str, Manager]] | None = ... + fields: List[Tuple[str, Field]] + options: Dict[str, Any] + bases: Sequence[Type[Model] | str] | None + managers: Sequence[Tuple[str, Manager]] | None def __init__( self, name: str, @@ -32,8 +32,8 @@ class CreateModel(ModelOperation): class DeleteModel(ModelOperation): ... class RenameModel(ModelOperation): - old_name: str = ... - new_name: str = ... + old_name: str + new_name: str def __init__(self, old_name: str, new_name: str) -> None: ... @property def old_name_lower(self) -> str: ... @@ -43,11 +43,11 @@ class RenameModel(ModelOperation): class ModelOptionOperation(ModelOperation): ... class AlterModelTable(ModelOptionOperation): - table: str | None = ... + table: str | None def __init__(self, name: str, table: str | None) -> None: ... class AlterTogetherOptionOperation(ModelOptionOperation): - option_name: str = ... + option_name: str def __init__( self, name: str, @@ -69,41 +69,41 @@ class AlterTogetherOptionOperation(ModelOptionOperation): def migration_name_fragment(self) -> str: ... class AlterUniqueTogether(AlterTogetherOptionOperation): - option_name: str = ... - unique_together: Set[Tuple[str, ...]] | None = ... + option_name: str + unique_together: Set[Tuple[str, ...]] | None def __init__(self, name: str, unique_together: _OptionTogetherT | None) -> None: ... class AlterIndexTogether(AlterTogetherOptionOperation): - option_name: str = ... - index_together: Set[Tuple[str, ...]] | None = ... + option_name: str + index_together: Set[Tuple[str, ...]] | None def __init__(self, name: str, index_together: _OptionTogetherT | None) -> None: ... class AlterOrderWithRespectTo(ModelOptionOperation): - order_with_respect_to: str = ... + order_with_respect_to: str def __init__(self, name: str, order_with_respect_to: str) -> None: ... class AlterModelOptions(ModelOptionOperation): - ALTER_OPTION_KEYS: List[str] = ... - options: Dict[str, Any] = ... + ALTER_OPTION_KEYS: List[str] + options: Dict[str, Any] def __init__(self, name: str, options: Dict[str, Any]) -> None: ... class AlterModelManagers(ModelOptionOperation): - managers: Sequence[Tuple[str, Manager]] = ... + managers: Sequence[Tuple[str, Manager]] def __init__(self, name: str, managers: Sequence[Tuple[str, Manager]]) -> None: ... class IndexOperation(Operation): - option_name: str = ... + option_name: str @property def model_name_lower(self) -> str: ... class AddIndex(IndexOperation): - model_name: str = ... - index: Index = ... + model_name: str + index: Index def __init__(self, model_name: str, index: Index) -> None: ... class RemoveIndex(IndexOperation): - model_name: str = ... - name: str = ... + model_name: str + name: str def __init__(self, model_name: str, name: str) -> None: ... class AddConstraint(IndexOperation): diff --git a/django-stubs/db/migrations/operations/special.pyi b/django-stubs/db/migrations/operations/special.pyi index c820b1d97..0597246a5 100644 --- a/django-stubs/db/migrations/operations/special.pyi +++ b/django-stubs/db/migrations/operations/special.pyi @@ -8,20 +8,20 @@ from typing_extensions import Literal, Protocol from .base import Operation class SeparateDatabaseAndState(Operation): - database_operations: Sequence[Operation] = ... - state_operations: Sequence[Operation] = ... + database_operations: Sequence[Operation] + state_operations: Sequence[Operation] def __init__( self, database_operations: Sequence[Operation] = ..., state_operations: Sequence[Operation] = ... ) -> None: ... class RunSQL(Operation): - noop: Literal[""] = ... - sql: Union[str, _ListOrTuple[Union[str, Tuple[str, Union[Dict[str, Any], Optional[_ListOrTuple[str]]]]]]] = ... + noop: Literal[""] + sql: Union[str, _ListOrTuple[Union[str, Tuple[str, Union[Dict[str, Any], Optional[_ListOrTuple[str]]]]]]] reverse_sql: Optional[ Union[str, _ListOrTuple[Union[str, Tuple[str, Union[Dict[str, Any], Optional[_ListOrTuple[str]]]]]]] - ] = ... - state_operations: Sequence[Operation] = ... - hints: Mapping[str, Any] = ... + ] + state_operations: Sequence[Operation] + hints: Mapping[str, Any] def __init__( self, sql: Union[str, _ListOrTuple[Union[str, Tuple[str, Union[Dict[str, Any], Optional[_ListOrTuple[str]]]]]]], @@ -37,9 +37,9 @@ class _CodeCallable(Protocol): def __call__(self, __state_apps: StateApps, __shema_editor: BaseDatabaseSchemaEditor) -> None: ... class RunPython(Operation): - code: _CodeCallable = ... - reverse_code: _CodeCallable | None = ... - hints: Mapping[str, Any] = ... + code: _CodeCallable + reverse_code: _CodeCallable | None + hints: Mapping[str, Any] def __init__( self, code: _CodeCallable, diff --git a/django-stubs/db/migrations/questioner.pyi b/django-stubs/db/migrations/questioner.pyi index 91bd2b9f3..f21dff694 100644 --- a/django-stubs/db/migrations/questioner.pyi +++ b/django-stubs/db/migrations/questioner.pyi @@ -4,9 +4,9 @@ from django.db.migrations.state import ModelState from django.db.models.fields import Field class MigrationQuestioner: - defaults: Dict[str, Any] = ... - specified_apps: Set[str] = ... - dry_run: bool | None = ... + defaults: Dict[str, Any] + specified_apps: Set[str] + dry_run: bool | None def __init__( self, defaults: Dict[str, bool] | None = ..., diff --git a/django-stubs/db/migrations/recorder.pyi b/django-stubs/db/migrations/recorder.pyi index b46124318..e515c199b 100644 --- a/django-stubs/db/migrations/recorder.pyi +++ b/django-stubs/db/migrations/recorder.pyi @@ -6,10 +6,10 @@ from django.db.models.query import QuerySet class MigrationRecorder: class Migration(Model): - app: Any = ... - name: Any = ... - applied: Any = ... - connection: BaseDatabaseWrapper = ... + app: Any + name: Any + applied: Any + connection: BaseDatabaseWrapper def __init__(self, connection: BaseDatabaseWrapper) -> None: ... @property def migration_qs(self) -> QuerySet: ... diff --git a/django-stubs/db/migrations/serializer.pyi b/django-stubs/db/migrations/serializer.pyi index f187a3d10..4dc563ed5 100644 --- a/django-stubs/db/migrations/serializer.pyi +++ b/django-stubs/db/migrations/serializer.pyi @@ -1,7 +1,7 @@ from typing import Any, Callable, Dict, List, Set, Tuple, Type class BaseSerializer: - value: Any = ... + value: Any def __init__(self, value: Any) -> None: ... def serialize(self) -> Tuple[str, Set[str]]: ... diff --git a/django-stubs/db/migrations/state.pyi b/django-stubs/db/migrations/state.pyi index 2976b82b2..0b02d20b8 100644 --- a/django-stubs/db/migrations/state.pyi +++ b/django-stubs/db/migrations/state.pyi @@ -13,9 +13,9 @@ class ModelState: name: str app_label: str fields: Dict[str, Field] - options: Dict[str, Any] = ... - bases: Sequence[Type[Model] | str] = ... - managers: List[Tuple[str, Manager]] = ... + options: Dict[str, Any] + bases: Sequence[Type[Model] | str] + managers: List[Tuple[str, Manager]] def __init__( self, app_label: str, diff --git a/django-stubs/db/migrations/utils.pyi b/django-stubs/db/migrations/utils.pyi index fb98a1e3d..9cd93bfbc 100644 --- a/django-stubs/db/migrations/utils.pyi +++ b/django-stubs/db/migrations/utils.pyi @@ -3,8 +3,8 @@ from typing import Any COMPILED_REGEX_TYPE: Any class RegexObject: - pattern: str = ... - flags: int = ... + pattern: str + flags: int def __init__(self, obj: Any) -> None: ... def get_migration_name_timestamp() -> str: ... diff --git a/django-stubs/db/migrations/writer.pyi b/django-stubs/db/migrations/writer.pyi index a25518183..8afb50914 100644 --- a/django-stubs/db/migrations/writer.pyi +++ b/django-stubs/db/migrations/writer.pyi @@ -5,9 +5,9 @@ from django.db.migrations.operations.base import Operation from django.db.migrations.serializer import BaseSerializer class OperationWriter: - operation: Operation = ... - buff: List[Any] = ... - indentation: int = ... + operation: Operation + buff: List[Any] + indentation: int def __init__(self, operation: Operation, indentation: int = ...) -> None: ... def serialize(self) -> Tuple[str, Set[str]]: ... def indent(self) -> None: ... @@ -16,8 +16,8 @@ class OperationWriter: def render(self) -> str: ... class MigrationWriter: - migration: Migration = ... - needs_manual_porting: bool = ... + migration: Migration + needs_manual_porting: bool def __init__(self, migration: Migration, include_header: bool = ...) -> None: ... def as_string(self) -> str: ... @property @@ -33,5 +33,5 @@ class MigrationWriter: @classmethod def unregister_serializer(cls, type_: type) -> None: ... -MIGRATION_HEADER_TEMPLATE: str = ... -MIGRATION_TEMPLATE: str = ... +MIGRATION_HEADER_TEMPLATE: str +MIGRATION_TEMPLATE: str diff --git a/django-stubs/db/models/aggregates.pyi b/django-stubs/db/models/aggregates.pyi index c1abb2132..e712f937d 100644 --- a/django-stubs/db/models/aggregates.pyi +++ b/django-stubs/db/models/aggregates.pyi @@ -4,9 +4,9 @@ from django.db.models.expressions import Func from django.db.models.functions.mixins import FixDurationInputMixin, NumericOutputFieldMixin class Aggregate(Func): - filter_template: str = ... - filter: Any = ... - allow_distinct: bool = ... + filter_template: str + filter: Any + allow_distinct: bool def __init__(self, *expressions: Any, distinct: bool = ..., filter: Any | None = ..., **extra: Any) -> None: ... class Avg(FixDurationInputMixin, NumericOutputFieldMixin, Aggregate): ... diff --git a/django-stubs/db/models/base.pyi b/django-stubs/db/models/base.pyi index 4bdd15a89..0d03dac40 100644 --- a/django-stubs/db/models/base.pyi +++ b/django-stubs/db/models/base.pyi @@ -11,9 +11,9 @@ _Self = TypeVar("_Self", bound="Model") class ModelStateFieldsCacheDescriptor: ... class ModelState: - db: str | None = ... - adding: bool = ... - fields_cache: ModelStateFieldsCacheDescriptor = ... + db: str | None + adding: bool + fields_cache: ModelStateFieldsCacheDescriptor class ModelBase(type): @property @@ -28,7 +28,7 @@ class Model(metaclass=ModelBase): class MultipleObjectsReturned(BaseMultipleObjectsReturned): ... class Meta: ... _meta: Options[Any] - pk: Any = ... + pk: Any _state: ModelState def __init__(self: _Self, *args: Any, **kwargs: Any) -> None: ... @classmethod diff --git a/django-stubs/db/models/constants.pyi b/django-stubs/db/models/constants.pyi index 6dde4acb0..00d9cf58f 100644 --- a/django-stubs/db/models/constants.pyi +++ b/django-stubs/db/models/constants.pyi @@ -1 +1 @@ -LOOKUP_SEP: str = ... +LOOKUP_SEP: str diff --git a/django-stubs/db/models/enums.pyi b/django-stubs/db/models/enums.pyi index b2e0aad39..a90616c79 100644 --- a/django-stubs/db/models/enums.pyi +++ b/django-stubs/db/models/enums.pyi @@ -8,10 +8,10 @@ else: enum_property = property class ChoicesMeta(enum.EnumMeta): - names: List[str] = ... - choices: List[Tuple[Any, str]] = ... - labels: List[str] = ... - values: List[Any] = ... + names: List[str] + choices: List[Tuple[Any, str]] + labels: List[str] + values: List[Any] def __contains__(self, member: Any) -> bool: ... class Choices(enum.Enum, metaclass=ChoicesMeta): @@ -23,10 +23,10 @@ class Choices(enum.Enum, metaclass=ChoicesMeta): # fake class _IntegerChoicesMeta(ChoicesMeta): - names: List[str] = ... - choices: List[Tuple[int, str]] = ... - labels: List[str] = ... - values: List[int] = ... + names: List[str] + choices: List[Tuple[int, str]] + labels: List[str] + values: List[int] class IntegerChoices(int, Choices, metaclass=_IntegerChoicesMeta): @enum_property @@ -34,10 +34,10 @@ class IntegerChoices(int, Choices, metaclass=_IntegerChoicesMeta): # fake class _TextChoicesMeta(ChoicesMeta): - names: List[str] = ... - choices: List[Tuple[str, str]] = ... - labels: List[str] = ... - values: List[str] = ... + names: List[str] + choices: List[Tuple[str, str]] + labels: List[str] + values: List[str] class TextChoices(str, Choices, metaclass=_TextChoicesMeta): @enum_property diff --git a/django-stubs/db/models/expressions.pyi b/django-stubs/db/models/expressions.pyi index 604cf377a..8cd445533 100644 --- a/django-stubs/db/models/expressions.pyi +++ b/django-stubs/db/models/expressions.pyi @@ -18,17 +18,17 @@ _Self = TypeVar("_Self") _Numeric = float | Decimal class Combinable: - ADD: str = ... - SUB: str = ... - MUL: str = ... - DIV: str = ... - POW: str = ... - MOD: str = ... - BITAND: str = ... - BITOR: str = ... - BITLEFTSHIFT: str = ... - BITRIGHTSHIFT: str = ... - BITXOR: str = ... + ADD: str + SUB: str + MUL: str + DIV: str + POW: str + MOD: str + BITAND: str + BITOR: str + BITLEFTSHIFT: str + BITRIGHTSHIFT: str + BITXOR: str def __neg__(self) -> CombinedExpression: ... def __add__(self, other: datetime.timedelta | Combinable | _Numeric | str | None) -> CombinedExpression: ... def __sub__(self, other: datetime.timedelta | Combinable | _Numeric) -> CombinedExpression: ... @@ -55,9 +55,9 @@ class Combinable: _SelfB = TypeVar("_SelfB", bound="BaseExpression") class BaseExpression: - is_summary: bool = ... - filterable: bool = ... - window_compatible: bool = ... + is_summary: bool + filterable: bool + window_compatible: bool def __init__(self, output_field: Field | None = ...) -> None: ... def get_db_converters(self, connection: BaseDatabaseWrapper) -> List[Callable]: ... def get_source_expressions(self) -> List[Any]: ... @@ -111,9 +111,9 @@ class BaseExpression: class Expression(BaseExpression, Combinable): ... class CombinedExpression(SQLiteNumericMixin, Expression): - connector: str = ... - lhs: Combinable = ... - rhs: Combinable = ... + connector: str + lhs: Combinable + rhs: Combinable def __init__(self, lhs: Combinable, connector: str, rhs: Combinable, output_field: Field | None = ...) -> None: ... class F(Combinable): @@ -150,22 +150,22 @@ class OuterRef(F): def relabeled_clone(self: _Self, relabels: Any) -> _Self: ... class Subquery(BaseExpression, Combinable): - template: str = ... - query: Query = ... - extra: Dict[Any, Any] = ... + template: str + query: Query + extra: Dict[Any, Any] def __init__(self, queryset: Query | QuerySet, output_field: Field | None = ..., **extra: Any) -> None: ... class Exists(Subquery): - negated: bool = ... + negated: bool def __init__(self, queryset: Query | QuerySet, negated: bool = ..., **kwargs: Any) -> None: ... def __invert__(self) -> Exists: ... class OrderBy(Expression): - template: str = ... - nulls_first: bool = ... - nulls_last: bool = ... - descending: bool = ... - expression: Expression | F | Subquery = ... + template: str + nulls_first: bool + nulls_last: bool + descending: bool + expression: Expression | F | Subquery def __init__( self, expression: Expression | F | Subquery, @@ -175,7 +175,7 @@ class OrderBy(Expression): ) -> None: ... class Value(Expression): - value: Any = ... + value: Any def __init__(self, value: Any, output_field: Field | None = ...) -> None: ... class RawSQL(Expression): @@ -184,27 +184,27 @@ class RawSQL(Expression): def __init__(self, sql: str, params: Sequence[Any], output_field: Field | None = ...) -> None: ... class Func(SQLiteNumericMixin, Expression): - function: str = ... - name: str = ... - template: str = ... - arg_joiner: str = ... - arity: int | None = ... - source_expressions: List[Expression] = ... - extra: Dict[Any, Any] = ... + function: str + name: str + template: str + arg_joiner: str + arity: int | None + source_expressions: List[Expression] + extra: Dict[Any, Any] def __init__(self, *expressions: Any, output_field: Field | None = ..., **extra: Any) -> None: ... class When(Expression): - template: str = ... - condition: Any = ... - result: Any = ... + template: str + condition: Any + result: Any def __init__(self, condition: Any = ..., then: Any = ..., **lookups: Any) -> None: ... class Case(Expression): - template: str = ... - case_joiner: str = ... - cases: Any = ... - default: Any = ... - extra: Any = ... + template: str + case_joiner: str + cases: Any + default: Any + extra: Any def __init__( self, *cases: Any, default: Any | None = ..., output_field: Field | None = ..., **extra: Any ) -> None: ... @@ -215,8 +215,8 @@ class ExpressionWrapper(Expression): class Col(Expression): target: Field alias: str - contains_column_references: Literal[True] = ... - possibly_multivalued: Literal[False] = ... + contains_column_references: Literal[True] + possibly_multivalued: Literal[False] def __init__(self, alias: str, target: Field, output_field: Field | None = ...) -> None: ... class Ref(Expression): @@ -226,9 +226,9 @@ class ExpressionList(Func): def __init__(self, *expressions: BaseExpression | Combinable, **extra: Any) -> None: ... class Window(SQLiteNumericMixin, Expression): - template: str = ... - contains_aggregate: bool = ... - contains_over_clause: bool = ... + template: str + contains_aggregate: bool + contains_over_clause: bool partition_by: ExpressionList | None order_by: ExpressionList | None def __init__( @@ -241,8 +241,8 @@ class Window(SQLiteNumericMixin, Expression): ) -> None: ... class WindowFrame(Expression): - template: str = ... - frame_type: str = ... + template: str + frame_type: str def __init__(self, start: int | None = ..., end: int | None = ...) -> None: ... def window_frame_start_end( self, connection: BaseDatabaseWrapper, start: int | None, end: int | None diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index b3f548cdf..76851c53e 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -22,7 +22,7 @@ from typing_extensions import Protocol class Empty: ... class NOT_PROVIDED: ... -BLANK_CHOICE_DASH: List[Tuple[str, str]] = ... +BLANK_CHOICE_DASH: List[Tuple[str, str]] _Choice = Tuple[Any, Any] _ChoiceNamedGroup = Tuple[str, Iterable[_Choice]] @@ -113,10 +113,10 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): remote_field: ForeignObjectRel | None is_relation: bool related_model: Type[Model] | None - one_to_many: bool | None = ... - one_to_one: bool | None = ... - many_to_many: bool | None = ... - many_to_one: bool | None = ... + one_to_many: bool | None + one_to_one: bool | None + many_to_many: bool | None + many_to_one: bool | None max_length: int | None model: Type[Model] name: str @@ -126,14 +126,14 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): null: bool unique: bool editable: bool - empty_strings_allowed: bool = ... - choices: _ChoicesList | None = ... + empty_strings_allowed: bool + choices: _ChoicesList | None db_column: str | None column: str concrete: bool default: Any error_messages: _ErrorMessagesT - empty_values: Sequence[Any] = ... + empty_values: Sequence[Any] creation_counter: int auto_creation_counter: int default_validators: Sequence[validators._ValidatorCallable] @@ -242,8 +242,8 @@ class DecimalField(Field[_ST, _GT]): _pyi_private_get_type: decimal.Decimal _pyi_lookup_exact_type: str | decimal.Decimal # attributes - max_digits: int = ... - decimal_places: int = ... + max_digits: int + decimal_places: int def __init__( self, verbose_name: _StrOrPromise | None = ..., @@ -410,9 +410,9 @@ class GenericIPAddressField(Field[_ST, _GT]): _pyi_private_set_type: str | int | Callable[..., Any] | Combinable _pyi_private_get_type: str - default_error_messages: Dict[str, str] = ... - unpack_ipv4: bool = ... - protocol: str = ... + default_error_messages: Dict[str, str] + unpack_ipv4: bool + protocol: str def __init__( self, verbose_name: _StrOrPromise | None = ..., @@ -535,11 +535,11 @@ class UUIDField(Field[_ST, _GT]): ) -> None: ... class FilePathField(Field[_ST, _GT]): - path: Any = ... - match: str | None = ... - recursive: bool = ... - allow_files: bool = ... - allow_folders: bool = ... + path: Any + match: str | None + recursive: bool + allow_files: bool + allow_folders: bool def __init__( self, verbose_name: _StrOrPromise | None = ..., @@ -575,7 +575,7 @@ class DurationField(Field[_ST, _GT]): _pyi_private_get_type: timedelta class AutoFieldMixin: - db_returning: bool = ... + db_returning: bool class AutoFieldMeta(type): ... diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index 743880460..691186f0a 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -12,12 +12,12 @@ from django.utils.functional import _StrOrPromise from typing_extensions import Protocol class FieldFile(File): - instance: Model = ... - field: FileField = ... - storage: Storage = ... + instance: Model + field: FileField + storage: Storage name: str | None def __init__(self, instance: Model, field: FileField, name: str | None) -> None: ... - file: Any = ... + file: Any @property def path(self) -> str: ... @property @@ -30,7 +30,7 @@ class FieldFile(File): def closed(self) -> bool: ... class FileDescriptor(DeferredAttribute): - field: FileField = ... + field: FileField def __set__(self, instance: Model, value: Any | None) -> None: ... def __get__(self, instance: Model | None, cls: Type[Model] | None = ...) -> FieldFile | FileDescriptor: ... @@ -41,8 +41,8 @@ class _UploadToCallable(Protocol[_M]): def __call__(self, __instance: _M, __filename: str) -> _PathCompatible: ... class FileField(Field): - storage: Storage = ... - upload_to: _PathCompatible | _UploadToCallable = ... + storage: Storage + upload_to: _PathCompatible | _UploadToCallable def __init__( self, verbose_name: _StrOrPromise | None = ..., diff --git a/django-stubs/db/models/fields/json.pyi b/django-stubs/db/models/fields/json.pyi index 8f7177018..b48cbb234 100644 --- a/django-stubs/db/models/fields/json.pyi +++ b/django-stubs/db/models/fields/json.pyi @@ -26,31 +26,31 @@ class DataContains(PostgresOperatorLookup): ... class ContainedBy(PostgresOperatorLookup): ... class HasKeyLookup(PostgresOperatorLookup): - logical_operator: str | None = ... + logical_operator: str | None class HasKey(HasKeyLookup): - postgres_operator: str = ... + postgres_operator: str class HasKeys(HasKeyLookup): - postgres_operator: str = ... - logical_operator: str = ... + postgres_operator: str + logical_operator: str class HasAnyKeys(HasKeys): - postgres_operator: str = ... - logical_operator: str = ... + postgres_operator: str + logical_operator: str class JSONExact(lookups.Exact): ... class KeyTransform(Transform): - key_name: str = ... - postgres_operator: str = ... - postgres_nested_operator: str = ... + key_name: str + postgres_operator: str + postgres_nested_operator: str def __init__(self, key_name: Any, *args: Any, **kwargs: Any) -> None: ... def preprocess_lhs(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> Any: ... class KeyTextTransform(KeyTransform): - postgres_operator: str = ... - postgres_nested_operator: str = ... + postgres_operator: str + postgres_nested_operator: str class KeyTransformTextLookupMixin: def __init__(self, key_transform: Any, *args: Any, **kwargs: Any) -> None: ... @@ -74,6 +74,6 @@ class KeyTransformGt(KeyTransformNumericLookupMixin, lookups.GreaterThan): ... class KeyTransformGte(KeyTransformNumericLookupMixin, lookups.GreaterThanOrEqual): ... class KeyTransformFactory: - key_name: Any = ... + key_name: Any def __init__(self, key_name: Any) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> KeyTransform: ... diff --git a/django-stubs/db/models/fields/related.pyi b/django-stubs/db/models/fields/related.pyi index 6c223bf42..c182d07bc 100644 --- a/django-stubs/db/models/fields/related.pyi +++ b/django-stubs/db/models/fields/related.pyi @@ -26,7 +26,7 @@ from typing_extensions import Literal _T = TypeVar("_T", bound=models.Model) _F = TypeVar("_F", bound=models.Field) -RECURSIVE_RELATIONSHIP_CONSTANT: Literal["self"] = ... +RECURSIVE_RELATIONSHIP_CONSTANT: Literal["self"] def resolve_relation(scope_model: Type[Model], relation: str | Type[Model]) -> str | Type[Model]: ... @@ -36,11 +36,11 @@ _ST = TypeVar("_ST") _GT = TypeVar("_GT") class RelatedField(FieldCacheMixin, Field[_ST, _GT]): - one_to_many: bool = ... - one_to_one: bool = ... - many_to_many: bool = ... - many_to_one: bool = ... - opts: Any = ... + one_to_many: bool + one_to_one: bool + many_to_many: bool + many_to_one: bool + opts: Any remote_field: ForeignObjectRel rel_class: Type[ForeignObjectRel] @@ -208,9 +208,9 @@ class ManyToManyField(RelatedField[_ST, _GT]): _pyi_private_set_type: Sequence[Any] _pyi_private_get_type: RelatedManager[Any] - description: str = ... - has_null_arg: bool = ... - swappable: bool = ... + description: str + has_null_arg: bool + swappable: bool many_to_many: Literal[True] many_to_one: Literal[False] diff --git a/django-stubs/db/models/fields/related_descriptors.pyi b/django-stubs/db/models/fields/related_descriptors.pyi index c1b479582..cb962fcd1 100644 --- a/django-stubs/db/models/fields/related_descriptors.pyi +++ b/django-stubs/db/models/fields/related_descriptors.pyi @@ -37,7 +37,7 @@ class ForwardOneToOneDescriptor(ForwardManyToOneDescriptor): def get_object(self, instance: Model) -> Model: ... class ReverseOneToOneDescriptor: - related: OneToOneRel = ... + related: OneToOneRel def __init__(self, related: OneToOneRel) -> None: ... @property def RelatedObjectDoesNotExist(self) -> Type[ObjectDoesNotExist]: ... @@ -51,8 +51,8 @@ class ReverseOneToOneDescriptor: def __reduce__(self) -> Tuple[Callable, Tuple[Type[Model], str]]: ... class ReverseManyToOneDescriptor: - rel: ManyToOneRel = ... - field: ForeignKey = ... + rel: ManyToOneRel + field: ForeignKey def __init__(self, rel: ManyToOneRel) -> None: ... @property def related_manager_cls(self) -> Type[RelatedManager]: ... @@ -64,7 +64,7 @@ def create_reverse_many_to_one_manager(superclass: Type, rel: Any) -> Type[Relat class ManyToManyDescriptor(ReverseManyToOneDescriptor): field: ManyToManyField # type: ignore[assignment] rel: ManyToManyRel # type: ignore[assignment] - reverse: bool = ... + reverse: bool def __init__(self, rel: ManyToManyRel, reverse: bool = ...) -> None: ... @property def through(self) -> Type[Model]: ... diff --git a/django-stubs/db/models/fields/related_lookups.pyi b/django-stubs/db/models/fields/related_lookups.pyi index 2b9d868ad..3b32cbf9d 100644 --- a/django-stubs/db/models/fields/related_lookups.pyi +++ b/django-stubs/db/models/fields/related_lookups.pyi @@ -17,8 +17,8 @@ class MultiColSource: field: Field sources: Tuple[Field, Field] targets: Tuple[Field, Field] - contains_aggregate: bool = ... - output_field: Field = ... + contains_aggregate: bool + output_field: Field def __init__( self, alias: str, targets: Tuple[Field, Field], sources: Tuple[Field, Field], field: Field ) -> None: ... @@ -30,11 +30,11 @@ def get_normalized_value(value: Any, lhs: Any) -> Tuple[Any, ...]: ... class RelatedIn(In): bilateral_transforms: List[Any] lhs: Any - rhs: Any = ... + rhs: Any def get_prep_lookup(self) -> Iterable[Any]: ... class RelatedLookupMixin: - rhs: Any = ... + rhs: Any def get_prep_lookup(self) -> Any: ... class RelatedExact(RelatedLookupMixin, Exact): ... diff --git a/django-stubs/db/models/fields/reverse_related.pyi b/django-stubs/db/models/fields/reverse_related.pyi index ed037ba5b..65807e856 100644 --- a/django-stubs/db/models/fields/reverse_related.pyi +++ b/django-stubs/db/models/fields/reverse_related.pyi @@ -17,21 +17,21 @@ from .mixins import FieldCacheMixin # `Type[Model]` class ForeignObjectRel(FieldCacheMixin): - auto_created: bool = ... - concrete: Literal[False] = ... - editable: bool = ... - is_relation: bool = ... - null: bool = ... - field: ForeignObject = ... - model: Type[Model] = ... - related_name: str | None = ... - related_query_name: str | None = ... - limit_choices_to: _AllLimitChoicesTo | None = ... - parent_link: bool = ... - on_delete: Callable = ... - symmetrical: bool = ... - multiple: bool = ... - field_name: str | None = ... + auto_created: bool + concrete: Literal[False] + editable: bool + is_relation: bool + null: bool + field: ForeignObject + model: Type[Model] + related_name: str | None + related_query_name: str | None + limit_choices_to: _AllLimitChoicesTo | None + parent_link: bool + on_delete: Callable + symmetrical: bool + multiple: bool + field_name: str | None def __init__( self, field: ForeignObject, @@ -113,9 +113,9 @@ class OneToOneRel(ManyToOneRel): class ManyToManyRel(ForeignObjectRel): field: ManyToManyField # type: ignore - through: Type[Model] | None = ... - through_fields: Tuple[str, str] | None = ... - db_constraint: bool = ... + through: Type[Model] | None + through_fields: Tuple[str, str] | None + db_constraint: bool def __init__( self, field: ManyToManyField, diff --git a/django-stubs/db/models/functions/datetime.pyi b/django-stubs/db/models/functions/datetime.pyi index 2680d8adb..e5ce958ae 100644 --- a/django-stubs/db/models/functions/datetime.pyi +++ b/django-stubs/db/models/functions/datetime.pyi @@ -4,7 +4,7 @@ from django.db import models from django.db.models import Func, Transform class TimezoneMixin: - tzinfo: Any = ... + tzinfo: Any def get_tzname(self) -> str | None: ... class Extract(TimezoneMixin, Transform): @@ -30,8 +30,8 @@ class Now(Func): output_field: models.DateTimeField class TruncBase(TimezoneMixin, Transform): - kind: str = ... - tzinfo: Any = ... + kind: str + tzinfo: Any class Trunc(TruncBase): ... class TruncYear(TruncBase): ... diff --git a/django-stubs/db/models/functions/text.pyi b/django-stubs/db/models/functions/text.pyi index 6d72c1a9f..14631e4f6 100644 --- a/django-stubs/db/models/functions/text.pyi +++ b/django-stubs/db/models/functions/text.pyi @@ -33,20 +33,20 @@ class Concat(Func): def __init__(self, *expressions: Any, **extra: Any) -> None: ... class Left(Func): - output_field: models.CharField = ... + output_field: models.CharField def __init__(self, expression: Expression | str, length: Expression | int, **extra: Any) -> None: ... def get_substr(self) -> Substr: ... def as_oracle(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... class Length(Transform): - output_field: models.IntegerField = ... + output_field: models.IntegerField def as_mysql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... class Lower(Transform): ... class LPad(Func): - output_field: models.CharField = ... + output_field: models.CharField def __init__( self, expression: Expression | str, length: Expression | int | None, fill_text: Expression = ..., **extra: Any ) -> None: ... @@ -54,12 +54,12 @@ class LPad(Func): class LTrim(Transform): ... class Ord(Transform): - output_field: models.IntegerField = ... + output_field: models.IntegerField def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... def as_mysql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... class Repeat(Func): - output_field: models.CharField = ... + output_field: models.CharField def __init__(self, expression: Expression | str, number: Expression | int | None, **extra: Any) -> None: ... def as_oracle(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... @@ -84,13 +84,13 @@ class SHA384(MySQLSHA2Mixin, OracleHashMixin, PostgreSQLSHAMixin, Transform): .. class SHA512(MySQLSHA2Mixin, OracleHashMixin, PostgreSQLSHAMixin, Transform): ... class StrIndex(Func): - output_field: models.IntegerField = ... + output_field: models.IntegerField def as_postgresql( self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any ) -> _AsSqlType: ... class Substr(Func): - output_field: models.CharField = ... + output_field: models.CharField def __init__( self, expression: Expression | str, pos: Expression | int, length: Expression | int | None = ..., **extra: Any ) -> None: ... diff --git a/django-stubs/db/models/functions/window.pyi b/django-stubs/db/models/functions/window.pyi index 3b080a94c..7de622d19 100644 --- a/django-stubs/db/models/functions/window.pyi +++ b/django-stubs/db/models/functions/window.pyi @@ -4,10 +4,10 @@ from django.db import models from django.db.models.expressions import Func class CumeDist(Func): - output_field: models.FloatField = ... + output_field: models.FloatField class DenseRank(Func): - output_field: models.IntegerField = ... + output_field: models.IntegerField class FirstValue(Func): ... @@ -23,13 +23,13 @@ class NthValue(Func): class Ntile(Func): def __init__(self, num_buckets: int = ..., **extra: Any) -> None: ... - output_field: models.IntegerField = ... + output_field: models.IntegerField class PercentRank(Func): - output_field: models.FloatField = ... + output_field: models.FloatField class Rank(Func): - output_field: models.IntegerField = ... + output_field: models.IntegerField class RowNumber(Func): - output_field: models.IntegerField = ... + output_field: models.IntegerField diff --git a/django-stubs/db/models/indexes.pyi b/django-stubs/db/models/indexes.pyi index b10fd55ae..4bdb37a2a 100644 --- a/django-stubs/db/models/indexes.pyi +++ b/django-stubs/db/models/indexes.pyi @@ -10,14 +10,14 @@ from django.db.models.sql.compiler import SQLCompiler, _AsSqlType class Index: model: Type[Model] - suffix: str = ... - max_name_length: int = ... - fields: Sequence[str] = ... - fields_orders: Sequence[Tuple[str, str]] = ... - name: str = ... - db_tablespace: str | None = ... - opclasses: Sequence[str] = ... - condition: Q | None = ... + suffix: str + max_name_length: int + fields: Sequence[str] + fields_orders: Sequence[Tuple[str, str]] + name: str + db_tablespace: str | None + opclasses: Sequence[str] + condition: Q | None expressions: Sequence[BaseExpression | Combinable] include: Sequence[str] def __init__( @@ -41,8 +41,8 @@ class Index: def set_name_with_model(self, model: Type[Model]) -> None: ... class IndexExpression(Func): - template: str = ... - wrapper_classes: Sequence[Expression] = ... + template: str + wrapper_classes: Sequence[Expression] def set_wrapper_classes(self, connection: Any | None = ...) -> None: ... @classmethod def register_wrappers(cls, *wrapper_classes: Expression) -> None: ... diff --git a/django-stubs/db/models/lookups.pyi b/django-stubs/db/models/lookups.pyi index 6fd5052a7..9c694a5b1 100644 --- a/django-stubs/db/models/lookups.pyi +++ b/django-stubs/db/models/lookups.pyi @@ -11,12 +11,12 @@ _L = TypeVar("_L", bound="Lookup") _T = TypeVar("_T") class Lookup(Generic[_T]): - lookup_name: str = ... - prepare_rhs: bool = ... - can_use_none_as_rhs: bool = ... - lhs: Any = ... - rhs: Any = ... - bilateral_transforms: List[Type[Transform]] = ... + lookup_name: str + prepare_rhs: bool + can_use_none_as_rhs: bool + lhs: Any + rhs: Any + bilateral_transforms: List[Type[Transform]] def __init__(self, lhs: Any, rhs: Any) -> None: ... def apply_bilateral_transforms(self, value: Expression) -> Expression: ... def batch_process_rhs( @@ -45,7 +45,7 @@ class Lookup(Generic[_T]): def identity(self) -> Tuple[Type[Lookup], Any, Any]: ... class Transform(RegisterLookupMixin, Func): - bilateral: bool = ... + bilateral: bool @property def lhs(self) -> Expression: ... def get_bilateral_transforms(self) -> List[Type[Transform]]: ... @@ -57,18 +57,18 @@ class BuiltinLookup(Lookup[_T]): def get_rhs_op(self, connection: BaseDatabaseWrapper, rhs: str) -> str: ... class FieldGetDbPrepValueMixin: - get_db_prep_lookup_value_is_iterable: bool = ... + get_db_prep_lookup_value_is_iterable: bool def get_db_prep_lookup(self, value: _ParamT, connection: BaseDatabaseWrapper) -> _AsSqlType: ... class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin): - get_db_prep_lookup_value_is_iterable: Literal[True] = ... + get_db_prep_lookup_value_is_iterable: Literal[True] def get_prep_lookup(self) -> Iterable[Any]: ... def resolve_expression_parameter( self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, sql: str, param: Any ) -> _AsSqlType: ... class PostgresOperatorLookup(FieldGetDbPrepValueMixin, Lookup[_T]): - postgres_operator: str = ... + postgres_operator: str def as_postgresql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... class Exact(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ... @@ -79,7 +79,7 @@ class LessThan(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ... class LessThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ... class IntegerFieldFloatRounding: - rhs: Any = ... + rhs: Any def get_prep_lookup(self) -> Any: ... class IntegerGreaterThanOrEqual(IntegerFieldFloatRounding, GreaterThanOrEqual[int | float]): ... @@ -89,7 +89,7 @@ class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup): def split_parameter_list_as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> Any: ... class PatternLookup(BuiltinLookup[str]): - param_pattern: str = ... + param_pattern: str class Contains(PatternLookup): ... class IContains(Contains): ... @@ -123,7 +123,7 @@ class YearLte(YearLookup, LessThanOrEqual[_T]): def get_bound_params(self, start: Any, finish: Any) -> Tuple[Any]: ... class UUIDTextMixin: - rhs: Any = ... + rhs: Any def process_rhs(self, qn: Any, connection: BaseDatabaseWrapper) -> Any: ... class UUIDIExact(UUIDTextMixin, IExact[_T]): ... diff --git a/django-stubs/db/models/manager.pyi b/django-stubs/db/models/manager.pyi index ea76d7e01..f471ada24 100644 --- a/django-stubs/db/models/manager.pyi +++ b/django-stubs/db/models/manager.pyi @@ -26,11 +26,11 @@ _T = TypeVar("_T", bound=Model, covariant=True) _M = TypeVar("_M", bound="BaseManager") class BaseManager(Generic[_T]): - creation_counter: int = ... - auto_created: bool = ... - use_in_migrations: bool = ... - name: str = ... - model: Type[_T] = ... + creation_counter: int + auto_created: bool + use_in_migrations: bool + name: str + model: Type[_T] _db: str | None def __init__(self) -> None: ... def deconstruct( @@ -169,7 +169,7 @@ class RelatedManager(Manager[_T]): def __call__(self, *, manager: str) -> RelatedManager[_T]: ... class ManagerDescriptor: - manager: BaseManager = ... + manager: BaseManager def __init__(self, manager: BaseManager) -> None: ... @overload def __get__(self, instance: None, cls: Type[Model] | None = ...) -> BaseManager: ... diff --git a/django-stubs/db/models/options.pyi b/django-stubs/db/models/options.pyi index 8663c01c3..dc693029e 100644 --- a/django-stubs/db/models/options.pyi +++ b/django-stubs/db/models/options.pyi @@ -37,49 +37,49 @@ _M = TypeVar("_M", bound="Model") class Options(Generic[_M]): constraints: List[BaseConstraint] - FORWARD_PROPERTIES: Set[str] = ... - REVERSE_PROPERTIES: Set[str] = ... - default_apps: Any = ... - local_fields: List[Field] = ... - local_many_to_many: List[ManyToManyField] = ... - private_fields: List[Any] = ... - local_managers: List[Manager] = ... - base_manager_name: str | None = ... - default_manager_name: str | None = ... - model_name: str | None = ... - verbose_name: _StrOrPromise | None = ... - verbose_name_plural: _StrOrPromise | None = ... - db_table: str = ... - ordering: Sequence[str] | None = ... - indexes: List[Any] = ... - unique_together: Sequence[Tuple[str]] = ... # Are always normalized - index_together: Sequence[Tuple[str]] = ... # Are always normalized - select_on_save: bool = ... - default_permissions: Sequence[str] = ... - permissions: List[Any] = ... - object_name: str | None = ... - app_label: str = ... - get_latest_by: Sequence[str] | None = ... - order_with_respect_to: str | None = ... - db_tablespace: str = ... - required_db_features: List[str] = ... - required_db_vendor: Literal["sqlite", "postgresql", "mysql", "oracle"] | None = ... - meta: type | None = ... - pk: Field | None = ... - auto_field: AutoField | None = ... - abstract: bool = ... - managed: bool = ... - proxy: bool = ... - proxy_for_model: Type[Model] | None = ... - concrete_model: Type[Model] | None = ... - swappable: str | None = ... - parents: Dict[Type[Model], GenericForeignKey | Field] = ... - auto_created: bool = ... - related_fkey_lookups: List[Any] = ... - apps: Apps = ... - default_related_name: str | None = ... - model: Type[Model] = ... - original_attrs: Dict[str, Any] = ... + FORWARD_PROPERTIES: Set[str] + REVERSE_PROPERTIES: Set[str] + default_apps: Any + local_fields: List[Field] + local_many_to_many: List[ManyToManyField] + private_fields: List[Any] + local_managers: List[Manager] + base_manager_name: str | None + default_manager_name: str | None + model_name: str | None + verbose_name: _StrOrPromise | None + verbose_name_plural: _StrOrPromise | None + db_table: str + ordering: Sequence[str] | None + indexes: List[Any] + unique_together: Sequence[Tuple[str]] # Are always normalized + index_together: Sequence[Tuple[str]] # Are always normalized + select_on_save: bool + default_permissions: Sequence[str] + permissions: List[Any] + object_name: str | None + app_label: str + get_latest_by: Sequence[str] | None + order_with_respect_to: str | None + db_tablespace: str + required_db_features: List[str] + required_db_vendor: Literal["sqlite", "postgresql", "mysql", "oracle"] | None + meta: type | None + pk: Field | None + auto_field: AutoField | None + abstract: bool + managed: bool + proxy: bool + proxy_for_model: Type[Model] | None + concrete_model: Type[Model] | None + swappable: str | None + parents: Dict[Type[Model], GenericForeignKey | Field] + auto_created: bool + related_fkey_lookups: List[Any] + apps: Apps + default_related_name: str | None + model: Type[Model] + original_attrs: Dict[str, Any] def __init__(self, meta: type | None, app_label: str | None = ...) -> None: ... @property def label(self) -> str: ... diff --git a/django-stubs/db/models/query.pyi b/django-stubs/db/models/query.pyi index 4176724ce..f6989b52c 100644 --- a/django-stubs/db/models/query.pyi +++ b/django-stubs/db/models/query.pyi @@ -31,8 +31,8 @@ _Row = TypeVar("_Row", covariant=True) _QS = TypeVar("_QS", bound="_QuerySet") _TupleT = TypeVar("_TupleT", bound=tuple[Any, ...], covariant=True) -MAX_GET_RESULTS: int = ... -REPR_OUTPUT_SIZE: int = ... +MAX_GET_RESULTS: int +REPR_OUTPUT_SIZE: int class BaseIterable(Generic[_Row]): queryset: QuerySet[Model] diff --git a/django-stubs/db/models/query_utils.pyi b/django-stubs/db/models/query_utils.pyi index ebe12799e..e45eb9e65 100644 --- a/django-stubs/db/models/query_utils.pyi +++ b/django-stubs/db/models/query_utils.pyi @@ -22,9 +22,9 @@ class InvalidQuery(Exception): ... def subclasses(cls: Type[RegisterLookupMixin]) -> Iterator[Type[RegisterLookupMixin]]: ... class Q(tree.Node): - AND: str = ... - OR: str = ... - conditional: bool = ... + AND: str + OR: str + conditional: bool def __init__(self, *args: Any, **kwargs: Any) -> None: ... # Fake signature, the real is # def __init__(self, *args: Any, _connector: Optional[Any] = ..., _negated: bool = ..., **kwargs: Any) -> None: ... @@ -43,7 +43,7 @@ class Q(tree.Node): def deconstruct(self) -> Tuple[str, Tuple, Dict[str, str]]: ... class DeferredAttribute: - field_name: str = ... + field_name: str field: Field def __init__(self, field: Field) -> None: ... @@ -79,10 +79,10 @@ def refs_expression( def check_rel_lookup_compatibility(model: Type[Model], target_opts: Any, field: FieldCacheMixin) -> bool: ... class FilteredRelation: - relation_name: str = ... - alias: str | None = ... - condition: Q = ... - path: List[str] = ... + relation_name: str + alias: str | None + condition: Q + path: List[str] def __init__(self, relation_name: str, *, condition: Q = ...) -> None: ... def clone(self) -> FilteredRelation: ... def resolve_expression(self, *args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/db/models/sql/compiler.pyi b/django-stubs/db/models/sql/compiler.pyi index bfed85476..9dd9451b5 100644 --- a/django-stubs/db/models/sql/compiler.pyi +++ b/django-stubs/db/models/sql/compiler.pyi @@ -16,18 +16,18 @@ _ParamsT = List[_ParamT] _AsSqlType = Tuple[str, _ParamsT] class SQLCompiler: - query: Query = ... - connection: BaseDatabaseWrapper = ... - using: str | None = ... - quote_cache: Any = ... - select: Any = ... - annotation_col_map: Any = ... - klass_info: Any = ... - ordering_parts: Any = ... + query: Query + connection: BaseDatabaseWrapper + using: str | None + quote_cache: Any + select: Any + annotation_col_map: Any + klass_info: Any + ordering_parts: Any def __init__(self, query: Query, connection: BaseDatabaseWrapper, using: str | None) -> None: ... - col_count: int | None = ... + col_count: int | None def setup_query(self) -> None: ... - has_extra_select: Any = ... + has_extra_select: Any def pre_sql_setup( self, ) -> Tuple[ @@ -113,8 +113,8 @@ class SQLCompiler: class SQLInsertCompiler(SQLCompiler): query: InsertQuery - returning_fields: Sequence[Any] | None = ... - returning_params: Sequence[Any] = ... + returning_fields: Sequence[Any] | None + returning_params: Sequence[Any] def field_as_sql(self, field: Any, val: Any) -> _AsSqlType: ... def prepare_value(self, field: Any, value: Any) -> Any: ... def pre_save_val(self, field: Any, obj: Any) -> Any: ... @@ -140,7 +140,7 @@ class SQLUpdateCompiler(SQLCompiler): class SQLAggregateCompiler(SQLCompiler): query: AggregateQuery - col_count: int = ... + col_count: int def as_sql(self) -> _AsSqlType: ... # type: ignore def cursor_iter( diff --git a/django-stubs/db/models/sql/constants.pyi b/django-stubs/db/models/sql/constants.pyi index f4dfc92db..8e9df3f7d 100644 --- a/django-stubs/db/models/sql/constants.pyi +++ b/django-stubs/db/models/sql/constants.pyi @@ -2,15 +2,15 @@ from typing import Dict, Pattern, Tuple from typing_extensions import Final, Literal -GET_ITERATOR_CHUNK_SIZE: Final[int] = ... +GET_ITERATOR_CHUNK_SIZE: Final[int] -MULTI: Literal["multi"] = ... -SINGLE: Literal["single"] = ... -CURSOR: Literal["cursor"] = ... -NO_RESULTS: Literal["no results"] = ... +MULTI: Literal["multi"] +SINGLE: Literal["single"] +CURSOR: Literal["cursor"] +NO_RESULTS: Literal["no results"] -ORDER_PATTERN: Pattern = ... -ORDER_DIR: Dict[str, Tuple[str, str]] = ... +ORDER_PATTERN: Pattern +ORDER_DIR: Dict[str, Tuple[str, str]] -INNER: Literal["INNER JOIN"] = ... -LOUTER: Literal["LEFT OUTER JOIN"] = ... +INNER: Literal["INNER JOIN"] +LOUTER: Literal["LEFT OUTER JOIN"] diff --git a/django-stubs/db/models/sql/datastructures.pyi b/django-stubs/db/models/sql/datastructures.pyi index f56b7e2ab..57c6a90c1 100644 --- a/django-stubs/db/models/sql/datastructures.pyi +++ b/django-stubs/db/models/sql/datastructures.pyi @@ -6,21 +6,21 @@ from django.db.models.query_utils import FilteredRelation, PathInfo from django.db.models.sql.compiler import SQLCompiler, _AsSqlType class MultiJoin(Exception): - level: int = ... - names_with_path: List[Tuple[str, List[PathInfo]]] = ... + level: int + names_with_path: List[Tuple[str, List[PathInfo]]] def __init__(self, names_pos: int, path_with_names: List[Tuple[str, List[PathInfo]]]) -> None: ... class Empty: ... class Join: - table_name: str = ... - parent_alias: str = ... - table_alias: str | None = ... - join_type: str = ... - join_cols: Tuple = ... - join_field: FieldCacheMixin = ... - nullable: bool = ... - filtered_relation: FilteredRelation | None = ... + table_name: str + parent_alias: str + table_alias: str | None + join_type: str + join_cols: Tuple + join_field: FieldCacheMixin + nullable: bool + filtered_relation: FilteredRelation | None def __init__( self, table_name: str, @@ -38,11 +38,11 @@ class Join: def promote(self) -> Join: ... class BaseTable: - join_type: Any = ... - parent_alias: Any = ... - filtered_relation: Any = ... - table_name: str = ... - table_alias: str | None = ... + join_type: Any + parent_alias: Any + filtered_relation: Any + table_name: str + table_alias: str | None def __init__(self, table_name: str, alias: str | None) -> None: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... def relabeled_clone(self, change_map: Dict[str | None, str]) -> BaseTable: ... diff --git a/django-stubs/db/models/sql/query.pyi b/django-stubs/db/models/sql/query.pyi index 3b2503432..a269c5010 100644 --- a/django-stubs/db/models/sql/query.pyi +++ b/django-stubs/db/models/sql/query.pyi @@ -19,12 +19,12 @@ JoinInfo = namedtuple("JoinInfo", ("final_field", "targets", "opts", "joins", "p class RawQuery: high_mark: int | None low_mark: int | None - params: Any = ... - sql: str = ... - using: str = ... - extra_select: Dict[Any, Any] = ... - annotation_select: Dict[Any, Any] = ... - cursor: CursorWrapper | None = ... + params: Any + sql: str + using: str + extra_select: Dict[Any, Any] + annotation_select: Dict[Any, Any] + cursor: CursorWrapper | None def __init__(self, sql: str, using: str, params: Any = ...) -> None: ... def chain(self, using: str) -> RawQuery: ... def clone(self, using: str) -> RawQuery: ... @@ -37,46 +37,46 @@ class Query(BaseExpression): related_ids: List[int] | None related_updates: Dict[Type[Model], List[Tuple[Field, None, int | str]]] values: List[Any] - alias_prefix: str = ... - subq_aliases: FrozenSet[Any] = ... - compiler: str = ... - model: Type[Model] | None = ... - alias_refcount: Dict[str, int] = ... - alias_map: Dict[str, BaseTable | Join] = ... - external_aliases: Dict[str, bool] = ... - table_map: Dict[str, List[str]] = ... - default_cols: bool = ... - default_ordering: bool = ... - standard_ordering: bool = ... - used_aliases: Set[str] = ... - filter_is_sticky: bool = ... - subquery: bool = ... - group_by: None | Sequence[Combinable] | Sequence[str] | Literal[True] = ... - order_by: Sequence[Any] = ... - distinct: bool = ... - distinct_fields: Tuple[str, ...] = ... + alias_prefix: str + subq_aliases: FrozenSet[Any] + compiler: str + model: Type[Model] | None + alias_refcount: Dict[str, int] + alias_map: Dict[str, BaseTable | Join] + external_aliases: Dict[str, bool] + table_map: Dict[str, List[str]] + default_cols: bool + default_ordering: bool + standard_ordering: bool + used_aliases: Set[str] + filter_is_sticky: bool + subquery: bool + group_by: None | Sequence[Combinable] | Sequence[str] | Literal[True] + order_by: Sequence[Any] + distinct: bool + distinct_fields: Tuple[str, ...] select: Sequence[BaseExpression] - select_for_update: bool = ... - select_for_update_nowait: bool = ... - select_for_update_skip_locked: bool = ... - select_for_update_of: Tuple = ... - select_for_no_key_update: bool = ... - select_related: Dict[str, Any] | bool = ... - max_depth: int = ... - values_select: Tuple = ... - annotation_select_mask: Set[str] | None = ... - combinator: str | None = ... - combinator_all: bool = ... - combined_queries: Tuple = ... - extra_select_mask: Set[str] | None = ... - extra_tables: Tuple = ... - extra_order_by: Sequence[Any] = ... - deferred_loading: Tuple[Set[str] | FrozenSet[str], bool] = ... - explain_query: bool = ... - explain_format: str | None = ... - explain_options: Dict[str, int] = ... - high_mark: int | None = ... - low_mark: int = ... + select_for_update: bool + select_for_update_nowait: bool + select_for_update_skip_locked: bool + select_for_update_of: Tuple + select_for_no_key_update: bool + select_related: Dict[str, Any] | bool + max_depth: int + values_select: Tuple + annotation_select_mask: Set[str] | None + combinator: str | None + combinator_all: bool + combined_queries: Tuple + extra_select_mask: Set[str] | None + extra_tables: Tuple + extra_order_by: Sequence[Any] + deferred_loading: Tuple[Set[str] | FrozenSet[str], bool] + explain_query: bool + explain_format: str | None + explain_options: Dict[str, int] + high_mark: int | None + low_mark: int extra: Dict[str, Any] annotations: Dict[str, Expression] def __init__(self, model: Type[Model] | None, where: Type[WhereNode] = ..., alias_cols: bool = ...) -> None: ... @@ -198,11 +198,11 @@ class Query(BaseExpression): def try_transform(self, lhs: Expression | Query, name: str) -> Transform: ... class JoinPromoter: - connector: str = ... - negated: bool = ... - effective_connector: str = ... - num_children: int = ... - votes: collections.Counter = ... + connector: str + negated: bool + effective_connector: str + num_children: int + votes: collections.Counter def __init__(self, connector: str, num_children: int, negated: bool) -> None: ... def add_votes(self, votes: Iterable[str]) -> None: ... def update_join_types(self, query: Query) -> Set[str]: ... diff --git a/django-stubs/db/models/sql/subqueries.pyi b/django-stubs/db/models/sql/subqueries.pyi index afdab04d0..5d3cd1988 100644 --- a/django-stubs/db/models/sql/subqueries.pyi +++ b/django-stubs/db/models/sql/subqueries.pyi @@ -10,7 +10,7 @@ from django.db.models.sql.where import WhereNode class DeleteQuery(Query): select: Tuple where_class: Type[WhereNode] - where: WhereNode = ... + where: WhereNode def do_query(self, table: str, where: WhereNode, using: str) -> int: ... def delete_batch(self, pk_list: List[int] | List[str], using: str) -> int: ... @@ -18,7 +18,7 @@ class UpdateQuery(Query): select: Tuple where_class: Type[WhereNode] def __init__(self, *args: Any, **kwargs: Any) -> None: ... - where: WhereNode = ... + where: WhereNode def update_batch(self, pk_list: List[int], values: Dict[str, int | None], using: str) -> None: ... def add_update_values(self, values: Dict[str, Any]) -> None: ... def add_update_fields(self, values_seq: List[Tuple[Field, Type[Model] | None, Case]]) -> None: ... @@ -29,9 +29,9 @@ class InsertQuery(Query): select: Tuple where: WhereNode where_class: Type[WhereNode] - fields: Iterable[Field] = ... - objs: List[Model] = ... - raw: bool = ... + fields: Iterable[Field] + objs: List[Model] + raw: bool def __init__(self, *args: Any, ignore_conflicts: bool = ..., **kwargs: Any) -> None: ... def insert_values(self, fields: Iterable[Field], objs: List[Model], raw: bool = ...) -> None: ... diff --git a/django-stubs/db/models/sql/where.pyi b/django-stubs/db/models/sql/where.pyi index e4ccdce77..a904a837a 100644 --- a/django-stubs/db/models/sql/where.pyi +++ b/django-stubs/db/models/sql/where.pyi @@ -12,9 +12,9 @@ OR: str class WhereNode(tree.Node): connector: str negated: bool - default: str = ... - resolved: bool = ... - conditional: bool = ... + default: str + resolved: bool + conditional: bool def split_having(self, negated: bool = ...) -> Tuple[WhereNode | None, WhereNode | None]: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> Any: ... def get_group_by_cols(self, alias: str | None = ...) -> List[Expression]: ... @@ -30,25 +30,25 @@ class WhereNode(tree.Node): def is_summary(self) -> bool: ... class NothingNode: - contains_aggregate: bool = ... + contains_aggregate: bool def as_sql( self, compiler: SQLCompiler | None = ..., connection: BaseDatabaseWrapper | None = ... ) -> _AsSqlType: ... class ExtraWhere: - contains_aggregate: bool = ... - sqls: Sequence[str] = ... - params: Sequence[int] | Sequence[str] | None = ... + contains_aggregate: bool + sqls: Sequence[str] + params: Sequence[int] | Sequence[str] | None def __init__(self, sqls: Sequence[str], params: Sequence[int] | Sequence[str] | None) -> None: ... def as_sql( self, compiler: SQLCompiler | None = ..., connection: BaseDatabaseWrapper | None = ... ) -> _AsSqlType: ... class SubqueryConstraint: - contains_aggregate: bool = ... - alias: str = ... - columns: List[str] = ... - targets: List[str] = ... - query_object: Query = ... + contains_aggregate: bool + alias: str + columns: List[str] + targets: List[str] + query_object: Query def __init__(self, alias: str, columns: List[str], targets: List[str], query_object: Query) -> None: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... diff --git a/django-stubs/db/transaction.pyi b/django-stubs/db/transaction.pyi index 0aab49c48..d93405813 100644 --- a/django-stubs/db/transaction.pyi +++ b/django-stubs/db/transaction.pyi @@ -25,8 +25,8 @@ _C = TypeVar("_C", bound=Callable) # Any callable # Don't inherit from ContextDecorator, so we can provide a more specific signature for __call__ class Atomic: - using: str | None = ... - savepoint: bool = ... + using: str | None + savepoint: bool def __init__(self, using: str | None, savepoint: bool, durable: bool) -> None: ... # When decorating, return the decorated function as-is, rather than clobbering it as ContextDecorator does. def __call__(self, func: _C) -> _C: ... diff --git a/django-stubs/dispatch/dispatcher.pyi b/django-stubs/dispatch/dispatcher.pyi index 55f069096..bb1fcb2bb 100644 --- a/django-stubs/dispatch/dispatcher.pyi +++ b/django-stubs/dispatch/dispatcher.pyi @@ -4,11 +4,11 @@ NONE_ID: Any NO_RECEIVERS: Any class Signal: - receivers: Any = ... - providing_args: Any = ... - lock: Any = ... - use_caching: Any = ... - sender_receivers_cache: Any = ... + receivers: Any + providing_args: Any + lock: Any + use_caching: Any + sender_receivers_cache: Any def __init__(self, providing_args: List[str] = ..., use_caching: bool = ...) -> None: ... def connect( self, receiver: Callable, sender: object | None = ..., weak: bool = ..., dispatch_uid: str | None = ... diff --git a/django-stubs/forms/boundfield.pyi b/django-stubs/forms/boundfield.pyi index 8e6c8c5fa..31ba7e192 100644 --- a/django-stubs/forms/boundfield.pyi +++ b/django-stubs/forms/boundfield.pyi @@ -11,14 +11,14 @@ from django.utils.safestring import SafeString _AttrsT = Dict[str, str | bool] class BoundField: - form: BaseForm = ... - field: Field = ... - name: str = ... - html_name: str = ... - html_initial_name: str = ... - html_initial_id: str = ... - label: _StrOrPromise = ... - help_text: _StrOrPromise = ... + form: BaseForm + field: Field + name: str + html_name: str + html_initial_name: str + html_initial_id: str + label: _StrOrPromise + help_text: _StrOrPromise def __init__(self, form: BaseForm, field: Field, name: str) -> None: ... @property def subwidgets(self) -> List[BoundWidget]: ... @@ -57,9 +57,9 @@ class BoundField: def widget_type(self) -> str: ... class BoundWidget: - parent_widget: Widget = ... - data: Dict[str, Any] = ... - renderer: BaseRenderer = ... + parent_widget: Widget + data: Dict[str, Any] + renderer: BaseRenderer def __init__(self, parent_widget: Widget, data: Dict[str, Any], renderer: BaseRenderer) -> None: ... def tag(self, wrap_label: bool = ...) -> SafeString: ... @property diff --git a/django-stubs/forms/fields.pyi b/django-stubs/forms/fields.pyi index cc6def18b..55ca32365 100644 --- a/django-stubs/forms/fields.pyi +++ b/django-stubs/forms/fields.pyi @@ -25,19 +25,19 @@ class Field: initial: Any label: _StrOrPromise | None required: bool - widget: _ClassLevelWidgetT = ... - hidden_widget: Type[Widget] = ... - default_validators: List[_ValidatorCallable] = ... - default_error_messages: _ErrorMessagesT = ... - empty_values: Sequence[Any] = ... - show_hidden_initial: bool = ... - help_text: _StrOrPromise = ... - disabled: bool = ... - label_suffix: str | None = ... - localize: bool = ... - error_messages: _ErrorMessagesT = ... - validators: List[_ValidatorCallable] = ... - max_length: int | None = ... + widget: _ClassLevelWidgetT + hidden_widget: Type[Widget] + default_validators: List[_ValidatorCallable] + default_error_messages: _ErrorMessagesT + empty_values: Sequence[Any] + show_hidden_initial: bool + help_text: _StrOrPromise + disabled: bool + label_suffix: str | None + localize: bool + error_messages: _ErrorMessagesT + validators: List[_ValidatorCallable] + max_length: int | None def __init__( self, *, @@ -65,10 +65,10 @@ class Field: def deconstruct(self) -> Any: ... class CharField(Field): - max_length: int | None = ... - min_length: int | None = ... - strip: bool = ... - empty_value: str | None = ... + max_length: int | None + min_length: int | None + strip: bool + empty_value: str | None def __init__( self, *, @@ -94,7 +94,7 @@ class CharField(Field): class IntegerField(Field): max_value: int | None min_value: int | None - re_decimal: Any = ... + re_decimal: Any def __init__( self, *, @@ -164,7 +164,7 @@ class DecimalField(IntegerField): def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... class BaseTemporalField(Field): - input_formats: Any = ... + input_formats: Any def __init__( self, *, @@ -204,7 +204,7 @@ class DurationField(Field): def to_python(self, value: Any | None) -> datetime.timedelta | None: ... class RegexField(CharField): - regex: _PropertyDescriptor[str | Pattern[str], Pattern[str]] = ... + regex: _PropertyDescriptor[str | Pattern[str], Pattern[str]] def __init__( self, regex: str | Pattern[str], @@ -248,7 +248,7 @@ class EmailField(CharField): ) -> None: ... class FileField(Field): - allow_empty_file: bool = ... + allow_empty_file: bool def __init__( self, *, @@ -307,7 +307,7 @@ class NullBooleanField(BooleanField): def validate(self, value: Any) -> None: ... class CallableChoiceIterator: - choices_func: _ChoicesCallable = ... + choices_func: _ChoicesCallable def __init__(self, choices_func: _ChoicesCallable) -> None: ... def __iter__(self) -> Iterator[_Choice | _ChoiceNamedGroup]: ... @@ -315,7 +315,7 @@ class ChoiceField(Field): choices: _PropertyDescriptor[ _FieldChoices | _ChoicesCallable | CallableChoiceIterator, _FieldChoices | CallableChoiceIterator, - ] = ... + ] widget: _ClassLevelWidgetT def __init__( self, @@ -343,8 +343,8 @@ class _CoerceCallable(Protocol): def __call__(self, __value: Any) -> Any: ... class TypedChoiceField(ChoiceField): - coerce: _CoerceCallable = ... - empty_value: str | None = ... + coerce: _CoerceCallable + empty_value: str | None def __init__( self, *, @@ -371,8 +371,8 @@ class MultipleChoiceField(ChoiceField): def has_changed(self, initial: Collection[Any] | None, data: Collection[Any] | None) -> bool: ... class TypedMultipleChoiceField(MultipleChoiceField): - coerce: _CoerceCallable = ... - empty_value: List[Any] | None = ... + coerce: _CoerceCallable + empty_value: List[Any] | None def __init__( self, *, @@ -395,7 +395,7 @@ class TypedMultipleChoiceField(MultipleChoiceField): def validate(self, value: Any) -> None: ... class ComboField(Field): - fields: Sequence[Field] = ... + fields: Sequence[Field] def __init__( self, fields: Sequence[Field], @@ -415,8 +415,8 @@ class ComboField(Field): def clean(self, value: Any) -> Any: ... class MultiValueField(Field): - require_all_fields: bool = ... - fields: Sequence[Field] = ... + require_all_fields: bool + fields: Sequence[Field] def __init__( self, fields: Sequence[Field], @@ -445,7 +445,7 @@ class FilePathField(ChoiceField): match: str | None path: str recursive: bool - match_re: Pattern[str] | None = ... + match_re: Pattern[str] | None def __init__( self, path: str, @@ -491,7 +491,7 @@ class SplitDateTimeField(MultiValueField): def compress(self, data_list: Tuple[datetime.date, datetime.time] | None) -> datetime.datetime | None: ... class GenericIPAddressField(CharField): - unpack_ipv4: bool = ... + unpack_ipv4: bool def __init__( self, *, @@ -512,7 +512,7 @@ class GenericIPAddressField(CharField): def to_python(self, value: Any) -> str: ... class SlugField(CharField): - allow_unicode: bool = ... + allow_unicode: bool def __init__( self, *, @@ -542,10 +542,10 @@ class InvalidJSONInput(str): ... class JSONString(str): ... class JSONField(CharField): - default_error_messages: _ErrorMessagesT = ... - widget: _ClassLevelWidgetT = ... - encoder: Any = ... - decoder: Any = ... + default_error_messages: _ErrorMessagesT + widget: _ClassLevelWidgetT + encoder: Any + decoder: Any def __init__(self, encoder: Any | None = ..., decoder: Any | None = ..., **kwargs: Any) -> None: ... def to_python(self, value: Any) -> Any: ... def bound_data(self, data: Any, initial: Any) -> Any: ... diff --git a/django-stubs/forms/forms.pyi b/django-stubs/forms/forms.pyi index d38cc70f4..c8c6e11ca 100644 --- a/django-stubs/forms/forms.pyi +++ b/django-stubs/forms/forms.pyi @@ -12,22 +12,22 @@ class DeclarativeFieldsMetaclass(MediaDefiningClass): ... class BaseForm: class Meta: - fields: Sequence[str] = ... - default_renderer: BaseRenderer | Type[BaseRenderer] | None = ... - field_order: Iterable[str] | None = ... - use_required_attribute: bool = ... - is_bound: bool = ... - data: _DataT = ... - files: _FilesT = ... - auto_id: bool | str = ... - initial: Mapping[str, Any] = ... - error_class: Type[ErrorList] = ... - prefix: str | None = ... - label_suffix: str = ... - empty_permitted: bool = ... - fields: Dict[str, Field] = ... - renderer: BaseRenderer = ... - cleaned_data: Dict[str, Any] = ... + fields: Sequence[str] + default_renderer: BaseRenderer | Type[BaseRenderer] | None + field_order: Iterable[str] | None + use_required_attribute: bool + is_bound: bool + data: _DataT + files: _FilesT + auto_id: bool | str + initial: Mapping[str, Any] + error_class: Type[ErrorList] + prefix: str | None + label_suffix: str + empty_permitted: bool + fields: Dict[str, Field] + renderer: BaseRenderer + cleaned_data: Dict[str, Any] def __init__( self, data: _DataT | None = ..., diff --git a/django-stubs/forms/formsets.pyi b/django-stubs/forms/formsets.pyi index a27e7bcb1..f95f0bc2a 100644 --- a/django-stubs/forms/formsets.pyi +++ b/django-stubs/forms/formsets.pyi @@ -5,15 +5,15 @@ from django.forms.utils import ErrorList, _DataT, _FilesT from django.forms.widgets import Media, Widget from django.utils.safestring import SafeString -TOTAL_FORM_COUNT: str = ... -INITIAL_FORM_COUNT: str = ... -MIN_NUM_FORM_COUNT: str = ... -MAX_NUM_FORM_COUNT: str = ... -ORDERING_FIELD_NAME: str = ... -DELETION_FIELD_NAME: str = ... +TOTAL_FORM_COUNT: str +INITIAL_FORM_COUNT: str +MIN_NUM_FORM_COUNT: str +MAX_NUM_FORM_COUNT: str +ORDERING_FIELD_NAME: str +DELETION_FIELD_NAME: str -DEFAULT_MIN_NUM: int = ... -DEFAULT_MAX_NUM: int = ... +DEFAULT_MIN_NUM: int +DEFAULT_MAX_NUM: int _F = TypeVar("_F", bound=BaseForm) @@ -34,14 +34,14 @@ class BaseFormSet(Generic[_F], Sized): validate_min: bool validate_max: bool - is_bound: bool = ... - prefix: str | None = ... - auto_id: str = ... - data: _DataT = ... - files: _FilesT = ... - initial: Sequence[Mapping[str, Any]] | None = ... - form_kwargs: Dict[str, Any] = ... - error_class: Type[ErrorList] = ... + is_bound: bool + prefix: str | None + auto_id: str + data: _DataT + files: _FilesT + initial: Sequence[Mapping[str, Any]] | None + form_kwargs: Dict[str, Any] + error_class: Type[ErrorList] ordering_widget: Type[Widget] def __init__( self, diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index 43b154f8c..3fe96acd6 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -69,15 +69,15 @@ def fields_for_model( ) -> Dict[str, Any]: ... class ModelFormOptions(Generic[_M]): - model: Type[_M] = ... - fields: _Fields | None = ... - exclude: _Fields | None = ... - widgets: _Widgets | None = ... - localized_fields: _Fields | None = ... - labels: _Labels | None = ... - help_texts: _HelpTexts | None = ... - error_messages: _ErrorMessages | None = ... - field_classes: Dict[str, Type[Field]] | None = ... + model: Type[_M] + fields: _Fields | None + exclude: _Fields | None + widgets: _Widgets | None + localized_fields: _Fields | None + labels: _Labels | None + help_texts: _HelpTexts | None + error_messages: _ErrorMessages | None + field_classes: Dict[str, Type[Field]] | None def __init__(self, options: type | None = ...) -> None: ... class ModelFormMetaclass(DeclarativeFieldsMetaclass): ... @@ -104,7 +104,7 @@ class BaseModelForm(Generic[_M], BaseForm): def save_m2m(self) -> None: ... class ModelForm(BaseModelForm[_M], metaclass=ModelFormMetaclass): - base_fields: ClassVar[Dict[str, Field]] = ... + base_fields: ClassVar[Dict[str, Field]] def modelform_factory( model: Type[_M], @@ -123,10 +123,10 @@ def modelform_factory( _ModelFormT = TypeVar("_ModelFormT", bound=ModelForm) class BaseModelFormSet(Generic[_M, _ModelFormT], BaseFormSet[_ModelFormT]): - model: Type[_M] = ... - unique_fields: Collection[str] = ... - queryset: QuerySet[_M] | None = ... - initial_extra: Sequence[Dict[str, Any]] | None = ... + model: Type[_M] + unique_fields: Collection[str] + queryset: QuerySet[_M] | None + initial_extra: Sequence[Dict[str, Any]] | None def __init__( self, data: _DataT | None = ..., @@ -143,7 +143,7 @@ class BaseModelFormSet(Generic[_M, _ModelFormT], BaseFormSet[_ModelFormT]): def save_new(self, form: _ModelFormT, commit: bool = ...) -> _M: ... def save_existing(self, form: _ModelFormT, instance: _M, commit: bool = ...) -> _M: ... def delete_existing(self, obj: _M, commit: bool = ...) -> None: ... - saved_forms: List[_ModelFormT] = ... + saved_forms: List[_ModelFormT] def save_m2m(self) -> None: ... def save(self, commit: bool = ...) -> List[_M]: ... def clean(self) -> None: ... @@ -151,10 +151,10 @@ class BaseModelFormSet(Generic[_M, _ModelFormT], BaseFormSet[_ModelFormT]): def get_unique_error_message(self, unique_check: Sequence[str]) -> str: ... def get_date_error_message(self, date_check: Tuple[str, Literal["date", "year", "month"], str, str]) -> str: ... def get_form_error(self) -> str: ... - changed_objects: List[Tuple[_M, List[str]]] = ... - deleted_objects: List[_M] = ... + changed_objects: List[Tuple[_M, List[str]]] + deleted_objects: List[_M] def save_existing_objects(self, commit: bool = ...) -> List[_M]: ... - new_objects: List[_M] = ... + new_objects: List[_M] def save_new_objects(self, commit: bool = ...) -> List[_M]: ... def add_fields(self, form: _ModelFormT, index: int | None) -> None: ... @@ -184,8 +184,8 @@ def modelformset_factory( class BaseInlineFormSet(Generic[_M, _ParentM, _ModelFormT], BaseModelFormSet[_M, _ModelFormT]): instance: _ParentM - save_as_new: bool = ... - unique_fields: Collection[str] = ... + save_as_new: bool + unique_fields: Collection[str] fk: ForeignKey # set by inlineformset_set def __init__( self, @@ -235,11 +235,11 @@ class InlineForeignKeyField(Field): help_text: _StrOrPromise required: bool show_hidden_initial: bool - widget: _ClassLevelWidgetT = ... - default_error_messages: Dict[str, str] = ... - parent_instance: Model = ... - pk_field: bool = ... - to_field: str | None = ... + widget: _ClassLevelWidgetT + default_error_messages: Dict[str, str] + parent_instance: Model + pk_field: bool + to_field: str | None def __init__( self, parent_instance: Model, @@ -256,8 +256,8 @@ class ModelChoiceIteratorValue: def __str__(self) -> str: ... class ModelChoiceIterator: - field: ModelChoiceField = ... - queryset: QuerySet = ... + field: ModelChoiceField + queryset: QuerySet def __init__(self, field: ModelChoiceField) -> None: ... def __iter__(self) -> Iterator[Tuple[ModelChoiceIteratorValue | str, str]]: ... def __len__(self) -> int: ... @@ -271,12 +271,12 @@ class ModelChoiceField(ChoiceField): required: bool show_hidden_initial: bool validators: List[Any] - default_error_messages: Dict[str, str] = ... - iterator: Type[ModelChoiceIterator] = ... - empty_label: _StrOrPromise | None = ... - queryset: QuerySet[models.Model] | None = ... - limit_choices_to: _AllLimitChoicesTo | None = ... - to_field_name: str | None = ... + default_error_messages: Dict[str, str] + iterator: Type[ModelChoiceIterator] + empty_label: _StrOrPromise | None + queryset: QuerySet[models.Model] | None + limit_choices_to: _AllLimitChoicesTo | None + to_field_name: str | None def __init__( self, queryset: None | Manager[models.Model] | QuerySet[models.Model], @@ -297,7 +297,7 @@ class ModelChoiceField(ChoiceField): choices: _PropertyDescriptor[ _FieldChoices | _ChoicesCallable | CallableChoiceIterator, _FieldChoices | CallableChoiceIterator | ModelChoiceIterator, - ] = ... + ] def prepare_value(self, value: Any) -> Any: ... def to_python(self, value: Any | None) -> Model | None: ... def validate(self, value: Model | None) -> None: ... @@ -309,9 +309,9 @@ class ModelMultipleChoiceField(ModelChoiceField): help_text: _StrOrPromise required: bool show_hidden_initial: bool - widget: _ClassLevelWidgetT = ... - hidden_widget: Type[Widget] = ... - default_error_messages: Dict[str, str] = ... + widget: _ClassLevelWidgetT + hidden_widget: Type[Widget] + default_error_messages: Dict[str, str] def __init__(self, queryset: None | Manager[Model] | QuerySet[Model], **kwargs: Any) -> None: ... def to_python(self, value: Any) -> List[Model]: ... # type: ignore[override] def clean(self, value: Any) -> QuerySet[Model]: ... diff --git a/django-stubs/forms/renderers.pyi b/django-stubs/forms/renderers.pyi index d59fdb18d..afa9ef106 100644 --- a/django-stubs/forms/renderers.pyi +++ b/django-stubs/forms/renderers.pyi @@ -18,7 +18,7 @@ class EngineMixin: def engine(self) -> BaseEngine: ... class DjangoTemplates(EngineMixin, BaseRenderer): - backend: Type[DjangoTemplatesR] = ... + backend: Type[DjangoTemplatesR] class Jinja2(EngineMixin, BaseRenderer): @property diff --git a/django-stubs/forms/utils.pyi b/django-stubs/forms/utils.pyi index 5c239ac63..d9d879c3e 100644 --- a/django-stubs/forms/utils.pyi +++ b/django-stubs/forms/utils.pyi @@ -22,7 +22,7 @@ class ErrorDict(dict): class ErrorList(UserList): data: List[ValidationError | str] - error_class: str = ... + error_class: str def __init__( self, initlist: ErrorList | Sequence[str | Exception] | None = ..., diff --git a/django-stubs/forms/widgets.pyi b/django-stubs/forms/widgets.pyi index 8428bff2f..598920e37 100644 --- a/django-stubs/forms/widgets.pyi +++ b/django-stubs/forms/widgets.pyi @@ -33,11 +33,11 @@ class Media: class MediaDefiningClass(type): ... class Widget(metaclass=MediaDefiningClass): - needs_multipart_form: bool = ... - is_localized: bool = ... - is_required: bool = ... - supports_microseconds: bool = ... - attrs: _OptAttrs = ... + needs_multipart_form: bool + is_localized: bool + is_required: bool + supports_microseconds: bool + attrs: _OptAttrs template_name: str media: _Getter[Media] def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... @@ -56,44 +56,44 @@ class Widget(metaclass=MediaDefiningClass): def use_required_attribute(self, initial: Any) -> bool: ... class Input(Widget): - input_type: str = ... - template_name: str = ... + input_type: str + template_name: str class TextInput(Input): - input_type: str = ... - template_name: str = ... + input_type: str + template_name: str class NumberInput(Input): - input_type: str = ... - template_name: str = ... + input_type: str + template_name: str class EmailInput(Input): - input_type: str = ... - template_name: str = ... + input_type: str + template_name: str class URLInput(Input): - input_type: str = ... - template_name: str = ... + input_type: str + template_name: str class PasswordInput(Input): - render_value: bool = ... - input_type: str = ... - template_name: str = ... + render_value: bool + input_type: str + template_name: str def __init__(self, attrs: _OptAttrs | None = ..., render_value: bool = ...) -> None: ... def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... class HiddenInput(Input): choices: _FieldChoices - input_type: str = ... - template_name: str = ... + input_type: str + template_name: str class MultipleHiddenInput(HiddenInput): - template_name: str = ... + template_name: str class FileInput(Input): - input_type: str = ... - template_name: str = ... - needs_multipart_form: bool = ... + input_type: str + template_name: str + needs_multipart_form: bool def format_value(self, value: Any) -> None: ... def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... @@ -102,10 +102,10 @@ class FileInput(Input): FILE_INPUT_CONTRADICTION: object class ClearableFileInput(FileInput): - clear_checkbox_label: str = ... - initial_text: str = ... - input_text: str = ... - template_name: str = ... + clear_checkbox_label: str + initial_text: str + input_text: str + template_name: str def clear_checkbox_name(self, name: str) -> str: ... def clear_checkbox_id(self, name: str) -> str: ... def is_initial(self, value: File | str | None) -> bool: ... @@ -114,26 +114,26 @@ class ClearableFileInput(FileInput): def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... class Textarea(Widget): - template_name: str = ... + template_name: str def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... class DateTimeBaseInput(TextInput): - format_key: str = ... - format: str | None = ... - supports_microseconds: bool = ... + format_key: str + format: str | None + supports_microseconds: bool def __init__(self, attrs: _OptAttrs | None = ..., format: str | None = ...) -> None: ... class DateInput(DateTimeBaseInput): - format_key: str = ... - template_name: str = ... + format_key: str + template_name: str class DateTimeInput(DateTimeBaseInput): - format_key: str = ... - template_name: str = ... + format_key: str + template_name: str class TimeInput(DateTimeBaseInput): - format_key: str = ... - template_name: str = ... + format_key: str + template_name: str def boolean_check(v: Any) -> bool: ... @@ -141,20 +141,20 @@ class _CheckCallable(Protocol): def __call__(self, __value: Any) -> bool: ... class CheckboxInput(Input): - check_test: _CheckCallable = ... - input_type: str = ... - template_name: str = ... + check_test: _CheckCallable + input_type: str + template_name: str def __init__(self, attrs: _OptAttrs | None = ..., check_test: _CheckCallable | None = ...) -> None: ... class ChoiceWidget(Widget): - allow_multiple_selected: bool = ... - input_type: str | None = ... - template_name: str = ... - option_template_name: str | None = ... - add_id_index: bool = ... - checked_attribute: Any = ... - option_inherits_attrs: bool = ... - choices: _FieldChoices = ... + allow_multiple_selected: bool + input_type: str | None + template_name: str + option_template_name: str | None + add_id_index: bool + checked_attribute: Any + option_inherits_attrs: bool + choices: _FieldChoices def __init__(self, attrs: _OptAttrs | None = ..., choices: _FieldChoices = ...) -> None: ... def subwidgets(self, name: str, value: Any, attrs: _OptAttrs = ...) -> Iterator[Dict[str, Any]]: ... def options(self, name: str, value: List[str], attrs: _OptAttrs | None = ...) -> Iterator[Dict[str, Any]]: ... @@ -177,12 +177,12 @@ class ChoiceWidget(Widget): def format_value(self, value: Any) -> List[str]: ... # type: ignore class Select(ChoiceWidget): - input_type: str | None = ... - template_name: str = ... - option_template_name: str = ... - add_id_index: bool = ... - checked_attribute: Any = ... - option_inherits_attrs: bool = ... + input_type: str | None + template_name: str + option_template_name: str + add_id_index: bool + checked_attribute: Any + option_inherits_attrs: bool def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... def use_required_attribute(self, initial: Any) -> bool: ... @@ -192,28 +192,28 @@ class NullBooleanSelect(Select): def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> bool | None: ... class SelectMultiple(Select): - allow_multiple_selected: bool = ... + allow_multiple_selected: bool def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... class RadioSelect(ChoiceWidget): can_add_related: bool - input_type: str = ... - template_name: str = ... - option_template_name: str = ... + input_type: str + template_name: str + option_template_name: str class CheckboxSelectMultiple(ChoiceWidget): can_add_related: bool - input_type: str = ... - template_name: str = ... - option_template_name: str = ... + input_type: str + template_name: str + option_template_name: str def use_required_attribute(self, initial: Any) -> bool: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... def id_for_label(self, id_: str, index: str | None = ...) -> str: ... class MultiWidget(Widget): - template_name: str = ... - widgets: Sequence[Widget] = ... + template_name: str + widgets: Sequence[Widget] def __init__( self, widgets: Dict[str, Widget | Type[Widget]] | Sequence[Widget | Type[Widget]], @@ -226,13 +226,13 @@ class MultiWidget(Widget): def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> List[Any]: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... def decompress(self, value: Any) -> Any | None: ... - media: _Getter[Media] = ... + media: _Getter[Media] @property def needs_multipart_form(self) -> bool: ... # type: ignore class SplitDateTimeWidget(MultiWidget): - supports_microseconds: bool = ... - template_name: str = ... + supports_microseconds: bool + template_name: str widgets: Tuple[DateInput, TimeInput] def __init__( self, @@ -245,7 +245,7 @@ class SplitDateTimeWidget(MultiWidget): def decompress(self, value: Any) -> Tuple[datetime.date | None, datetime.time | None]: ... class SplitHiddenDateTimeWidget(SplitDateTimeWidget): - template_name: str = ... + template_name: str def __init__( self, attrs: _OptAttrs | None = ..., @@ -256,19 +256,19 @@ class SplitHiddenDateTimeWidget(SplitDateTimeWidget): ) -> None: ... class SelectDateWidget(Widget): - none_value: Tuple[Literal[""], str] = ... - month_field: str = ... - day_field: str = ... - year_field: str = ... - template_name: str = ... - input_type: str = ... - select_widget: Type[ChoiceWidget] = ... - date_re: Any = ... - years: Iterable[int | str] = ... - months: Mapping[int, str] = ... - year_none_value: Tuple[Literal[""], str] = ... - month_none_value: Tuple[Literal[""], str] = ... - day_none_value: Tuple[Literal[""], str] = ... + none_value: Tuple[Literal[""], str] + month_field: str + day_field: str + year_field: str + template_name: str + input_type: str + select_widget: Type[ChoiceWidget] + date_re: Any + years: Iterable[int | str] + months: Mapping[int, str] + year_none_value: Tuple[Literal[""], str] + month_none_value: Tuple[Literal[""], str] + day_none_value: Tuple[Literal[""], str] def __init__( self, attrs: _OptAttrs | None = ..., diff --git a/django-stubs/http/multipartparser.pyi b/django-stubs/http/multipartparser.pyi index 87ac8a5f6..b344f0d7c 100644 --- a/django-stubs/http/multipartparser.pyi +++ b/django-stubs/http/multipartparser.pyi @@ -24,8 +24,8 @@ class MultiPartParser: def sanitize_file_name(self, file_name: str) -> str | None: ... class LazyStream: - length: int | None = ... - position: int = ... + length: int | None + position: int def __init__(self, producer: BoundaryIter | ChunkIter, length: int | None = ...) -> None: ... def tell(self) -> int: ... def read(self, size: int | None = ...) -> bytes: ... @@ -35,8 +35,8 @@ class LazyStream: def unget(self, bytes: bytes) -> None: ... class ChunkIter: - flo: IO[bytes] = ... - chunk_size: int = ... + flo: IO[bytes] + chunk_size: int def __init__(self, flo: IO[bytes], chunk_size: int = ...) -> None: ... def __next__(self) -> bytes: ... def __iter__(self) -> ChunkIter: ... diff --git a/django-stubs/http/request.pyi b/django-stubs/http/request.pyi index 8126697f8..541da24c1 100644 --- a/django-stubs/http/request.pyi +++ b/django-stubs/http/request.pyi @@ -10,8 +10,8 @@ from django.urls import ResolverMatch from django.utils.datastructures import CaseInsensitiveMapping, ImmutableList, MultiValueDict from typing_extensions import Literal -RAISE_ERROR: object = ... -host_validation_re: Pattern[str] = ... +RAISE_ERROR: object +host_validation_re: Pattern[str] class UnreadablePostError(OSError): ... class RawPostDataException(Exception): ... @@ -19,24 +19,24 @@ class RawPostDataException(Exception): ... UploadHandlerList = List[uploadhandler.FileUploadHandler] | ImmutableList[uploadhandler.FileUploadHandler] class HttpHeaders(CaseInsensitiveMapping[str]): - HTTP_PREFIX: str = ... - UNPREFIXED_HEADERS: Set[str] = ... + HTTP_PREFIX: str + UNPREFIXED_HEADERS: Set[str] def __init__(self, environ: Mapping[str, Any]) -> None: ... @classmethod def parse_header_name(cls, header: str) -> str | None: ... class HttpRequest(BytesIO): - GET: _ImmutableQueryDict = ... - POST: _ImmutableQueryDict = ... - COOKIES: Dict[str, str] = ... - META: Dict[str, Any] = ... - FILES: MultiValueDict[str, uploadedfile.UploadedFile] = ... - path: str = ... - path_info: str = ... - method: str | None = ... - resolver_match: ResolverMatch | None = ... - content_type: str | None = ... - content_params: Dict[str, str] | None = ... + GET: _ImmutableQueryDict + POST: _ImmutableQueryDict + COOKIES: Dict[str, str] + META: Dict[str, Any] + FILES: MultiValueDict[str, uploadedfile.UploadedFile] + path: str + path_info: str + method: str | None + resolver_match: ResolverMatch | None + content_type: str | None + content_params: Dict[str, str] | None _stream: BinaryIO # Attributes added by optional parts of Django # django.contrib.admin views: @@ -93,14 +93,14 @@ class HttpRequest(BytesIO): def accepts(self, media_type: str) -> bool: ... class _MutableHttpRequest(HttpRequest): - GET: QueryDict = ... # type: ignore[assignment] - POST: QueryDict = ... # type: ignore[assignment] + GET: QueryDict # type: ignore[assignment] + POST: QueryDict # type: ignore[assignment] _Q = TypeVar("_Q", bound="QueryDict") _Z = TypeVar("_Z") class QueryDict(MultiValueDict[str, str]): - _mutable: bool = ... + _mutable: bool # We can make it mutable only by specifying `mutable=True`. # It can be done a) with kwarg and b) with pos. arg. `overload` has # some problems with args/kwargs + Literal, so two signatures are required. diff --git a/django-stubs/http/response.pyi b/django-stubs/http/response.pyi index f7c604360..80df78c19 100644 --- a/django-stubs/http/response.pyi +++ b/django-stubs/http/response.pyi @@ -20,11 +20,11 @@ class ResponseHeaders(CaseInsensitiveMapping[str]): def setdefault(self, key: str, value: str | bytes | int) -> None: ... class HttpResponseBase: - status_code: int = ... - streaming: bool = ... - cookies: SimpleCookie = ... - closed: bool = ... - headers: ResponseHeaders = ... + status_code: int + streaming: bool + cookies: SimpleCookie + closed: bool + headers: ResponseHeaders def __init__( self, content_type: str | None = ..., @@ -111,14 +111,14 @@ class StreamingHttpResponse(HttpResponseBase, Iterable[bytes]): class FileResponse(StreamingHttpResponse): file_to_stream: BytesIO | None - block_size: int = ... - as_attachment: bool = ... - filename: str = ... + block_size: int + as_attachment: bool + filename: str def __init__(self, *args: Any, as_attachment: bool = ..., filename: str = ..., **kwargs: Any) -> None: ... def set_headers(self, filelike: BytesIO) -> None: ... class HttpResponseRedirectBase(HttpResponse): - allowed_schemes: List[str] = ... + allowed_schemes: List[str] def __init__(self, redirect_to: str, *args: Any, **kwargs: Any) -> None: ... @property def url(self) -> str: ... diff --git a/django-stubs/middleware/cache.pyi b/django-stubs/middleware/cache.pyi index da13dc32f..be9de09b0 100644 --- a/django-stubs/middleware/cache.pyi +++ b/django-stubs/middleware/cache.pyi @@ -6,23 +6,23 @@ from django.http.response import HttpResponse, HttpResponseBase from django.utils.deprecation import MiddlewareMixin class UpdateCacheMiddleware(MiddlewareMixin): - cache_timeout: float = ... - key_prefix: str = ... - cache_alias: str = ... - cache: BaseCache = ... + cache_timeout: float + key_prefix: str + cache_alias: str + cache: BaseCache def process_response(self, request: HttpRequest, response: HttpResponseBase | str) -> HttpResponseBase | str: ... class FetchFromCacheMiddleware(MiddlewareMixin): - key_prefix: str = ... - cache_alias: str = ... - cache: BaseCache = ... + key_prefix: str + cache_alias: str + cache: BaseCache def process_request(self, request: HttpRequest) -> HttpResponse | None: ... class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware): - key_prefix: str = ... - cache_alias: str = ... - cache_timeout: float = ... - cache: BaseCache = ... + key_prefix: str + cache_alias: str + cache_timeout: float + cache: BaseCache def __init__( self, get_response: Callable = ..., diff --git a/django-stubs/middleware/common.pyi b/django-stubs/middleware/common.pyi index 2fe18ff99..3fb1651f5 100644 --- a/django-stubs/middleware/common.pyi +++ b/django-stubs/middleware/common.pyi @@ -5,7 +5,7 @@ from django.http.response import HttpResponseBase, HttpResponsePermanentRedirect from django.utils.deprecation import MiddlewareMixin class CommonMiddleware(MiddlewareMixin): - response_redirect_class: Any = ... + response_redirect_class: Any def process_request(self, request: HttpRequest) -> HttpResponsePermanentRedirect | None: ... def should_redirect_with_slash(self, request: HttpRequest) -> bool: ... def get_full_path_with_slash(self, request: HttpRequest) -> str: ... diff --git a/django-stubs/middleware/locale.pyi b/django-stubs/middleware/locale.pyi index ed2476793..b772011f7 100644 --- a/django-stubs/middleware/locale.pyi +++ b/django-stubs/middleware/locale.pyi @@ -5,6 +5,6 @@ from django.http.response import HttpResponseBase from django.utils.deprecation import MiddlewareMixin class LocaleMiddleware(MiddlewareMixin): - response_redirect_class: Any = ... + response_redirect_class: Any def process_request(self, request: HttpRequest) -> None: ... def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ... diff --git a/django-stubs/middleware/security.pyi b/django-stubs/middleware/security.pyi index 800a25452..a1bb853b9 100644 --- a/django-stubs/middleware/security.pyi +++ b/django-stubs/middleware/security.pyi @@ -5,13 +5,13 @@ from django.http.response import HttpResponse, HttpResponsePermanentRedirect from django.utils.deprecation import MiddlewareMixin class SecurityMiddleware(MiddlewareMixin): - sts_seconds: int = ... - sts_include_subdomains: bool = ... - sts_preload: bool = ... - content_type_nosniff: bool = ... - xss_filter: bool = ... - redirect: bool = ... - redirect_host: str | None = ... - redirect_exempt: List[Any] = ... + sts_seconds: int + sts_include_subdomains: bool + sts_preload: bool + content_type_nosniff: bool + xss_filter: bool + redirect: bool + redirect_host: str | None + redirect_exempt: List[Any] def process_request(self, request: HttpRequest) -> HttpResponsePermanentRedirect | None: ... def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ... diff --git a/django-stubs/template/backends/base.pyi b/django-stubs/template/backends/base.pyi index 7baa26b09..ee2a9d4bc 100644 --- a/django-stubs/template/backends/base.pyi +++ b/django-stubs/template/backends/base.pyi @@ -6,9 +6,9 @@ from django.template.base import Context from django.utils.safestring import SafeString class BaseEngine: - name: str = ... - dirs: List[str] = ... - app_dirs: bool = ... + name: str + dirs: List[str] + app_dirs: bool def __init__(self, params: Mapping[str, Any]) -> None: ... @property def app_dirname(self) -> str | None: ... diff --git a/django-stubs/template/backends/django.pyi b/django-stubs/template/backends/django.pyi index ea8e430fc..968e01e44 100644 --- a/django-stubs/template/backends/django.pyi +++ b/django-stubs/template/backends/django.pyi @@ -6,7 +6,7 @@ from django.template.exceptions import TemplateDoesNotExist from .base import BaseEngine class DjangoTemplates(BaseEngine): - engine: Engine = ... + engine: Engine def __init__(self, params: Dict[str, Any]) -> None: ... def get_templatetag_libraries(self, custom_libraries: Dict[str, str]) -> Dict[str, str]: ... diff --git a/django-stubs/template/backends/jinja2.pyi b/django-stubs/template/backends/jinja2.pyi index 7578a6c1b..46d150008 100644 --- a/django-stubs/template/backends/jinja2.pyi +++ b/django-stubs/template/backends/jinja2.pyi @@ -5,15 +5,15 @@ from django.template.exceptions import TemplateSyntaxError from .base import BaseEngine class Jinja2(BaseEngine): - env: Any = ... - context_processors: List[str] = ... + env: Any + context_processors: List[str] def __init__(self, params: Dict[str, Any]) -> None: ... @property def template_context_processors(self) -> List[Callable]: ... class Origin: - name: str = ... - template_name: str | None = ... + name: str + template_name: str | None def __init__(self, name: str, template_name: str | None) -> None: ... def get_exception_info(exception: TemplateSyntaxError) -> Dict[str, Any]: ... diff --git a/django-stubs/template/base.pyi b/django-stubs/template/base.pyi index 9e975c711..7e05f256a 100644 --- a/django-stubs/template/base.pyi +++ b/django-stubs/template/base.pyi @@ -25,30 +25,30 @@ tag_re: Pattern[str] logger: Logger class TokenType(Enum): - TEXT: int = ... - VAR: int = ... - BLOCK: int = ... - COMMENT: int = ... + TEXT: int + VAR: int + BLOCK: int + COMMENT: int class VariableDoesNotExist(Exception): - msg: str = ... - params: Tuple[Dict[str, str] | str] = ... + msg: str + params: Tuple[Dict[str, str] | str] def __init__(self, msg: str, params: Tuple[Dict[str, str] | str] = ...) -> None: ... class Origin: - name: str = ... - template_name: bytes | str | None = ... - loader: Loader | None = ... + name: str + template_name: bytes | str | None + loader: Loader | None def __init__(self, name: str, template_name: bytes | str | None = ..., loader: Loader | None = ...) -> None: ... @property def loader_name(self) -> str | None: ... class Template: - name: str | None = ... - origin: Origin = ... - engine: Engine = ... - source: str = ... - nodelist: NodeList = ... + name: str | None + origin: Origin + engine: Engine + source: str + nodelist: NodeList def __init__( self, template_string: Template | str, @@ -66,8 +66,8 @@ def linebreak_iter(template_source: str) -> Iterator[int]: ... class Token: contents: str token_type: TokenType - lineno: int | None = ... - position: Tuple[int, int] | None = ... + lineno: int | None + position: Tuple[int, int] | None def __init__( self, token_type: TokenType, @@ -78,8 +78,8 @@ class Token: def split_contents(self) -> List[str]: ... class Lexer: - template_string: str = ... - verbatim: bool | str = ... + template_string: str + verbatim: bool | str def __init__(self, template_string: str) -> None: ... def tokenize(self) -> List[Token]: ... def create_token(self, token_string: str, position: Tuple[int, int] | None, lineno: int, in_tag: bool) -> Token: ... @@ -90,12 +90,12 @@ class DebugLexer(Lexer): def tokenize(self) -> List[Token]: ... class Parser: - tokens: List[Token] | str = ... - tags: Dict[str, Callable] = ... - filters: Dict[str, Callable] = ... - command_stack: List[Tuple[str, Token]] = ... - libraries: Dict[str, Library] = ... - origin: Origin | None = ... + tokens: List[Token] | str + tags: Dict[str, Callable] + filters: Dict[str, Callable] + command_stack: List[Tuple[str, Token]] + libraries: Dict[str, Library] + origin: Origin | None def __init__( self, tokens: List[Token] | str, @@ -121,46 +121,46 @@ filter_raw_string: str filter_re: Pattern[str] class FilterExpression: - token: str = ... - filters: List[Any] = ... - var: Any = ... + token: str + filters: List[Any] + var: Any def __init__(self, token: str, parser: Parser) -> None: ... def resolve(self, context: Context, ignore_failures: bool = ...) -> Any: ... @staticmethod def args_check(name: str, func: Callable, provided: List[Tuple[bool, Any]]) -> bool: ... class Variable: - var: Dict[Any, Any] | str = ... - literal: SafeString | float | None = ... - lookups: Tuple[str] | None = ... - translate: bool = ... - message_context: str | None = ... + var: Dict[Any, Any] | str + literal: SafeString | float | None + lookups: Tuple[str] | None + translate: bool + message_context: str | None def __init__(self, var: Dict[Any, Any] | str) -> None: ... def resolve(self, context: Mapping[str, Mapping[str, Any]] | Context | int | str) -> Any: ... class Node: - must_be_first: bool = ... - child_nodelists: Any = ... + must_be_first: bool + child_nodelists: Any origin: Origin - token: Token | None = ... + token: Token | None def render(self, context: Context) -> str: ... def render_annotated(self, context: Context) -> int | str: ... def __iter__(self) -> Iterator[Node]: ... def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ... class NodeList(List[Node]): - contains_nontext: bool = ... + contains_nontext: bool def render(self, context: Context) -> SafeString: ... def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ... class TextNode(Node): - s: str = ... + s: str def __init__(self, s: str) -> None: ... def render_value_in_context(value: Any, context: Context) -> str: ... class VariableNode(Node): - filter_expression: FilterExpression = ... + filter_expression: FilterExpression def __init__(self, filter_expression: FilterExpression) -> None: ... kwarg_re: Pattern[str] diff --git a/django-stubs/template/context.pyi b/django-stubs/template/context.pyi index 7e1e5f2b4..9a3ccd9a5 100644 --- a/django-stubs/template/context.pyi +++ b/django-stubs/template/context.pyi @@ -14,7 +14,7 @@ _ContextCopy = TypeVar("_ContextCopy", bound="BaseContext") class ContextPopException(Exception): ... class ContextDict(dict): - context: BaseContext = ... + context: BaseContext def __init__(self, context: BaseContext, *args: Any, **kwargs: Any) -> None: ... def __enter__(self) -> ContextDict: ... def __exit__( @@ -42,12 +42,12 @@ class BaseContext(Iterable[Any]): class Context(BaseContext): dicts: Any - autoescape: bool = ... - use_l10n: bool | None = ... - use_tz: bool | None = ... - template_name: str | None = ... - render_context: RenderContext = ... - template: Template | None = ... + autoescape: bool + use_l10n: bool | None + use_tz: bool | None + template_name: str | None + render_context: RenderContext + template: Template | None def __init__( self, dict_: Any = ..., autoescape: bool = ..., use_l10n: bool | None = ..., use_tz: bool | None = ... ) -> None: ... @@ -57,7 +57,7 @@ class Context(BaseContext): class RenderContext(BaseContext): dicts: List[Dict[IncludeNode | str, str]] - template: Template | None = ... + template: Template | None @contextmanager def push_state(self, template: Template, isolated_context: bool = ...) -> Iterator[None]: ... @@ -68,7 +68,7 @@ class RequestContext(Context): template_name: str | None use_l10n: bool | None use_tz: bool | None - request: HttpRequest = ... + request: HttpRequest def __init__( self, request: HttpRequest, @@ -78,7 +78,7 @@ class RequestContext(Context): use_tz: bool | None = ..., autoescape: bool = ..., ) -> None: ... - template: Template | None = ... + template: Template | None @contextmanager def bind_template(self, template: Template) -> Iterator[None]: ... def new(self, values: _ContextValues | None = ...) -> RequestContext: ... diff --git a/django-stubs/template/defaulttags.pyi b/django-stubs/template/defaulttags.pyi index 808c9f459..10aaa9f76 100644 --- a/django-stubs/template/defaulttags.pyi +++ b/django-stubs/template/defaulttags.pyi @@ -21,9 +21,9 @@ class CommentNode(Node): ... class CsrfTokenNode(Node): ... class CycleNode(Node): - cyclevars: List[FilterExpression] = ... - variable_name: str | None = ... - silent: bool = ... + cyclevars: List[FilterExpression] + variable_name: str | None + silent: bool def __init__( self, cyclevars: List[FilterExpression], variable_name: str | None = ..., silent: bool = ... ) -> None: ... @@ -37,17 +37,17 @@ class FilterNode(Node): def __init__(self, filter_expr: FilterExpression, nodelist: NodeList) -> None: ... class FirstOfNode(Node): - vars: List[FilterExpression] = ... - asvar: str | None = ... + vars: List[FilterExpression] + asvar: str | None def __init__(self, variables: List[FilterExpression], asvar: str | None = ...) -> None: ... class ForNode(Node): loopvars: List[str] | str sequence: FilterExpression | str - child_nodelists: Any = ... - is_reversed: bool = ... - nodelist_loop: List[str] | NodeList = ... - nodelist_empty: List[str] | NodeList = ... + child_nodelists: Any + is_reversed: bool + nodelist_loop: List[str] | NodeList + nodelist_empty: List[str] | NodeList def __init__( self, loopvars: List[str] | str, @@ -60,7 +60,7 @@ class ForNode(Node): class IfChangedNode(Node): nodelist_false: NodeList nodelist_true: NodeList - child_nodelists: Any = ... + child_nodelists: Any def __init__(self, nodelist_true: NodeList, nodelist_false: NodeList, *varlist: Any) -> None: ... class IfEqualNode(Node): @@ -68,8 +68,8 @@ class IfEqualNode(Node): nodelist_true: List[Any] | NodeList var1: FilterExpression | str var2: FilterExpression | str - child_nodelists: Any = ... - negate: bool = ... + child_nodelists: Any + negate: bool def __init__( self, var1: FilterExpression | str, @@ -80,7 +80,7 @@ class IfEqualNode(Node): ) -> None: ... class IfNode(Node): - conditions_nodelists: List[Tuple[TemplateLiteral | None, NodeList]] = ... + conditions_nodelists: List[Tuple[TemplateLiteral | None, NodeList]] def __init__(self, conditions_nodelists: List[Tuple[TemplateLiteral | None, NodeList]]) -> None: ... def __iter__(self) -> Iterator[Node]: ... @property @@ -97,35 +97,35 @@ GroupedResult = namedtuple("GroupedResult", ["grouper", "list"]) class RegroupNode(Node): expression: FilterExpression target: FilterExpression - var_name: str = ... + var_name: str def __init__(self, target: FilterExpression, expression: FilterExpression, var_name: str) -> None: ... def resolve_expression(self, obj: Dict[str, real_date], context: Context) -> int | str: ... class LoadNode(Node): ... class NowNode(Node): - format_string: str = ... - asvar: str | None = ... + format_string: str + asvar: str | None def __init__(self, format_string: str, asvar: str | None = ...) -> None: ... class ResetCycleNode(Node): - node: CycleNode = ... + node: CycleNode def __init__(self, node: CycleNode) -> None: ... class SpacelessNode(Node): - nodelist: NodeList = ... + nodelist: NodeList def __init__(self, nodelist: NodeList) -> None: ... class TemplateTagNode(Node): - mapping: Any = ... - tagtype: str = ... + mapping: Any + tagtype: str def __init__(self, tagtype: str) -> None: ... class URLNode(Node): - view_name: FilterExpression = ... - args: List[FilterExpression] = ... - kwargs: Dict[str, FilterExpression] = ... - asvar: str | None = ... + view_name: FilterExpression + args: List[FilterExpression] + kwargs: Dict[str, FilterExpression] + asvar: str | None def __init__( self, view_name: FilterExpression, @@ -135,14 +135,14 @@ class URLNode(Node): ) -> None: ... class VerbatimNode(Node): - content: SafeString = ... + content: SafeString def __init__(self, content: SafeString) -> None: ... class WidthRatioNode(Node): - val_expr: FilterExpression = ... - max_expr: FilterExpression = ... - max_width: FilterExpression = ... - asvar: str | None = ... + val_expr: FilterExpression + max_expr: FilterExpression + max_width: FilterExpression + asvar: str | None def __init__( self, val_expr: FilterExpression, @@ -152,8 +152,8 @@ class WidthRatioNode(Node): ) -> None: ... class WithNode(Node): - nodelist: NodeList = ... - extra_context: Dict[str, Any] = ... + nodelist: NodeList + extra_context: Dict[str, Any] def __init__( self, var: str | None, @@ -175,7 +175,7 @@ def ifequal(parser: Parser, token: Token) -> IfEqualNode: ... def ifnotequal(parser: Parser, token: Token) -> IfEqualNode: ... class TemplateLiteral(Literal): - text: str = ... + text: str def __init__(self, value: FilterExpression, text: str) -> None: ... def display(self) -> str: ... @@ -183,8 +183,8 @@ class TemplateIfParser(IfParser): current_token: TemplateLiteral pos: int tokens: List[TemplateLiteral] - error_class: Any = ... - template_parser: Parser = ... + error_class: Any + template_parser: Parser def __init__(self, parser: Parser, *args: Any, **kwargs: Any) -> None: ... def do_if(parser: Parser, token: Token) -> IfNode: ... diff --git a/django-stubs/template/engine.pyi b/django-stubs/template/engine.pyi index 137079579..03077e51d 100644 --- a/django-stubs/template/engine.pyi +++ b/django-stubs/template/engine.pyi @@ -10,19 +10,19 @@ from .base import Template _Loader = Any class Engine: - default_builtins: Any = ... - dirs: List[str] = ... - app_dirs: bool = ... - autoescape: bool = ... - context_processors: List[str] | Tuple[str] = ... - debug: bool = ... - loaders: Sequence[_Loader] = ... - string_if_invalid: str = ... - file_charset: str = ... - libraries: Dict[str, str] = ... - template_libraries: Dict[str, Library] = ... - builtins: List[str] = ... - template_builtins: List[Library] = ... + default_builtins: Any + dirs: List[str] + app_dirs: bool + autoescape: bool + context_processors: List[str] | Tuple[str] + debug: bool + loaders: Sequence[_Loader] + string_if_invalid: str + file_charset: str + libraries: Dict[str, str] + template_libraries: Dict[str, Library] + builtins: List[str] + template_builtins: List[Library] def __init__( self, dirs: List[str] | None = ..., diff --git a/django-stubs/template/exceptions.pyi b/django-stubs/template/exceptions.pyi index 8ce0b76b9..a90eea536 100644 --- a/django-stubs/template/exceptions.pyi +++ b/django-stubs/template/exceptions.pyi @@ -4,9 +4,9 @@ from django.template.backends.base import BaseEngine from django.template.base import Origin class TemplateDoesNotExist(Exception): - backend: BaseEngine | None = ... - tried: List[Tuple[Origin, str]] = ... - chain: List[TemplateDoesNotExist] = ... + backend: BaseEngine | None + tried: List[Tuple[Origin, str]] + chain: List[TemplateDoesNotExist] def __init__( self, msg: Origin | str, diff --git a/django-stubs/template/library.pyi b/django-stubs/template/library.pyi index cfd5b1eb8..9e0b078fd 100644 --- a/django-stubs/template/library.pyi +++ b/django-stubs/template/library.pyi @@ -11,8 +11,8 @@ class InvalidTemplateLibrary(Exception): ... _C = TypeVar("_C", bound=Callable[..., Any]) class Library: - filters: Dict[str, Callable] = ... - tags: Dict[str, Callable] = ... + filters: Dict[str, Callable] + tags: Dict[str, Callable] def __init__(self) -> None: ... @overload def tag(self, name: _C) -> _C: ... @@ -40,10 +40,10 @@ class Library: ) -> Callable[[_C], _C]: ... class TagHelperNode(Node): - func: Any = ... - takes_context: Any = ... - args: Any = ... - kwargs: Any = ... + func: Any + takes_context: Any + args: Any + kwargs: Any def __init__( self, func: Callable, @@ -60,7 +60,7 @@ class SimpleNode(TagHelperNode): origin: Origin takes_context: bool | None token: Token - target_var: str | None = ... + target_var: str | None def __init__( self, func: Callable, @@ -77,7 +77,7 @@ class InclusionNode(TagHelperNode): origin: Origin takes_context: bool | None token: Token - filename: Template | str = ... + filename: Template | str def __init__( self, func: Callable, diff --git a/django-stubs/template/loader_tags.pyi b/django-stubs/template/loader_tags.pyi index 9909e8e81..44d7a14ab 100644 --- a/django-stubs/template/loader_tags.pyi +++ b/django-stubs/template/loader_tags.pyi @@ -11,7 +11,7 @@ register: Any BLOCK_CONTEXT_KEY: str class BlockContext: - blocks: collections.defaultdict = ... + blocks: collections.defaultdict def __init__(self) -> None: ... def add_blocks(self, blocks: Dict[str, BlockNode]) -> None: ... def pop(self, name: str) -> BlockNode: ... @@ -32,12 +32,12 @@ class BlockNode(Node): class ExtendsNode(Node): origin: Origin token: Token - must_be_first: bool = ... - context_key: str = ... - nodelist: NodeList = ... - parent_name: FilterExpression | Node = ... - template_dirs: List[Any] | None = ... - blocks: Dict[str, BlockNode] = ... + must_be_first: bool + context_key: str + nodelist: NodeList + parent_name: FilterExpression | Node + template_dirs: List[Any] | None + blocks: Dict[str, BlockNode] def __init__( self, nodelist: NodeList, parent_name: FilterExpression | Node, template_dirs: List[Any] | None = ... ) -> None: ... @@ -48,10 +48,10 @@ class ExtendsNode(Node): class IncludeNode(Node): origin: Origin token: Token - context_key: str = ... - template: FilterExpression = ... - extra_context: Dict[str, FilterExpression] = ... - isolated_context: bool = ... + context_key: str + template: FilterExpression + extra_context: Dict[str, FilterExpression] + isolated_context: bool def __init__( self, template: FilterExpression, diff --git a/django-stubs/template/loaders/base.pyi b/django-stubs/template/loaders/base.pyi index b109fbcf4..9679413f5 100644 --- a/django-stubs/template/loaders/base.pyi +++ b/django-stubs/template/loaders/base.pyi @@ -4,8 +4,8 @@ from django.template.base import Origin, Template from django.template.engine import Engine class Loader: - engine: Engine = ... - get_template_cache: Dict[str, Any] = ... + engine: Engine + get_template_cache: Dict[str, Any] def __init__(self, engine: Engine) -> None: ... def get_template(self, template_name: str, skip: List[Origin] | None = ...) -> Template: ... def get_template_sources(self, template_name: str) -> Iterable[Origin]: ... diff --git a/django-stubs/template/loaders/cached.pyi b/django-stubs/template/loaders/cached.pyi index c4c082c48..3f18142ff 100644 --- a/django-stubs/template/loaders/cached.pyi +++ b/django-stubs/template/loaders/cached.pyi @@ -6,8 +6,8 @@ from django.template.engine import Engine from .base import Loader as BaseLoader class Loader(BaseLoader): - template_cache: Dict[str, Any] = ... - loaders: List[BaseLoader] = ... + template_cache: Dict[str, Any] + loaders: List[BaseLoader] def __init__(self, engine: Engine, loaders: Sequence[Any]) -> None: ... def get_contents(self, origin: Origin) -> str: ... def cache_key(self, template_name: str, skip: List[Origin] | None = ...) -> str: ... diff --git a/django-stubs/template/loaders/filesystem.pyi b/django-stubs/template/loaders/filesystem.pyi index 79bf07adf..51aa3f437 100644 --- a/django-stubs/template/loaders/filesystem.pyi +++ b/django-stubs/template/loaders/filesystem.pyi @@ -7,7 +7,7 @@ from django.template.engine import Engine from .base import Loader as BaseLoader class Loader(BaseLoader): - dirs: List[str | Path] | None = ... + dirs: List[str | Path] | None def __init__(self, engine: Engine, dirs: List[str | Path] | None = ...) -> None: ... def get_dirs(self) -> List[str | Path]: ... def get_contents(self, origin: Origin) -> str: ... diff --git a/django-stubs/template/loaders/locmem.pyi b/django-stubs/template/loaders/locmem.pyi index ddeb87af9..35d332a3f 100644 --- a/django-stubs/template/loaders/locmem.pyi +++ b/django-stubs/template/loaders/locmem.pyi @@ -6,6 +6,6 @@ from django.template.engine import Engine from .base import Loader as BaseLoader class Loader(BaseLoader): - templates_dict: Dict[str, str] = ... + templates_dict: Dict[str, str] def __init__(self, engine: Engine, templates_dict: Dict[str, str]) -> None: ... def get_contents(self, origin: Origin) -> str: ... diff --git a/django-stubs/template/response.pyi b/django-stubs/template/response.pyi index 495d7abd5..9e8b06814 100644 --- a/django-stubs/template/response.pyi +++ b/django-stubs/template/response.pyi @@ -15,14 +15,14 @@ _TemplateForResponseT = Union[_ListOrTuple[str], Template, str] class ContentNotRenderedError(Exception): ... class SimpleTemplateResponse(HttpResponse): - content: Any = ... + content: Any closed: bool cookies: SimpleCookie[str] status_code: int - rendering_attrs: Any = ... - template_name: _TemplateForResponseT = ... - context_data: Dict[str, Any] | None = ... - using: str | None = ... + rendering_attrs: Any + template_name: _TemplateForResponseT + context_data: Dict[str, Any] | None + using: str | None def __init__( self, template: _TemplateForResponseT, @@ -57,7 +57,7 @@ class TemplateResponse(SimpleTemplateResponse): templates: List[Template] using: str | None wsgi_request: WSGIRequest - rendering_attrs: Any = ... + rendering_attrs: Any def __init__( self, request: HttpRequest, diff --git a/django-stubs/template/smartif.pyi b/django-stubs/template/smartif.pyi index 3aa2338cb..610d20463 100644 --- a/django-stubs/template/smartif.pyi +++ b/django-stubs/template/smartif.pyi @@ -5,10 +5,10 @@ from django.template.defaulttags import TemplateLiteral _Token = List[int] | int | str class TokenBase: - id: Any = ... - value: Any = ... - first: Any = ... - second: Any = ... + id: Any + value: Any + first: Any + second: Any def nud(self, parser: Any) -> None: ... def led(self, left: Any, parser: Any) -> None: ... def display(self) -> Any: ... @@ -19,22 +19,22 @@ def prefix(bp: Any, func: Any) -> Type[TokenBase]: ... OPERATORS: Any class Literal(TokenBase): - id: str = ... - lbp: int = ... - value: _Token | None = ... + id: str + lbp: int + value: _Token | None def __init__(self, value: _Token | None) -> None: ... def display(self) -> str: ... def eval(self, context: Dict[Any, Any]) -> _Token | None: ... class EndToken(TokenBase): - lbp: int = ... + lbp: int def nud(self, parser: Any) -> None: ... class IfParser: - error_class: Any = ... - tokens: Any = ... - pos: int = ... - current_token: Any = ... + error_class: Any + tokens: Any + pos: int + current_token: Any def __init__(self, tokens: List[_Token | None]) -> None: ... def translate_token(self, token: _Token | None) -> Literal: ... def next_token(self) -> Literal: ... diff --git a/django-stubs/templatetags/cache.pyi b/django-stubs/templatetags/cache.pyi index ef074743e..17cda82c4 100644 --- a/django-stubs/templatetags/cache.pyi +++ b/django-stubs/templatetags/cache.pyi @@ -6,11 +6,11 @@ from django.template.base import FilterExpression, NodeList, Parser, Token register: Any class CacheNode(Node): - nodelist: NodeList = ... - expire_time_var: FilterExpression = ... - fragment_name: str = ... - vary_on: List[FilterExpression] = ... - cache_name: FilterExpression | None = ... + nodelist: NodeList + expire_time_var: FilterExpression + fragment_name: str + vary_on: List[FilterExpression] + cache_name: FilterExpression | None def __init__( self, nodelist: NodeList, diff --git a/django-stubs/templatetags/i18n.pyi b/django-stubs/templatetags/i18n.pyi index 6542d04ea..5c24c7167 100644 --- a/django-stubs/templatetags/i18n.pyi +++ b/django-stubs/templatetags/i18n.pyi @@ -7,38 +7,38 @@ from django.template.context import Context register: Any class GetAvailableLanguagesNode(Node): - variable: str = ... + variable: str def __init__(self, variable: str) -> None: ... def render(self, context: Context) -> str: ... class GetLanguageInfoNode(Node): - lang_code: FilterExpression = ... - variable: str = ... + lang_code: FilterExpression + variable: str def __init__(self, lang_code: FilterExpression, variable: str) -> None: ... def render(self, context: Context) -> str: ... class GetLanguageInfoListNode(Node): - languages: FilterExpression = ... - variable: str = ... + languages: FilterExpression + variable: str def __init__(self, languages: FilterExpression, variable: str) -> None: ... def get_language_info(self, language: Any) -> Any: ... def render(self, context: Context) -> str: ... class GetCurrentLanguageNode(Node): - variable: str = ... + variable: str def __init__(self, variable: str) -> None: ... def render(self, context: Context) -> str: ... class GetCurrentLanguageBidiNode(Node): - variable: str = ... + variable: str def __init__(self, variable: str) -> None: ... def render(self, context: Context) -> str: ... class TranslateNode(Node): - noop: bool = ... - asvar: str | None = ... - message_context: FilterExpression | None = ... - filter_expression: FilterExpression = ... + noop: bool + asvar: str | None + message_context: FilterExpression | None + filter_expression: FilterExpression def __init__( self, filter_expression: FilterExpression, @@ -49,14 +49,14 @@ class TranslateNode(Node): def render(self, context: Context) -> str: ... class BlockTranslateNode(Node): - extra_context: Dict[str, FilterExpression] = ... - singular: List[Token] = ... - plural: List[Token] = ... - countervar: str | None = ... - counter: FilterExpression | None = ... - message_context: FilterExpression | None = ... - trimmed: bool = ... - asvar: str | None = ... + extra_context: Dict[str, FilterExpression] + singular: List[Token] + plural: List[Token] + countervar: str | None + counter: FilterExpression | None + message_context: FilterExpression | None + trimmed: bool + asvar: str | None def __init__( self, extra_context: Dict[str, FilterExpression], @@ -73,8 +73,8 @@ class BlockTranslateNode(Node): def render(self, context: Context, nested: bool = ...) -> str: ... class LanguageNode(Node): - nodelist: NodeList = ... - language: FilterExpression = ... + nodelist: NodeList + language: FilterExpression def __init__(self, nodelist: NodeList, language: FilterExpression) -> None: ... def render(self, context: Context) -> str: ... diff --git a/django-stubs/templatetags/l10n.pyi b/django-stubs/templatetags/l10n.pyi index 2dc3d5258..f9d53178a 100644 --- a/django-stubs/templatetags/l10n.pyi +++ b/django-stubs/templatetags/l10n.pyi @@ -9,8 +9,8 @@ def localize(value: Any) -> str: ... def unlocalize(value: Any) -> str: ... class LocalizeNode(Node): - nodelist: List[Node] = ... - use_l10n: bool = ... + nodelist: List[Node] + use_l10n: bool def __init__(self, nodelist: List[Node], use_l10n: bool) -> None: ... def localize_tag(parser: Parser, token: Token) -> LocalizeNode: ... diff --git a/django-stubs/templatetags/static.pyi b/django-stubs/templatetags/static.pyi index 141284b36..2fd5fdc18 100644 --- a/django-stubs/templatetags/static.pyi +++ b/django-stubs/templatetags/static.pyi @@ -7,8 +7,8 @@ from django.template.context import Context register: Any class PrefixNode(template.Node): - varname: str | None = ... - name: str = ... + varname: str | None + name: str def __init__(self, varname: str | None = ..., name: str = ...) -> None: ... @classmethod def handle_token(cls, parser: Parser, token: Token, name: str) -> PrefixNode: ... @@ -19,8 +19,8 @@ def get_static_prefix(parser: Parser, token: Token) -> PrefixNode: ... def get_media_prefix(parser: Parser, token: Token) -> PrefixNode: ... class StaticNode(template.Node): - path: FilterExpression = ... - varname: str | None = ... + path: FilterExpression + varname: str | None def __init__(self, varname: str | None = ..., path: FilterExpression = ...) -> None: ... def url(self, context: Context) -> str: ... @classmethod diff --git a/django-stubs/templatetags/tz.pyi b/django-stubs/templatetags/tz.pyi index 99ffd00ad..a959c5866 100644 --- a/django-stubs/templatetags/tz.pyi +++ b/django-stubs/templatetags/tz.pyi @@ -14,17 +14,17 @@ def utc(value: datetime | str | None) -> Any: ... def do_timezone(value: datetime | str | None, arg: _TzInfoT | str | None) -> Any: ... class LocalTimeNode(Node): - nodelist: NodeList = ... - use_tz: bool = ... + nodelist: NodeList + use_tz: bool def __init__(self, nodelist: NodeList, use_tz: bool) -> None: ... class TimezoneNode(Node): - nodelist: NodeList = ... - tz: FilterExpression = ... + nodelist: NodeList + tz: FilterExpression def __init__(self, nodelist: NodeList, tz: FilterExpression) -> None: ... class GetCurrentTimezoneNode(Node): - variable: str = ... + variable: str def __init__(self, variable: str) -> None: ... def localtime_tag(parser: Parser, token: Token) -> LocalTimeNode: ... diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index 69f9b5b7c..42a5ca7a2 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -31,18 +31,18 @@ from django.test.utils import ContextList from django.urls import ResolverMatch from typing_extensions import Literal -BOUNDARY: str = ... -MULTIPART_CONTENT: str = ... -CONTENT_TYPE_RE: Pattern = ... -JSON_CONTENT_TYPE_RE: Pattern = ... +BOUNDARY: str +MULTIPART_CONTENT: str +CONTENT_TYPE_RE: Pattern +JSON_CONTENT_TYPE_RE: Pattern class RedirectCycleError(Exception): - last_response: HttpResponseBase = ... - redirect_chain: List[Tuple[str, int]] = ... + last_response: HttpResponseBase + redirect_chain: List[Tuple[str, int]] def __init__(self, message: str, last_response: HttpResponseBase) -> None: ... class FakePayload: - read_started: bool = ... + read_started: bool def __init__(self, content: bytes | str | None = ...) -> None: ... def __len__(self) -> int: ... def read(self, num_bytes: int = ...) -> bytes: ... @@ -60,12 +60,12 @@ class _ASGIResponse(HttpResponseBase): asgi_request: ASGIRequest class ClientHandler(BaseHandler): - enforce_csrf_checks: bool = ... + enforce_csrf_checks: bool def __init__(self, enforce_csrf_checks: bool = ..., *args: Any, **kwargs: Any) -> None: ... def __call__(self, environ: Dict[str, Any]) -> _WSGIResponse: ... class AsyncClientHandler(BaseHandler): - enforce_csrf_checks: bool = ... + enforce_csrf_checks: bool def __init__(self, enforce_csrf_checks: bool = ..., *args: Any, **kwargs: Any) -> None: ... async def __call__(self, scope: Dict[str, Any]) -> _ASGIResponse: ... diff --git a/django-stubs/test/html.pyi b/django-stubs/test/html.pyi index 75994764f..c35b2d588 100644 --- a/django-stubs/test/html.pyi +++ b/django-stubs/test/html.pyi @@ -10,9 +10,9 @@ def normalize_whitespace(string: str) -> str: ... _ElementAttribute = Tuple[str, str | None] class Element: - name: str | None = ... - attributes: List[_ElementAttribute] = ... - children: List[Any] = ... + name: str | None + attributes: List[_ElementAttribute] + children: List[Any] def __init__(self, name: str | None, attributes: Sequence[_ElementAttribute]) -> None: ... def append(self, element: Element | str) -> None: ... def finalize(self) -> None: ... @@ -26,10 +26,10 @@ class RootElement(Element): class HTMLParseError(Exception): ... class Parser(HTMLParser): - SELF_CLOSING_TAGS: Any = ... - root: Any = ... - open_tags: Any = ... - element_positions: Any = ... + SELF_CLOSING_TAGS: Any + root: Any + open_tags: Any + element_positions: Any def __init__(self) -> None: ... def format_position(self, position: Any = ..., element: Any = ...) -> str: ... @property diff --git a/django-stubs/test/runner.pyi b/django-stubs/test/runner.pyi index 1e468573c..7c4f73bee 100644 --- a/django-stubs/test/runner.pyi +++ b/django-stubs/test/runner.pyi @@ -23,14 +23,14 @@ class DebugSQLTextTestResult(TextTestResult): tb_locals: bool testsRun: int unexpectedSuccesses: List[Any] - logger: logging.Logger = ... + logger: logging.Logger # typeshed thinks it's TextIO, but unittest wraps it with _WritelnDecorator # adding `writeln` method # See https://github.com/python/cpython/blob/main/Lib/unittest/runner.py stream: Any def __init__(self, stream: Any, descriptions: bool, verbosity: int) -> None: ... - debug_sql_stream: StringIO = ... - handler: logging.StreamHandler = ... + debug_sql_stream: StringIO + handler: logging.StreamHandler def startTest(self, test: TestCase) -> None: ... def stopTest(self, test: TestCase) -> None: ... def addError(self, test: Any, err: Any) -> None: ... @@ -39,10 +39,10 @@ class DebugSQLTextTestResult(TextTestResult): class PDBDebugResult(TextTestResult): ... class RemoteTestResult: - events: List[Any] = ... - failfast: bool = ... - shouldStop: bool = ... - testsRun: int = ... + events: List[Any] + failfast: bool + shouldStop: bool + testsRun: int def __init__(self) -> None: ... @property def test_index(self) -> int: ... @@ -64,53 +64,53 @@ class RemoteTestResult: def addUnexpectedSuccess(self, test: Any) -> None: ... class RemoteTestRunner: - resultclass: Any = ... - failfast: bool = ... - buffer: bool = ... + resultclass: Any + failfast: bool + buffer: bool def __init__(self, failfast: bool = ..., resultclass: Any | None = ..., buffer: bool = ...) -> None: ... def run(self, test: Any) -> Any: ... def default_test_processes() -> int: ... class ParallelTestSuite(TestSuite): - init_worker: Any = ... - run_subsuite: Any = ... - runner_class: Any = ... - subsuites: List[TestSuite] = ... - processes: int = ... - failfast: bool = ... - buffer: bool = ... - initial_settings: Any = ... - serialized_contents: Any = ... + init_worker: Any + run_subsuite: Any + runner_class: Any + subsuites: List[TestSuite] + processes: int + failfast: bool + buffer: bool + initial_settings: Any + serialized_contents: Any def __init__( self, subsuites: List[TestSuite], processes: int, failfast: bool = ..., buffer: bool = ... ) -> None: ... def run(self, result: Any) -> Any: ... # type: ignore[override] class DiscoverRunner: - test_suite: Type[TestSuite] = ... - parallel_test_suite: Type[ParallelTestSuite] = ... - test_runner: Type[TextTestRunner] = ... - test_loader: TestLoader = ... - reorder_by: Tuple[SimpleTestCase, ...] = ... - pattern: str | None = ... - top_level: str | None = ... - verbosity: int = ... - interactive: bool = ... - failfast: bool = ... - keepdb: bool = ... - reverse: bool = ... - debug_mode: bool = ... - debug_sql: bool = ... - parallel: int = ... - tags: Set[str] = ... - exclude_tags: Set[str] = ... - pdb: bool = ... - buffer: bool = ... - test_name_patterns: Set[str] | None = ... - time_keeper: TimeKeeperProtocol = ... - shuffle: int | Literal[False] = ... - logger: logging.Logger | None = ... + test_suite: Type[TestSuite] + parallel_test_suite: Type[ParallelTestSuite] + test_runner: Type[TextTestRunner] + test_loader: TestLoader + reorder_by: Tuple[SimpleTestCase, ...] + pattern: str | None + top_level: str | None + verbosity: int + interactive: bool + failfast: bool + keepdb: bool + reverse: bool + debug_mode: bool + debug_sql: bool + parallel: int + tags: Set[str] + exclude_tags: Set[str] + pdb: bool + buffer: bool + test_name_patterns: Set[str] | None + time_keeper: TimeKeeperProtocol + shuffle: int | Literal[False] + logger: logging.Logger | None def __init__( self, pattern: str | None = ..., diff --git a/django-stubs/test/selenium.pyi b/django-stubs/test/selenium.pyi index f87f8bbfb..ea88de243 100644 --- a/django-stubs/test/selenium.pyi +++ b/django-stubs/test/selenium.pyi @@ -4,14 +4,14 @@ from typing import Any, Generator, Type from django.test import LiveServerTestCase class SeleniumTestCaseBase: - browsers: Any = ... - browser: Any = ... + browsers: Any + browser: Any @classmethod def import_webdriver(cls, browser: Any) -> Type[Any]: ... # Type[WebDriver] def create_webdriver(self) -> Any: ... # WebDriver class SeleniumTestCase(LiveServerTestCase): - implicit_wait: int = ... + implicit_wait: int selenium: Any @contextmanager def disable_implicit_wait(self) -> Generator[None, None, None]: ... diff --git a/django-stubs/test/testcases.pyi b/django-stubs/test/testcases.pyi index 9f06eeaa2..c2e970cd2 100644 --- a/django-stubs/test/testcases.pyi +++ b/django-stubs/test/testcases.pyi @@ -41,16 +41,16 @@ def to_list(value: Any) -> list[Any]: ... def assert_and_parse_html(self: Any, html: str, user_msg: str, msg: str) -> Element: ... class _AssertNumQueriesContext(CaptureQueriesContext): - test_case: SimpleTestCase = ... - num: int = ... + test_case: SimpleTestCase + num: int def __init__(self, test_case: Any, num: Any, connection: BaseDatabaseWrapper) -> None: ... class _AssertTemplateUsedContext: - test_case: SimpleTestCase = ... - template_name: str = ... - rendered_templates: List[Template] = ... - rendered_template_names: List[str] = ... - context: ContextList = ... + test_case: SimpleTestCase + template_name: str + rendered_templates: List[Template] + rendered_template_names: List[str] + context: ContextList def __init__(self, test_case: Any, template_name: Any) -> None: ... def on_template_render(self, sender: Any, signal: Any, template: Any, context: Any, **kwargs: Any) -> None: ... def test(self) -> None: ... @@ -66,19 +66,19 @@ class _AssertTemplateUsedContext: class _AssertTemplateNotUsedContext(_AssertTemplateUsedContext): ... class _DatabaseFailure: - wrapped: Any = ... - message: str = ... + wrapped: Any + message: str def __init__(self, wrapped: Any, message: str) -> None: ... def __call__(self) -> None: ... class SimpleTestCase(unittest.TestCase): - client_class: Type[Client] = ... + client_class: Type[Client] client: Client - async_client_class: Type[AsyncClient] = ... + async_client_class: Type[AsyncClient] async_client: AsyncClient - allow_database_queries: bool = ... + allow_database_queries: bool # TODO: str -> Literal['__all__'] - databases: Set[str] | str = ... + databases: Set[str] | str def __call__(self, result: unittest.TestResult | None = ...) -> None: ... def settings(self, **kwargs: Any) -> Any: ... def modify_settings(self, **kwargs: Any) -> Any: ... @@ -194,11 +194,11 @@ class SimpleTestCase(unittest.TestCase): def assertXMLNotEqual(self, xml1: str, xml2: str, msg: str | None = ...) -> None: ... class TransactionTestCase(SimpleTestCase): - reset_sequences: bool = ... - available_apps: Any = ... - fixtures: Any = ... - multi_db: bool = ... - serialized_rollback: bool = ... + reset_sequences: bool + available_apps: Any + fixtures: Any + multi_db: bool + serialized_rollback: bool def assertQuerysetEqual( self, qs: Iterator[Any] | List[Model] | QuerySet | RawQuerySet, @@ -224,7 +224,7 @@ class TestCase(TransactionTestCase): ) -> Generator[List[Callable[[], Any]], None, None]: ... class CheckCondition: - conditions: Sequence[Tuple[Callable, str]] = ... + conditions: Sequence[Tuple[Callable, str]] def __init__(self, *conditions: Tuple[Callable, str]) -> None: ... def add_condition(self, condition: Callable, reason: str) -> CheckCondition: ... def __get__(self, instance: None, cls: Type[TransactionTestCase] | None = ...) -> bool: ... @@ -236,8 +236,8 @@ def skipUnlessAnyDBFeature(*features: Any) -> Callable: ... class QuietWSGIRequestHandler(WSGIRequestHandler): ... class FSFilesHandler(WSGIHandler): - application: Any = ... - base_url: Any = ... + application: Any + base_url: Any def __init__(self, application: Any) -> None: ... def file_path(self, url: Any) -> str: ... def serve(self, request: HttpRequest) -> FileResponse: ... @@ -251,12 +251,12 @@ class _MediaFilesHandler(FSFilesHandler): def get_base_url(self) -> str: ... class LiveServerThread(threading.Thread): - host: str = ... - port: int = ... - is_ready: threading.Event = ... - error: ImproperlyConfigured | None = ... - static_handler: Type[WSGIHandler] = ... - connections_override: Dict[str, BaseDatabaseWrapper] = ... + host: str + port: int + is_ready: threading.Event + error: ImproperlyConfigured | None + static_handler: Type[WSGIHandler] + connections_override: Dict[str, BaseDatabaseWrapper] def __init__( self, host: str, @@ -264,22 +264,22 @@ class LiveServerThread(threading.Thread): connections_override: Dict[str, BaseDatabaseWrapper] = ..., port: int = ..., ) -> None: ... - httpd: ThreadedWSGIServer = ... + httpd: ThreadedWSGIServer def terminate(self) -> None: ... class LiveServerTestCase(TransactionTestCase): - host: str = ... - port: int = ... - server_thread_class: Type[Any] = ... + host: str + port: int + server_thread_class: Type[Any] server_thread: Any - static_handler: Any = ... + static_handler: Any @classproperty def live_server_url(cls) -> str: ... @classproperty def allowed_host(cls) -> str: ... class SerializeMixin: - lockfile: Any = ... + lockfile: Any @classmethod def setUpClass(cls) -> None: ... @classmethod diff --git a/django-stubs/test/utils.pyi b/django-stubs/test/utils.pyi index 254a80b0b..af7219e65 100644 --- a/django-stubs/test/utils.pyi +++ b/django-stubs/test/utils.pyi @@ -34,11 +34,11 @@ _TestClass = Type[SimpleTestCase] _DecoratedTest = Callable | _TestClass _C = TypeVar("_C", bound=Callable) # Any callable -TZ_SUPPORT: bool = ... +TZ_SUPPORT: bool class Approximate: - val: decimal.Decimal | float = ... - places: int = ... + val: decimal.Decimal | float + places: int def __init__(self, val: Decimal | float, places: int = ...) -> None: ... class ContextList(List[Dict[str, Any]]): @@ -54,8 +54,8 @@ def teardown_test_environment() -> None: ... def get_runner(settings: LazySettings, test_runner_class: str | None = ...) -> Type[DiscoverRunner]: ... class TestContextDecorator: - attr_name: str | None = ... - kwarg_name: str | None = ... + attr_name: str | None + kwarg_name: str | None def __init__(self, attr_name: str | None = ..., kwarg_name: str | None = ...) -> None: ... def enable(self) -> Any: ... def disable(self) -> None: ... @@ -71,32 +71,32 @@ class TestContextDecorator: def __call__(self, decorated: _DecoratedTest) -> Any: ... class override_settings(TestContextDecorator): - options: Dict[str, Any] = ... + options: Dict[str, Any] def __init__(self, **kwargs: Any) -> None: ... - wrapped: Settings = ... + wrapped: Settings def save_options(self, test_func: _DecoratedTest) -> None: ... def decorate_class(self, cls: type) -> type: ... class modify_settings(override_settings): wrapped: Settings - operations: List[Tuple[str, Dict[str, List[str] | str]]] = ... + operations: List[Tuple[str, Dict[str, List[str] | str]]] def __init__(self, *args: Any, **kwargs: Any) -> None: ... def save_options(self, test_func: _DecoratedTest) -> None: ... - options: Dict[str, List[Tuple[str, str] | str]] = ... + options: Dict[str, List[Tuple[str, str] | str]] class override_system_checks(TestContextDecorator): - registry: CheckRegistry = ... - new_checks: List[Callable] = ... - deployment_checks: List[Callable] | None = ... + registry: CheckRegistry + new_checks: List[Callable] + deployment_checks: List[Callable] | None def __init__(self, new_checks: List[Callable], deployment_checks: List[Callable] | None = ...) -> None: ... - old_checks: Set[Callable] = ... - old_deployment_checks: Set[Callable] = ... + old_checks: Set[Callable] + old_deployment_checks: Set[Callable] class CaptureQueriesContext: - connection: BaseDatabaseWrapper = ... - force_debug_cursor: bool = ... - initial_queries: int = ... - final_queries: int | None = ... + connection: BaseDatabaseWrapper + force_debug_cursor: bool + initial_queries: int + final_queries: int | None def __init__(self, connection: BaseDatabaseWrapper) -> None: ... def __iter__(self) -> Iterator[Dict[str, str]]: ... def __getitem__(self, index: int) -> Dict[str, str]: ... @@ -112,10 +112,10 @@ class CaptureQueriesContext: ) -> None: ... class ignore_warnings(TestContextDecorator): - ignore_kwargs: Dict[str, Any] = ... - filter_func: Callable = ... + ignore_kwargs: Dict[str, Any] + filter_func: Callable def __init__(self, **kwargs: Any) -> None: ... - catch_warnings: ContextManager[list | None] = ... + catch_warnings: ContextManager[list | None] requires_tz_support: Any @@ -123,21 +123,21 @@ requires_tz_support: Any def isolate_lru_cache(lru_cache_object: Callable) -> Iterator[None]: ... class override_script_prefix(TestContextDecorator): - prefix: str = ... + prefix: str def __init__(self, prefix: str) -> None: ... - old_prefix: str = ... + old_prefix: str class LoggingCaptureMixin: - logger: Logger = ... - old_stream: Any = ... - logger_output: Any = ... + logger: Logger + old_stream: Any + logger_output: Any def setUp(self) -> None: ... def tearDown(self) -> None: ... class isolate_apps(TestContextDecorator): - installed_apps: Tuple[str] = ... + installed_apps: Tuple[str] def __init__(self, *installed_apps: Any, **kwargs: Any) -> None: ... - old_apps: Apps = ... + old_apps: Apps @contextmanager def extend_sys_path(*paths: str) -> Iterator[None]: ... diff --git a/django-stubs/urls/converters.pyi b/django-stubs/urls/converters.pyi index f8c5eb0a0..2a4e54ed6 100644 --- a/django-stubs/urls/converters.pyi +++ b/django-stubs/urls/converters.pyi @@ -2,17 +2,17 @@ from typing import Any, Dict, Type from uuid import UUID class IntConverter: - regex: str = ... + regex: str def to_python(self, value: str) -> int: ... def to_url(self, value: str | int) -> str: ... class StringConverter: - regex: str = ... + regex: str def to_python(self, value: str) -> str: ... def to_url(self, value: str) -> str: ... class UUIDConverter: - regex: str = ... + regex: str def to_python(self, value: str) -> UUID: ... def to_url(self, value: str | UUID) -> str: ... diff --git a/django-stubs/urls/resolvers.pyi b/django-stubs/urls/resolvers.pyi index 0756a2ee7..f8d86d894 100644 --- a/django-stubs/urls/resolvers.pyi +++ b/django-stubs/urls/resolvers.pyi @@ -7,16 +7,16 @@ from django.urls.converters import UUIDConverter from django.utils.datastructures import MultiValueDict class ResolverMatch: - func: Callable = ... - args: Tuple[Any, ...] = ... - kwargs: Dict[str, Any] = ... - url_name: str | None = ... - app_names: List[str] = ... - app_name: str = ... - namespaces: List[str] = ... - namespace: str = ... - view_name: str = ... - route: str = ... + func: Callable + args: Tuple[Any, ...] + kwargs: Dict[str, Any] + url_name: str | None + app_names: List[str] + app_name: str + namespaces: List[str] + namespace: str + view_name: str + route: str tried: Any | None _func_path: str def __init__( @@ -40,7 +40,7 @@ def get_ns_resolver(ns_pattern: str, resolver: URLResolver, converters: Tuple) - _Pattern = RegexPattern | RoutePattern | LocalePrefixPattern class LocaleRegexDescriptor: - attr: str = ... + attr: str def __init__(self, attr: Any) -> None: ... @overload def __get__(self, instance: None, cls: Type[_Pattern] = ...) -> LocaleRegexDescriptor: ... @@ -51,24 +51,24 @@ class CheckURLMixin: def describe(self) -> str: ... class RegexPattern(CheckURLMixin): - regex: LocaleRegexDescriptor = ... - name: str | None = ... - converters: Dict[Any, Any] = ... + regex: LocaleRegexDescriptor + name: str | None + converters: Dict[Any, Any] def __init__(self, regex: str, name: str | None = ..., is_endpoint: bool = ...) -> None: ... def match(self, path: str) -> Tuple[str, Tuple, Dict[str, str]] | None: ... def check(self) -> List[CheckMessage]: ... class RoutePattern(CheckURLMixin): - regex: LocaleRegexDescriptor = ... - name: str | None = ... - converters: Dict[str, UUIDConverter] = ... + regex: LocaleRegexDescriptor + name: str | None + converters: Dict[str, UUIDConverter] def __init__(self, route: str, name: str | None = ..., is_endpoint: bool = ...) -> None: ... def match(self, path: str) -> Tuple[str, Tuple, Dict[str, int | str]] | None: ... def check(self) -> List[CheckMessage]: ... class LocalePrefixPattern: - prefix_default_language: bool = ... - converters: Dict[Any, Any] = ... + prefix_default_language: bool + converters: Dict[Any, Any] def __init__(self, prefix_default_language: bool = ...) -> None: ... @property def regex(self) -> Pattern[str]: ... @@ -79,10 +79,10 @@ class LocalePrefixPattern: def describe(self) -> str: ... class URLPattern: - pattern: _Pattern = ... - callback: Callable = ... - default_args: Dict[str, str] | None = ... - name: str | None = ... + pattern: _Pattern + callback: Callable + default_args: Dict[str, str] | None + name: str | None def __init__( self, pattern: _Pattern, @@ -96,12 +96,12 @@ class URLPattern: def lookup_str(self) -> str: ... class URLResolver: - pattern: _Pattern = ... - urlconf_name: str | None | Sequence[_AnyURL] = ... - callback: None = ... - default_kwargs: Dict[str, Any] = ... - namespace: str | None = ... - app_name: str | None = ... + pattern: _Pattern + urlconf_name: str | None | Sequence[_AnyURL] + callback: None + default_kwargs: Dict[str, Any] + namespace: str | None + app_name: str | None _local: Any _reverse_dict: MultiValueDict def __init__( diff --git a/django-stubs/utils/baseconv.pyi b/django-stubs/utils/baseconv.pyi index 6b2b34e03..db6b26239 100644 --- a/django-stubs/utils/baseconv.pyi +++ b/django-stubs/utils/baseconv.pyi @@ -8,9 +8,9 @@ BASE62_ALPHABET: str BASE64_ALPHABET: str class BaseConverter: - decimal_digits: str = ... - sign: str = ... - digits: str = ... + decimal_digits: str + sign: str + digits: str def __init__(self, digits: str, sign: str = ...) -> None: ... def encode(self, i: int) -> str: ... def decode(self, s: str) -> int: ... diff --git a/django-stubs/utils/connection.pyi b/django-stubs/utils/connection.pyi index 873b6715c..79205cc00 100644 --- a/django-stubs/utils/connection.pyi +++ b/django-stubs/utils/connection.pyi @@ -13,9 +13,9 @@ class ConnectionDoesNotExist(Exception): ... _T = TypeVar("_T") class BaseConnectionHandler(Generic[_T]): - settings_name: str | None = ... - exception_class: Type[Exception] = ... - thread_critical: bool = ... + settings_name: str | None + exception_class: Type[Exception] + thread_critical: bool def __init__(self, settings: Any | None = ...) -> None: ... @property def settings(self) -> Dict[str, Any]: ... diff --git a/django-stubs/utils/datastructures.pyi b/django-stubs/utils/datastructures.pyi index b3419bbc3..5873e61d3 100644 --- a/django-stubs/utils/datastructures.pyi +++ b/django-stubs/utils/datastructures.pyi @@ -55,7 +55,7 @@ class _IndexableCollection(Protocol[_I], Collection[_I]): def __getitem__(self: _IC, index: slice) -> _IC: ... class OrderedSet(MutableSet[_K]): - dict: Dict[_K, None] = ... + dict: Dict[_K, None] def __init__(self, iterable: Iterable[_K] | None = ...) -> None: ... def __contains__(self, item: object) -> bool: ... def __iter__(self) -> Iterator[_K]: ... @@ -97,7 +97,7 @@ class MultiValueDict(Dict[_K, _V]): def values(self) -> Iterator[_V | List[object]]: ... # type: ignore[override] class ImmutableList(Tuple[_V, ...]): - warning: str = ... + warning: str def __new__(cls, *args: Any, warning: str = ..., **kwargs: Any) -> ImmutableList: ... def complain(self, *args: Any, **kwargs: Any) -> None: ... @@ -107,8 +107,8 @@ class _ItemCallable(Protocol[_V]): def __call__(self, __value: _V) -> _V: ... class DictWrapper(Dict[str, _V]): - func: _ItemCallable[_V] = ... - prefix: str = ... + func: _ItemCallable[_V] + prefix: str @overload def __init__(self, data: Mapping[str, _V], func: _ItemCallable[_V], prefix: str) -> None: ... @overload diff --git a/django-stubs/utils/dateformat.pyi b/django-stubs/utils/dateformat.pyi index dd6812ccf..1dc505787 100644 --- a/django-stubs/utils/dateformat.pyi +++ b/django-stubs/utils/dateformat.pyi @@ -13,8 +13,8 @@ class Formatter: def format(self, formatstr: str) -> str: ... class TimeFormat(Formatter): - data: builtin_datetime | builtin_time = ... - timezone: _TzInfoT | None = ... + data: builtin_datetime | builtin_time + timezone: _TzInfoT | None def __init__(self, obj: builtin_datetime | builtin_time) -> None: ... def a(self) -> str: ... def A(self) -> str: ... @@ -35,7 +35,7 @@ class TimeFormat(Formatter): class DateFormat(TimeFormat): data: builtin_datetime | date | builtin_time # type: ignore timezone: _TzInfoT | None - year_days: Any = ... + year_days: Any def __init__(self, obj: builtin_datetime | builtin_time | date) -> None: ... def b(self) -> str: ... def c(self) -> str: ... diff --git a/django-stubs/utils/deprecation.pyi b/django-stubs/utils/deprecation.pyi index f7d5354c8..fe4c5fe7b 100644 --- a/django-stubs/utils/deprecation.pyi +++ b/django-stubs/utils/deprecation.pyi @@ -9,17 +9,17 @@ class RemovedInDjango41Warning(PendingDeprecationWarning): ... RemovedInNextVersionWarning = RemovedInDjango40Warning class warn_about_renamed_method: - class_name: str = ... - old_method_name: str = ... - new_method_name: str = ... - deprecation_warning: Type[DeprecationWarning] = ... + class_name: str + old_method_name: str + new_method_name: str + deprecation_warning: Type[DeprecationWarning] def __init__( self, class_name: str, old_method_name: str, new_method_name: str, deprecation_warning: Type[DeprecationWarning] ) -> None: ... def __call__(self, f: Callable) -> Callable: ... class RenameMethodsBase(type): - renamed_methods: Any = ... + renamed_methods: Any def __new__(cls, name: Any, bases: Any, attrs: Any) -> Type: ... class DeprecationInstanceCheck(type): @@ -31,6 +31,6 @@ class GetResponseCallable(Protocol): def __call__(self, __request: HttpRequest) -> HttpResponse: ... class MiddlewareMixin: - get_response: GetResponseCallable = ... + get_response: GetResponseCallable def __init__(self, get_response: GetResponseCallable = ...) -> None: ... def __call__(self, request: HttpRequest) -> HttpResponse: ... diff --git a/django-stubs/utils/encoding.pyi b/django-stubs/utils/encoding.pyi index 3b2ead945..bd7482a92 100644 --- a/django-stubs/utils/encoding.pyi +++ b/django-stubs/utils/encoding.pyi @@ -6,7 +6,7 @@ from django.utils.functional import Promise from typing_extensions import Literal, TypeGuard class DjangoUnicodeDecodeError(UnicodeDecodeError): - obj: bytes = ... + obj: bytes def __init__(self, obj: bytes, *args: Any) -> None: ... _P = TypeVar("_P", bound=Promise) diff --git a/django-stubs/utils/feedgenerator.pyi b/django-stubs/utils/feedgenerator.pyi index c25036a2e..afd1b3b63 100644 --- a/django-stubs/utils/feedgenerator.pyi +++ b/django-stubs/utils/feedgenerator.pyi @@ -7,8 +7,8 @@ def rfc3339_date(date: datetime.date) -> str: ... def get_tag_uri(url: str, date: datetime.date | None) -> str: ... class SyndicationFeed: - feed: Dict[str, Any] = ... - items: List[Dict[str, Any]] = ... + feed: Dict[str, Any] + items: List[Dict[str, Any]] def __init__( self, title: str, @@ -57,11 +57,11 @@ class SyndicationFeed: class Enclosure: length: Any mime_type: str - url: str = ... + url: str def __init__(self, url: str, length: int | str, mime_type: str) -> None: ... class RssFeed(SyndicationFeed): - content_type: str = ... + content_type: str def write_items(self, handler: ContentHandler) -> None: ... def endChannelElement(self, handler: ContentHandler) -> None: ... @@ -69,8 +69,8 @@ class RssUserland091Feed(RssFeed): ... class Rss201rev2Feed(RssFeed): ... class Atom1Feed(SyndicationFeed): - content_type: str = ... - ns: str = ... + content_type: str + ns: str def write_items(self, handler: ContentHandler) -> None: ... DefaultFeed = Rss201rev2Feed diff --git a/django-stubs/utils/functional.pyi b/django-stubs/utils/functional.pyi index 0e5780ebc..16ec3f902 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -7,8 +7,8 @@ from typing_extensions import Protocol, SupportsIndex _T = TypeVar("_T") class cached_property(Generic[_T]): - func: Callable[..., _T] = ... - name: str = ... + func: Callable[..., _T] + name: str def __init__(self, func: Callable[..., _T], name: str = ...) -> None: ... @overload def __get__(self, instance: None, cls: Type[Any] = ...) -> "cached_property[_T]": ... @@ -57,22 +57,22 @@ def new_method_proxy(func: Callable[..., _T]) -> Callable[..., _T]: ... class LazyObject: def __init__(self) -> None: ... - __getattr__: Callable = ... + __getattr__: Callable def __setattr__(self, name: str, value: Any) -> None: ... def __delattr__(self, name: str) -> None: ... def __reduce__(self) -> Tuple[Callable, Tuple[Model]]: ... def __copy__(self) -> LazyObject: ... - __bytes__: Callable = ... - __bool__: Callable = ... - __dir__: Callable = ... - __ne__: Callable = ... - __hash__: Callable = ... - __getitem__: Callable = ... - __setitem__: Callable = ... - __delitem__: Callable = ... - __iter__: Callable = ... - __len__: Callable = ... - __contains__: Callable = ... + __bytes__: Callable + __bool__: Callable + __dir__: Callable + __ne__: Callable + __hash__: Callable + __getitem__: Callable + __setitem__: Callable + __delitem__: Callable + __iter__: Callable + __len__: Callable + __contains__: Callable def unpickle_lazyobject(wrapped: Model) -> Model: ... @@ -90,7 +90,7 @@ _Get = TypeVar("_Get", covariant=True) _Self = TypeVar("_Self") class classproperty(Generic[_Get]): - fget: Callable[[_Self], _Get] | None = ... + fget: Callable[[_Self], _Get] | None def __init__(self, method: Callable[[_Self], _Get] | None = ...) -> None: ... def __get__(self, instance: _Self | None, cls: Type[_Self] = ...) -> _Get: ... def getter(self, method: Callable[[_Self], _Get]) -> classproperty[_Get]: ... diff --git a/django-stubs/utils/html.pyi b/django-stubs/utils/html.pyi index 2645bcb02..9e3e8c3ca 100644 --- a/django-stubs/utils/html.pyi +++ b/django-stubs/utils/html.pyi @@ -19,7 +19,7 @@ def format_html_join(sep: str, format_string: str, args_generator: Iterable[Iter def linebreaks(value: Any, autoescape: bool = ...) -> str: ... class MLStripper(HTMLParser): - fed: Any = ... + fed: Any def __init__(self) -> None: ... def handle_data(self, d: str) -> None: ... def handle_entityref(self, name: str) -> None: ... diff --git a/django-stubs/utils/jslex.pyi b/django-stubs/utils/jslex.pyi index db7834481..5804ba220 100644 --- a/django-stubs/utils/jslex.pyi +++ b/django-stubs/utils/jslex.pyi @@ -1,26 +1,26 @@ from typing import Any, Dict, Iterator, List, Tuple class Tok: - num: int = ... - id: int = ... - name: str = ... - regex: str = ... - next: str | None = ... + num: int + id: int + name: str + regex: str + next: str | None def __init__(self, name: str, regex: str, next: str | None = ...) -> None: ... def literals(choices: str, prefix: str = ..., suffix: str = ...) -> str: ... class Lexer: - regexes: Any = ... - toks: Dict[str, Tok] = ... - state: str = ... + regexes: Any + toks: Dict[str, Tok] + state: str def __init__(self, states: Dict[str, List[Tok]], first: str) -> None: ... def lex(self, text: str) -> Iterator[Tuple[str, str]]: ... class JsLexer(Lexer): - both_before: List[Tok] = ... - both_after: List[Tok] = ... - states: Dict[str, List[Tok]] = ... + both_before: List[Tok] + both_after: List[Tok] + states: Dict[str, List[Tok]] def __init__(self) -> None: ... def prepare_js_for_gettext(js: str) -> str: ... diff --git a/django-stubs/utils/log.pyi b/django-stubs/utils/log.pyi index 745cb3e16..c1831b411 100644 --- a/django-stubs/utils/log.pyi +++ b/django-stubs/utils/log.pyi @@ -11,8 +11,8 @@ DEFAULT_LOGGING: Any def configure_logging(logging_config: str, logging_settings: Dict[str, Any]) -> None: ... class AdminEmailHandler(logging.Handler): - include_html: bool = ... - email_backend: str | None = ... + include_html: bool + email_backend: str | None def __init__( self, include_html: bool = ..., @@ -24,7 +24,7 @@ class AdminEmailHandler(logging.Handler): def format_subject(self, subject: str) -> str: ... class CallbackFilter(logging.Filter): - callback: Callable = ... + callback: Callable def __init__(self, callback: Callable) -> None: ... def filter(self, record: str | LogRecord) -> bool: ... @@ -35,8 +35,8 @@ class RequireDebugTrue(logging.Filter): def filter(self, record: str | LogRecord) -> bool: ... class ServerFormatter(logging.Formatter): - default_time_format: str = ... - style: Style = ... + default_time_format: str + style: Style def __init__(self, *args: Any, **kwargs: Any) -> None: ... def uses_server_time(self) -> bool: ... diff --git a/django-stubs/utils/termcolors.pyi b/django-stubs/utils/termcolors.pyi index 3a5b74efb..66a7a089f 100644 --- a/django-stubs/utils/termcolors.pyi +++ b/django-stubs/utils/termcolors.pyi @@ -13,6 +13,6 @@ NOCOLOR_PALETTE: str DARK_PALETTE: str LIGHT_PALETTE: str PALETTES: Any -DEFAULT_PALETTE: str = ... +DEFAULT_PALETTE: str def parse_color_setting(config_string: str) -> Dict[str, Dict[str, Tuple[str, ...] | str]] | None: ... diff --git a/django-stubs/utils/text.pyi b/django-stubs/utils/text.pyi index 5548186de..4c270fc9d 100644 --- a/django-stubs/utils/text.pyi +++ b/django-stubs/utils/text.pyi @@ -28,7 +28,7 @@ def phone2numeric(phone: str) -> str: ... def compress_string(s: bytes) -> bytes: ... class StreamingBuffer(BytesIO): - vals: List[bytes] = ... + vals: List[bytes] def read(self) -> bytes: ... # type: ignore def compress_sequence(sequence: Iterable[bytes]) -> Iterator[bytes]: ... diff --git a/django-stubs/utils/timezone.pyi b/django-stubs/utils/timezone.pyi index 5f2cf6ce8..bb1944cc4 100644 --- a/django-stubs/utils/timezone.pyi +++ b/django-stubs/utils/timezone.pyi @@ -15,7 +15,7 @@ from typing_extensions import Literal, TypeGuard _PytzTzInfoT = pytz.tzinfo.BaseTzInfo | pytz._FixedOffset _TzInfoT = _PytzTzInfoT | tzinfo -utc: Any = ... +utc: Any def get_fixed_timezone(offset: timedelta | int) -> timezone: ... def get_default_timezone() -> BaseTzInfo: ... @@ -30,8 +30,8 @@ def activate(timezone: _TzInfoT | str) -> None: ... def deactivate() -> None: ... class override(ContextDecorator): - timezone: str | _TzInfoT | None = ... - old_timezone: _TzInfoT | None = ... + timezone: str | _TzInfoT | None + old_timezone: _TzInfoT | None def __init__(self, timezone: str | _TzInfoT | None) -> None: ... def __enter__(self) -> None: ... def __exit__( diff --git a/django-stubs/utils/translation/__init__.pyi b/django-stubs/utils/translation/__init__.pyi index e1e20642e..b4b7840a5 100644 --- a/django-stubs/utils/translation/__init__.pyi +++ b/django-stubs/utils/translation/__init__.pyi @@ -51,10 +51,10 @@ def activate(language: str) -> None: ... def deactivate() -> None: ... class override(ContextDecorator): - language: str | None = ... - deactivate: bool = ... + language: str | None + deactivate: bool def __init__(self, language: str | None, deactivate: bool = ...) -> None: ... - old_language: str | None = ... + old_language: str | None def __enter__(self) -> None: ... def __exit__( self, diff --git a/django-stubs/utils/translation/trans_real.pyi b/django-stubs/utils/translation/trans_real.pyi index 626be60a7..9e2901144 100644 --- a/django-stubs/utils/translation/trans_real.pyi +++ b/django-stubs/utils/translation/trans_real.pyi @@ -31,8 +31,8 @@ class TranslationCatalog: def plural(self, msgid: str, num: int) -> str: ... class DjangoTranslation(gettext_module.GNUTranslations): - domain: str = ... - plural: _PluralCallable = ... + domain: str + plural: _PluralCallable def __init__(self, language: str, domain: str | None = ..., localedirs: List[str] | None = ...) -> None: ... def merge(self, other: NullTranslations) -> None: ... def language(self) -> str: ... diff --git a/django-stubs/utils/tree.pyi b/django-stubs/utils/tree.pyi index 57abdfed9..14df3d5b8 100644 --- a/django-stubs/utils/tree.pyi +++ b/django-stubs/utils/tree.pyi @@ -6,9 +6,9 @@ _NodeChildren = List["Node" | NothingNode | Sequence[Any]] class Node: children: _NodeChildren - default: str = ... - connector: str = ... - negated: bool = ... + default: str + connector: str + negated: bool def __init__( self, children: _NodeChildren | None = ..., connector: str | None = ..., negated: bool = ... ) -> None: ... diff --git a/django-stubs/views/debug.pyi b/django-stubs/views/debug.pyi index bdd2f1f40..5fcc5ab1f 100644 --- a/django-stubs/views/debug.pyi +++ b/django-stubs/views/debug.pyi @@ -33,15 +33,15 @@ class SafeExceptionReporterFilter: def get_traceback_frame_variables(self, request: Any, tb_frame: Any) -> ItemsView[str, Any]: ... class ExceptionReporter: - request: HttpRequest | None = ... - filter: SafeExceptionReporterFilter = ... - exc_type: Type[BaseException] | None = ... - exc_value: BaseException | None = ... - tb: TracebackType | None = ... - is_email: bool = ... - template_info: Any | None = ... - template_does_not_exist: bool = ... - postmortem: Any | None = ... + request: HttpRequest | None + filter: SafeExceptionReporterFilter + exc_type: Type[BaseException] | None + exc_value: BaseException | None + tb: TracebackType | None + is_email: bool + template_info: Any | None + template_does_not_exist: bool + postmortem: Any | None @property def html_template_path(self) -> Path: ... @property diff --git a/django-stubs/views/decorators/gzip.pyi b/django-stubs/views/decorators/gzip.pyi index ed3f3515c..c723517d9 100644 --- a/django-stubs/views/decorators/gzip.pyi +++ b/django-stubs/views/decorators/gzip.pyi @@ -2,4 +2,4 @@ from typing import Any, Callable, TypeVar _C = TypeVar("_C", bound=Callable[..., Any]) -gzip_page: Callable[[_C], _C] = ... +gzip_page: Callable[[_C], _C] diff --git a/django-stubs/views/decorators/http.pyi b/django-stubs/views/decorators/http.pyi index f215916c1..cc5f99379 100644 --- a/django-stubs/views/decorators/http.pyi +++ b/django-stubs/views/decorators/http.pyi @@ -2,13 +2,13 @@ from typing import Any, Callable, Container, TypeVar _F = TypeVar("_F", bound=Callable[..., Any]) -conditional_page: Callable[[_F], _F] = ... +conditional_page: Callable[[_F], _F] def require_http_methods(request_method_list: Container[str]) -> Callable[[_F], _F]: ... -require_GET: Callable[[_F], _F] = ... -require_POST: Callable[[_F], _F] = ... -require_safe: Callable[[_F], _F] = ... +require_GET: Callable[[_F], _F] +require_POST: Callable[[_F], _F] +require_safe: Callable[[_F], _F] def condition(etag_func: Callable | None = ..., last_modified_func: Callable | None = ...) -> Callable: ... def etag(etag_func: Callable[..., Any]) -> Callable[[_F], _F]: ... diff --git a/django-stubs/views/generic/base.pyi b/django-stubs/views/generic/base.pyi index 8cdd4ce3d..751dd2c1b 100644 --- a/django-stubs/views/generic/base.pyi +++ b/django-stubs/views/generic/base.pyi @@ -8,10 +8,10 @@ class ContextMixin: def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... class View: - http_method_names: List[str] = ... - request: HttpRequest = ... - args: Any = ... - kwargs: Any = ... + http_method_names: List[str] + request: HttpRequest + args: Any + kwargs: Any def __init__(self, **kwargs: Any) -> None: ... @classmethod def as_view(cls: Any, **initkwargs: Any) -> Callable[..., HttpResponseBase]: ... @@ -21,11 +21,11 @@ class View: def options(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ... class TemplateResponseMixin: - template_name: str = ... - template_engine: str | None = ... - response_class: Type[HttpResponse] = ... - content_type: str | None = ... - request: HttpRequest = ... + template_name: str + template_engine: str | None + response_class: Type[HttpResponse] + content_type: str | None + request: HttpRequest def render_to_response(self, context: Dict[str, Any], **response_kwargs: Any) -> HttpResponse: ... def get_template_names(self) -> List[str]: ... @@ -33,10 +33,10 @@ class TemplateView(TemplateResponseMixin, ContextMixin, View): def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... class RedirectView(View): - permanent: bool = ... - url: str | None = ... - pattern_name: str | None = ... - query_string: bool = ... + permanent: bool + url: str | None + pattern_name: str | None + query_string: bool def get_redirect_url(self, *args: Any, **kwargs: Any) -> str | None: ... def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ... def head(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ... diff --git a/django-stubs/views/generic/dates.pyi b/django-stubs/views/generic/dates.pyi index befcba0ab..533d6558d 100644 --- a/django-stubs/views/generic/dates.pyi +++ b/django-stubs/views/generic/dates.pyi @@ -12,40 +12,40 @@ from django.views.generic.list import MultipleObjectMixin, MultipleObjectTemplat _M = TypeVar("_M", bound=models.Model) class YearMixin: - year_format: str = ... - year: str | None = ... + year_format: str + year: str | None def get_year_format(self) -> str: ... def get_year(self) -> str: ... def get_next_year(self, date: datetime.date) -> datetime.date | None: ... def get_previous_year(self, date: datetime.date) -> datetime.date | None: ... class MonthMixin: - month_format: str = ... - month: str | None = ... + month_format: str + month: str | None def get_month_format(self) -> str: ... def get_month(self) -> str: ... def get_next_month(self, date: datetime.date) -> datetime.date | None: ... def get_previous_month(self, date: datetime.date) -> datetime.date | None: ... class DayMixin: - day_format: str = ... - day: str | None = ... + day_format: str + day: str | None def get_day_format(self) -> str: ... def get_day(self) -> str: ... def get_next_day(self, date: datetime.date) -> datetime.date | None: ... def get_previous_day(self, date: datetime.date) -> datetime.date | None: ... class WeekMixin: - week_format: str = ... - week: str | None = ... + week_format: str + week: str | None def get_week_format(self) -> str: ... def get_week(self) -> str: ... def get_next_week(self, date: datetime.date) -> datetime.date | None: ... def get_previous_week(self, date: datetime.date) -> datetime.date | None: ... class DateMixin: - date_field: str | None = ... - allow_future: bool = ... + date_field: str | None + allow_future: bool def get_date_field(self) -> str: ... def get_allow_future(self) -> bool: ... @property @@ -54,7 +54,7 @@ class DateMixin: DatedItems = Tuple[_IndexableCollection[datetime.date] | None, _IndexableCollection[_M], Dict[str, Any]] class BaseDateListView(MultipleObjectMixin[_M], DateMixin, View): - date_list_period: str = ... + date_list_period: str def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def get_dated_items(self) -> DatedItems: ... def get_ordering(self) -> str | Sequence[str]: ... @@ -65,50 +65,50 @@ class BaseDateListView(MultipleObjectMixin[_M], DateMixin, View): ) -> models.query.QuerySet: ... class BaseArchiveIndexView(BaseDateListView[_M]): - context_object_name: str = ... + context_object_name: str def get_dated_items(self) -> DatedItems[_M]: ... class ArchiveIndexView(MultipleObjectTemplateResponseMixin, BaseArchiveIndexView): - template_name_suffix: str = ... + template_name_suffix: str class BaseYearArchiveView(YearMixin, BaseDateListView[_M]): - date_list_period: str = ... - make_object_list: bool = ... + date_list_period: str + make_object_list: bool def get_dated_items(self) -> DatedItems[_M]: ... def get_make_object_list(self) -> bool: ... class YearArchiveView(MultipleObjectTemplateResponseMixin, BaseYearArchiveView): - template_name_suffix: str = ... + template_name_suffix: str class BaseMonthArchiveView(YearMixin, MonthMixin, BaseDateListView[_M]): - date_list_period: str = ... + date_list_period: str def get_dated_items(self) -> DatedItems[_M]: ... class MonthArchiveView(MultipleObjectTemplateResponseMixin, BaseMonthArchiveView): - template_name_suffix: str = ... + template_name_suffix: str class BaseWeekArchiveView(YearMixin, WeekMixin, BaseDateListView[_M]): def get_dated_items(self) -> DatedItems[_M]: ... class WeekArchiveView(MultipleObjectTemplateResponseMixin, BaseWeekArchiveView): - template_name_suffix: str = ... + template_name_suffix: str class BaseDayArchiveView(YearMixin, MonthMixin, DayMixin, BaseDateListView[_M]): def get_dated_items(self) -> DatedItems[_M]: ... class DayArchiveView(MultipleObjectTemplateResponseMixin, BaseDayArchiveView): - template_name_suffix: str = ... + template_name_suffix: str class BaseTodayArchiveView(BaseDayArchiveView[_M]): def get_dated_items(self) -> DatedItems[_M]: ... class TodayArchiveView(MultipleObjectTemplateResponseMixin, BaseTodayArchiveView): - template_name_suffix: str = ... + template_name_suffix: str class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailView[_M]): def get_object(self, queryset: QuerySet[_M] | None = ...) -> _M: ... class DateDetailView(SingleObjectTemplateResponseMixin, BaseDateDetailView): - template_name_suffix: str = ... + template_name_suffix: str def timezone_today() -> datetime.date: ... diff --git a/django-stubs/views/generic/detail.pyi b/django-stubs/views/generic/detail.pyi index 79c2d4535..2d92a8acd 100644 --- a/django-stubs/views/generic/detail.pyi +++ b/django-stubs/views/generic/detail.pyi @@ -7,13 +7,13 @@ from django.views.generic.base import ContextMixin, TemplateResponseMixin, View _M = TypeVar("_M", bound=models.Model) class SingleObjectMixin(Generic[_M], ContextMixin): - model: Type[_M] = ... - queryset: models.query.QuerySet[_M] | None = ... - slug_field: str = ... - context_object_name: str | None = ... - slug_url_kwarg: str = ... - pk_url_kwarg: str = ... - query_pk_and_slug: bool = ... + model: Type[_M] + queryset: models.query.QuerySet[_M] | None + slug_field: str + context_object_name: str | None + slug_url_kwarg: str + pk_url_kwarg: str + query_pk_and_slug: bool def get_object(self, queryset: models.query.QuerySet[_M] | None = ...) -> _M: ... def get_queryset(self) -> models.query.QuerySet[_M]: ... def get_slug_field(self) -> str: ... @@ -24,7 +24,7 @@ class BaseDetailView(SingleObjectMixin[_M], View): def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... class SingleObjectTemplateResponseMixin(TemplateResponseMixin): - template_name_field: str | None = ... - template_name_suffix: str = ... + template_name_field: str | None + template_name_suffix: str class DetailView(SingleObjectTemplateResponseMixin, BaseDetailView[_M]): ... diff --git a/django-stubs/views/generic/edit.pyi b/django-stubs/views/generic/edit.pyi index 3f09b403f..93e0463e9 100644 --- a/django-stubs/views/generic/edit.pyi +++ b/django-stubs/views/generic/edit.pyi @@ -14,10 +14,10 @@ _ModelFormT = TypeVar("_ModelFormT", bound=BaseModelForm) _M = TypeVar("_M", bound=models.Model) class FormMixin(Generic[_FormT], ContextMixin): - initial: Dict[str, Any] = ... - form_class: Type[_FormT] | None = ... - success_url: str | None = ... - prefix: str | None = ... + initial: Dict[str, Any] + form_class: Type[_FormT] | None + success_url: str | None + prefix: str | None def get_initial(self) -> Dict[str, Any]: ... def get_prefix(self) -> str | None: ... def get_form_class(self) -> Type[_FormT]: ... @@ -29,7 +29,7 @@ class FormMixin(Generic[_FormT], ContextMixin): def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... class ModelFormMixin(Generic[_M, _ModelFormT], FormMixin[_ModelFormT], SingleObjectMixin[_M]): - fields: _ListOrTuple[str] | Literal["__all__"] | None = ... + fields: _ListOrTuple[str] | Literal["__all__"] | None def get_form_class(self) -> Type[_ModelFormT]: ... def get_form_kwargs(self) -> Dict[str, Any]: ... def get_success_url(self) -> str: ... @@ -49,7 +49,7 @@ class BaseCreateView(ModelFormMixin[_M, _ModelFormT], ProcessFormView): def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... class CreateView(SingleObjectTemplateResponseMixin, BaseCreateView[_M, _ModelFormT]): - template_name_suffix: str = ... + template_name_suffix: str class BaseUpdateView(ModelFormMixin[_M, _ModelFormT], ProcessFormView): object: _M @@ -57,10 +57,10 @@ class BaseUpdateView(ModelFormMixin[_M, _ModelFormT], ProcessFormView): def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... class UpdateView(SingleObjectTemplateResponseMixin, BaseUpdateView[_M, _ModelFormT]): - template_name_suffix: str = ... + template_name_suffix: str class DeletionMixin(Generic[_M]): - success_url: str | None = ... + success_url: str | None object: _M def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def delete(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... @@ -71,4 +71,4 @@ class BaseDeleteView(Generic[_M, _ModelFormT], DeletionMixin[_M], FormMixin[_Mod class DeleteView(Generic[_M, _ModelFormT], SingleObjectTemplateResponseMixin, BaseDeleteView[_M, _ModelFormT]): object: _M - template_name_suffix: str = ... + template_name_suffix: str diff --git a/django-stubs/views/generic/list.pyi b/django-stubs/views/generic/list.pyi index 2c9f92fe0..4a42a153e 100644 --- a/django-stubs/views/generic/list.pyi +++ b/django-stubs/views/generic/list.pyi @@ -8,15 +8,15 @@ from django.views.generic.base import ContextMixin, TemplateResponseMixin, View _M = TypeVar("_M", bound=Model, covariant=True) class MultipleObjectMixin(Generic[_M], ContextMixin): - allow_empty: bool = ... - queryset: _SupportsPagination[_M] | None = ... - model: Type[_M] | None = ... - paginate_by: int = ... - paginate_orphans: int = ... - context_object_name: str | None = ... - paginator_class: Type[Paginator] = ... - page_kwarg: str = ... - ordering: str | Sequence[str] | None = ... + allow_empty: bool + queryset: _SupportsPagination[_M] | None + model: Type[_M] | None + paginate_by: int + paginate_orphans: int + context_object_name: str | None + paginator_class: Type[Paginator] + page_kwarg: str + ordering: str | Sequence[str] | None def get_queryset(self) -> _SupportsPagination[_M]: ... def get_ordering(self) -> str | Sequence[str] | None: ... def paginate_queryset( @@ -40,6 +40,6 @@ class BaseListView(MultipleObjectMixin[_M], View): def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... class MultipleObjectTemplateResponseMixin(TemplateResponseMixin): - template_name_suffix: str = ... + template_name_suffix: str class ListView(MultipleObjectTemplateResponseMixin, BaseListView[_M]): ... diff --git a/django-stubs/views/i18n.pyi b/django-stubs/views/i18n.pyi index 6fed6203f..b33b53696 100644 --- a/django-stubs/views/i18n.pyi +++ b/django-stubs/views/i18n.pyi @@ -14,9 +14,9 @@ js_catalog_template: str class JavaScriptCatalog(View): head: Callable - domain: str = ... - packages: List[str] = ... - translation: DjangoTranslation = ... + domain: str + packages: List[str] + translation: DjangoTranslation def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def get_paths(self, packages: List[str]) -> List[str]: ... def get_plural(self) -> List[str] | None: ... From cf56059584b02cab1b2cbe24bc49ed5089b2b0d3 Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sun, 13 Nov 2022 14:07:01 +0100 Subject: [PATCH 08/13] use PEP 585 container types where possible, replace obsolete typing types with collections.abc Signed-off-by: Oleg Hoefling --- django-stubs/apps/config.pyi | 8 +- django-stubs/apps/registry.pyi | 21 +-- django-stubs/conf/global_settings.pyi | 65 ++++----- django-stubs/conf/locale/__init__.pyi | 4 +- django-stubs/conf/urls/__init__.pyi | 11 +- django-stubs/conf/urls/i18n.pyi | 8 +- django-stubs/conf/urls/static.pyi | 5 +- django-stubs/contrib/admin/checks.pyi | 19 +-- django-stubs/contrib/admin/decorators.pyi | 5 +- django-stubs/contrib/admin/filters.pyi | 45 ++++--- django-stubs/contrib/admin/helpers.pyi | 19 +-- django-stubs/contrib/admin/options.pyi | 115 +++++++--------- django-stubs/contrib/admin/sites.pyi | 47 +++---- .../contrib/admin/templatetags/admin_list.pyi | 13 +- .../contrib/admin/templatetags/admin_urls.pyi | 4 +- .../contrib/admin/templatetags/base.pyi | 7 +- django-stubs/contrib/admin/tests.pyi | 3 +- django-stubs/contrib/admin/utils.pyi | 41 +++--- .../contrib/admin/views/decorators.pyi | 3 +- django-stubs/contrib/admin/views/main.pyi | 23 ++-- django-stubs/contrib/admin/widgets.pyi | 33 ++--- django-stubs/contrib/admindocs/middleware.pyi | 7 +- django-stubs/contrib/admindocs/urls.pyi | 4 +- django-stubs/contrib/admindocs/utils.pyi | 9 +- django-stubs/contrib/admindocs/views.pyi | 5 +- django-stubs/contrib/auth/__init__.pyi | 8 +- django-stubs/contrib/auth/backends.pyi | 8 +- django-stubs/contrib/auth/base_user.pyi | 6 +- django-stubs/contrib/auth/checks.pyi | 3 +- .../contrib/auth/context_processors.pyi | 5 +- django-stubs/contrib/auth/decorators.pyi | 3 +- django-stubs/contrib/auth/forms.pyi | 17 +-- .../contrib/auth/handlers/modwsgi.pyi | 6 +- django-stubs/contrib/auth/hashers.pyi | 9 +- django-stubs/contrib/auth/mixins.pyi | 3 +- django-stubs/contrib/auth/models.pyi | 21 +-- .../contrib/auth/password_validation.pyi | 11 +- django-stubs/contrib/auth/urls.pyi | 4 +- django-stubs/contrib/auth/views.pyi | 6 +- django-stubs/contrib/contenttypes/admin.pyi | 6 +- django-stubs/contrib/contenttypes/checks.pyi | 3 +- django-stubs/contrib/contenttypes/fields.pyi | 37 +++--- django-stubs/contrib/contenttypes/forms.pyi | 8 +- .../contenttypes/management/__init__.pyi | 8 +- .../commands/remove_stale_contenttypes.pyi | 10 +- django-stubs/contrib/contenttypes/models.pyi | 10 +- django-stubs/contrib/flatpages/urls.pyi | 4 +- .../gis/db/backends/base/operations.pyi | 4 +- .../gis/db/backends/mysql/features.pyi | 4 +- .../gis/db/backends/mysql/operations.pyi | 9 +- .../gis/db/backends/spatialite/operations.pyi | 4 +- django-stubs/contrib/gis/db/models/fields.pyi | 5 +- django-stubs/contrib/gis/gdal/layer.pyi | 3 +- django-stubs/contrib/gis/gdal/raster/band.pyi | 3 +- django-stubs/contrib/gis/geos/collections.pyi | 3 +- django-stubs/contrib/gis/geos/coordseq.pyi | 3 +- django-stubs/contrib/gis/geos/linestring.pyi | 3 +- django-stubs/contrib/gis/geos/point.pyi | 3 +- django-stubs/contrib/gis/geos/polygon.pyi | 3 +- django-stubs/contrib/gis/views.pyi | 4 +- .../humanize/templatetags/humanize.pyi | 13 +- django-stubs/contrib/messages/api.pyi | 4 +- django-stubs/contrib/messages/constants.pyi | 6 +- .../contrib/messages/context_processors.pyi | 4 +- .../contrib/messages/storage/base.pyi | 5 +- .../contrib/messages/storage/session.pyi | 5 +- django-stubs/contrib/messages/utils.pyi | 4 +- django-stubs/contrib/messages/views.pyi | 4 +- django-stubs/contrib/postgres/constraints.pyi | 10 +- .../contrib/postgres/fields/array.pyi | 7 +- .../contrib/postgres/fields/ranges.pyi | 6 +- django-stubs/contrib/postgres/forms/array.pyi | 7 +- .../contrib/postgres/forms/hstore.pyi | 4 +- .../contrib/postgres/forms/ranges.pyi | 30 ++--- django-stubs/contrib/postgres/indexes.pyi | 5 +- django-stubs/contrib/postgres/search.pyi | 4 +- django-stubs/contrib/postgres/serializers.pyi | 4 +- django-stubs/contrib/postgres/signals.pyi | 6 +- django-stubs/contrib/postgres/validators.pyi | 5 +- .../contrib/sessions/backends/base.pyi | 10 +- django-stubs/contrib/sessions/backends/db.pyi | 8 +- .../contrib/sessions/base_session.pyi | 10 +- django-stubs/contrib/sessions/middleware.pyi | 4 +- django-stubs/contrib/sessions/serializers.pyi | 6 +- django-stubs/contrib/sitemaps/__init__.pyi | 5 +- django-stubs/contrib/sitemaps/views.pyi | 7 +- django-stubs/contrib/sites/models.pyi | 6 +- django-stubs/contrib/staticfiles/checks.pyi | 5 +- django-stubs/contrib/staticfiles/finders.pyi | 25 ++-- django-stubs/contrib/staticfiles/handlers.pyi | 9 +- .../management/commands/collectstatic.pyi | 4 +- django-stubs/contrib/staticfiles/storage.pyi | 11 +- django-stubs/contrib/staticfiles/urls.pyi | 6 +- django-stubs/contrib/staticfiles/utils.pyi | 2 +- django-stubs/contrib/syndication/views.pyi | 12 +- django-stubs/core/cache/__init__.pyi | 6 +- django-stubs/core/cache/backends/base.pyi | 15 ++- django-stubs/core/cache/backends/db.pyi | 4 +- .../core/cache/backends/filebased.pyi | 4 +- django-stubs/core/cache/backends/locmem.pyi | 4 +- .../core/cache/backends/memcached.pyi | 11 +- django-stubs/core/cache/utils.pyi | 3 +- django-stubs/core/checks/async_checks.pyi | 3 +- django-stubs/core/checks/caches.pyi | 3 +- django-stubs/core/checks/database.pyi | 3 +- django-stubs/core/checks/model_checks.pyi | 3 +- django-stubs/core/checks/registry.pyi | 13 +- django-stubs/core/checks/security/base.pyi | 3 +- django-stubs/core/checks/security/csrf.pyi | 3 +- .../core/checks/security/sessions.pyi | 3 +- django-stubs/core/checks/templates.pyi | 3 +- django-stubs/core/checks/translation.pyi | 3 +- django-stubs/core/checks/urls.pyi | 3 +- django-stubs/core/exceptions.pyi | 21 +-- django-stubs/core/files/base.pyi | 5 +- django-stubs/core/files/images.pyi | 4 +- django-stubs/core/files/storage.pyi | 6 +- django-stubs/core/files/uploadedfile.pyi | 12 +- django-stubs/core/files/uploadhandler.pyi | 18 +-- django-stubs/core/files/utils.pyi | 3 +- django-stubs/core/handlers/asgi.pyi | 15 ++- django-stubs/core/handlers/base.pyi | 3 +- django-stubs/core/handlers/exception.pyi | 3 +- django-stubs/core/handlers/wsgi.pyi | 9 +- django-stubs/core/mail/__init__.pyi | 7 +- django-stubs/core/mail/backends/base.pyi | 5 +- django-stubs/core/mail/message.pyi | 41 +++--- django-stubs/core/management/__init__.pyi | 12 +- django-stubs/core/management/base.pyi | 11 +- .../core/management/commands/check.pyi | 4 +- .../management/commands/compilemessages.pyi | 5 +- .../management/commands/createcachetable.pyi | 4 +- .../core/management/commands/diffsettings.pyi | 13 +- .../core/management/commands/flush.pyi | 4 +- .../core/management/commands/inspectdb.pyi | 15 ++- .../core/management/commands/loaddata.pyi | 12 +- .../core/management/commands/makemessages.pyi | 14 +- .../management/commands/makemigrations.pyi | 6 +- .../core/management/commands/migrate.pyi | 4 +- .../core/management/commands/runserver.pyi | 4 +- .../core/management/commands/shell.pyi | 4 +- .../management/commands/showmigrations.pyi | 6 +- django-stubs/core/management/sql.pyi | 4 +- django-stubs/core/management/templates.pyi | 7 +- django-stubs/core/management/utils.pyi | 11 +- django-stubs/core/paginator.pyi | 3 +- django-stubs/core/serializers/__init__.pyi | 15 ++- django-stubs/core/serializers/base.pyi | 21 +-- django-stubs/core/serializers/json.pyi | 5 +- django-stubs/core/serializers/jsonl.pyi | 5 +- django-stubs/core/serializers/python.pyi | 9 +- django-stubs/core/serializers/pyyaml.pyi | 3 +- django-stubs/core/servers/basehttp.pyi | 4 +- django-stubs/core/signing.pyi | 10 +- django-stubs/core/validators.pyi | 9 +- django-stubs/db/backends/base/base.pyi | 43 +++--- django-stubs/db/backends/base/client.pyi | 7 +- django-stubs/db/backends/base/creation.pyi | 8 +- django-stubs/db/backends/base/features.pyi | 19 +-- .../db/backends/base/introspection.pyi | 13 +- django-stubs/db/backends/base/operations.pyi | 39 +++--- django-stubs/db/backends/base/schema.pyi | 27 ++-- django-stubs/db/backends/base/validation.pyi | 6 +- django-stubs/db/backends/ddl_references.pyi | 25 ++-- django-stubs/db/backends/mysql/base.pyi | 23 ++-- django-stubs/db/backends/mysql/client.pyi | 7 +- django-stubs/db/backends/mysql/features.pyi | 6 +- django-stubs/db/backends/mysql/operations.pyi | 6 +- django-stubs/db/backends/oracle/base.pyi | 15 ++- django-stubs/db/backends/oracle/client.pyi | 9 +- .../db/backends/oracle/operations.pyi | 8 +- django-stubs/db/backends/postgresql/base.pyi | 20 +-- .../db/backends/postgresql/client.pyi | 7 +- django-stubs/db/backends/sqlite3/base.pyi | 13 +- django-stubs/db/backends/sqlite3/client.pyi | 7 +- django-stubs/db/backends/utils.pyi | 15 ++- django-stubs/db/migrations/autodetector.pyi | 25 ++-- django-stubs/db/migrations/exceptions.pyi | 6 +- django-stubs/db/migrations/executor.pyi | 12 +- django-stubs/db/migrations/graph.pyi | 47 +++---- django-stubs/db/migrations/loader.pyi | 23 ++-- django-stubs/db/migrations/migration.pyi | 14 +- .../db/migrations/operations/base.pyi | 13 +- .../db/migrations/operations/models.pyi | 37 +++--- .../db/migrations/operations/special.pyi | 11 +- .../db/migrations/operations/utils.pyi | 18 +-- django-stubs/db/migrations/optimizer.pyi | 6 +- django-stubs/db/migrations/questioner.pyi | 10 +- django-stubs/db/migrations/recorder.pyi | 4 +- django-stubs/db/migrations/serializer.pyi | 11 +- django-stubs/db/migrations/state.pyi | 43 +++--- django-stubs/db/migrations/writer.pyi | 10 +- django-stubs/db/models/base.pyi | 21 +-- django-stubs/db/models/constraints.pyi | 13 +- django-stubs/db/models/deletion.pyi | 29 ++-- django-stubs/db/models/enums.pyi | 26 ++-- django-stubs/db/models/expressions.pyi | 31 ++--- django-stubs/db/models/fields/__init__.pyi | 35 ++--- django-stubs/db/models/fields/files.pyi | 5 +- django-stubs/db/models/fields/json.pyi | 10 +- django-stubs/db/models/fields/related.pyi | 51 +++---- .../db/models/fields/related_descriptors.pyi | 37 +++--- .../db/models/fields/related_lookups.pyi | 15 ++- .../db/models/fields/reverse_related.pyi | 33 ++--- django-stubs/db/models/functions/text.pyi | 2 +- django-stubs/db/models/indexes.pyi | 15 ++- django-stubs/db/models/lookups.pyi | 29 ++-- django-stubs/db/models/manager.pyi | 76 +++++------ django-stubs/db/models/options.pyi | 71 +++++----- django-stubs/db/models/query.pyi | 83 +++++------- django-stubs/db/models/query_utils.pyi | 29 ++-- django-stubs/db/models/signals.pyi | 7 +- django-stubs/db/models/sql/compiler.pyi | 79 +++++------ django-stubs/db/models/sql/constants.pyi | 4 +- django-stubs/db/models/sql/datastructures.pyi | 12 +- django-stubs/db/models/sql/query.pyi | 119 ++++++++--------- django-stubs/db/models/sql/subqueries.pyi | 37 +++--- django-stubs/db/models/sql/where.pyi | 17 +-- django-stubs/db/models/utils.pyi | 9 +- django-stubs/db/transaction.pyi | 5 +- django-stubs/db/utils.pyi | 17 +-- django-stubs/dispatch/dispatcher.pyi | 11 +- django-stubs/forms/boundfield.pyi | 13 +- django-stubs/forms/fields.pyi | 67 +++++----- django-stubs/forms/forms.pyi | 25 ++-- django-stubs/forms/formsets.pyi | 43 +++--- django-stubs/forms/models.pyi | 125 ++++++++---------- django-stubs/forms/renderers.pyi | 8 +- django-stubs/forms/utils.pyi | 15 ++- django-stubs/forms/widgets.pyi | 69 +++++----- django-stubs/http/cookie.pyi | 4 +- django-stubs/http/multipartparser.pyi | 13 +- django-stubs/http/request.pyi | 31 ++--- django-stubs/http/response.pyi | 17 +-- django-stubs/middleware/cache.pyi | 3 +- django-stubs/middleware/csrf.pyi | 5 +- django-stubs/middleware/security.pyi | 4 +- django-stubs/shortcuts.pyi | 7 +- django-stubs/template/backends/base.pyi | 9 +- django-stubs/template/backends/django.pyi | 9 +- django-stubs/template/backends/dummy.pyi | 8 +- django-stubs/template/backends/jinja2.pyi | 11 +- django-stubs/template/base.pyi | 57 ++++---- django-stubs/template/context.pyi | 21 +-- django-stubs/template/context_processors.pyi | 17 +-- django-stubs/template/defaultfilters.pyi | 13 +- django-stubs/template/defaulttags.pyi | 53 ++++---- django-stubs/template/engine.pyi | 39 +++--- django-stubs/template/exceptions.pyi | 10 +- django-stubs/template/library.pyi | 31 ++--- django-stubs/template/loader.pyi | 3 +- django-stubs/template/loader_tags.pyi | 12 +- django-stubs/template/loaders/base.pyi | 7 +- django-stubs/template/loaders/cached.pyi | 11 +- django-stubs/template/loaders/filesystem.pyi | 8 +- django-stubs/template/loaders/locmem.pyi | 6 +- django-stubs/template/response.pyi | 19 +-- django-stubs/template/smartif.pyi | 12 +- django-stubs/template/utils.pyi | 11 +- django-stubs/templatetags/cache.pyi | 6 +- django-stubs/templatetags/i18n.pyi | 16 +-- django-stubs/templatetags/l10n.pyi | 6 +- django-stubs/test/client.pyi | 54 +++----- django-stubs/test/html.pyi | 9 +- django-stubs/test/runner.pyi | 63 ++++----- django-stubs/test/selenium.pyi | 5 +- django-stubs/test/testcases.pyi | 74 +++++------ django-stubs/test/utils.pyi | 71 ++++------ django-stubs/urls/base.pyi | 5 +- django-stubs/urls/conf.pyi | 17 +-- django-stubs/urls/converters.pyi | 10 +- django-stubs/urls/resolvers.pyi | 59 +++++---- django-stubs/urls/utils.pyi | 4 +- django-stubs/utils/archive.pyi | 7 +- django-stubs/utils/asyncio.pyi | 3 +- django-stubs/utils/autoreload.pyi | 17 +-- django-stubs/utils/baseconv.pyi | 4 +- django-stubs/utils/cache.pyi | 4 +- django-stubs/utils/connection.pyi | 9 +- django-stubs/utils/crypto.pyi | 2 +- django-stubs/utils/datastructures.pyi | 52 +++----- django-stubs/utils/dates.pyi | 14 +- django-stubs/utils/deconstruct.pyi | 3 +- django-stubs/utils/decorators.pyi | 5 +- django-stubs/utils/deprecation.pyi | 11 +- django-stubs/utils/feedgenerator.pyi | 18 +-- django-stubs/utils/formats.pyi | 11 +- django-stubs/utils/functional.pyi | 21 +-- django-stubs/utils/html.pyi | 9 +- django-stubs/utils/http.pyi | 9 +- django-stubs/utils/inspect.pyi | 7 +- django-stubs/utils/jslex.pyi | 15 ++- django-stubs/utils/log.pyi | 5 +- django-stubs/utils/lorem_ipsum.pyi | 4 +- django-stubs/utils/numberformat.pyi | 2 +- django-stubs/utils/regex_helper.pyi | 17 +-- django-stubs/utils/safestring.pyi | 3 +- django-stubs/utils/termcolors.pyi | 7 +- django-stubs/utils/text.pyi | 7 +- django-stubs/utils/timesince.pyi | 8 +- django-stubs/utils/timezone.pyi | 4 +- django-stubs/utils/topological_sort.pyi | 7 +- django-stubs/utils/translation/__init__.pyi | 5 +- django-stubs/utils/translation/trans_real.pyi | 17 +-- django-stubs/utils/tree.pyi | 9 +- django-stubs/utils/version.pyi | 6 +- django-stubs/utils/xmlutils.pyi | 5 +- django-stubs/views/debug.pyi | 21 +-- django-stubs/views/decorators/cache.pyi | 3 +- .../views/decorators/clickjacking.pyi | 3 +- django-stubs/views/decorators/common.pyi | 3 +- django-stubs/views/decorators/csrf.pyi | 3 +- django-stubs/views/decorators/debug.pyi | 3 +- django-stubs/views/decorators/gzip.pyi | 3 +- django-stubs/views/decorators/http.pyi | 3 +- django-stubs/views/decorators/vary.pyi | 3 +- django-stubs/views/generic/base.pyi | 15 ++- django-stubs/views/generic/dates.pyi | 5 +- django-stubs/views/generic/detail.pyi | 4 +- django-stubs/views/generic/edit.pyi | 20 +-- django-stubs/views/generic/list.pyi | 9 +- django-stubs/views/i18n.pyi | 17 +-- 322 files changed, 2369 insertions(+), 2329 deletions(-) diff --git a/django-stubs/apps/config.pyi b/django-stubs/apps/config.pyi index b453a1f94..81762861a 100644 --- a/django-stubs/apps/config.pyi +++ b/django-stubs/apps/config.pyi @@ -1,5 +1,5 @@ import types -from typing import Dict, Iterator, Type +from collections.abc import Iterator from django.apps.registry import Apps from django.db.models.base import Model @@ -15,11 +15,11 @@ class AppConfig: verbose_name: _StrOrPromise path: str models_module: str | None - models: Dict[str, Type[Model]] + models: dict[str, type[Model]] def __init__(self, app_name: str, app_module: types.ModuleType | None) -> None: ... @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_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 import_models(self) -> None: ... def ready(self) -> None: ... diff --git a/django-stubs/apps/registry.pyi b/django-stubs/apps/registry.pyi index 2091bd264..528704e31 100644 --- a/django-stubs/apps/registry.pyi +++ b/django-stubs/apps/registry.pyi @@ -1,18 +1,19 @@ import threading -from typing import Any, Callable, Dict, Iterable, List, Tuple, Type +from collections.abc import Callable, Iterable +from typing import Any from django.db.models.base import Model from .config import AppConfig class Apps: - all_models: Dict[str, Dict[str, Type[Model]]] - app_configs: Dict[str, AppConfig] - stored_app_configs: List[Any] + all_models: dict[str, dict[str, type[Model]]] + app_configs: dict[str, AppConfig] + stored_app_configs: list[Any] apps_ready: bool ready_event: threading.Event loading: bool - _pending_operations: Dict[Tuple[str, str], List] + _pending_operations: dict[tuple[str, str], list] models_ready: bool ready: bool def __init__(self, installed_apps: Iterable[AppConfig | str] | None = ...) -> None: ... @@ -22,12 +23,12 @@ class Apps: 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[Any]: ... - def register_model(self, app_label: str, model: Type[Model]) -> None: ... + 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[Any]: ... + 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: ... - def get_registered_model(self, app_label: str, model_name: str) -> Type[Model]: ... + def get_registered_model(self, app_label: str, model_name: str) -> type[Model]: ... def get_swappable_settings_name(self, to_string: str) -> str | None: ... def set_available_apps(self, available: Iterable[str]) -> None: ... def unset_available_apps(self) -> None: ... @@ -35,6 +36,6 @@ class Apps: def unset_installed_apps(self) -> None: ... def clear_cache(self) -> None: ... def lazy_model_operation(self, function: Callable, *model_keys: Any) -> None: ... - def do_pending_operations(self, model: Type[Model]) -> None: ... + def do_pending_operations(self, model: type[Model]) -> None: ... apps: Apps diff --git a/django-stubs/conf/global_settings.pyi b/django-stubs/conf/global_settings.pyi index 72adc7611..d90d8c7c8 100644 --- a/django-stubs/conf/global_settings.pyi +++ b/django-stubs/conf/global_settings.pyi @@ -2,10 +2,11 @@ Default Django settings. Override these with settings in the module pointed to by the DJANGO_SETTINGS_MODULE environment variable. """ +from collections.abc import Sequence # This is defined here as a do-nothing function because we can't import # django.utils.translation -- that module depends on the settings. -from typing import Any, Dict, List, Pattern, Protocol, Sequence, Tuple +from typing import Any, Pattern, Protocol from typing_extensions import Literal @@ -21,16 +22,16 @@ DEBUG_PROPAGATE_EXCEPTIONS: bool # People who get code error notifications. # In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')] -ADMINS: List[Tuple[str, str]] +ADMINS: list[tuple[str, str]] # List of IP addresses, as strings, that: # * See debug comments, when DEBUG is true # * Receive x-headers -INTERNAL_IPS: List[str] +INTERNAL_IPS: list[str] # Hosts/domain names that are valid for this site. # "*" matches anything, ".example.com" matches example.com and all subdomains -ALLOWED_HOSTS: List[str] +ALLOWED_HOSTS: list[str] # Local time zone for this installation. All choices can be found here: # https://en.wikipedia.org/wiki/List_of_tz_zones_by_name (although not all @@ -46,15 +47,15 @@ USE_TZ: bool LANGUAGE_CODE: str # Languages we provide translations for, out of the box. -LANGUAGES: List[Tuple[str, str]] +LANGUAGES: list[tuple[str, str]] # Languages using BiDi (right-to-left) layout -LANGUAGES_BIDI: List[str] +LANGUAGES_BIDI: list[str] # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N: bool -LOCALE_PATHS: List[str] +LOCALE_PATHS: list[str] # Settings for language cookie LANGUAGE_COOKIE_NAME: str @@ -81,13 +82,13 @@ DEFAULT_CHARSET: str SERVER_EMAIL: str # Database connection info. If left empty, will default to the dummy backend. -DATABASES: Dict[str, Dict[str, Any]] +DATABASES: dict[str, dict[str, Any]] # Classes used to implement DB routing behavior. class Router(Protocol): def allow_migrate(self, db: str, app_label: str, **hints: Any) -> bool | None: ... -DATABASE_ROUTERS: List[str | Router] +DATABASE_ROUTERS: list[str | Router] # The email backend to use. For possible shortcuts see django.core.mail. # The default is to use the SMTP backend. @@ -114,9 +115,9 @@ EMAIL_SSL_KEYFILE: str | None EMAIL_TIMEOUT: int | None # List of strings representing installed apps. -INSTALLED_APPS: List[str] +INSTALLED_APPS: list[str] -TEMPLATES: List[Dict[str, Any]] +TEMPLATES: list[dict[str, Any]] # Default form rendering class. FORM_RENDERER: str @@ -148,9 +149,9 @@ FORCE_SCRIPT_NAME: str | None # re.compile(r'^SiteSucker.*'), # re.compile(r'^sohu-search'), # ] -DISALLOWED_USER_AGENTS: List[Pattern[str]] +DISALLOWED_USER_AGENTS: list[Pattern[str]] -ABSOLUTE_URL_OVERRIDES: Dict[str, Any] +ABSOLUTE_URL_OVERRIDES: dict[str, Any] # List of compiled regular expression objects representing URLs that need not # be reported by BrokenLinkEmailsMiddleware. Here are a few examples: @@ -162,7 +163,7 @@ ABSOLUTE_URL_OVERRIDES: Dict[str, Any] # re.compile(r'^/phpmyadmin/'), # re.compile(r'\.(cgi|php|pl)$'), # ] -IGNORABLE_404_URLS: List[Pattern[str]] +IGNORABLE_404_URLS: list[Pattern[str]] # A secret key for this particular Django installation. Used in secret-key # hashing algorithms. Set this in your settings, or Django will complain @@ -189,7 +190,7 @@ STATIC_ROOT: str | None STATIC_URL: str | None # List of upload handler classes to be applied in order. -FILE_UPLOAD_HANDLERS: List[str] +FILE_UPLOAD_HANDLERS: list[str] # Maximum size, in bytes, of a request before it will be streamed to the # file system instead of into memory. @@ -258,20 +259,20 @@ SHORT_DATETIME_FORMAT: str # See all available format string here: # https://docs.python.org/library/datetime.html#strftime-behavior # * Note that these format strings are different from the ones to display dates -DATE_INPUT_FORMATS: List[str] +DATE_INPUT_FORMATS: list[str] # Default formats to be used when parsing times from input boxes, in order # See all available format string here: # https://docs.python.org/library/datetime.html#strftime-behavior # * Note that these format strings are different from the ones to display dates -TIME_INPUT_FORMATS: List[str] # '14:30:59' # '14:30:59.000200' # '14:30' +TIME_INPUT_FORMATS: list[str] # '14:30:59' # '14:30:59.000200' # '14:30' # Default formats to be used when parsing dates and times from input boxes, # in order # See all available format string here: # https://docs.python.org/library/datetime.html#strftime-behavior # * Note that these format strings are different from the ones to display dates -DATETIME_INPUT_FORMATS: List[str] +DATETIME_INPUT_FORMATS: list[str] # First day of week, to be used on calendars # 0 means Sunday, 1 means Monday... @@ -314,7 +315,7 @@ WSGI_APPLICATION: str | None # that header/value, request.is_secure() will return True. # WARNING! Only set this if you fully understand what you're doing. Otherwise, # you may be opening yourself up to a security risk. -SECURE_PROXY_SSL_HEADER: Tuple[str, str] | None +SECURE_PROXY_SSL_HEADER: tuple[str, str] | None ############## # MIDDLEWARE # @@ -323,7 +324,7 @@ SECURE_PROXY_SSL_HEADER: Tuple[str, str] | None # List of middleware to use. Order is important; in the request phase, these # middleware will be applied in the order given, and in the response # phase the middleware will be applied in reverse order. -MIDDLEWARE: List[str] +MIDDLEWARE: list[str] ############ # SESSIONS # @@ -363,7 +364,7 @@ SESSION_SERIALIZER: str ######### # The cache backends to use. -CACHES: Dict[str, Dict[str, Any]] +CACHES: dict[str, dict[str, Any]] CACHE_MIDDLEWARE_KEY_PREFIX: str CACHE_MIDDLEWARE_SECONDS: int CACHE_MIDDLEWARE_ALIAS: str @@ -388,9 +389,9 @@ PASSWORD_RESET_TIMEOUT_DAYS: int # the first hasher in this list is the preferred algorithm. any # password using different algorithms will be converted automatically # upon login -PASSWORD_HASHERS: List[str] +PASSWORD_HASHERS: list[str] -AUTH_PASSWORD_VALIDATORS: List[Dict[str, str]] +AUTH_PASSWORD_VALIDATORS: list[dict[str, str]] ########### # SIGNING # @@ -415,7 +416,7 @@ CSRF_COOKIE_SECURE: bool CSRF_COOKIE_HTTPONLY: bool CSRF_COOKIE_SAMESITE: Literal["Lax", "Strict", "None", False] CSRF_HEADER_NAME: str -CSRF_TRUSTED_ORIGINS: List[str] +CSRF_TRUSTED_ORIGINS: list[str] CSRF_USE_SESSIONS: bool ############ @@ -436,7 +437,7 @@ MESSAGE_STORAGE: str LOGGING_CONFIG: str # Custom logging configuration. -LOGGING: Dict[str, Any] +LOGGING: dict[str, Any] # Default exception reporter filter class used in case none has been # specifically assigned to the HttpRequest instance. @@ -451,35 +452,35 @@ TEST_RUNNER: str # Apps that don't need to be serialized at test database creation time # (only apps with migrations are to start with) -TEST_NON_SERIALIZED_APPS: List[str] +TEST_NON_SERIALIZED_APPS: list[str] ############ # FIXTURES # ############ # The list of directories to search for fixtures -FIXTURE_DIRS: List[str] +FIXTURE_DIRS: list[str] ############### # STATICFILES # ############### # A list of locations of additional static files -STATICFILES_DIRS: List[str] +STATICFILES_DIRS: list[str] # The default file storage backend used during the build process STATICFILES_STORAGE: str # List of finder classes that know how to find static files in # various locations. -STATICFILES_FINDERS: List[str] +STATICFILES_FINDERS: list[str] ############## # MIGRATIONS # ############## # Migration module overrides for apps, by app label. -MIGRATION_MODULES: Dict[str, str] +MIGRATION_MODULES: dict[str, str] ################# # SYSTEM CHECKS # @@ -489,7 +490,7 @@ MIGRATION_MODULES: Dict[str, str] # issues like warnings, infos or debugs will not generate a message. Silencing # serious issues like errors and criticals does not result in hiding the # message, but Django will not stop you from e.g. running server. -SILENCED_SYSTEM_CHECKS: List[str] +SILENCED_SYSTEM_CHECKS: list[str] ####################### # SECURITY MIDDLEWARE # @@ -499,6 +500,6 @@ SECURE_CONTENT_TYPE_NOSNIFF: bool SECURE_HSTS_INCLUDE_SUBDOMAINS: bool SECURE_HSTS_PRELOAD: bool SECURE_HSTS_SECONDS: int -SECURE_REDIRECT_EXEMPT: List[str] +SECURE_REDIRECT_EXEMPT: list[str] SECURE_SSL_HOST: str | None SECURE_SSL_REDIRECT: bool diff --git a/django-stubs/conf/locale/__init__.pyi b/django-stubs/conf/locale/__init__.pyi index c5ecead17..285cc8198 100644 --- a/django-stubs/conf/locale/__init__.pyi +++ b/django-stubs/conf/locale/__init__.pyi @@ -1,3 +1,3 @@ -from typing import Any, Dict +from typing import Any -LANG_INFO: Dict[str, Any] +LANG_INFO: dict[str, Any] diff --git a/django-stubs/conf/urls/__init__.pyi b/django-stubs/conf/urls/__init__.pyi index f8197f8a6..bc830bd1c 100644 --- a/django-stubs/conf/urls/__init__.pyi +++ b/django-stubs/conf/urls/__init__.pyi @@ -1,5 +1,6 @@ # Stubs for django.conf.urls (Python 3.5) -from typing import Any, Callable, Dict, Sequence, Tuple, overload +from collections.abc import Callable, Sequence +from typing import Any, overload from django.http.response import HttpResponse, HttpResponseBase from django.urls import URLPattern, URLResolver @@ -10,21 +11,21 @@ handler403: str | Callable[..., HttpResponse] handler404: str | Callable[..., HttpResponse] handler500: str | Callable[..., HttpResponse] -IncludedURLConf = Tuple[Sequence[URLResolver | URLPattern], str | None, str | None] +IncludedURLConf = tuple[Sequence[URLResolver | URLPattern], str | None, str | None] # Deprecated @overload def url( - regex: str, view: Callable[..., HttpResponseBase], kwargs: Dict[str, Any] | None = ..., name: str | None = ... + regex: str, view: Callable[..., HttpResponseBase], kwargs: dict[str, Any] | None = ..., name: str | None = ... ) -> URLPattern: ... @overload def url( - regex: str, view: IncludedURLConf, kwargs: Dict[str, Any] | None = ..., name: str | None = ... + regex: str, view: IncludedURLConf, kwargs: dict[str, Any] | None = ..., name: str | None = ... ) -> URLResolver: ... @overload def url( regex: str, view: Sequence[URLResolver | str], - kwargs: Dict[str, Any] | None = ..., + kwargs: dict[str, Any] | None = ..., name: str | None = ..., ) -> URLResolver: ... diff --git a/django-stubs/conf/urls/i18n.pyi b/django-stubs/conf/urls/i18n.pyi index 9e7681e4a..5e7b3b619 100644 --- a/django-stubs/conf/urls/i18n.pyi +++ b/django-stubs/conf/urls/i18n.pyi @@ -1,8 +1,6 @@ -from typing import List, Tuple - from django.urls import _AnyURL -def i18n_patterns(*urls: _AnyURL, prefix_default_language: bool = ...) -> List[_AnyURL]: ... -def is_language_prefix_patterns_used(urlconf: str) -> Tuple[bool, bool]: ... +def i18n_patterns(*urls: _AnyURL, prefix_default_language: bool = ...) -> list[_AnyURL]: ... +def is_language_prefix_patterns_used(urlconf: str) -> tuple[bool, bool]: ... -urlpatterns: List[_AnyURL] +urlpatterns: list[_AnyURL] diff --git a/django-stubs/conf/urls/static.pyi b/django-stubs/conf/urls/static.pyi index bcad0db70..f658cace7 100644 --- a/django-stubs/conf/urls/static.pyi +++ b/django-stubs/conf/urls/static.pyi @@ -1,5 +1,6 @@ -from typing import Any, Callable, List +from collections.abc import Callable +from typing import Any from django.urls.resolvers import URLPattern -def static(prefix: str, view: Callable = ..., **kwargs: Any) -> List[URLPattern]: ... +def static(prefix: str, view: Callable = ..., **kwargs: Any) -> list[URLPattern]: ... diff --git a/django-stubs/contrib/admin/checks.pyi b/django-stubs/contrib/admin/checks.pyi index 2500aa411..ecef0ea7f 100644 --- a/django-stubs/contrib/admin/checks.pyi +++ b/django-stubs/contrib/admin/checks.pyi @@ -1,21 +1,22 @@ -from typing import Any, List, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.contrib.admin.options import BaseModelAdmin from django.core.checks.messages import CheckMessage, Error -def check_admin_app(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> List[CheckMessage]: ... -def check_dependencies(**kwargs: Any) -> List[CheckMessage]: ... +def check_admin_app(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> list[CheckMessage]: ... +def check_dependencies(**kwargs: Any) -> list[CheckMessage]: ... class BaseModelAdminChecks: - def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[CheckMessage]: ... + def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> list[CheckMessage]: ... class ModelAdminChecks(BaseModelAdminChecks): - def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[CheckMessage]: ... + def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> list[CheckMessage]: ... class InlineModelAdminChecks(BaseModelAdminChecks): - def check(self, inline_obj: BaseModelAdmin, **kwargs: Any) -> List[CheckMessage]: ... # type: ignore + def check(self, inline_obj: BaseModelAdmin, **kwargs: Any) -> list[CheckMessage]: ... # type: ignore -def must_be(type: Any, option: Any, obj: Any, id: Any) -> List[CheckMessage]: ... -def must_inherit_from(parent: Any, option: Any, obj: Any, id: Any) -> List[CheckMessage]: ... -def refer_to_missing_field(field: Any, option: Any, obj: Any, id: Any) -> List[CheckMessage]: ... +def must_be(type: Any, option: Any, obj: Any, id: Any) -> list[CheckMessage]: ... +def must_inherit_from(parent: Any, option: Any, obj: Any, id: Any) -> list[CheckMessage]: ... +def refer_to_missing_field(field: Any, option: Any, obj: Any, id: Any) -> list[CheckMessage]: ... diff --git a/django-stubs/contrib/admin/decorators.pyi b/django-stubs/contrib/admin/decorators.pyi index f01e3bb97..c716728f7 100644 --- a/django-stubs/contrib/admin/decorators.pyi +++ b/django-stubs/contrib/admin/decorators.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Sequence, Type, TypeVar +from collections.abc import Callable, Sequence +from typing import Any, TypeVar from django.contrib.admin import ModelAdmin from django.contrib.admin.sites import AdminSite @@ -23,4 +24,4 @@ def display( description: str | None = ..., empty_value: str | None = ..., ) -> Callable: ... -def register(*models: Type[Model], site: AdminSite | None = ...) -> Callable: ... +def register(*models: type[Model], site: AdminSite | None = ...) -> Callable: ... diff --git a/django-stubs/contrib/admin/filters.pyi b/django-stubs/contrib/admin/filters.pyi index ffe0c0a10..5664c27fd 100644 --- a/django-stubs/contrib/admin/filters.pyi +++ b/django-stubs/contrib/admin/filters.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, List, Tuple, Type +from collections.abc import Callable, Iterable, Iterator +from typing import Any from django.contrib.admin.options import ModelAdmin from django.db.models.base import Model @@ -12,19 +13,19 @@ class ListFilter: template: str used_parameters: Any def __init__( - self, request: HttpRequest, params: Dict[str, str], model: Type[Model], model_admin: ModelAdmin + self, request: HttpRequest, params: dict[str, str], model: type[Model], model_admin: ModelAdmin ) -> None: ... def has_output(self) -> bool: ... - def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... + def choices(self, changelist: Any) -> Iterator[dict[str, Any]]: ... def queryset(self, request: HttpRequest, queryset: QuerySet) -> QuerySet | None: ... - def expected_parameters(self) -> List[str] | None: ... + def expected_parameters(self) -> list[str] | None: ... class SimpleListFilter(ListFilter): parameter_name: str lookup_choices: Any def value(self) -> str | None: ... - def lookups(self, request: HttpRequest, model_admin: ModelAdmin) -> Iterable[Tuple[Any, str]] | None: ... - def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... + def lookups(self, request: HttpRequest, model_admin: ModelAdmin) -> Iterable[tuple[Any, str]] | None: ... + def choices(self, changelist: Any) -> Iterator[dict[str, Any]]: ... class FieldListFilter(ListFilter): field: Field @@ -34,26 +35,26 @@ class FieldListFilter(ListFilter): self, field: Field, request: HttpRequest, - params: Dict[str, str], - model: Type[Model], + params: dict[str, str], + model: type[Model], model_admin: ModelAdmin, field_path: str, ) -> None: ... @classmethod - def register(cls, test: Callable, list_filter_class: Type[FieldListFilter], take_priority: bool = ...) -> None: ... + def register(cls, test: Callable, list_filter_class: type[FieldListFilter], take_priority: bool = ...) -> None: ... @classmethod def create( cls, field: Field, request: HttpRequest, - params: Dict[str, str], - model: Type[Model], + params: dict[str, str], + model: type[Model], model_admin: ModelAdmin, field_path: str, ) -> FieldListFilter: ... class RelatedFieldListFilter(FieldListFilter): - used_parameters: Dict[Any, Any] + used_parameters: dict[Any, Any] lookup_kwarg: str lookup_kwarg_isnull: str lookup_val: Any @@ -66,24 +67,24 @@ class RelatedFieldListFilter(FieldListFilter): def include_empty_choice(self) -> bool: ... def field_choices( self, field: RelatedField, request: HttpRequest, model_admin: ModelAdmin - ) -> List[Tuple[str, str]]: ... - def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... + ) -> list[tuple[str, str]]: ... + def choices(self, changelist: Any) -> Iterator[dict[str, Any]]: ... class BooleanFieldListFilter(FieldListFilter): lookup_kwarg: str lookup_kwarg2: str lookup_val: Any lookup_val2: Any - def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... + def choices(self, changelist: Any) -> Iterator[dict[str, Any]]: ... class ChoicesFieldListFilter(FieldListFilter): title: str - used_parameters: Dict[Any, Any] + used_parameters: dict[Any, Any] lookup_kwarg: str lookup_kwarg_isnull: str lookup_val: Any lookup_val_isnull: Any - def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... + def choices(self, changelist: Any) -> Iterator[dict[str, Any]]: ... class DateFieldListFilter(FieldListFilter): field_generic: Any @@ -92,18 +93,18 @@ class DateFieldListFilter(FieldListFilter): lookup_kwarg_until: Any links: Any lookup_kwarg_isnull: Any - def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... + def choices(self, changelist: Any) -> Iterator[dict[str, Any]]: ... class AllValuesFieldListFilter(FieldListFilter): title: str - used_parameters: Dict[Any, Any] + used_parameters: dict[Any, Any] lookup_kwarg: str lookup_kwarg_isnull: str lookup_val: Any lookup_val_isnull: Any empty_value_display: str lookup_choices: QuerySet - def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... + def choices(self, changelist: Any) -> Iterator[dict[str, Any]]: ... class RelatedOnlyFieldListFilter(RelatedFieldListFilter): lookup_kwarg: str @@ -111,9 +112,9 @@ class RelatedOnlyFieldListFilter(RelatedFieldListFilter): lookup_val: Any lookup_val_isnull: Any title: str - used_parameters: Dict[Any, Any] + used_parameters: dict[Any, Any] class EmptyFieldListFilter(FieldListFilter): lookup_kwarg: str lookup_val: Any - def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ... + def choices(self, changelist: Any) -> Iterator[dict[str, Any]]: ... diff --git a/django-stubs/contrib/admin/helpers.pyi b/django-stubs/contrib/admin/helpers.pyi index 5233dbc2d..e9e916f06 100644 --- a/django-stubs/contrib/admin/helpers.pyi +++ b/django-stubs/contrib/admin/helpers.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, List, Mapping, Sequence, Tuple +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence +from typing import Any from django import forms from django.contrib.admin.options import ModelAdmin @@ -22,18 +23,18 @@ checkbox: Any class _PrepopulatedDict(TypedDict): field: BoundField - dependencies: List[BoundField] + dependencies: list[BoundField] class AdminForm: - prepopulated_fields: List[_PrepopulatedDict] + prepopulated_fields: list[_PrepopulatedDict] model_admin: ModelAdmin | None readonly_fields: Sequence[str] form: ModelForm - fieldsets: List[Tuple[Any, Dict[str, List[str]]]] + fieldsets: list[tuple[Any, dict[str, list[str]]]] def __init__( self, form: ModelForm, - fieldsets: List[Tuple[Any, Dict[str, List[str]]]], + fieldsets: list[tuple[Any, dict[str, list[str]]]], prepopulated_fields: Mapping[str, Iterable[str]], readonly_fields: Sequence[str] | None = ..., model_admin: ModelAdmin | None = ..., @@ -121,7 +122,7 @@ class InlineAdminFormSet: fieldsets: Any model_admin: ModelAdmin | None readonly_fields: Sequence[str] - prepopulated_fields: Dict[str, Any] + prepopulated_fields: dict[str, Any] classes: str has_add_permission: bool has_change_permission: bool @@ -132,7 +133,7 @@ class InlineAdminFormSet: inline: Any, formset: Any, fieldsets: Any, - prepopulated_fields: Dict[str, Any] | None = ..., + prepopulated_fields: dict[str, Any] | None = ..., readonly_fields: Sequence[str] | None = ..., model_admin: ModelAdmin | None = ..., has_add_permission: bool = ..., @@ -141,10 +142,10 @@ class InlineAdminFormSet: has_view_permission: bool = ..., ) -> None: ... def __iter__(self) -> Iterator[InlineAdminForm]: ... - def fields(self) -> Iterator[Dict[str, Dict[str, bool] | bool | Widget | str]]: ... + def fields(self) -> Iterator[dict[str, dict[str, bool] | bool | Widget | str]]: ... def inline_formset_data(self) -> str: ... @property - def forms(self) -> List[BaseForm]: ... + def forms(self) -> list[BaseForm]: ... @property def non_form_errors(self) -> Callable[[], ErrorList]: ... @property diff --git a/django-stubs/contrib/admin/options.pyi b/django-stubs/contrib/admin/options.pyi index 5414ab324..622ffd8ef 100644 --- a/django-stubs/contrib/admin/options.pyi +++ b/django-stubs/contrib/admin/options.pyi @@ -1,20 +1,5 @@ -from typing import ( - Any, - Callable, - Dict, - Generic, - Iterable, - Iterator, - List, - Mapping, - Optional, - Sequence, - Set, - Tuple, - Type, - TypeVar, - Union, -) +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence +from typing import Any, Generic, Optional, TypeVar, Union from django import forms from django.contrib.admin.filters import FieldListFilter, ListFilter @@ -58,7 +43,7 @@ VERTICAL: Literal[2] _Direction = Union[Literal[1], Literal[2]] -def get_content_type_for_model(obj: Type[Model] | Model) -> ContentType: ... +def get_content_type_for_model(obj: type[Model] | Model) -> ContentType: ... def get_ul_class(radio_style: int) -> str: ... class IncorrectLookupParameters(Exception): ... @@ -78,13 +63,13 @@ class _FieldOpts(_OptionalFieldOpts, total=True): # Workaround for mypy issue, a Sequence type should be preferred here. # https://github.com/python/mypy/issues/8921 # _FieldsetSpec = Sequence[Tuple[Optional[str], _FieldOpts]] -_FieldsetSpec = _ListOrTuple[Tuple[Optional[_StrOrPromise], _FieldOpts]] +_FieldsetSpec = _ListOrTuple[tuple[Optional[_StrOrPromise], _FieldOpts]] _ListFilterT = Union[ - Type[ListFilter], + type[ListFilter], Field, str, - Tuple[Union[Field, str], Type[FieldListFilter]], - List[Union[Field, str, Type[FieldListFilter]]], + tuple[Union[Field, str], type[FieldListFilter]], + list[Union[Field, str, type[FieldListFilter]]], ] # Generic type specifically for models, for use in BaseModelAdmin and subclasses @@ -97,23 +82,23 @@ class BaseModelAdmin(Generic[_ModelT]): fields: _FieldGroups | None exclude: Sequence[str] | None fieldsets: Optional[_FieldsetSpec] - form: Type[forms.ModelForm[_ModelT]] + form: type[forms.ModelForm[_ModelT]] filter_vertical: Sequence[str] filter_horizontal: Sequence[str] radio_fields: Mapping[str, _Direction] - prepopulated_fields: Dict[str, Sequence[str]] - formfield_overrides: Mapping[Type[Field], Mapping[str, Any]] + prepopulated_fields: dict[str, Sequence[str]] + formfield_overrides: Mapping[type[Field], Mapping[str, Any]] readonly_fields: Sequence[str] ordering: Sequence[str] | None sortable_by: _ListOrTuple[str] | None view_on_site: bool | Callable[[_ModelT], str] show_full_result_count: bool checks_class: Any - model: Type[_ModelT] + model: type[_ModelT] opts: Options[_ModelT] admin_site: AdminSite def __init__(self) -> None: ... - def check(self, **kwargs: Any) -> List[CheckMessage]: ... + def check(self, **kwargs: Any) -> list[CheckMessage]: ... def formfield_for_dbfield(self, db_field: Field, request: HttpRequest, **kwargs: Any) -> FormField | None: ... def formfield_for_choice_field(self, db_field: Field, request: HttpRequest, **kwargs: Any) -> TypedChoiceField: ... def get_field_queryset(self, db: str | None, db_field: RelatedField, request: HttpRequest) -> QuerySet | None: ... @@ -129,10 +114,10 @@ class BaseModelAdmin(Generic[_ModelT]): def get_exclude(self, request: HttpRequest, obj: _ModelT | None = ...) -> Sequence[str] | None: ... def get_fields(self, request: HttpRequest, obj: _ModelT | None = ...) -> _FieldGroups: ... def get_fieldsets(self, request: HttpRequest, obj: _ModelT | None = ...) -> _FieldsetSpec: ... - def get_inlines(self, request: HttpRequest, obj: _ModelT | None) -> List[Type[InlineModelAdmin]]: ... + def get_inlines(self, request: HttpRequest, obj: _ModelT | None) -> list[type[InlineModelAdmin]]: ... def get_ordering(self, request: HttpRequest) -> Sequence[str]: ... def get_readonly_fields(self, request: HttpRequest, obj: _ModelT | None = ...) -> Sequence[str]: ... - def get_prepopulated_fields(self, request: HttpRequest, obj: _ModelT | None = ...) -> Dict[str, Sequence[str]]: ... + def get_prepopulated_fields(self, request: HttpRequest, obj: _ModelT | None = ...) -> dict[str, Sequence[str]]: ... def get_queryset(self, request: HttpRequest) -> QuerySet[_ModelT]: ... def get_sortable_by(self, request: HttpRequest) -> Sequence[str]: ... def lookup_allowed(self, lookup: str, value: str) -> bool: ... @@ -159,9 +144,9 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): save_as: bool save_as_continue: bool save_on_top: bool - paginator: Type + paginator: type preserve_filters: bool - inlines: Sequence[Type[InlineModelAdmin]] + inlines: Sequence[type[InlineModelAdmin]] add_form_template: _TemplateForResponseT | None change_form_template: _TemplateForResponseT | None change_list_template: _TemplateForResponseT | None @@ -174,27 +159,27 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): actions_on_top: bool actions_on_bottom: bool actions_selection_counter: bool - model: Type[_ModelT] + model: type[_ModelT] opts: Options[_ModelT] admin_site: AdminSite - def __init__(self, model: Type[_ModelT], admin_site: AdminSite) -> None: ... - def get_inline_instances(self, request: HttpRequest, obj: _ModelT | None = ...) -> List[InlineModelAdmin]: ... - def get_urls(self) -> List[URLPattern]: ... + def __init__(self, model: type[_ModelT], admin_site: AdminSite) -> None: ... + def get_inline_instances(self, request: HttpRequest, obj: _ModelT | None = ...) -> list[InlineModelAdmin]: ... + def get_urls(self) -> list[URLPattern]: ... @property - def urls(self) -> List[URLPattern]: ... + def urls(self) -> list[URLPattern]: ... @property def media(self) -> Media: ... - def get_model_perms(self, request: HttpRequest) -> Dict[str, bool]: ... + def get_model_perms(self, request: HttpRequest) -> dict[str, bool]: ... def get_form( self, request: HttpRequest, obj: _ModelT | None = ..., change: bool = ..., **kwargs: Any - ) -> Type[forms.ModelForm[_ModelT]]: ... - def get_changelist(self, request: HttpRequest, **kwargs: Any) -> Type[ChangeList]: ... + ) -> type[forms.ModelForm[_ModelT]]: ... + def get_changelist(self, request: HttpRequest, **kwargs: Any) -> type[ChangeList]: ... def get_changelist_instance(self, request: HttpRequest) -> ChangeList: ... def get_object(self, request: HttpRequest, object_id: str, from_field: str | None = ...) -> _ModelT | None: ... - def get_changelist_form(self, request: HttpRequest, **kwargs: Any) -> Type[ModelForm[_ModelT]]: ... + def get_changelist_form(self, request: HttpRequest, **kwargs: Any) -> type[ModelForm[_ModelT]]: ... def get_changelist_formset( self, request: HttpRequest, **kwargs: Any - ) -> Type[BaseModelFormSet[_ModelT, ModelForm[_ModelT]]]: ... + ) -> type[BaseModelFormSet[_ModelT, ModelForm[_ModelT]]]: ... def get_formsets_with_inlines(self, request: HttpRequest, obj: _ModelT | None = ...) -> Iterator[Any]: ... def get_paginator( self, @@ -208,11 +193,11 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): def log_change(self, request: HttpRequest, object: _ModelT, message: Any) -> LogEntry: ... def log_deletion(self, request: HttpRequest, object: _ModelT, object_repr: str) -> LogEntry: ... def action_checkbox(self, obj: _ModelT) -> SafeString: ... - def get_actions(self, request: HttpRequest) -> Dict[str, Tuple[Callable[..., str], str, str] | None]: ... + def get_actions(self, request: HttpRequest) -> dict[str, tuple[Callable[..., str], str, str] | None]: ... def get_action_choices( - self, request: HttpRequest, default_choices: List[Tuple[str, str]] = ... - ) -> List[Tuple[str, str]]: ... - def get_action(self, action: Callable | str) -> Tuple[Callable[..., str], str, str] | None: ... + self, request: HttpRequest, default_choices: list[tuple[str, str]] = ... + ) -> list[tuple[str, str]]: ... + def get_action(self, action: Callable | str) -> tuple[Callable[..., str], str, str] | None: ... def get_list_display(self, request: HttpRequest) -> _DisplayT: ... def get_list_display_links(self, request: HttpRequest, list_display: _DisplayT) -> _DisplayT: ... def get_list_filter(self, request: HttpRequest) -> Sequence[_ListFilterT]: ... @@ -220,13 +205,13 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): def get_search_fields(self, request: HttpRequest) -> Sequence[str]: ... def get_search_results( self, request: HttpRequest, queryset: QuerySet, search_term: str - ) -> Tuple[QuerySet[_ModelT], bool]: ... + ) -> tuple[QuerySet[_ModelT], bool]: ... def get_preserved_filters(self, request: HttpRequest) -> str: ... - def _get_edited_object_pks(self, request: HttpRequest, prefix: str) -> List[str]: ... + def _get_edited_object_pks(self, request: HttpRequest, prefix: str) -> list[str]: ... def _get_list_editable_queryset(self, request: HttpRequest, prefix: str) -> QuerySet[_ModelT]: ... def construct_change_message( self, request: HttpRequest, form: AdminPasswordChangeForm, formsets: Iterable[BaseFormSet], add: bool = ... - ) -> List[Dict[str, Dict[str, List[str]]]]: ... + ) -> list[dict[str, dict[str, list[str]]]]: ... def message_user( self, request: HttpRequest, @@ -244,7 +229,7 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): def render_change_form( self, request: HttpRequest, - context: Dict[str, Any], + context: dict[str, Any], add: bool = ..., change: bool = ..., form_url: str = ..., @@ -257,42 +242,42 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): # Probably FileResponse cannot come from ModelAdmin views def response_action(self, request: HttpRequest, queryset: QuerySet) -> HttpResponse | None: ... def response_delete(self, request: HttpRequest, obj_display: str, obj_id: int) -> HttpResponse: ... - def render_delete_form(self, request: HttpRequest, context: Dict[str, Any]) -> HttpResponse: ... + def render_delete_form(self, request: HttpRequest, context: dict[str, Any]) -> HttpResponse: ... def get_inline_formsets( - self, request: HttpRequest, formsets: List[Any], inline_instances: List[Any], obj: _ModelT | None = ... - ) -> List[Any]: ... - def get_changeform_initial_data(self, request: HttpRequest) -> Dict[str, str | List[str]]: ... + self, request: HttpRequest, formsets: list[Any], inline_instances: list[Any], obj: _ModelT | None = ... + ) -> list[Any]: ... + def get_changeform_initial_data(self, request: HttpRequest) -> dict[str, str | list[str]]: ... def changeform_view( self, request: HttpRequest, object_id: str | None = ..., form_url: str = ..., - extra_context: Dict[str, Any] | None = ..., + extra_context: dict[str, Any] | None = ..., ) -> HttpResponse: ... def add_view( - self, request: HttpRequest, form_url: str = ..., extra_context: Dict[str, Any] | None = ... + self, request: HttpRequest, form_url: str = ..., extra_context: dict[str, Any] | None = ... ) -> HttpResponse: ... def change_view( - self, request: HttpRequest, object_id: str, form_url: str = ..., extra_context: Dict[str, Any] | None = ... + self, request: HttpRequest, object_id: str, form_url: str = ..., extra_context: dict[str, Any] | None = ... ) -> HttpResponse: ... - def changelist_view(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> HttpResponse: ... + def changelist_view(self, request: HttpRequest, extra_context: dict[str, Any] | None = ...) -> HttpResponse: ... def get_deleted_objects( self, objs: Sequence[_ModelT] | QuerySet[_ModelT], request: HttpRequest - ) -> Tuple[List[Model], Dict[str, int], Set[str], List[str]]: ... + ) -> tuple[list[Model], dict[str, int], set[str], list[str]]: ... def delete_view( - self, request: HttpRequest, object_id: str, extra_context: Dict[str, Any] | None = ... + self, request: HttpRequest, object_id: str, extra_context: dict[str, Any] | None = ... ) -> HttpResponse: ... def history_view( - self, request: HttpRequest, object_id: str, extra_context: Dict[str, Any] | None = ... + self, request: HttpRequest, object_id: str, extra_context: dict[str, Any] | None = ... ) -> HttpResponse: ... _ChildModelT = TypeVar("_ChildModelT", bound=Model) _ParentModelT = TypeVar("_ParentModelT", bound=Model) class InlineModelAdmin(Generic[_ChildModelT, _ParentModelT], BaseModelAdmin[_ChildModelT]): - model: Type[_ChildModelT] + model: type[_ChildModelT] fk_name: str | None - formset: Type[BaseInlineFormSet[_ChildModelT, _ParentModelT, forms.ModelForm[_ChildModelT]]] + formset: type[BaseInlineFormSet[_ChildModelT, _ParentModelT, forms.ModelForm[_ChildModelT]]] extra: int min_num: int | None max_num: int | None @@ -303,10 +288,10 @@ class InlineModelAdmin(Generic[_ChildModelT, _ParentModelT], BaseModelAdmin[_Chi show_change_link: bool classes: Sequence[str] | None admin_site: AdminSite - parent_model: Type[_ParentModelT] + parent_model: type[_ParentModelT] opts: Options[_ChildModelT] has_registered_model: bool - def __init__(self, parent_model: Type[_ParentModelT], admin_site: AdminSite) -> None: ... + def __init__(self, parent_model: type[_ParentModelT], admin_site: AdminSite) -> None: ... @property def media(self) -> Media: ... def get_extra(self, request: HttpRequest, obj: _ParentModelT | None = ..., **kwargs: Any) -> int: ... @@ -314,7 +299,7 @@ class InlineModelAdmin(Generic[_ChildModelT, _ParentModelT], BaseModelAdmin[_Chi def get_max_num(self, request: HttpRequest, obj: _ParentModelT | None = ..., **kwargs: Any) -> int | None: ... def get_formset( self, request: HttpRequest, obj: _ParentModelT | None = ..., **kwargs: Any - ) -> Type[BaseInlineFormSet[_ChildModelT, _ParentModelT, forms.ModelForm[_ChildModelT]]]: ... + ) -> type[BaseInlineFormSet[_ChildModelT, _ParentModelT, forms.ModelForm[_ChildModelT]]]: ... def get_queryset(self, request: HttpRequest) -> QuerySet[_ChildModelT]: ... def has_add_permission(self, request: HttpRequest, obj: _ParentModelT | None) -> bool: ... # type: ignore def has_change_permission(self, request: HttpRequest, obj: _ParentModelT | None = ...) -> bool: ... # type: ignore diff --git a/django-stubs/contrib/admin/sites.pyi b/django-stubs/contrib/admin/sites.pyi index 774a8f137..ae80b4f76 100644 --- a/django-stubs/contrib/admin/sites.pyi +++ b/django-stubs/contrib/admin/sites.pyi @@ -1,5 +1,6 @@ import sys -from typing import Any, Callable, Dict, Iterable, List, Tuple, Type +from collections.abc import Callable, Iterable +from typing import Any from django.apps.config import AppConfig from django.contrib.admin.options import ModelAdmin @@ -32,7 +33,7 @@ class AdminSite: site_header: str index_title: str site_url: str - login_form: Type[AuthenticationForm] | None + login_form: type[AuthenticationForm] | None index_template: str | None app_index_template: str | None login_template: str | None @@ -44,42 +45,42 @@ class AdminSite: empty_value_display: str final_catch_all_view: bool _empty_value_display: str - _registry: Dict[Type[Model], ModelAdmin] - _global_actions: Dict[str, _ActionCallback] - _actions: Dict[str, _ActionCallback] + _registry: dict[type[Model], ModelAdmin] + _global_actions: dict[str, _ActionCallback] + _actions: dict[str, _ActionCallback] def __init__(self, name: str = ...) -> None: ... - def check(self, app_configs: Iterable[AppConfig] | None) -> List[CheckMessage]: ... + def check(self, app_configs: Iterable[AppConfig] | None) -> list[CheckMessage]: ... def register( self, - model_or_iterable: Type[Model] | Iterable[Type[Model]], - admin_class: Type[ModelAdmin] | None = ..., + model_or_iterable: type[Model] | Iterable[type[Model]], + admin_class: type[ModelAdmin] | None = ..., **options: Any ) -> None: ... - def unregister(self, model_or_iterable: Type[Model] | Iterable[Type[Model]]) -> None: ... - def is_registered(self, model: Type[Model]) -> bool: ... + def unregister(self, model_or_iterable: type[Model] | Iterable[type[Model]]) -> None: ... + def is_registered(self, model: type[Model]) -> bool: ... def add_action(self, action: _ActionCallback, name: str | None = ...) -> None: ... def disable_action(self, name: str) -> None: ... def get_action(self, name: str) -> Callable: ... @property - def actions(self) -> Iterable[Tuple[str, _ActionCallback]]: ... + def actions(self) -> Iterable[tuple[str, _ActionCallback]]: ... def has_permission(self, request: HttpRequest) -> bool: ... def admin_view(self, view: Callable, cacheable: bool = ...) -> Callable: ... - def get_urls(self) -> List[URLResolver | URLPattern]: ... + def get_urls(self) -> list[URLResolver | URLPattern]: ... @property - def urls(self) -> Tuple[List[URLResolver | URLPattern], str, str]: ... - def each_context(self, request: HttpRequest) -> Dict[str, Any]: ... - def password_change(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> TemplateResponse: ... + def urls(self) -> tuple[list[URLResolver | URLPattern], str, str]: ... + def each_context(self, request: HttpRequest) -> dict[str, Any]: ... + def password_change(self, request: HttpRequest, extra_context: dict[str, Any] | None = ...) -> TemplateResponse: ... def password_change_done( - self, request: HttpRequest, extra_context: Dict[str, Any] | None = ... + self, request: HttpRequest, extra_context: dict[str, Any] | None = ... ) -> TemplateResponse: ... - def i18n_javascript(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> HttpResponse: ... - def logout(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> TemplateResponse: ... - def login(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> HttpResponse: ... - def _build_app_dict(self, request: HttpRequest, label: _StrOrPromise | None = ...) -> Dict[str, Any]: ... - def get_app_list(self, request: HttpRequest) -> List[Any]: ... - def index(self, request: HttpRequest, extra_context: Dict[str, Any] | None = ...) -> TemplateResponse: ... + def i18n_javascript(self, request: HttpRequest, extra_context: dict[str, Any] | None = ...) -> HttpResponse: ... + def logout(self, request: HttpRequest, extra_context: dict[str, Any] | None = ...) -> TemplateResponse: ... + def login(self, request: HttpRequest, extra_context: dict[str, Any] | None = ...) -> HttpResponse: ... + def _build_app_dict(self, request: HttpRequest, label: _StrOrPromise | None = ...) -> dict[str, Any]: ... + def get_app_list(self, request: HttpRequest) -> list[Any]: ... + def index(self, request: HttpRequest, extra_context: dict[str, Any] | None = ...) -> TemplateResponse: ... def app_index( - self, request: HttpRequest, app_label: str, extra_context: Dict[str, Any] | None = ... + self, request: HttpRequest, app_label: str, extra_context: dict[str, Any] | None = ... ) -> TemplateResponse: ... def autocomplete_view(self, request: HttpRequest) -> HttpResponse: ... def catch_all_view(self, request: HttpRequest, url: str) -> HttpResponse: ... diff --git a/django-stubs/contrib/admin/templatetags/admin_list.pyi b/django-stubs/contrib/admin/templatetags/admin_list.pyi index c689cbce4..d50e5b3bf 100644 --- a/django-stubs/contrib/admin/templatetags/admin_list.pyi +++ b/django-stubs/contrib/admin/templatetags/admin_list.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, Iterator, List +from collections.abc import Iterable, Iterator +from typing import Any from django.contrib.admin.filters import FieldListFilter from django.contrib.admin.templatetags.base import InclusionAdminNode @@ -16,9 +17,9 @@ register: Any DOT: str def paginator_number(cl: ChangeList, i: int) -> SafeString: ... -def pagination(cl: ChangeList) -> Dict[str, Any]: ... +def pagination(cl: ChangeList) -> dict[str, Any]: ... def pagination_tag(parser: Parser, token: Token) -> InclusionAdminNode: ... -def result_headers(cl: ChangeList) -> Iterator[Dict[str, int | str | None]]: ... +def result_headers(cl: ChangeList) -> Iterator[dict[str, int | str | None]]: ... def items_for_result(cl: ChangeList, result: Model, form: ModelForm | None) -> Iterator[SafeString]: ... class ResultList(list): @@ -29,11 +30,11 @@ def results(cl: ChangeList) -> Iterator[ResultList]: ... def result_hidden_fields(cl: ChangeList) -> Iterator[BoundField]: ... def result_list( cl: ChangeList, -) -> Dict[str, List[Dict[str, int | str | None]] | List[ResultList] | List[BoundField] | ChangeList | int]: ... +) -> dict[str, list[dict[str, int | str | None]] | list[ResultList] | list[BoundField] | ChangeList | int]: ... def result_list_tag(parser: Parser, token: Token) -> InclusionAdminNode: ... -def date_hierarchy(cl: ChangeList) -> Dict[str, Any] | None: ... +def date_hierarchy(cl: ChangeList) -> dict[str, Any] | None: ... def date_hierarchy_tag(parser: Parser, token: Token) -> InclusionAdminNode: ... -def search_form(cl: ChangeList) -> Dict[str, bool | ChangeList | str]: ... +def search_form(cl: ChangeList) -> dict[str, bool | ChangeList | str]: ... def search_form_tag(parser: Parser, token: Token) -> InclusionAdminNode: ... def admin_list_filter(cl: ChangeList, spec: FieldListFilter) -> SafeString: ... def admin_actions(context: RequestContext) -> RequestContext: ... diff --git a/django-stubs/contrib/admin/templatetags/admin_urls.pyi b/django-stubs/contrib/admin/templatetags/admin_urls.pyi index ab3081d49..02b0351be 100644 --- a/django-stubs/contrib/admin/templatetags/admin_urls.pyi +++ b/django-stubs/contrib/admin/templatetags/admin_urls.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict +from typing import Any from uuid import UUID from django.db.models.options import Options @@ -10,7 +10,7 @@ register: Any def admin_urlname(value: Options, arg: SafeString) -> str: ... def admin_urlquote(value: int | str | UUID) -> int | str | UUID: ... def add_preserved_filters( - context: Dict[str, Options | str] | RequestContext, + context: dict[str, Options | str] | RequestContext, url: str, popup: bool = ..., to_field: str | None = ..., diff --git a/django-stubs/contrib/admin/templatetags/base.pyi b/django-stubs/contrib/admin/templatetags/base.pyi index e822b28df..d0edf2cfd 100644 --- a/django-stubs/contrib/admin/templatetags/base.pyi +++ b/django-stubs/contrib/admin/templatetags/base.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, List +from collections.abc import Callable +from typing import Any from django.template.base import Parser, Token from django.template.context import Context @@ -6,9 +7,9 @@ from django.template.library import InclusionNode from django.utils.safestring import SafeString class InclusionAdminNode(InclusionNode): - args: List[Any] + args: list[Any] func: Callable - kwargs: Dict[str, Any] + kwargs: dict[str, Any] takes_context: bool template_name: str def __init__( diff --git a/django-stubs/contrib/admin/tests.pyi b/django-stubs/contrib/admin/tests.pyi index 5c7256ad8..3a9a53232 100644 --- a/django-stubs/contrib/admin/tests.pyi +++ b/django-stubs/contrib/admin/tests.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Generator from contextlib import contextmanager -from typing import Any, Callable, Generator +from typing import Any from django.contrib.staticfiles.testing import StaticLiveServerTestCase from django.test.selenium import SeleniumTestCase diff --git a/django-stubs/contrib/admin/utils.pyi b/django-stubs/contrib/admin/utils.pyi index b0e1d766a..a45479e61 100644 --- a/django-stubs/contrib/admin/utils.pyi +++ b/django-stubs/contrib/admin/utils.pyi @@ -1,5 +1,6 @@ import datetime -from typing import Any, Callable, Dict, Iterable, List, Sequence, Set, Tuple, Type, overload +from collections.abc import Callable, Iterable, Sequence +from typing import Any, overload from uuid import UUID from django.contrib.admin.options import BaseModelAdmin @@ -22,17 +23,17 @@ def lookup_needs_distinct(opts: Options, lookup_path: str) -> bool: ... def prepare_lookup_value(key: str, value: datetime.datetime | str) -> bool | datetime.datetime | str: ... def quote(s: int | str | UUID) -> str: ... def unquote(s: str) -> str: ... -def flatten(fields: Any) -> List[Callable | str]: ... -def flatten_fieldsets(fieldsets: Any) -> List[Callable | str]: ... +def flatten(fields: Any) -> list[Callable | str]: ... +def flatten_fieldsets(fieldsets: Any) -> list[Callable | str]: ... def get_deleted_objects( objs: Sequence[Model | None] | QuerySet[Model], request: HttpRequest, admin_site: AdminSite -) -> Tuple[List[Model], Dict[str, int], Set[str], List[str]]: ... +) -> tuple[list[Model], dict[str, int], set[str], list[str]]: ... class NestedObjects(Collector): - data: Dict[str, Any] - dependencies: Dict[Any, Any] - fast_deletes: List[Any] - field_updates: Dict[Any, Any] + data: dict[str, Any] + dependencies: dict[Any, Any] + fast_deletes: list[Any] + field_updates: dict[Any, Any] using: str edges: Any protected: Any @@ -40,45 +41,45 @@ class NestedObjects(Collector): def __init__(self, *args: Any, **kwargs: Any) -> None: ... def add_edge(self, source: Model | None, target: Model) -> None: ... def related_objects( - self, related_model: Type[Model], related_fields: Iterable[Field], objs: _IndexableCollection[Model] + self, related_model: type[Model], related_fields: Iterable[Field], objs: _IndexableCollection[Model] ) -> QuerySet[Model]: ... - def nested(self, format_callback: Callable = ...) -> List[Any]: ... + def nested(self, format_callback: Callable = ...) -> list[Any]: ... def can_fast_delete(self, *args: Any, **kwargs: Any) -> bool: ... class _ModelFormatDict(TypedDict): verbose_name: str verbose_name_plural: str -def model_format_dict(obj: Model | Type[Model] | QuerySet | Options[Model]) -> _ModelFormatDict: ... +def model_format_dict(obj: Model | type[Model] | QuerySet | Options[Model]) -> _ModelFormatDict: ... def model_ngettext(obj: Options | QuerySet, n: int | None = ...) -> str: ... def lookup_field( name: Callable | str, obj: Model, model_admin: BaseModelAdmin | None = ... -) -> Tuple[Field | None, str | None, Any]: ... +) -> tuple[Field | None, str | None, Any]: ... @overload def label_for_field( # type: ignore name: Callable | str, - model: Type[Model], + model: type[Model], model_admin: BaseModelAdmin | None = ..., return_attr: Literal[True] = ..., form: BaseForm | None = ..., -) -> Tuple[str, Callable | str | None]: ... +) -> tuple[str, Callable | str | None]: ... @overload def label_for_field( name: Callable | str, - model: Type[Model], + model: type[Model], model_admin: BaseModelAdmin | None = ..., return_attr: Literal[False] = ..., form: BaseForm | None = ..., ) -> str: ... -def help_text_for_field(name: str, model: Type[Model]) -> str: ... +def help_text_for_field(name: str, model: type[Model]) -> str: ... def display_for_field(value: Any, field: Field, empty_value_display: str) -> str: ... def display_for_value(value: Any, empty_value_display: str, boolean: bool = ...) -> str: ... class NotRelationField(Exception): ... -def get_model_from_relation(field: Field | reverse_related.ForeignObjectRel) -> Type[Model]: ... -def reverse_field_path(model: Type[Model], path: str) -> Tuple[Type[Model], str]: ... -def get_fields_from_path(model: Type[Model], path: str) -> List[Field]: ... +def get_model_from_relation(field: Field | reverse_related.ForeignObjectRel) -> type[Model]: ... +def reverse_field_path(model: type[Model], path: str) -> tuple[type[Model], str]: ... +def get_fields_from_path(model: type[Model], path: str) -> list[Field]: ... def construct_change_message( form: AdminPasswordChangeForm, formsets: Iterable[BaseFormSet], add: bool -) -> List[Dict[str, Dict[str, List[str]]]]: ... +) -> list[dict[str, dict[str, list[str]]]]: ... diff --git a/django-stubs/contrib/admin/views/decorators.pyi b/django-stubs/contrib/admin/views/decorators.pyi index 95eb3e352..6a6a6c23a 100644 --- a/django-stubs/contrib/admin/views/decorators.pyi +++ b/django-stubs/contrib/admin/views/decorators.pyi @@ -1,4 +1,5 @@ -from typing import Callable, TypeVar, overload +from collections.abc import Callable +from typing import TypeVar, overload _C = TypeVar("_C", bound=Callable) diff --git a/django-stubs/contrib/admin/views/main.pyi b/django-stubs/contrib/admin/views/main.pyi index 003bffe44..231788ddf 100644 --- a/django-stubs/contrib/admin/views/main.pyi +++ b/django-stubs/contrib/admin/views/main.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, Iterable, List, Sequence, Tuple, Type +from collections.abc import Callable, Iterable, Sequence +from typing import Any from django.contrib.admin.filters import ListFilter from django.contrib.admin.options import IS_POPUP_VAR as IS_POPUP_VAR # noqa: F401 @@ -18,10 +19,10 @@ ORDER_TYPE_VAR: str PAGE_VAR: str SEARCH_VAR: str ERROR_FLAG: str -IGNORED_PARAMS: Tuple[str, ...] +IGNORED_PARAMS: tuple[str, ...] class ChangeList: - model: Type[Model] + model: type[Model] opts: Options lookup_opts: Options root_queryset: QuerySet @@ -40,7 +41,7 @@ class ChangeList: show_all: bool is_popup: bool to_field: Any - params: Dict[str, Any] + params: dict[str, Any] list_editable: Sequence[str] query: str queryset: Any @@ -50,7 +51,7 @@ class ChangeList: def __init__( self, request: HttpRequest, - model: Type[Model], + model: type[Model], list_display: _DisplayT, list_display_links: _DisplayT, list_filter: Sequence[_ListFilterT], @@ -63,9 +64,9 @@ class ChangeList: model_admin: ModelAdmin, sortable_by: Sequence[str] | None, ) -> None: ... - def get_filters_params(self, params: Dict[str, Any] | None = ...) -> Dict[str, Any]: ... - def get_filters(self, request: HttpRequest) -> Tuple[List[ListFilter], bool, Dict[str, bool | str], bool, bool]: ... - def get_query_string(self, new_params: Dict[str, Any] | None = ..., remove: Iterable[str] | None = ...) -> str: ... + def get_filters_params(self, params: dict[str, Any] | None = ...) -> dict[str, Any]: ... + def get_filters(self, request: HttpRequest) -> tuple[list[ListFilter], bool, dict[str, bool | str], bool, bool]: ... + def get_query_string(self, new_params: dict[str, Any] | None = ..., remove: Iterable[str] | None = ...) -> str: ... result_count: int show_full_result_count: bool show_admin_actions: bool @@ -76,10 +77,10 @@ class ChangeList: paginator: Any def get_results(self, request: HttpRequest) -> None: ... def get_ordering_field(self, field_name: Callable | str) -> Expression | str | None: ... - def get_ordering(self, request: HttpRequest, queryset: QuerySet) -> List[Expression | str]: ... - def get_ordering_field_columns(self) -> Dict[int, Literal["desc", "asc"]]: ... + def get_ordering(self, request: HttpRequest, queryset: QuerySet) -> list[Expression | str]: ... + def get_ordering_field_columns(self) -> dict[int, Literal["desc", "asc"]]: ... def get_queryset(self, request: HttpRequest) -> QuerySet: ... - filter_specs: List[ListFilter] + filter_specs: list[ListFilter] has_filters: bool has_active_filters: bool clear_all_filters_qs: str diff --git a/django-stubs/contrib/admin/widgets.pyi b/django-stubs/contrib/admin/widgets.pyi index 41f048ca0..901d833d8 100644 --- a/django-stubs/contrib/admin/widgets.pyi +++ b/django-stubs/contrib/admin/widgets.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, List, Mapping, Sequence, Tuple +from collections.abc import Iterable, Mapping, Sequence +from typing import Any from django import forms from django.contrib.admin.sites import AdminSite @@ -29,12 +30,12 @@ class AdminTimeWidget(forms.TimeInput): class AdminSplitDateTime(forms.SplitDateTimeWidget): template_name: str def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... class AdminRadioSelect(forms.RadioSelect): ... class AdminFileWidget(forms.ClearableFileInput): ... -def url_params_from_lookup_dict(lookups: Any) -> Dict[str, str]: ... +def url_params_from_lookup_dict(lookups: Any) -> dict[str, str]: ... class ForeignKeyRawIdWidget(forms.TextInput): rel: ManyToOneRel @@ -43,16 +44,16 @@ class ForeignKeyRawIdWidget(forms.TextInput): def __init__( self, rel: ManyToOneRel, admin_site: AdminSite, attrs: _OptAttrs | None = ..., using: str | None = ... ) -> None: ... - def base_url_parameters(self) -> Dict[str, str]: ... - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... - def url_parameters(self) -> Dict[str, str]: ... - def label_and_url_for_value(self, value: Any) -> Tuple[str, str]: ... + def base_url_parameters(self) -> dict[str, str]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... + def url_parameters(self) -> dict[str, str]: ... + def label_and_url_for_value(self, value: Any) -> tuple[str, str]: ... class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): rel: ManyToManyRel # type: ignore - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... - def url_parameters(self) -> Dict[str, str]: ... - def label_and_url_for_value(self, value: Any) -> Tuple[str, str]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... + def url_parameters(self) -> dict[str, str]: ... + def label_and_url_for_value(self, value: Any) -> tuple[str, str]: ... def format_value(self, value: Any) -> str | None: ... def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Iterable[File]], name: str) -> Any: ... @@ -80,8 +81,8 @@ class RelatedFieldWidgetWrapper(forms.Widget): def media(self) -> Media: ... # type: ignore @property def is_hidden(self) -> bool: ... - def get_related_url(self, info: Tuple[str, str], action: str, *args: Any) -> str: ... - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... + def get_related_url(self, info: tuple[str, str], action: str, *args: Any) -> str: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Iterable[File]], name: str) -> Any: ... def value_omitted_from_data( self, data: Mapping[str, Any], files: Mapping[str, Iterable[File]], name: str @@ -100,7 +101,7 @@ class AdminEmailInputWidget(forms.EmailInput): class AdminURLFieldWidget(forms.URLInput): template_name: str def __init__(self, attrs: _OptAttrs | None = ..., validator_class: Any = ...) -> None: ... - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... class AdminIntegerFieldWidget(forms.NumberInput): def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... @@ -112,7 +113,7 @@ class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): class AdminUUIDInputWidget(forms.TextInput): def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... -SELECT2_TRANSLATIONS: Dict[str, str] +SELECT2_TRANSLATIONS: dict[str, str] class AutocompleteMixin: url_name: str @@ -132,11 +133,11 @@ class AutocompleteMixin: def get_url(self) -> str: ... @property def media(self) -> Media: ... - def build_attrs(self, base_attrs: _OptAttrs, extra_attrs: _OptAttrs | None = ...) -> Dict[str, Any]: ... + def build_attrs(self, base_attrs: _OptAttrs, extra_attrs: _OptAttrs | None = ...) -> dict[str, Any]: ... # typo in source: `attr` instead of `attrs` def optgroups( self, name: str, value: Sequence[str], attr: _OptAttrs | None = ... - ) -> List[Tuple[str | None, List[Dict[str, Any]], int | None]]: ... + ) -> list[tuple[str | None, list[dict[str, Any]], int | None]]: ... class AutocompleteSelect(AutocompleteMixin, forms.Select): ... # type: ignore class AutocompleteSelectMultiple(AutocompleteMixin, forms.SelectMultiple): ... # type: ignore diff --git a/django-stubs/contrib/admindocs/middleware.pyi b/django-stubs/contrib/admindocs/middleware.pyi index 117e564ca..d065145d7 100644 --- a/django-stubs/contrib/admindocs/middleware.pyi +++ b/django-stubs/contrib/admindocs/middleware.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, Tuple +from collections.abc import Callable +from typing import Any from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponseBase @@ -9,6 +10,6 @@ class XViewMiddleware(MiddlewareMixin): self, request: HttpRequest, view_func: Callable[..., HttpResponseBase], - view_args: Tuple, - view_kwargs: Dict[Any, Any], + view_args: tuple, + view_kwargs: dict[Any, Any], ) -> HttpResponse | None: ... diff --git a/django-stubs/contrib/admindocs/urls.pyi b/django-stubs/contrib/admindocs/urls.pyi index 14e91f5b3..df4275ee2 100644 --- a/django-stubs/contrib/admindocs/urls.pyi +++ b/django-stubs/contrib/admindocs/urls.pyi @@ -1,5 +1,3 @@ -from typing import List - from django.urls import _AnyURL -urlpatterns: List[_AnyURL] +urlpatterns: list[_AnyURL] diff --git a/django-stubs/contrib/admindocs/utils.pyi b/django-stubs/contrib/admindocs/utils.pyi index 055be3fcc..9c7f5d2fb 100644 --- a/django-stubs/contrib/admindocs/utils.pyi +++ b/django-stubs/contrib/admindocs/utils.pyi @@ -1,14 +1,15 @@ -from typing import Any, Callable, Dict, List, Tuple +from collections.abc import Callable +from typing import Any from django.utils.safestring import SafeString docutils_is_available: bool def get_view_name(view_func: Callable) -> str: ... -def parse_docstring(docstring: str) -> Tuple[str, str, Dict[str, str]]: ... +def parse_docstring(docstring: str) -> tuple[str, str, dict[str, str]]: ... def parse_rst(text: str, default_reference_context: Any, thing_being_parsed: Any | None = ...) -> SafeString: ... -ROLES: Dict[str, str] +ROLES: dict[str, str] def create_reference_role(rolename: str, urlbase: str) -> None: ... def default_reference_role( @@ -19,7 +20,7 @@ def default_reference_role( inliner: Any, options: Any | None = ..., content: Any | None = ..., -) -> Tuple[List[Any], List[Any]]: ... +) -> tuple[list[Any], list[Any]]: ... named_group_matcher: Any unnamed_group_matcher: Any diff --git a/django-stubs/contrib/admindocs/views.pyi b/django-stubs/contrib/admindocs/views.pyi index cf03083ae..68051690e 100644 --- a/django-stubs/contrib/admindocs/views.pyi +++ b/django-stubs/contrib/admindocs/views.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Iterable, List, Pattern, Tuple +from collections.abc import Callable, Iterable +from typing import Any, Pattern from django.db.models.fields import Field from django.urls import _AnyURL @@ -20,5 +21,5 @@ def get_return_data_type(func_name: Any) -> str: ... def get_readable_field_data_type(field: Field | str) -> str: ... def extract_views_from_urlpatterns( urlpatterns: Iterable[_AnyURL], base: str = ..., namespace: str | None = ... -) -> List[Tuple[Callable, Pattern[str], str | None, str | None]]: ... +) -> list[tuple[Callable, Pattern[str], str | None, str | None]]: ... def simplify_regex(pattern: str) -> str: ... diff --git a/django-stubs/contrib/auth/__init__.pyi b/django-stubs/contrib/auth/__init__.pyi index 27a4e6915..0d24bb9b0 100644 --- a/django-stubs/contrib/auth/__init__.pyi +++ b/django-stubs/contrib/auth/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Type +from typing import Any from django.contrib.auth.backends import ModelBackend from django.contrib.auth.base_user import AbstractBaseUser @@ -17,13 +17,13 @@ HASH_SESSION_KEY: str REDIRECT_FIELD_NAME: str def load_backend(path: str) -> ModelBackend: ... -def get_backends() -> List[ModelBackend]: ... +def get_backends() -> list[ModelBackend]: ... def authenticate(request: HttpRequest | None = ..., **credentials: Any) -> AbstractBaseUser | None: ... def login( - request: HttpRequest, user: AbstractBaseUser | None, backend: Type[ModelBackend] | str | None = ... + request: HttpRequest, user: AbstractBaseUser | None, backend: type[ModelBackend] | str | None = ... ) -> None: ... def logout(request: HttpRequest) -> None: ... -def get_user_model() -> Type[AbstractBaseUser]: ... +def get_user_model() -> type[AbstractBaseUser]: ... def get_user(request: HttpRequest | Client) -> AbstractBaseUser | AnonymousUser: ... def get_permission_codename(action: str, opts: Options) -> str: ... def update_session_auth_hash(request: HttpRequest, user: AbstractBaseUser) -> None: ... diff --git a/django-stubs/contrib/auth/backends.pyi b/django-stubs/contrib/auth/backends.pyi index c306eff61..1a4e9ad68 100644 --- a/django-stubs/contrib/auth/backends.pyi +++ b/django-stubs/contrib/auth/backends.pyi @@ -1,4 +1,4 @@ -from typing import Any, Set, TypeVar +from typing import Any, TypeVar from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import AnonymousUser, Permission @@ -13,9 +13,9 @@ UserModel: Any class BaseBackend: def authenticate(self, request: HttpRequest | None, **kwargs: Any) -> AbstractBaseUser | None: ... def get_user(self, user_id: int) -> AbstractBaseUser | None: ... - def get_user_permissions(self, user_obj: _AnyUser, obj: Model | None = ...) -> Set[str]: ... - def get_group_permissions(self, user_obj: _AnyUser, obj: Model | None = ...) -> Set[str]: ... - def get_all_permissions(self, user_obj: _AnyUser, obj: Model | None = ...) -> Set[str]: ... + def get_user_permissions(self, user_obj: _AnyUser, obj: Model | None = ...) -> set[str]: ... + def get_group_permissions(self, user_obj: _AnyUser, obj: Model | None = ...) -> set[str]: ... + def get_all_permissions(self, user_obj: _AnyUser, obj: Model | None = ...) -> set[str]: ... def has_perm(self, user_obj: _AnyUser, perm: str, obj: Model | None = ...) -> bool: ... class ModelBackend(BaseBackend): diff --git a/django-stubs/contrib/auth/base_user.pyi b/django-stubs/contrib/auth/base_user.pyi index 53b1de2d0..a4c185f24 100644 --- a/django-stubs/contrib/auth/base_user.pyi +++ b/django-stubs/contrib/auth/base_user.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Tuple, TypeVar, overload +from typing import Any, TypeVar, overload from django.db import models from django.db.models.base import Model @@ -15,13 +15,13 @@ class BaseUserManager(models.Manager[_T]): def get_by_natural_key(self, username: str | None) -> _T: ... class AbstractBaseUser(models.Model): - REQUIRED_FIELDS: List[str] + REQUIRED_FIELDS: list[str] password = models.CharField(max_length=128) last_login = models.DateTimeField(blank=True, null=True) is_active: bool | BooleanField[bool | Combinable, bool] def get_username(self) -> str: ... - def natural_key(self) -> Tuple[str]: ... + def natural_key(self) -> tuple[str]: ... @property def is_anonymous(self) -> Literal[False]: ... @property diff --git a/django-stubs/contrib/auth/checks.pyi b/django-stubs/contrib/auth/checks.pyi index fc954593c..fcf0253e6 100644 --- a/django-stubs/contrib/auth/checks.pyi +++ b/django-stubs/contrib/auth/checks.pyi @@ -1,4 +1,5 @@ -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage diff --git a/django-stubs/contrib/auth/context_processors.pyi b/django-stubs/contrib/auth/context_processors.pyi index c9cce2a2b..50a7ef637 100644 --- a/django-stubs/contrib/auth/context_processors.pyi +++ b/django-stubs/contrib/auth/context_processors.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterator +from collections.abc import Iterator +from typing import Any from django.http.request import HttpRequest @@ -17,4 +18,4 @@ class PermWrapper: def __iter__(self) -> Iterator[Any]: ... def __contains__(self, perm_name: Any) -> bool: ... -def auth(request: HttpRequest) -> Dict[str, Any]: ... +def auth(request: HttpRequest) -> dict[str, Any]: ... diff --git a/django-stubs/contrib/auth/decorators.pyi b/django-stubs/contrib/auth/decorators.pyi index 094c7bd32..d4657c302 100644 --- a/django-stubs/contrib/auth/decorators.pyi +++ b/django-stubs/contrib/auth/decorators.pyi @@ -1,4 +1,5 @@ -from typing import Callable, Iterable, TypeVar, overload +from collections.abc import Callable, Iterable +from typing import TypeVar, overload from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME # noqa: F401 from django.contrib.auth.models import AbstractBaseUser, AnonymousUser diff --git a/django-stubs/contrib/auth/forms.pyi b/django-stubs/contrib/auth/forms.pyi index f125f437d..f6f3edfbb 100644 --- a/django-stubs/contrib/auth/forms.pyi +++ b/django-stubs/contrib/auth/forms.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, List, Type, TypeVar +from collections.abc import Iterable +from typing import Any, TypeVar from django import forms from django.contrib.auth.base_user import AbstractBaseUser @@ -10,13 +11,13 @@ from django.forms.fields import _ClassLevelWidgetT from django.forms.widgets import Widget from django.http.request import HttpRequest -UserModel: Type[AbstractBaseUser] +UserModel: type[AbstractBaseUser] _User = TypeVar("_User", bound=AbstractBaseUser) class ReadOnlyPasswordHashWidget(forms.Widget): template_name: str read_only: bool - def get_context(self, name: str, value: Any, attrs: Dict[str, Any] | None) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: dict[str, Any] | None) -> dict[str, Any]: ... class ReadOnlyPasswordHashField(forms.Field): widget: _ClassLevelWidgetT @@ -24,7 +25,7 @@ class ReadOnlyPasswordHashField(forms.Field): class UsernameField(forms.CharField): def to_python(self, value: Any | None) -> Any | None: ... - def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... + def widget_attrs(self, widget: Widget) -> dict[str, Any]: ... class UserCreationForm(forms.ModelForm[_User]): error_messages: _ErrorMessagesT @@ -49,7 +50,7 @@ class AuthenticationForm(forms.Form): def confirm_login_allowed(self, user: AbstractBaseUser) -> None: ... def get_user(self) -> AbstractBaseUser: ... def get_invalid_login_error(self) -> ValidationError: ... - def clean(self) -> Dict[str, Any]: ... + def clean(self) -> dict[str, Any]: ... class PasswordResetForm(forms.Form): email: forms.Field @@ -57,7 +58,7 @@ class PasswordResetForm(forms.Form): self, subject_template_name: str, email_template_name: str, - context: Dict[str, Any], + context: dict[str, Any], from_email: str | None, to_email: str, html_email_template_name: str | None = ..., @@ -73,7 +74,7 @@ class PasswordResetForm(forms.Form): from_email: str | None = ..., request: HttpRequest | None = ..., html_email_template_name: str | None = ..., - extra_email_context: Dict[str, str] | None = ..., + extra_email_context: dict[str, str] | None = ..., ) -> None: ... class SetPasswordForm(forms.Form): @@ -100,4 +101,4 @@ class AdminPasswordChangeForm(forms.Form): def clean_password2(self) -> str: ... def save(self, commit: bool = ...) -> AbstractBaseUser: ... @property - def changed_data(self) -> List[str]: ... + def changed_data(self) -> list[str]: ... diff --git a/django-stubs/contrib/auth/handlers/modwsgi.pyi b/django-stubs/contrib/auth/handlers/modwsgi.pyi index 47be491f7..e9845da56 100644 --- a/django-stubs/contrib/auth/handlers/modwsgi.pyi +++ b/django-stubs/contrib/auth/handlers/modwsgi.pyi @@ -1,6 +1,6 @@ -from typing import Any, Dict +from typing import Any UserModel: Any -def check_password(environ: Dict[Any, Any], username: str, password: str) -> Any: ... -def groups_for_user(environ: Dict[Any, Any], username: str) -> Any: ... +def check_password(environ: dict[Any, Any], username: str, password: str) -> Any: ... +def groups_for_user(environ: dict[Any, Any], username: str) -> Any: ... diff --git a/django-stubs/contrib/auth/hashers.pyi b/django-stubs/contrib/auth/hashers.pyi index b0f31bf21..b1eba698f 100644 --- a/django-stubs/contrib/auth/hashers.pyi +++ b/django-stubs/contrib/auth/hashers.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, List, Tuple +from collections.abc import Callable +from typing import Any UNUSABLE_PASSWORD_PREFIX: str UNUSABLE_PASSWORD_SUFFIX_LENGTH: int @@ -6,8 +7,8 @@ UNUSABLE_PASSWORD_SUFFIX_LENGTH: int def is_password_usable(encoded: str | None) -> bool: ... def check_password(password: str | None, encoded: str, setter: Callable | None = ..., preferred: str = ...) -> bool: ... def make_password(password: str | None, salt: str | None = ..., hasher: str | BasePasswordHasher = ...) -> str: ... -def get_hashers() -> List[BasePasswordHasher]: ... -def get_hashers_by_algorithm() -> Dict[str, BasePasswordHasher]: ... +def get_hashers() -> list[BasePasswordHasher]: ... +def get_hashers_by_algorithm() -> dict[str, BasePasswordHasher]: ... def reset_hashers(**kwargs: Any) -> None: ... def get_hasher(algorithm: str | BasePasswordHasher = ...) -> BasePasswordHasher: ... def identify_hasher(encoded: str) -> BasePasswordHasher: ... @@ -15,7 +16,7 @@ def mask_hash(hash: str, show: int = ..., char: str = ...) -> str: ... class BasePasswordHasher: algorithm: str - library: str | Tuple[str, str] + library: str | tuple[str, str] rounds: int time_cost: int memory_cost: int diff --git a/django-stubs/contrib/auth/mixins.pyi b/django-stubs/contrib/auth/mixins.pyi index 5162dfb3f..d344dfa5c 100644 --- a/django-stubs/contrib/auth/mixins.pyi +++ b/django-stubs/contrib/auth/mixins.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Sequence +from collections.abc import Callable, Sequence +from typing import Any from django import http from django.http.response import HttpResponseBase, HttpResponseRedirect diff --git a/django-stubs/contrib/auth/models.pyi b/django-stubs/contrib/auth/models.pyi index e1c939677..017982390 100644 --- a/django-stubs/contrib/auth/models.pyi +++ b/django-stubs/contrib/auth/models.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, Set, Tuple, Type, TypeVar +from collections.abc import Iterable +from typing import Any, TypeVar from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser from django.contrib.auth.base_user import BaseUserManager as BaseUserManager @@ -12,7 +13,7 @@ from typing_extensions import Literal _AnyUser = Model | "AnonymousUser" -def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ... +def update_last_login(sender: type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ... class PermissionManager(models.Manager["Permission"]): def get_by_natural_key(self, codename: str, app_label: str, model: str) -> Permission: ... @@ -24,7 +25,7 @@ class Permission(models.Model): name = models.CharField(max_length=255) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) codename = models.CharField(max_length=100) - def natural_key(self) -> Tuple[str, str, str]: ... + def natural_key(self) -> tuple[str, str, str]: ... class GroupManager(models.Manager["Group"]): def get_by_natural_key(self, name: str) -> Group: ... @@ -34,7 +35,7 @@ class Group(models.Model): name = models.CharField(max_length=150) permissions = models.ManyToManyField(Permission) - def natural_key(self) -> Tuple[str]: ... + def natural_key(self) -> tuple[str]: ... _T = TypeVar("_T", bound=Model) @@ -58,9 +59,9 @@ class PermissionsMixin(models.Model): is_superuser = models.BooleanField() groups = models.ManyToManyField(Group) user_permissions = models.ManyToManyField(Permission) - def get_user_permissions(self, obj: _AnyUser | None = ...) -> Set[str]: ... - def get_group_permissions(self, obj: _AnyUser | None = ...) -> Set[str]: ... - def get_all_permissions(self, obj: _AnyUser | None = ...) -> Set[str]: ... + def get_user_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ... + def get_group_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ... + def get_all_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ... def has_perm(self, perm: str, obj: _AnyUser | None = ...) -> bool: ... def has_perms(self, perm_list: Iterable[str], obj: _AnyUser | None = ...) -> bool: ... def has_module_perms(self, app_label: str) -> bool: ... @@ -99,9 +100,9 @@ class AnonymousUser: def groups(self) -> EmptyManager[Group]: ... @property def user_permissions(self) -> EmptyManager[Permission]: ... - def get_user_permissions(self, obj: _AnyUser | None = ...) -> Set[str]: ... - def get_group_permissions(self, obj: _AnyUser | None = ...) -> Set[Any]: ... - def get_all_permissions(self, obj: _AnyUser | None = ...) -> Set[str]: ... + def get_user_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ... + def get_group_permissions(self, obj: _AnyUser | None = ...) -> set[Any]: ... + def get_all_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ... def has_perm(self, perm: str, obj: _AnyUser | None = ...) -> bool: ... def has_perms(self, perm_list: Iterable[str], obj: _AnyUser | None = ...) -> bool: ... def has_module_perms(self, module: str) -> bool: ... diff --git a/django-stubs/contrib/auth/password_validation.pyi b/django-stubs/contrib/auth/password_validation.pyi index a6b68a987..b9a124244 100644 --- a/django-stubs/contrib/auth/password_validation.pyi +++ b/django-stubs/contrib/auth/password_validation.pyi @@ -1,5 +1,6 @@ +from collections.abc import Mapping, Sequence from pathlib import Path, PosixPath -from typing import Any, List, Mapping, Protocol, Sequence, Set +from typing import Any, Protocol from django.db.models.base import Model @@ -9,15 +10,15 @@ class PasswordValidator(Protocol): def validate(self, __password: str, __user: _UserModel | None = ...) -> None: ... def get_help_text(self) -> str: ... -def get_default_password_validators() -> List[PasswordValidator]: ... -def get_password_validators(validator_config: Sequence[Mapping[str, Any]]) -> List[PasswordValidator]: ... +def get_default_password_validators() -> list[PasswordValidator]: ... +def get_password_validators(validator_config: Sequence[Mapping[str, Any]]) -> list[PasswordValidator]: ... def validate_password( password: str, user: _UserModel | None = ..., password_validators: Sequence[PasswordValidator] | None = ... ) -> None: ... def password_changed( password: str, user: _UserModel | None = ..., password_validators: Sequence[PasswordValidator] | None = ... ) -> None: ... -def password_validators_help_texts(password_validators: Sequence[PasswordValidator] | None = ...) -> List[str]: ... +def password_validators_help_texts(password_validators: Sequence[PasswordValidator] | None = ...) -> list[str]: ... password_validators_help_text_html: Any @@ -37,7 +38,7 @@ class UserAttributeSimilarityValidator: class CommonPasswordValidator: DEFAULT_PASSWORD_LIST_PATH: Path - passwords: Set[str] + passwords: set[str] def __init__(self, password_list_path: Path | PosixPath | str = ...) -> None: ... def validate(self, password: str, user: _UserModel | None = ...) -> None: ... def get_help_text(self) -> str: ... diff --git a/django-stubs/contrib/auth/urls.pyi b/django-stubs/contrib/auth/urls.pyi index 14e91f5b3..df4275ee2 100644 --- a/django-stubs/contrib/auth/urls.pyi +++ b/django-stubs/contrib/auth/urls.pyi @@ -1,5 +1,3 @@ -from typing import List - from django.urls import _AnyURL -urlpatterns: List[_AnyURL] +urlpatterns: list[_AnyURL] diff --git a/django-stubs/contrib/auth/views.pyi b/django-stubs/contrib/auth/views.pyi index 2048d0ebc..b669fcf13 100644 --- a/django-stubs/contrib/auth/views.pyi +++ b/django-stubs/contrib/auth/views.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Set +from typing import Any from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.forms import AuthenticationForm @@ -11,7 +11,7 @@ UserModel: Any class SuccessURLAllowedHostsMixin: success_url_allowed_hosts: Any - def get_success_url_allowed_hosts(self) -> Set[str]: ... + def get_success_url_allowed_hosts(self) -> set[str]: ... class LoginView(SuccessURLAllowedHostsMixin, FormView[AuthenticationForm]): authentication_form: Any @@ -35,7 +35,7 @@ def redirect_to_login( class PasswordContextMixin: extra_context: Any - def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... + def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ... class PasswordResetView(PasswordContextMixin, FormView): email_template_name: str diff --git a/django-stubs/contrib/contenttypes/admin.pyi b/django-stubs/contrib/contenttypes/admin.pyi index fafbfff71..d19318806 100644 --- a/django-stubs/contrib/contenttypes/admin.pyi +++ b/django-stubs/contrib/contenttypes/admin.pyi @@ -1,12 +1,12 @@ -from typing import Any, List, Type +from typing import Any from django.contrib.admin.checks import InlineModelAdminChecks from django.contrib.admin.options import InlineModelAdmin from django.db.models.base import Model class GenericInlineModelAdminChecks(InlineModelAdminChecks): - def _check_exclude_of_parent_model(self, obj: GenericInlineModelAdmin, parent_model: Type[Model]) -> List[Any]: ... - def _check_relation(self, obj: GenericInlineModelAdmin, parent_model: Type[Model]) -> List[Any]: ... + def _check_exclude_of_parent_model(self, obj: GenericInlineModelAdmin, parent_model: type[Model]) -> list[Any]: ... + def _check_relation(self, obj: GenericInlineModelAdmin, parent_model: type[Model]) -> list[Any]: ... class GenericInlineModelAdmin(InlineModelAdmin): template: str diff --git a/django-stubs/contrib/contenttypes/checks.pyi b/django-stubs/contrib/contenttypes/checks.pyi index 983bbb607..635665a5b 100644 --- a/django-stubs/contrib/contenttypes/checks.pyi +++ b/django-stubs/contrib/contenttypes/checks.pyi @@ -1,4 +1,5 @@ -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage diff --git a/django-stubs/contrib/contenttypes/fields.pyi b/django-stubs/contrib/contenttypes/fields.pyi index 845c543f5..f1c5b9118 100644 --- a/django-stubs/contrib/contenttypes/fields.pyi +++ b/django-stubs/contrib/contenttypes/fields.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, List, Tuple, Type +from collections.abc import Callable +from typing import Any from django.contrib.contenttypes.models import ContentType from django.core.checks.messages import CheckMessage @@ -37,18 +38,18 @@ class GenericForeignKey(FieldCacheMixin): def __init__(self, ct_field: str = ..., fk_field: str = ..., for_concrete_model: bool = ...) -> None: ... name: Any model: Any - def contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ... - def get_filter_kwargs_for_object(self, obj: Model) -> Dict[str, ContentType | None]: ... - def get_forward_related_filter(self, obj: Model) -> Dict[str, int]: ... - def check(self, **kwargs: Any) -> List[CheckMessage]: ... + def contribute_to_class(self, cls: type[Model], name: str, **kwargs: Any) -> None: ... + def get_filter_kwargs_for_object(self, obj: Model) -> dict[str, ContentType | None]: ... + def get_forward_related_filter(self, obj: Model) -> dict[str, int]: ... + def check(self, **kwargs: Any) -> list[CheckMessage]: ... def get_cache_name(self) -> str: ... def get_content_type( self, obj: Model | None = ..., id: int | None = ..., using: str | None = ... ) -> ContentType: ... def get_prefetch_queryset( - self, instances: List[Model] | QuerySet, queryset: QuerySet | None = ... - ) -> Tuple[List[Model], Callable, Callable, bool, str, bool]: ... - def __get__(self, instance: Model | None, cls: Type[Model] | None = ...) -> Any | None: ... + self, instances: list[Model] | QuerySet, queryset: QuerySet | None = ... + ) -> tuple[list[Model], Callable, Callable, bool, str, bool]: ... + def __get__(self, instance: Model | None, cls: type[Model] | None = ...) -> Any | None: ... def __set__(self, instance: Model, value: Any | None) -> None: ... class GenericRel(ForeignObjectRel): @@ -56,10 +57,10 @@ class GenericRel(ForeignObjectRel): def __init__( self, field: GenericRelation, - to: Type[Model] | str, + to: type[Model] | str, related_name: str | None = ..., related_query_name: str | None = ..., - limit_choices_to: Dict[str, Any] | Callable[[], Any] | None = ..., + limit_choices_to: dict[str, Any] | Callable[[], Any] | None = ..., ) -> None: ... class GenericRelation(ForeignObject): @@ -71,23 +72,23 @@ class GenericRelation(ForeignObject): to_fields: Any def __init__( self, - to: Type[Model] | str, + to: type[Model] | str, object_id_field: str = ..., content_type_field: str = ..., for_concrete_model: bool = ..., related_query_name: str | None = ..., - limit_choices_to: Dict[str, Any] | Callable[[], Any] | None = ..., + limit_choices_to: dict[str, Any] | Callable[[], Any] | None = ..., **kwargs: Any ) -> None: ... - def resolve_related_fields(self) -> List[Tuple[Field, Field]]: ... - def get_path_info(self, filtered_relation: FilteredRelation | None = ...) -> List[PathInfo]: ... - def get_reverse_path_info(self, filtered_relation: FilteredRelation | None = ...) -> List[PathInfo]: ... + def resolve_related_fields(self) -> list[tuple[Field, Field]]: ... + def get_path_info(self, filtered_relation: FilteredRelation | None = ...) -> list[PathInfo]: ... + def get_reverse_path_info(self, filtered_relation: FilteredRelation | None = ...) -> list[PathInfo]: ... def get_content_type(self) -> ContentType: ... def get_extra_restriction( - self, where_class: Type[WhereNode], alias: str | None, remote_alias: str + self, where_class: type[WhereNode], alias: str | None, remote_alias: str ) -> WhereNode: ... - def bulk_related_objects(self, objs: List[Model], using: str = ...) -> QuerySet: ... + def bulk_related_objects(self, objs: list[Model], using: str = ...) -> QuerySet: ... class ReverseGenericManyToOneDescriptor(ReverseManyToOneDescriptor): ... -def create_generic_related_manager(superclass: Any, rel: Any) -> Type[Any]: ... # GenericRelatedObjectManager +def create_generic_related_manager(superclass: Any, rel: Any) -> type[Any]: ... # GenericRelatedObjectManager diff --git a/django-stubs/contrib/contenttypes/forms.pyi b/django-stubs/contrib/contenttypes/forms.pyi index 18e5070e4..c5c7ddaf3 100644 --- a/django-stubs/contrib/contenttypes/forms.pyi +++ b/django-stubs/contrib/contenttypes/forms.pyi @@ -1,4 +1,4 @@ -from typing import Any, Type, TypeVar +from typing import Any, TypeVar from django.db.models import Model from django.forms.models import BaseModelFormSet, ModelForm @@ -26,8 +26,8 @@ class BaseGenericInlineFormSet(BaseModelFormSet[_M, _ModelFormT]): def save_new(self, form: Any, commit: bool = ...) -> _M: ... def generic_inlineformset_factory( - model: Type[_M], - form: Type[_ModelFormT] = ..., + model: type[_M], + form: type[_ModelFormT] = ..., formset: Any = ..., ct_field: str = ..., fk_field: str = ..., @@ -44,4 +44,4 @@ def generic_inlineformset_factory( validate_min: bool = ..., absolute_max: int | None = ..., can_delete_extra: bool = ..., -) -> Type[BaseGenericInlineFormSet[_M, _ModelFormT]]: ... +) -> type[BaseGenericInlineFormSet[_M, _ModelFormT]]: ... diff --git a/django-stubs/contrib/contenttypes/management/__init__.pyi b/django-stubs/contrib/contenttypes/management/__init__.pyi index 489a527cc..9e9688be7 100644 --- a/django-stubs/contrib/contenttypes/management/__init__.pyi +++ b/django-stubs/contrib/contenttypes/management/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Tuple, Type +from typing import Any from django.apps.config import AppConfig from django.apps.registry import Apps @@ -18,11 +18,11 @@ class RenameContentType(migrations.RunPython): def rename_backward(self, apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: ... def inject_rename_contenttypes_operations( - plan: List[Tuple[Migration, bool]] = ..., apps: StateApps = ..., using: str = ..., **kwargs: Any + plan: list[tuple[Migration, bool]] = ..., apps: StateApps = ..., using: str = ..., **kwargs: Any ) -> None: ... def get_contenttypes_and_models( - app_config: AppConfig, using: str, ContentType: Type[ContentType] -) -> Tuple[Dict[str, ContentType], Dict[str, Type[Model]]]: ... + app_config: AppConfig, using: str, ContentType: type[ContentType] +) -> tuple[dict[str, ContentType], dict[str, type[Model]]]: ... def create_contenttypes( app_config: AppConfig, verbosity: int = ..., diff --git a/django-stubs/contrib/contenttypes/management/commands/remove_stale_contenttypes.pyi b/django-stubs/contrib/contenttypes/management/commands/remove_stale_contenttypes.pyi index 94452c093..eba352cf0 100644 --- a/django-stubs/contrib/contenttypes/management/commands/remove_stale_contenttypes.pyi +++ b/django-stubs/contrib/contenttypes/management/commands/remove_stale_contenttypes.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List +from typing import Any from django.core.management import BaseCommand from django.db.models.deletion import Collector @@ -6,9 +6,9 @@ from django.db.models.deletion import Collector class Command(BaseCommand): ... class NoFastDeleteCollector(Collector): - data: Dict[str, Any] - dependencies: Dict[Any, Any] - fast_deletes: List[Any] - field_updates: Dict[Any, Any] + data: dict[str, Any] + dependencies: dict[Any, Any] + fast_deletes: list[Any] + field_updates: dict[Any, Any] using: str def can_fast_delete(self, *args: Any, **kwargs: Any) -> bool: ... diff --git a/django-stubs/contrib/contenttypes/models.pyi b/django-stubs/contrib/contenttypes/models.pyi index 7485c68e2..16f417bb8 100644 --- a/django-stubs/contrib/contenttypes/models.pyi +++ b/django-stubs/contrib/contenttypes/models.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Tuple, Type +from typing import Any from django.db import models from django.db.models.base import Model @@ -6,8 +6,8 @@ from django.db.models.query import QuerySet class ContentTypeManager(models.Manager["ContentType"]): def get_by_natural_key(self, app_label: str, model: str) -> ContentType: ... - def get_for_model(self, model: Type[Model] | Model, for_concrete_model: bool = ...) -> ContentType: ... - def get_for_models(self, *models: Any, for_concrete_models: bool = ...) -> Dict[Type[Model], ContentType]: ... + def get_for_model(self, model: type[Model] | Model, for_concrete_model: bool = ...) -> ContentType: ... + def get_for_models(self, *models: Any, for_concrete_models: bool = ...) -> dict[type[Model], ContentType]: ... def get_for_id(self, id: int) -> ContentType: ... def clear_cache(self) -> None: ... @@ -18,7 +18,7 @@ class ContentType(models.Model): objects: ContentTypeManager @property def name(self) -> str: ... - def model_class(self) -> Type[Model] | None: ... + def model_class(self) -> type[Model] | None: ... def get_object_for_this_type(self, **kwargs: Any) -> Model: ... def get_all_objects_for_this_type(self, **kwargs: Any) -> QuerySet: ... - def natural_key(self) -> Tuple[str, str]: ... + def natural_key(self) -> tuple[str, str]: ... diff --git a/django-stubs/contrib/flatpages/urls.pyi b/django-stubs/contrib/flatpages/urls.pyi index 14e91f5b3..df4275ee2 100644 --- a/django-stubs/contrib/flatpages/urls.pyi +++ b/django-stubs/contrib/flatpages/urls.pyi @@ -1,5 +1,3 @@ -from typing import List - from django.urls import _AnyURL -urlpatterns: List[_AnyURL] +urlpatterns: list[_AnyURL] diff --git a/django-stubs/contrib/gis/db/backends/base/operations.pyi b/django-stubs/contrib/gis/db/backends/base/operations.pyi index e57f1bf91..fbebc81d2 100644 --- a/django-stubs/contrib/gis/db/backends/base/operations.pyi +++ b/django-stubs/contrib/gis/db/backends/base/operations.pyi @@ -1,4 +1,4 @@ -from typing import Any, Set +from typing import Any class BaseSpatialOperations: postgis: bool @@ -14,7 +14,7 @@ class BaseSpatialOperations: disallowed_aggregates: Any geom_func_prefix: str function_names: Any - unsupported_functions: Set[str] + unsupported_functions: set[str] from_text: bool def convert_extent(self, box: Any, srid: Any) -> Any: ... def convert_extent3d(self, box: Any, srid: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/db/backends/mysql/features.pyi b/django-stubs/contrib/gis/db/backends/mysql/features.pyi index cb1bf2c05..18c222a2f 100644 --- a/django-stubs/contrib/gis/db/backends/mysql/features.pyi +++ b/django-stubs/contrib/gis/db/backends/mysql/features.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict +from typing import Any from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as BaseSpatialFeatures from django.db.backends.mysql.features import DatabaseFeatures as MySQLDatabaseFeatures @@ -17,4 +17,4 @@ class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures): @property def supports_geometry_field_unique_index(self) -> bool: ... # type: ignore @property - def django_test_skips(self) -> Dict[str, Any]: ... # type: ignore + def django_test_skips(self) -> dict[str, Any]: ... # type: ignore diff --git a/django-stubs/contrib/gis/db/backends/mysql/operations.pyi b/django-stubs/contrib/gis/db/backends/mysql/operations.pyi index 84ab086a5..59260ea2e 100644 --- a/django-stubs/contrib/gis/db/backends/mysql/operations.pyi +++ b/django-stubs/contrib/gis/db/backends/mysql/operations.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, List, Set, Type +from collections.abc import Callable +from typing import Any from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations as BaseSpatialOperations from django.contrib.gis.db.backends.utils import SpatialOperator @@ -18,10 +19,10 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations): @property def from_text(self) -> str: ... # type: ignore @property - def gis_operators(self) -> Dict[str, SpatialOperator]: ... + def gis_operators(self) -> dict[str, SpatialOperator]: ... disallowed_aggregates: Any @property - def unsupported_functions(self) -> Set[str]: ... # type: ignore + def unsupported_functions(self) -> set[str]: ... # type: ignore def geo_db_type(self, f: Any) -> Any: ... - def get_distance(self, f: Any, value: Any, lookup_type: Any) -> List[Any]: ... + def get_distance(self, f: Any, value: Any, lookup_type: Any) -> list[Any]: ... def get_geometry_converter(self, expression: Any) -> Callable[[Any, Any, Any], GEOSGeometryBase | None]: ... diff --git a/django-stubs/contrib/gis/db/backends/spatialite/operations.pyi b/django-stubs/contrib/gis/db/backends/spatialite/operations.pyi index dab62a916..175ffb33c 100644 --- a/django-stubs/contrib/gis/db/backends/spatialite/operations.pyi +++ b/django-stubs/contrib/gis/db/backends/spatialite/operations.pyi @@ -1,4 +1,4 @@ -from typing import Any, Set +from typing import Any from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations from django.contrib.gis.db.backends.utils import SpatialOperator as SpatialOperator @@ -19,7 +19,7 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations): select: str function_names: Any @property - def unsupported_functions(self) -> Set[str]: ... # type: ignore[override] + def unsupported_functions(self) -> set[str]: ... # type: ignore[override] @property def spatial_version(self) -> Any: ... def geo_db_type(self, f: Any) -> None: ... diff --git a/django-stubs/contrib/gis/db/models/fields.pyi b/django-stubs/contrib/gis/db/models/fields.pyi index d6c98e496..736aa3f5f 100644 --- a/django-stubs/contrib/gis/db/models/fields.pyi +++ b/django-stubs/contrib/gis/db/models/fields.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, NamedTuple, Tuple, TypeVar +from collections.abc import Iterable +from typing import Any, NamedTuple, TypeVar from django.core.validators import _ValidatorCallable from django.db.models.fields import Field, _ErrorMessagesT, _FieldChoices @@ -70,7 +71,7 @@ class GeometryField(BaseSpatialField): dim: int = ..., geography: bool = ..., *, - extent: Tuple[float, float, float, float] = ..., + extent: tuple[float, float, float, float] = ..., tolerance: float = ..., srid: int = ..., spatial_index: bool = ..., diff --git a/django-stubs/contrib/gis/gdal/layer.pyi b/django-stubs/contrib/gis/gdal/layer.pyi index 205f4734c..b4d9c1f2f 100644 --- a/django-stubs/contrib/gis/gdal/layer.pyi +++ b/django-stubs/contrib/gis/gdal/layer.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator +from collections.abc import Iterator +from typing import Any from django.contrib.gis.gdal.base import GDALBase as GDALBase diff --git a/django-stubs/contrib/gis/gdal/raster/band.pyi b/django-stubs/contrib/gis/gdal/raster/band.pyi index 113a87500..42c9b4e2e 100644 --- a/django-stubs/contrib/gis/gdal/raster/band.pyi +++ b/django-stubs/contrib/gis/gdal/raster/band.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator +from collections.abc import Iterator +from typing import Any from django.contrib.gis.gdal.raster.base import GDALRasterBase as GDALRasterBase diff --git a/django-stubs/contrib/gis/geos/collections.pyi b/django-stubs/contrib/gis/geos/collections.pyi index b7209c5f4..2d9ed3002 100644 --- a/django-stubs/contrib/gis/geos/collections.pyi +++ b/django-stubs/contrib/gis/geos/collections.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator +from collections.abc import Iterator +from typing import Any from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry from django.contrib.gis.geos.geometry import LinearGeometryMixin as LinearGeometryMixin diff --git a/django-stubs/contrib/gis/geos/coordseq.pyi b/django-stubs/contrib/gis/geos/coordseq.pyi index 3ac53f42c..f5fa747f4 100644 --- a/django-stubs/contrib/gis/geos/coordseq.pyi +++ b/django-stubs/contrib/gis/geos/coordseq.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator +from collections.abc import Iterator +from typing import Any from django.contrib.gis.geos.base import GEOSBase as GEOSBase diff --git a/django-stubs/contrib/gis/geos/linestring.pyi b/django-stubs/contrib/gis/geos/linestring.pyi index c53212762..c022e31fe 100644 --- a/django-stubs/contrib/gis/geos/linestring.pyi +++ b/django-stubs/contrib/gis/geos/linestring.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator +from collections.abc import Iterator +from typing import Any from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry from django.contrib.gis.geos.geometry import LinearGeometryMixin as LinearGeometryMixin diff --git a/django-stubs/contrib/gis/geos/point.pyi b/django-stubs/contrib/gis/geos/point.pyi index b67bf27c1..ad66e45ca 100644 --- a/django-stubs/contrib/gis/geos/point.pyi +++ b/django-stubs/contrib/gis/geos/point.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator +from collections.abc import Iterator +from typing import Any from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry diff --git a/django-stubs/contrib/gis/geos/polygon.pyi b/django-stubs/contrib/gis/geos/polygon.pyi index 0d0e8bf71..cff17a912 100644 --- a/django-stubs/contrib/gis/geos/polygon.pyi +++ b/django-stubs/contrib/gis/geos/polygon.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator +from collections.abc import Iterator +from typing import Any from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry diff --git a/django-stubs/contrib/gis/views.pyi b/django-stubs/contrib/gis/views.pyi index f069f5ec1..fe9efc441 100644 --- a/django-stubs/contrib/gis/views.pyi +++ b/django-stubs/contrib/gis/views.pyi @@ -1,6 +1,4 @@ -from typing import Dict, Type - from django.contrib.gis.feeds import Feed from django.http import HttpRequest, HttpResponse -def feed(request: HttpRequest, url: str, feed_dict: Dict[str, Type[Feed]] | None = ...) -> HttpResponse: ... +def feed(request: HttpRequest, url: str, feed_dict: dict[str, type[Feed]] | None = ...) -> HttpResponse: ... diff --git a/django-stubs/contrib/humanize/templatetags/humanize.pyi b/django-stubs/contrib/humanize/templatetags/humanize.pyi index 0b06c7c6a..0bc6e2997 100644 --- a/django-stubs/contrib/humanize/templatetags/humanize.pyi +++ b/django-stubs/contrib/humanize/templatetags/humanize.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable from datetime import date from datetime import datetime as datetime -from typing import Any, Callable, Dict, SupportsInt, Tuple, Type +from typing import Any, SupportsInt from django import template @@ -9,7 +10,7 @@ register: template.Library def ordinal(value: str | SupportsInt | None) -> str | None: ... def intcomma(value: str | SupportsInt | None, use_l10n: bool = ...) -> str: ... -intword_converters: Tuple[Tuple[int, Callable]] +intword_converters: tuple[tuple[int, Callable]] def intword(value: str | SupportsInt | None) -> int | str | None: ... def apnumber(value: str | SupportsInt | None) -> int | str | None: ... @@ -17,8 +18,8 @@ def naturalday(value: date | str | None, arg: str | None = ...) -> str | None: . def naturaltime(value: datetime) -> str: ... class NaturalTimeFormatter: - time_strings: Dict[str, str] - past_substrings: Dict[str, str] - future_substrings: Dict[str, str] + time_strings: dict[str, str] + past_substrings: dict[str, str] + future_substrings: dict[str, str] @classmethod - def string_for(cls: Type[NaturalTimeFormatter], value: Any) -> Any: ... + def string_for(cls: type[NaturalTimeFormatter], value: Any) -> Any: ... diff --git a/django-stubs/contrib/messages/api.pyi b/django-stubs/contrib/messages/api.pyi index fabad0c0d..b16f69adf 100644 --- a/django-stubs/contrib/messages/api.pyi +++ b/django-stubs/contrib/messages/api.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from django.contrib.messages.storage.base import BaseStorage from django.http.request import HttpRequest @@ -12,7 +12,7 @@ def add_message( extra_tags: str = ..., fail_silently: bool | str = ..., ) -> None: ... -def get_messages(request: HttpRequest) -> List[Any] | BaseStorage: ... +def get_messages(request: HttpRequest) -> list[Any] | BaseStorage: ... def get_level(request: HttpRequest) -> int: ... def set_level(request: HttpRequest, level: int) -> bool: ... def debug(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: bool | str = ...) -> None: ... diff --git a/django-stubs/contrib/messages/constants.pyi b/django-stubs/contrib/messages/constants.pyi index 6b1eaa8c3..2904b34bd 100644 --- a/django-stubs/contrib/messages/constants.pyi +++ b/django-stubs/contrib/messages/constants.pyi @@ -1,11 +1,9 @@ -from typing import Dict - DEBUG: int INFO: int SUCCESS: int WARNING: int ERROR: int -DEFAULT_TAGS: Dict[int, str] +DEFAULT_TAGS: dict[int, str] -DEFAULT_LEVELS: Dict[str, int] +DEFAULT_LEVELS: dict[str, int] diff --git a/django-stubs/contrib/messages/context_processors.pyi b/django-stubs/contrib/messages/context_processors.pyi index a899f718c..7fb1a97da 100644 --- a/django-stubs/contrib/messages/context_processors.pyi +++ b/django-stubs/contrib/messages/context_processors.pyi @@ -1,6 +1,6 @@ -from typing import Any, Dict, List +from typing import Any from django.contrib.messages.storage.base import BaseStorage from django.http.request import HttpRequest -def messages(request: HttpRequest) -> Dict[str, Dict[str, int] | List[Any] | BaseStorage]: ... +def messages(request: HttpRequest) -> dict[str, dict[str, int] | list[Any] | BaseStorage]: ... diff --git a/django-stubs/contrib/messages/storage/base.pyi b/django-stubs/contrib/messages/storage/base.pyi index 9f1ebbe3a..08d46625f 100644 --- a/django-stubs/contrib/messages/storage/base.pyi +++ b/django-stubs/contrib/messages/storage/base.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator, List +from collections.abc import Iterator +from typing import Any from django.http.request import HttpRequest from django.http.response import HttpResponseBase @@ -23,6 +24,6 @@ class BaseStorage: def __len__(self) -> int: ... def __iter__(self) -> Iterator[Message]: ... def __contains__(self, item: Any) -> bool: ... - def update(self, response: HttpResponseBase) -> List[Message] | None: ... + def update(self, response: HttpResponseBase) -> list[Message] | None: ... def add(self, level: int, message: str, extra_tags: str | None = ...) -> None: ... level: Any diff --git a/django-stubs/contrib/messages/storage/session.pyi b/django-stubs/contrib/messages/storage/session.pyi index d14ee1fd0..e8880f958 100644 --- a/django-stubs/contrib/messages/storage/session.pyi +++ b/django-stubs/contrib/messages/storage/session.pyi @@ -1,4 +1,5 @@ -from typing import Any, List, Sequence +from collections.abc import Sequence +from typing import Any from django.contrib.messages.storage.base import BaseStorage from django.http.request import HttpRequest @@ -7,4 +8,4 @@ class SessionStorage(BaseStorage): session_key: str def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ... def serialize_messages(self, messages: Sequence[Any]) -> str: ... - def deserialize_messages(self, data: List[Any] | str | None) -> List[Any] | None: ... + def deserialize_messages(self, data: list[Any] | str | None) -> list[Any] | None: ... diff --git a/django-stubs/contrib/messages/utils.pyi b/django-stubs/contrib/messages/utils.pyi index 1f29b13af..13affff7c 100644 --- a/django-stubs/contrib/messages/utils.pyi +++ b/django-stubs/contrib/messages/utils.pyi @@ -1,3 +1 @@ -from typing import Dict - -def get_level_tags() -> Dict[int, str]: ... +def get_level_tags() -> dict[int, str]: ... diff --git a/django-stubs/contrib/messages/views.pyi b/django-stubs/contrib/messages/views.pyi index 56458dcbe..3bd494a92 100644 --- a/django-stubs/contrib/messages/views.pyi +++ b/django-stubs/contrib/messages/views.pyi @@ -1,5 +1,3 @@ -from typing import Dict - from django.forms.forms import BaseForm from django.http.response import HttpResponse from django.utils.functional import _StrOrPromise @@ -7,4 +5,4 @@ from django.utils.functional import _StrOrPromise class SuccessMessageMixin: success_message: _StrOrPromise def form_valid(self, form: BaseForm) -> HttpResponse: ... - def get_success_message(self, cleaned_data: Dict[str, str]) -> _StrOrPromise: ... + def get_success_message(self, cleaned_data: dict[str, str]) -> _StrOrPromise: ... diff --git a/django-stubs/contrib/postgres/constraints.pyi b/django-stubs/contrib/postgres/constraints.pyi index 563af8b53..dc93f0d11 100644 --- a/django-stubs/contrib/postgres/constraints.pyi +++ b/django-stubs/contrib/postgres/constraints.pyi @@ -1,4 +1,4 @@ -from typing import List, Sequence, Tuple +from collections.abc import Sequence from django.db.models import Deferrable from django.db.models.constraints import BaseConstraint @@ -6,17 +6,17 @@ from django.db.models.expressions import Combinable from django.db.models.query_utils import Q class ExclusionConstraint(BaseConstraint): - expressions: Sequence[Tuple[str | Combinable, str]] + expressions: Sequence[tuple[str | Combinable, str]] index_type: str condition: Q | None def __init__( self, *, name: str, - expressions: Sequence[Tuple[str | Combinable, str]], + expressions: Sequence[tuple[str | Combinable, str]], index_type: str | None = ..., condition: Q | None = ..., deferrable: Deferrable | None = ..., - include: List[str] | Tuple[str] | None = ..., - opclasses: List[str] | Tuple[str] = ..., + include: list[str] | tuple[str] | None = ..., + opclasses: list[str] | tuple[str] = ..., ) -> None: ... diff --git a/django-stubs/contrib/postgres/fields/array.pyi b/django-stubs/contrib/postgres/fields/array.pyi index 0d78cc51d..0eabe5105 100644 --- a/django-stubs/contrib/postgres/fields/array.pyi +++ b/django-stubs/contrib/postgres/fields/array.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, List, Sequence, Type, TypeVar +from collections.abc import Iterable, Sequence +from typing import Any, TypeVar from django.core.validators import _ValidatorCallable from django.db.models import Field, Transform @@ -14,7 +15,7 @@ _GT = TypeVar("_GT") class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]): _pyi_private_set_type: Sequence[Any] | Combinable - _pyi_private_get_type: List[Any] + _pyi_private_get_type: list[Any] empty_strings_allowed: bool default_error_messages: _ErrorMessagesT @@ -51,4 +52,4 @@ class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]): ) -> None: ... @property def description(self) -> str: ... # type: ignore - def get_transform(self, name: Any) -> Type[Transform] | None: ... + def get_transform(self, name: Any) -> type[Transform] | None: ... diff --git a/django-stubs/contrib/postgres/fields/ranges.pyi b/django-stubs/contrib/postgres/fields/ranges.pyi index 4ee89a363..a8259ce9f 100644 --- a/django-stubs/contrib/postgres/fields/ranges.pyi +++ b/django-stubs/contrib/postgres/fields/ranges.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Type +from typing import Any from django.db import models from django.db.models.lookups import PostgresOperatorLookup @@ -25,7 +25,7 @@ class RangeOperators: class RangeField(models.Field): empty_strings_allowed: bool base_field: models.Field - range_type: Type[Range] + range_type: type[Range] def get_prep_value(self, value: Any) -> Any | None: ... def to_python(self, value: Any) -> Any: ... @@ -50,7 +50,7 @@ class DateTimeRangeContains(PostgresOperatorLookup): class RangeContainedBy(PostgresOperatorLookup): lookup_name: str - type_mapping: Dict[str, str] + type_mapping: dict[str, str] postgres_operator: str class FullyLessThan(PostgresOperatorLookup): diff --git a/django-stubs/contrib/postgres/forms/array.pyi b/django-stubs/contrib/postgres/forms/array.pyi index 031953dfa..4ba068404 100644 --- a/django-stubs/contrib/postgres/forms/array.pyi +++ b/django-stubs/contrib/postgres/forms/array.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Sequence, Type +from collections.abc import Sequence +from typing import Any from django import forms as forms from django.contrib.postgres.validators import ArrayMaxLengthValidator as ArrayMaxLengthValidator @@ -37,13 +38,13 @@ class SplitArrayWidget(forms.Widget): template_name: str widget: _ClassLevelWidgetT size: int - def __init__(self, widget: forms.Widget | Type[forms.Widget], size: int, **kwargs: Any) -> None: ... + def __init__(self, widget: forms.Widget | type[forms.Widget], size: int, **kwargs: Any) -> None: ... @property def is_hidden(self) -> bool: ... def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... def id_for_label(self, id_: str) -> str: ... - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None = ...) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None = ...) -> dict[str, Any]: ... @property def media(self) -> Media: ... # type: ignore @property diff --git a/django-stubs/contrib/postgres/forms/hstore.pyi b/django-stubs/contrib/postgres/forms/hstore.pyi index 4778560ef..4fe7fe0b9 100644 --- a/django-stubs/contrib/postgres/forms/hstore.pyi +++ b/django-stubs/contrib/postgres/forms/hstore.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Type +from typing import Any from django import forms from django.db.models.fields import _ErrorMessagesT @@ -8,5 +8,5 @@ class HStoreField(forms.CharField): widget: _ClassLevelWidgetT default_error_messages: _ErrorMessagesT def prepare_value(self, value: Any) -> Any: ... - def to_python(self, value: Any) -> Dict[str, str | None]: ... # type: ignore + def to_python(self, value: Any) -> dict[str, str | None]: ... # type: ignore def has_changed(self, initial: Any, data: Any) -> bool: ... diff --git a/django-stubs/contrib/postgres/forms/ranges.pyi b/django-stubs/contrib/postgres/forms/ranges.pyi index 75f089e87..87492e05e 100644 --- a/django-stubs/contrib/postgres/forms/ranges.pyi +++ b/django-stubs/contrib/postgres/forms/ranges.pyi @@ -1,4 +1,4 @@ -from typing import Any, Tuple, Type +from typing import Any from django import forms from django.db.models.fields import _ErrorMessagesT @@ -6,37 +6,37 @@ from django.forms.widgets import MultiWidget, _OptAttrs from psycopg2.extras import Range class RangeWidget(MultiWidget): - def __init__(self, base_widget: forms.Widget | Type[forms.Widget], attrs: _OptAttrs | None = ...) -> None: ... - def decompress(self, value: Any) -> Tuple[Any | None, Any | None]: ... + def __init__(self, base_widget: forms.Widget | type[forms.Widget], attrs: _OptAttrs | None = ...) -> None: ... + def decompress(self, value: Any) -> tuple[Any | None, Any | None]: ... class HiddenRangeWidget(RangeWidget): def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... class BaseRangeField(forms.MultiValueField): default_error_messages: _ErrorMessagesT - base_field: Type[forms.Field] - range_type: Type[Range] - hidden_widget: Type[forms.Widget] + base_field: type[forms.Field] + range_type: type[Range] + hidden_widget: type[forms.Widget] def __init__(self, **kwargs: Any) -> None: ... def prepare_value(self, value: Any) -> Any: ... - def compress(self, values: Tuple[Any | None, Any | None]) -> Range | None: ... + def compress(self, values: tuple[Any | None, Any | None]) -> Range | None: ... class IntegerRangeField(BaseRangeField): default_error_messages: _ErrorMessagesT - base_field: Type[forms.Field] - range_type: Type[Range] + base_field: type[forms.Field] + range_type: type[Range] class DecimalRangeField(BaseRangeField): default_error_messages: _ErrorMessagesT - base_field: Type[forms.Field] - range_type: Type[Range] + base_field: type[forms.Field] + range_type: type[Range] class DateTimeRangeField(BaseRangeField): default_error_messages: _ErrorMessagesT - base_field: Type[forms.Field] - range_type: Type[Range] + base_field: type[forms.Field] + range_type: type[Range] class DateRangeField(BaseRangeField): default_error_messages: _ErrorMessagesT - base_field: Type[forms.Field] - range_type: Type[Range] + base_field: type[forms.Field] + range_type: type[Range] diff --git a/django-stubs/contrib/postgres/indexes.pyi b/django-stubs/contrib/postgres/indexes.pyi index 73f6371ce..6dcde3f10 100644 --- a/django-stubs/contrib/postgres/indexes.pyi +++ b/django-stubs/contrib/postgres/indexes.pyi @@ -1,4 +1,5 @@ -from typing import Any, List, Sequence, Tuple, Type +from collections.abc import Sequence +from typing import Any from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.backends.ddl_references import Statement @@ -11,7 +12,7 @@ class PostgresIndex(Index): @property def max_name_length(self) -> int: ... # type: ignore def create_sql( - self, model: Type[Model], schema_editor: BaseDatabaseSchemaEditor, using: str = ..., **kwargs: Any + self, model: type[Model], schema_editor: BaseDatabaseSchemaEditor, using: str = ..., **kwargs: Any ) -> Statement: ... def check_supported(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ... def get_with_params(self) -> Sequence[str]: ... diff --git a/django-stubs/contrib/postgres/search.pyi b/django-stubs/contrib/postgres/search.pyi index f3721de09..5896ddb8b 100644 --- a/django-stubs/contrib/postgres/search.pyi +++ b/django-stubs/contrib/postgres/search.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, TypeVar +from typing import Any, TypeVar from django.db.models import Expression, Field from django.db.models.expressions import Combinable, CombinedExpression, Func, Value @@ -49,7 +49,7 @@ class SearchQueryCombinable: def __rand__(self: _T, other: SearchQueryCombinable) -> _T: ... class SearchQuery(SearchQueryCombinable, Func): # type: ignore - SEARCH_TYPES: Dict[str, str] + SEARCH_TYPES: dict[str, str] def __init__( self, value: _Expression, diff --git a/django-stubs/contrib/postgres/serializers.pyi b/django-stubs/contrib/postgres/serializers.pyi index 3e3c1d56e..5bcc8c355 100644 --- a/django-stubs/contrib/postgres/serializers.pyi +++ b/django-stubs/contrib/postgres/serializers.pyi @@ -1,6 +1,4 @@ -from typing import Set, Tuple - from django.db.migrations.serializer import BaseSerializer as BaseSerializer class RangeSerializer(BaseSerializer): - def serialize(self) -> Tuple[str, Set[str]]: ... + def serialize(self) -> tuple[str, set[str]]: ... diff --git a/django-stubs/contrib/postgres/signals.pyi b/django-stubs/contrib/postgres/signals.pyi index e3475a904..f96766793 100644 --- a/django-stubs/contrib/postgres/signals.pyi +++ b/django-stubs/contrib/postgres/signals.pyi @@ -1,5 +1,5 @@ -from typing import Any, Tuple +from typing import Any -def get_hstore_oids(connection_alias: str) -> Tuple[Any, ...]: ... -def get_citext_oids(connection_alias: str) -> Tuple[Any, ...]: ... +def get_hstore_oids(connection_alias: str) -> tuple[Any, ...]: ... +def get_citext_oids(connection_alias: str) -> tuple[Any, ...]: ... def register_type_handlers(connection: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/contrib/postgres/validators.pyi b/django-stubs/contrib/postgres/validators.pyi index b7b42badb..35cf85569 100644 --- a/django-stubs/contrib/postgres/validators.pyi +++ b/django-stubs/contrib/postgres/validators.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, Mapping +from collections.abc import Iterable, Mapping +from typing import Any from django.core.validators import MaxLengthValidator, MaxValueValidator, MinLengthValidator, MinValueValidator @@ -6,7 +7,7 @@ class ArrayMaxLengthValidator(MaxLengthValidator): ... class ArrayMinLengthValidator(MinLengthValidator): ... class KeysValidator: - messages: Dict[str, str] + messages: dict[str, str] strict: bool def __init__(self, keys: Iterable[str], strict: bool = ..., messages: Mapping[str, str] | None = ...) -> None: ... def __call__(self, value: Any) -> None: ... diff --git a/django-stubs/contrib/sessions/backends/base.pyi b/django-stubs/contrib/sessions/backends/base.pyi index 049d08b27..a42f2eb76 100644 --- a/django-stubs/contrib/sessions/backends/base.pyi +++ b/django-stubs/contrib/sessions/backends/base.pyi @@ -1,12 +1,12 @@ from datetime import datetime -from typing import Any, Dict +from typing import Any VALID_KEY_CHARS: Any class CreateError(Exception): ... class UpdateError(Exception): ... -class SessionBase(Dict[str, Any]): +class SessionBase(dict[str, Any]): TEST_COOKIE_NAME: str TEST_COOKIE_VALUE: str accessed: bool @@ -16,8 +16,8 @@ class SessionBase(Dict[str, Any]): def set_test_cookie(self) -> None: ... def test_cookie_worked(self) -> bool: ... def delete_test_cookie(self) -> None: ... - def encode(self, session_dict: Dict[str, Any]) -> str: ... - def decode(self, session_data: bytes | str) -> Dict[str, Any]: ... + def encode(self, session_dict: dict[str, Any]) -> str: ... + def decode(self, session_data: bytes | str) -> dict[str, Any]: ... def has_key(self, key: Any) -> Any: ... def keys(self) -> Any: ... def values(self) -> Any: ... @@ -42,6 +42,6 @@ class SessionBase(Dict[str, Any]): def create(self) -> None: ... def save(self, must_create: bool = ...) -> None: ... def delete(self, session_key: str | None = ...) -> None: ... - def load(self) -> Dict[str, Any]: ... + def load(self) -> dict[str, Any]: ... @classmethod def clear_expired(cls) -> None: ... diff --git a/django-stubs/contrib/sessions/backends/db.pyi b/django-stubs/contrib/sessions/backends/db.pyi index 01763bce4..7fb112a29 100644 --- a/django-stubs/contrib/sessions/backends/db.pyi +++ b/django-stubs/contrib/sessions/backends/db.pyi @@ -1,5 +1,3 @@ -from typing import Dict, Type - from django.contrib.sessions.backends.base import SessionBase from django.contrib.sessions.base_session import AbstractBaseSession from django.contrib.sessions.models import Session @@ -8,7 +6,7 @@ from django.db.models.base import Model class SessionStore(SessionBase): def __init__(self, session_key: str | None = ...) -> None: ... @classmethod - def get_model_class(cls) -> Type[Session]: ... + def get_model_class(cls) -> type[Session]: ... @property - def model(self) -> Type[AbstractBaseSession]: ... - def create_model_instance(self, data: Dict[str, Model]) -> AbstractBaseSession: ... + def model(self) -> type[AbstractBaseSession]: ... + def create_model_instance(self, data: dict[str, Model]) -> AbstractBaseSession: ... diff --git a/django-stubs/contrib/sessions/base_session.pyi b/django-stubs/contrib/sessions/base_session.pyi index d26133853..9d4e54e0f 100644 --- a/django-stubs/contrib/sessions/base_session.pyi +++ b/django-stubs/contrib/sessions/base_session.pyi @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Dict, Type, TypeVar +from typing import Any, TypeVar from django.contrib.sessions.backends.base import SessionBase from django.db import models @@ -7,8 +7,8 @@ from django.db import models _T = TypeVar("_T", bound="AbstractBaseSession") class BaseSessionManager(models.Manager[_T]): - def encode(self, session_dict: Dict[str, Any]) -> str: ... - def save(self, session_key: str, session_dict: Dict[str, Any], expire_date: datetime) -> _T: ... + def encode(self, session_dict: dict[str, Any]) -> str: ... + def save(self, session_key: str, session_dict: dict[str, Any], expire_date: datetime) -> _T: ... class AbstractBaseSession(models.Model): expire_date: datetime @@ -16,5 +16,5 @@ class AbstractBaseSession(models.Model): session_key: str objects: Any @classmethod - def get_session_store_class(cls) -> Type[SessionBase] | None: ... - def get_decoded(self) -> Dict[str, Any]: ... + def get_session_store_class(cls) -> type[SessionBase] | None: ... + def get_decoded(self) -> dict[str, Any]: ... diff --git a/django-stubs/contrib/sessions/middleware.pyi b/django-stubs/contrib/sessions/middleware.pyi index 864e51dfd..b6e0eaaac 100644 --- a/django-stubs/contrib/sessions/middleware.pyi +++ b/django-stubs/contrib/sessions/middleware.pyi @@ -1,11 +1,9 @@ -from typing import Type - from django.contrib.sessions.backends.base import SessionBase from django.http.request import HttpRequest from django.http.response import HttpResponse from django.utils.deprecation import MiddlewareMixin class SessionMiddleware(MiddlewareMixin): - SessionStore: Type[SessionBase] + SessionStore: type[SessionBase] def process_request(self, request: HttpRequest) -> None: ... def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ... diff --git a/django-stubs/contrib/sessions/serializers.pyi b/django-stubs/contrib/sessions/serializers.pyi index 5c0eb15aa..ac0b34a66 100644 --- a/django-stubs/contrib/sessions/serializers.pyi +++ b/django-stubs/contrib/sessions/serializers.pyi @@ -1,10 +1,8 @@ -from typing import Dict - from django.core.signing import JSONSerializer as BaseJSONSerializer from django.db.models.base import Model class PickleSerializer: - def dumps(self, obj: Dict[str, Model]) -> bytes: ... - def loads(self, data: bytes) -> Dict[str, Model]: ... + def dumps(self, obj: dict[str, Model]) -> bytes: ... + def loads(self, data: bytes) -> dict[str, Model]: ... JSONSerializer = BaseJSONSerializer diff --git a/django-stubs/contrib/sitemaps/__init__.pyi b/django-stubs/contrib/sitemaps/__init__.pyi index 5118a95f1..03c99772c 100644 --- a/django-stubs/contrib/sitemaps/__init__.pyi +++ b/django-stubs/contrib/sitemaps/__init__.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, Mapping, Sequence from datetime import datetime -from typing import Any, Dict, Generic, Iterable, List, Mapping, Sequence, TypeVar +from typing import Any, Generic, TypeVar from django.contrib.sites.models import Site from django.contrib.sites.requests import RequestSite @@ -28,7 +29,7 @@ class Sitemap(Generic[_ItemT]): def paginator(self) -> Paginator: ... def get_urls( self, page: int | str = ..., site: Site | RequestSite | None = ..., protocol: str | None = ... - ) -> List[Dict[str, Any]]: ... + ) -> list[dict[str, Any]]: ... def get_latest_lastmod(self) -> datetime | None: ... _ModelT = TypeVar("_ModelT", bound=Model) diff --git a/django-stubs/contrib/sitemaps/views.pyi b/django-stubs/contrib/sitemaps/views.pyi index 3891589a7..9ba674d53 100644 --- a/django-stubs/contrib/sitemaps/views.pyi +++ b/django-stubs/contrib/sitemaps/views.pyi @@ -1,4 +1,5 @@ -from typing import Callable, Dict, Type, TypeVar +from collections.abc import Callable +from typing import TypeVar from django.contrib.sitemaps import GenericSitemap, Sitemap from django.http.request import HttpRequest @@ -9,14 +10,14 @@ _C = TypeVar("_C", bound=Callable) def x_robots_tag(func: _C) -> _C: ... def index( request: HttpRequest, - sitemaps: Dict[str, Type[Sitemap] | Sitemap], + sitemaps: dict[str, type[Sitemap] | Sitemap], template_name: str = ..., content_type: str = ..., sitemap_url_name: str = ..., ) -> TemplateResponse: ... def sitemap( request: HttpRequest, - sitemaps: Dict[str, Type[Sitemap] | Sitemap], + sitemaps: dict[str, type[Sitemap] | Sitemap], section: str | None = ..., template_name: str = ..., content_type: str = ..., diff --git a/django-stubs/contrib/sites/models.pyi b/django-stubs/contrib/sites/models.pyi index 68400d47c..05f0a3fbd 100644 --- a/django-stubs/contrib/sites/models.pyi +++ b/django-stubs/contrib/sites/models.pyi @@ -1,4 +1,4 @@ -from typing import Any, Tuple, Type +from typing import Any from django.db import models from django.http.request import HttpRequest @@ -15,6 +15,6 @@ class Site(models.Model): domain = models.CharField(max_length=100) name = models.CharField(max_length=50) - def natural_key(self) -> Tuple[str]: ... + def natural_key(self) -> tuple[str]: ... -def clear_site_cache(sender: Type[Site], **kwargs: Any) -> None: ... +def clear_site_cache(sender: type[Site], **kwargs: Any) -> None: ... diff --git a/django-stubs/contrib/staticfiles/checks.pyi b/django-stubs/contrib/staticfiles/checks.pyi index 159aa0ea6..5d4deba93 100644 --- a/django-stubs/contrib/staticfiles/checks.pyi +++ b/django-stubs/contrib/staticfiles/checks.pyi @@ -1,6 +1,7 @@ -from typing import Any, List, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage -def check_finders(app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any) -> List[CheckMessage]: ... +def check_finders(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 5e9ab5c2f..585b06436 100644 --- a/django-stubs/contrib/staticfiles/finders.pyi +++ b/django-stubs/contrib/staticfiles/finders.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, Iterator, List, Sequence, Tuple, Type, overload +from collections.abc import Iterable, Iterator, Sequence +from typing import Any, overload from django.core.checks.messages import CheckMessage from django.core.files.storage import FileSystemStorage, Storage @@ -7,35 +8,35 @@ from typing_extensions import Literal searched_locations: Any class BaseFinder: - def check(self, **kwargs: Any) -> List[CheckMessage]: ... + def check(self, **kwargs: Any) -> list[CheckMessage]: ... @overload def find(self, path: str, all: Literal[False] = ...) -> str | None: ... @overload - def find(self, path: str, all: Literal[True]) -> List[str]: ... + def find(self, path: str, all: Literal[True]) -> list[str]: ... def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... class FileSystemFinder(BaseFinder): - locations: List[Tuple[str, str]] - storages: Dict[str, Any] + locations: list[tuple[str, str]] + storages: dict[str, Any] def __init__(self, app_names: Sequence[str] = ..., *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: ... @overload - def find(self, path: str, all: Literal[True]) -> List[str]: ... + def find(self, path: str, all: Literal[True]) -> list[str]: ... def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... class AppDirectoriesFinder(BaseFinder): - storage_class: Type[FileSystemStorage] + storage_class: type[FileSystemStorage] source_dir: str - apps: List[str] - storages: Dict[str, FileSystemStorage] + apps: list[str] + storages: dict[str, FileSystemStorage] def __init__(self, app_names: Iterable[str] | None = ..., *args: Any, **kwargs: Any) -> None: ... def find_in_app(self, app: str, path: str) -> str | None: ... @overload def find(self, path: str, all: Literal[False] = ...) -> str | None: ... @overload - def find(self, path: str, all: Literal[True]) -> List[str]: ... + def find(self, path: str, all: Literal[True]) -> list[str]: ... def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... class BaseStorageFinder(BaseFinder): @@ -44,7 +45,7 @@ class BaseStorageFinder(BaseFinder): @overload def find(self, path: str, all: Literal[False] = ...) -> str | None: ... @overload - def find(self, path: str, all: Literal[True]) -> List[str]: ... + def find(self, path: str, all: Literal[True]) -> list[str]: ... def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ... class DefaultStorageFinder(BaseStorageFinder): @@ -54,7 +55,7 @@ class DefaultStorageFinder(BaseStorageFinder): @overload def find(path: str, all: Literal[False] = ...) -> str | None: ... @overload -def find(path: str, all: Literal[True]) -> List[str]: ... +def find(path: str, all: Literal[True]) -> list[str]: ... def get_finders() -> Iterator[BaseFinder]: ... @overload def get_finder( diff --git a/django-stubs/contrib/staticfiles/handlers.pyi b/django-stubs/contrib/staticfiles/handlers.pyi index 519b4efbc..b907953cc 100644 --- a/django-stubs/contrib/staticfiles/handlers.pyi +++ b/django-stubs/contrib/staticfiles/handlers.pyi @@ -1,4 +1,5 @@ -from typing import Any, Awaitable, Callable, Dict, Mapping, Sequence, Tuple +from collections.abc import Callable, Mapping, Sequence +from typing import Any, Awaitable from urllib.parse import ParseResult from django.core.handlers.asgi import ASGIHandler @@ -25,8 +26,8 @@ class StaticFilesHandler(StaticFilesHandlerMixin, WSGIHandler): # type: ignore def __init__(self, application: WSGIHandler) -> None: ... def __call__( self, - environ: Dict[str, Any], - start_response: Callable[[str, Sequence[Tuple[str, str]]], None], + environ: dict[str, Any], + start_response: Callable[[str, Sequence[tuple[str, str]]], None], ) -> HttpResponseBase: ... class ASGIStaticFilesHandler(StaticFilesHandlerMixin, ASGIHandler): # type: ignore @@ -35,7 +36,7 @@ class ASGIStaticFilesHandler(StaticFilesHandlerMixin, ASGIHandler): # type: ign def __init__(self, application: ASGIHandler) -> None: ... async def __call__( self, - scope: Dict[str, Any], + scope: dict[str, Any], receive: Callable[[], Awaitable[Mapping[str, Any]]], send: Callable[[Mapping[str, Any]], Awaitable[None]], ) -> None: ... diff --git a/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi b/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi index d0a4901f5..4a84039e1 100644 --- a/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi +++ b/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List +from typing import Any from django.core.files.storage import Storage from django.core.management.base import BaseCommand @@ -20,7 +20,7 @@ class Command(BaseCommand): ignore_patterns: Any post_process: Any def set_options(self, **options: Any) -> None: ... - def collect(self) -> Dict[str, List[str]]: ... + def collect(self) -> dict[str, list[str]]: ... 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/storage.pyi b/django-stubs/contrib/staticfiles/storage.pyi index b12fff8e8..6c5dc892c 100644 --- a/django-stubs/contrib/staticfiles/storage.pyi +++ b/django-stubs/contrib/staticfiles/storage.pyi @@ -1,11 +1,12 @@ -from typing import Any, Callable, Dict, Iterator, Tuple +from collections.abc import Callable, Iterator +from typing import Any from django.core.files.base import File from django.core.files.storage import FileSystemStorage, Storage from django.utils._os import _PathCompatible from django.utils.functional import LazyObject -_PostProcessT = Iterator[Tuple[str, str, bool] | Tuple[str, None, RuntimeError]] +_PostProcessT = Iterator[tuple[str, str, bool] | tuple[str, None, RuntimeError]] class StaticFilesStorage(FileSystemStorage): base_location: str @@ -25,8 +26,8 @@ class HashedFilesMixin: def file_hash(self, name: str, content: File = ...) -> str: ... 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 post_process(self, paths: Dict[str, Any], dry_run: bool = ..., **options: Any) -> _PostProcessT: ... + def url_converter(self, name: str, hashed_files: dict[str, Any], template: str = ...) -> Callable: ... + 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: ... def stored_name(self, name: str) -> str: ... @@ -38,7 +39,7 @@ class ManifestFilesMixin(HashedFilesMixin): keep_intermediate_files: bool def __init__(self, *args: Any, **kwargs: Any) -> None: ... def read_manifest(self) -> str: ... - def load_manifest(self) -> Dict[str, Any]: ... + def load_manifest(self) -> dict[str, Any]: ... def save_manifest(self) -> None: ... def post_process(self, *args: Any, **kwargs: Any) -> _PostProcessT: ... def stored_name(self, name: str) -> str: ... diff --git a/django-stubs/contrib/staticfiles/urls.pyi b/django-stubs/contrib/staticfiles/urls.pyi index c8344e9ec..b6825710e 100644 --- a/django-stubs/contrib/staticfiles/urls.pyi +++ b/django-stubs/contrib/staticfiles/urls.pyi @@ -1,7 +1,5 @@ -from typing import List - from django.urls import URLPattern, _AnyURL -urlpatterns: List[_AnyURL] +urlpatterns: list[_AnyURL] -def staticfiles_urlpatterns(prefix: str | None = ...) -> List[URLPattern]: ... +def staticfiles_urlpatterns(prefix: str | None = ...) -> list[URLPattern]: ... diff --git a/django-stubs/contrib/staticfiles/utils.pyi b/django-stubs/contrib/staticfiles/utils.pyi index 743293026..a9e54fd5e 100644 --- a/django-stubs/contrib/staticfiles/utils.pyi +++ b/django-stubs/contrib/staticfiles/utils.pyi @@ -1,4 +1,4 @@ -from typing import Iterable, Iterator +from collections.abc import Iterable, Iterator from django.core.files.storage import Storage diff --git a/django-stubs/contrib/syndication/views.pyi b/django-stubs/contrib/syndication/views.pyi index f8c7bc7fb..4bc241df7 100644 --- a/django-stubs/contrib/syndication/views.pyi +++ b/django-stubs/contrib/syndication/views.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Generic, List, Type, TypeVar +from typing import Any, Generic, TypeVar from django.core.exceptions import ObjectDoesNotExist from django.db.models import Model @@ -14,7 +14,7 @@ _Item = TypeVar("_Item", bound=Model) _Object = TypeVar("_Object") class Feed(Generic[_Item, _Object]): - feed_type: Type[SyndicationFeed] + feed_type: type[SyndicationFeed] title_template: str | None description_template: str | None language: str | None @@ -47,11 +47,11 @@ class Feed(Generic[_Item, _Object]): item_comments: Any def __call__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def get_object(self, request: HttpRequest, *args: Any, **kwargs: Any) -> _Object | None: ... - def feed_extra_kwargs(self, obj: _Object) -> Dict[Any, Any]: ... - def item_extra_kwargs(self, item: _Item) -> Dict[Any, Any]: ... - def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... + def feed_extra_kwargs(self, obj: _Object) -> dict[Any, Any]: ... + def item_extra_kwargs(self, item: _Item) -> dict[Any, Any]: ... + def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ... def get_feed(self, obj: _Object, request: HttpRequest) -> SyndicationFeed: ... def item_title(self, item: _Item) -> str: ... def item_description(self, item: _Item) -> str: ... def item_link(self, item: _Item) -> str: ... - def item_enclosures(self, item: _Item) -> List[Enclosure]: ... + def item_enclosures(self, item: _Item) -> list[Enclosure]: ... diff --git a/django-stubs/core/cache/__init__.pyi b/django-stubs/core/cache/__init__.pyi index 8a0e9d608..cf25cd760 100644 --- a/django-stubs/core/cache/__init__.pyi +++ b/django-stubs/core/cache/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Type +from typing import Any from django.utils.connection import BaseConnectionHandler, ConnectionProxy @@ -10,9 +10,9 @@ DEFAULT_CACHE_ALIAS: str class CacheHandler(BaseConnectionHandler): settings_name: str - exception_class: Type[Exception] + exception_class: type[Exception] def create_connection(self, alias: str) -> BaseCache: ... - def all(self, initialized_only: bool = ...) -> List[BaseCache]: ... + def all(self, initialized_only: bool = ...) -> list[BaseCache]: ... def close_caches(**kwargs: Any) -> None: ... diff --git a/django-stubs/core/cache/backends/base.pyi b/django-stubs/core/cache/backends/base.pyi index 63f3b0a5f..35ff48e22 100644 --- a/django-stubs/core/cache/backends/base.pyi +++ b/django-stubs/core/cache/backends/base.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, Iterable, List +from collections.abc import Callable, Iterable +from typing import Any from django.core.exceptions import ImproperlyConfigured @@ -20,7 +21,7 @@ class BaseCache: key_prefix: str version: int key_func: Callable - def __init__(self, params: Dict[str, Any]) -> None: ... + def __init__(self, params: dict[str, Any]) -> None: ... def get_backend_timeout(self, timeout: float | None = ...) -> float | None: ... def make_key(self, key: Any, version: int | None = ...) -> str: ... def validate_key(self, key: Any) -> None: ... @@ -35,8 +36,8 @@ class BaseCache: async def atouch(self, key: Any, timeout: float | None = ..., version: int | None = ...) -> bool: ... def delete(self, key: Any, version: int | None = ...) -> None: ... async def adelete(self, key: Any, version: int | None = ...) -> None: ... - def get_many(self, keys: Iterable[Any], version: int | None = ...) -> Dict[Any, Any]: ... - async def aget_many(self, keys: Iterable[Any], version: int | None = ...) -> Dict[Any, Any]: ... + def get_many(self, keys: Iterable[Any], version: int | None = ...) -> dict[Any, Any]: ... + async def aget_many(self, keys: Iterable[Any], version: int | None = ...) -> dict[Any, Any]: ... def get_or_set( self, key: Any, default: Any | None, timeout: float | None = ..., version: int | None = ... ) -> Any | None: ... @@ -50,10 +51,10 @@ class BaseCache: def decr(self, key: Any, delta: int = ..., version: int | None = ...) -> int: ... async def adecr(self, key: Any, delta: int = ..., version: int | None = ...) -> int: ... def __contains__(self, key: Any) -> bool: ... - def set_many(self, data: Dict[Any, Any], timeout: float | None = ..., version: int | None = ...) -> List[Any]: ... + def set_many(self, data: dict[Any, Any], timeout: float | None = ..., version: int | None = ...) -> list[Any]: ... async def aset_many( - self, data: Dict[Any, Any], timeout: float | None = ..., version: int | None = ... - ) -> List[Any]: ... + self, data: dict[Any, Any], timeout: float | None = ..., version: int | None = ... + ) -> list[Any]: ... def delete_many(self, keys: Iterable[Any], version: int | None = ...) -> None: ... async def adelete_many(self, keys: Iterable[Any], version: int | None = ...) -> None: ... def clear(self) -> None: ... diff --git a/django-stubs/core/cache/backends/db.pyi b/django-stubs/core/cache/backends/db.pyi index f88bd7c10..38de15b5e 100644 --- a/django-stubs/core/cache/backends/db.pyi +++ b/django-stubs/core/cache/backends/db.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict +from typing import Any from django.core.cache.backends.base import BaseCache from django.utils.functional import _StrOrPromise @@ -18,6 +18,6 @@ class Options: class BaseDatabaseCache(BaseCache): cache_model_class: Any - def __init__(self, table: str, params: Dict[str, Any]) -> None: ... + def __init__(self, table: str, params: dict[str, Any]) -> None: ... class DatabaseCache(BaseDatabaseCache): ... diff --git a/django-stubs/core/cache/backends/filebased.pyi b/django-stubs/core/cache/backends/filebased.pyi index 8a0bb424e..d4159de83 100644 --- a/django-stubs/core/cache/backends/filebased.pyi +++ b/django-stubs/core/cache/backends/filebased.pyi @@ -1,7 +1,7 @@ -from typing import Any, Dict +from typing import Any from django.core.cache.backends.base import BaseCache class FileBasedCache(BaseCache): cache_suffix: str - def __init__(self, dir: str, params: Dict[str, Any]) -> None: ... + def __init__(self, dir: str, params: dict[str, Any]) -> None: ... diff --git a/django-stubs/core/cache/backends/locmem.pyi b/django-stubs/core/cache/backends/locmem.pyi index ee9d36861..3a158d074 100644 --- a/django-stubs/core/cache/backends/locmem.pyi +++ b/django-stubs/core/cache/backends/locmem.pyi @@ -1,6 +1,6 @@ -from typing import Any, Dict +from typing import Any from django.core.cache.backends.base import BaseCache class LocMemCache(BaseCache): - def __init__(self, name: str, params: Dict[str, Any]) -> None: ... + def __init__(self, name: str, params: dict[str, Any]) -> None: ... diff --git a/django-stubs/core/cache/backends/memcached.pyi b/django-stubs/core/cache/backends/memcached.pyi index 1adcdc2e0..07785ed74 100644 --- a/django-stubs/core/cache/backends/memcached.pyi +++ b/django-stubs/core/cache/backends/memcached.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence from types import ModuleType -from typing import Any, Dict, Sequence, Type +from typing import Any from django.core.cache.backends.base import BaseCache @@ -7,13 +8,13 @@ class BaseMemcachedCache(BaseCache): def __init__( self, server: str | Sequence[str], - params: Dict[str, Any], + params: dict[str, Any], library: ModuleType, - value_not_found_exception: Type[BaseException], + value_not_found_exception: type[BaseException], ) -> None: ... class MemcachedCache(BaseMemcachedCache): - def __init__(self, server: str | Sequence[str], params: Dict[str, Any]) -> None: ... + def __init__(self, server: str | Sequence[str], params: dict[str, Any]) -> None: ... class PyLibMCCache(BaseMemcachedCache): - def __init__(self, server: str | Sequence[str], params: Dict[str, Any]) -> None: ... + def __init__(self, server: str | Sequence[str], params: dict[str, Any]) -> None: ... diff --git a/django-stubs/core/cache/utils.pyi b/django-stubs/core/cache/utils.pyi index 1d4a3dbf2..7a5e8b6ae 100644 --- a/django-stubs/core/cache/utils.pyi +++ b/django-stubs/core/cache/utils.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable +from collections.abc import Iterable +from typing import Any TEMPLATE_FRAGMENT_KEY_TEMPLATE: str diff --git a/django-stubs/core/checks/async_checks.pyi b/django-stubs/core/checks/async_checks.pyi index 8039902af..a4877a4ef 100644 --- a/django-stubs/core/checks/async_checks.pyi +++ b/django-stubs/core/checks/async_checks.pyi @@ -1,4 +1,5 @@ -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.core.checks.messages import Error diff --git a/django-stubs/core/checks/caches.pyi b/django-stubs/core/checks/caches.pyi index 2ff4ef50a..01ec34faa 100644 --- a/django-stubs/core/checks/caches.pyi +++ b/django-stubs/core/checks/caches.pyi @@ -1,4 +1,5 @@ -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.core.checks.messages import Error, Warning diff --git a/django-stubs/core/checks/database.pyi b/django-stubs/core/checks/database.pyi index 4f745579a..707bcec01 100644 --- a/django-stubs/core/checks/database.pyi +++ b/django-stubs/core/checks/database.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, Sequence +from collections.abc import Iterable, Sequence +from typing import Any from django.core.checks import CheckMessage diff --git a/django-stubs/core/checks/model_checks.pyi b/django-stubs/core/checks/model_checks.pyi index fb48f9c66..cb9a9012a 100644 --- a/django-stubs/core/checks/model_checks.pyi +++ b/django-stubs/core/checks/model_checks.pyi @@ -1,4 +1,5 @@ -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage diff --git a/django-stubs/core/checks/registry.pyi b/django-stubs/core/checks/registry.pyi index 74951a427..59f7cc90f 100644 --- a/django-stubs/core/checks/registry.pyi +++ b/django-stubs/core/checks/registry.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, List, Sequence, Set, TypeVar +from collections.abc import Callable, Sequence +from typing import Any, TypeVar from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage @@ -26,8 +27,8 @@ class _ProcessedCheckCallable(Protocol[_C]): __call__: _C class CheckRegistry: - registered_checks: Set[_ProcessedCheckCallable] - deployment_checks: Set[_ProcessedCheckCallable] + registered_checks: set[_ProcessedCheckCallable] + deployment_checks: set[_ProcessedCheckCallable] def __init__(self) -> None: ... def register( self, check: _CheckCallable | str | None = ..., *tags: str, **kwargs: Any @@ -38,10 +39,10 @@ class CheckRegistry: tags: Sequence[str] | None = ..., include_deployment_checks: bool = ..., databases: Any | None = ..., - ) -> List[CheckMessage]: ... + ) -> list[CheckMessage]: ... def tag_exists(self, tag: str, include_deployment_checks: bool = ...) -> bool: ... - def tags_available(self, deployment_checks: bool = ...) -> Set[str]: ... - def get_checks(self, include_deployment_checks: bool = ...) -> List[_ProcessedCheckCallable]: ... + def tags_available(self, deployment_checks: bool = ...) -> set[str]: ... + def get_checks(self, include_deployment_checks: bool = ...) -> list[_ProcessedCheckCallable]: ... registry: CheckRegistry register: Any diff --git a/django-stubs/core/checks/security/base.pyi b/django-stubs/core/checks/security/base.pyi index 4de228cd4..431b11f52 100644 --- a/django-stubs/core/checks/security/base.pyi +++ b/django-stubs/core/checks/security/base.pyi @@ -1,4 +1,5 @@ -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage, Error, Warning diff --git a/django-stubs/core/checks/security/csrf.pyi b/django-stubs/core/checks/security/csrf.pyi index fcbb046d5..27396bcd8 100644 --- a/django-stubs/core/checks/security/csrf.pyi +++ b/django-stubs/core/checks/security/csrf.pyi @@ -1,4 +1,5 @@ -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.core.checks.messages import Warning diff --git a/django-stubs/core/checks/security/sessions.pyi b/django-stubs/core/checks/security/sessions.pyi index 41a9fb1db..c8cbaefce 100644 --- a/django-stubs/core/checks/security/sessions.pyi +++ b/django-stubs/core/checks/security/sessions.pyi @@ -1,4 +1,5 @@ -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.core.checks.messages import Warning diff --git a/django-stubs/core/checks/templates.pyi b/django-stubs/core/checks/templates.pyi index 28ab6fe35..d72d8b3fd 100644 --- a/django-stubs/core/checks/templates.pyi +++ b/django-stubs/core/checks/templates.pyi @@ -1,4 +1,5 @@ -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.core.checks.messages import Error diff --git a/django-stubs/core/checks/translation.pyi b/django-stubs/core/checks/translation.pyi index e46691a58..07ee32180 100644 --- a/django-stubs/core/checks/translation.pyi +++ b/django-stubs/core/checks/translation.pyi @@ -1,4 +1,5 @@ -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig diff --git a/django-stubs/core/checks/urls.pyi b/django-stubs/core/checks/urls.pyi index 319035a88..5c4c6a1d5 100644 --- a/django-stubs/core/checks/urls.pyi +++ b/django-stubs/core/checks/urls.pyi @@ -1,4 +1,5 @@ -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage, Error, Warning diff --git a/django-stubs/core/exceptions.pyi b/django-stubs/core/exceptions.pyi index 7552effe0..3e49071c2 100644 --- a/django-stubs/core/exceptions.pyi +++ b/django-stubs/core/exceptions.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterator, List, Tuple +from collections.abc import Iterator +from typing import Any from django.utils.functional import _StrPromise from typing_extensions import Literal @@ -28,24 +29,24 @@ class FieldError(Exception): ... NON_FIELD_ERRORS: Literal["__all__"] class ValidationError(Exception): - error_dict: Dict[str, List[ValidationError]] - error_list: List[ValidationError] + error_dict: dict[str, list[ValidationError]] + error_list: list[ValidationError] message: str code: str | None - params: Dict[str, Any] | None + params: dict[str, Any] | None def __init__( self, # Accepts arbitrarily nested data structure, mypy doesn't allow describing it accurately. - message: str | _StrPromise | ValidationError | Dict[str, Any] | List[Any], + message: str | _StrPromise | ValidationError | dict[str, Any] | list[Any], code: str | None = ..., - params: Dict[str, Any] | None = ..., + params: dict[str, Any] | None = ..., ) -> None: ... @property - def message_dict(self) -> Dict[str, List[str]]: ... + def message_dict(self) -> dict[str, list[str]]: ... @property - def messages(self) -> List[str]: ... - def update_error_dict(self, error_dict: Dict[str, List[ValidationError]]) -> Dict[str, List[ValidationError]]: ... - def __iter__(self) -> Iterator[Tuple[str, List[str]] | str]: ... + def messages(self) -> list[str]: ... + def update_error_dict(self, error_dict: dict[str, list[ValidationError]]) -> dict[str, list[ValidationError]]: ... + def __iter__(self) -> Iterator[tuple[str, list[str]] | str]: ... class EmptyResultSet(Exception): ... class SynchronousOnlyOperation(Exception): ... diff --git a/django-stubs/core/files/base.pyi b/django-stubs/core/files/base.pyi index d10c51452..6ea00895c 100644 --- a/django-stubs/core/files/base.pyi +++ b/django-stubs/core/files/base.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterator from types import TracebackType -from typing import IO, AnyStr, Iterator, Type, TypeVar, type_check_only +from typing import IO, AnyStr, TypeVar, type_check_only from django.core.files.utils import FileProxyMixin @@ -23,7 +24,7 @@ class File(FileProxyMixin[AnyStr], IO[AnyStr]): def __enter__(self: _T) -> _T: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... diff --git a/django-stubs/core/files/images.pyi b/django-stubs/core/files/images.pyi index 04fa0b3a4..5a7bb8500 100644 --- a/django-stubs/core/files/images.pyi +++ b/django-stubs/core/files/images.pyi @@ -1,4 +1,4 @@ -from typing import IO, Tuple +from typing import IO from django.core.files import File from django.utils._os import _PathCompatible @@ -11,4 +11,4 @@ class ImageFile(File[bytes]): def get_image_dimensions( file_or_path: _PathCompatible | IO[bytes], close: bool = ... -) -> Tuple[int | None, int | None]: ... +) -> tuple[int | None, int | None]: ... diff --git a/django-stubs/core/files/storage.pyi b/django-stubs/core/files/storage.pyi index 5d64f10d1..d34b0cded 100644 --- a/django-stubs/core/files/storage.pyi +++ b/django-stubs/core/files/storage.pyi @@ -1,5 +1,5 @@ from datetime import datetime -from typing import IO, Any, List, Tuple, Type +from typing import IO, Any from django.core.files.base import File from django.utils._os import _PathCompatible @@ -15,7 +15,7 @@ class Storage: def path(self, name: str) -> str: ... def delete(self, name: str) -> None: ... def exists(self, name: str) -> bool: ... - def listdir(self, path: str) -> Tuple[List[str], List[str]]: ... + def listdir(self, path: str) -> tuple[list[str], list[str]]: ... def size(self, name: str) -> int: ... def url(self, name: str | None) -> str: ... def get_accessed_time(self, name: str) -> datetime: ... @@ -46,4 +46,4 @@ class DefaultStorage(LazyObject): ... default_storage: Any -def get_storage_class(import_path: str | None = ...) -> Type[Storage]: ... +def get_storage_class(import_path: str | None = ...) -> type[Storage]: ... diff --git a/django-stubs/core/files/uploadedfile.pyi b/django-stubs/core/files/uploadedfile.pyi index 35e11cade..2c63cfa66 100644 --- a/django-stubs/core/files/uploadedfile.pyi +++ b/django-stubs/core/files/uploadedfile.pyi @@ -1,11 +1,11 @@ -from typing import IO, Dict, Type, TypeVar +from typing import IO, TypeVar from django.core.files.base import File class UploadedFile(File): content_type: str | None charset: str | None - content_type_extra: Dict[str, str] | None + content_type_extra: dict[str, str] | None size: int | None # type: ignore[assignment] name: str | None def __init__( @@ -15,7 +15,7 @@ class UploadedFile(File): content_type: str | None = ..., size: int | None = ..., charset: str | None = ..., - content_type_extra: Dict[str, str] | None = ..., + content_type_extra: dict[str, str] | None = ..., ) -> None: ... class TemporaryUploadedFile(UploadedFile): @@ -25,7 +25,7 @@ class TemporaryUploadedFile(UploadedFile): content_type: str | None, size: int | None, charset: str | None, - content_type_extra: Dict[str, str] | None = ..., + content_type_extra: dict[str, str] | None = ..., ) -> None: ... def temporary_file_path(self) -> str: ... @@ -39,7 +39,7 @@ class InMemoryUploadedFile(UploadedFile): content_type: str | None, size: int | None, charset: str | None, - content_type_extra: Dict[str, str] = ..., + content_type_extra: dict[str, str] = ..., ) -> None: ... _C = TypeVar("_C", bound="SimpleUploadedFile") @@ -47,4 +47,4 @@ _C = TypeVar("_C", bound="SimpleUploadedFile") class SimpleUploadedFile(InMemoryUploadedFile): def __init__(self, name: str, content: bytes | None, content_type: str = ...) -> None: ... @classmethod - def from_dict(cls: Type[_C], file_dict: Dict[str, str | bytes]) -> _C: ... + def from_dict(cls: type[_C], file_dict: dict[str, str | bytes]) -> _C: ... diff --git a/django-stubs/core/files/uploadhandler.pyi b/django-stubs/core/files/uploadhandler.pyi index 3a01fbeb2..f1c936eae 100644 --- a/django-stubs/core/files/uploadhandler.pyi +++ b/django-stubs/core/files/uploadhandler.pyi @@ -1,6 +1,6 @@ # Stubs for django.core.files.uploadhandler (Python 3.5) -from typing import IO, Any, Dict, Tuple +from typing import IO, Any from django.core.files.uploadedfile import TemporaryUploadedFile, UploadedFile from django.http.request import HttpRequest, QueryDict @@ -22,18 +22,18 @@ class FileUploadHandler: content_type: str | None content_length: int | None charset: str | None - content_type_extra: Dict[str, str] | None + content_type_extra: dict[str, str] | None request: HttpRequest | None field_name: str def __init__(self, request: HttpRequest | None = ...) -> None: ... def handle_raw_input( self, input_data: IO[bytes], - META: Dict[str, str], + META: dict[str, str], content_length: int, boundary: str, encoding: str | None = ..., - ) -> Tuple[QueryDict, MultiValueDict[str, UploadedFile]] | None: ... + ) -> tuple[QueryDict, MultiValueDict[str, UploadedFile]] | None: ... def new_file( self, field_name: str, @@ -41,7 +41,7 @@ class FileUploadHandler: content_type: str, content_length: int | None, charset: str | None = ..., - content_type_extra: Dict[str, str] | None = ..., + content_type_extra: dict[str, str] | None = ..., ) -> None: ... def receive_data_chunk(self, raw_data: bytes, start: int) -> bytes | None: ... def file_complete(self, file_size: int) -> UploadedFile | None: ... @@ -57,7 +57,7 @@ class TemporaryFileUploadHandler(FileUploadHandler): content_type: str, content_length: int | None, charset: str | None = ..., - content_type_extra: Dict[str, str] | None = ..., + content_type_extra: dict[str, str] | None = ..., ) -> None: ... def receive_data_chunk(self, raw_data: bytes, start: int) -> bytes | None: ... def file_complete(self, file_size: int) -> UploadedFile | None: ... @@ -69,11 +69,11 @@ class MemoryFileUploadHandler(FileUploadHandler): def handle_raw_input( self, input_data: IO[bytes], - META: Dict[str, str], + META: dict[str, str], content_length: int, boundary: str, encoding: str | None = ..., - ) -> Tuple[QueryDict, MultiValueDict[str, UploadedFile]] | None: ... + ) -> tuple[QueryDict, MultiValueDict[str, UploadedFile]] | None: ... def new_file( self, field_name: str, @@ -81,7 +81,7 @@ class MemoryFileUploadHandler(FileUploadHandler): content_type: str, content_length: int | None, charset: str | None = ..., - content_type_extra: Dict[str, str] | None = ..., + content_type_extra: dict[str, str] | None = ..., ) -> None: ... def receive_data_chunk(self, raw_data: bytes, start: int) -> bytes | None: ... def file_complete(self, file_size: int) -> UploadedFile | None: ... diff --git a/django-stubs/core/files/utils.pyi b/django-stubs/core/files/utils.pyi index aa6f70279..5f937cc77 100644 --- a/django-stubs/core/files/utils.pyi +++ b/django-stubs/core/files/utils.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, AnyStr, Generic, Iterator +from collections.abc import Iterator +from typing import IO, Any, AnyStr, Generic from django.utils._os import _PathCompatible diff --git a/django-stubs/core/handlers/asgi.pyi b/django-stubs/core/handlers/asgi.pyi index 6a606fd0b..b399f4262 100644 --- a/django-stubs/core/handlers/asgi.pyi +++ b/django-stubs/core/handlers/asgi.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, Awaitable, Callable, Dict, Iterator, Mapping, Sequence, Tuple, Type, TypeVar +from collections.abc import Callable, Iterator, Mapping, Sequence +from typing import IO, Any, Awaitable, TypeVar from django.core.handlers import base as base from django.http.request import HttpRequest, _ImmutableQueryDict @@ -17,35 +18,35 @@ class ASGIRequest(HttpRequest): path_info: str path: str method: str - META: Dict[str, Any] + META: dict[str, Any] def __init__(self, scope: Mapping[str, Any], body_file: IO[bytes]) -> None: ... @property def GET(self) -> _ImmutableQueryDict: ... # type: ignore POST: _ImmutableQueryDict FILES: MultiValueDict @property - def COOKIES(self) -> Dict[str, str]: ... # type: ignore + def COOKIES(self) -> dict[str, str]: ... # type: ignore _T = TypeVar("_T") class ASGIHandler(base.BaseHandler): - request_class: Type[ASGIRequest] + request_class: type[ASGIRequest] chunk_size: int def __init__(self) -> None: ... async def __call__( self, - scope: Dict[str, Any], + scope: dict[str, Any], receive: _ReceiveCallback, send: _SendCallback, ) -> None: ... async def read_body(self, receive: _ReceiveCallback) -> IO[bytes]: ... def create_request( self, scope: Mapping[str, Any], body_file: IO[bytes] - ) -> Tuple[ASGIRequest, None] | Tuple[None, HttpResponseBase]: ... + ) -> tuple[ASGIRequest, None] | tuple[None, HttpResponseBase]: ... def handle_uncaught_exception( self, request: HttpRequest, resolver: URLResolver, exc_info: Any ) -> HttpResponseBase: ... async def send_response(self, response: HttpResponseBase, send: _SendCallback) -> None: ... @classmethod - def chunk_bytes(cls, data: Sequence[_T]) -> Iterator[Tuple[Sequence[_T], bool]]: ... + def chunk_bytes(cls, data: Sequence[_T]) -> Iterator[tuple[Sequence[_T], bool]]: ... def get_script_prefix(self, scope: Mapping[str, Any]) -> str: ... diff --git a/django-stubs/core/handlers/base.pyi b/django-stubs/core/handlers/base.pyi index 411fc42f2..15cdcd3ff 100644 --- a/django-stubs/core/handlers/base.pyi +++ b/django-stubs/core/handlers/base.pyi @@ -1,4 +1,5 @@ -from typing import Any, Awaitable, Callable +from collections.abc import Callable +from typing import Any, Awaitable from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponseBase diff --git a/django-stubs/core/handlers/exception.pyi b/django-stubs/core/handlers/exception.pyi index 6916bc3ab..488ee3864 100644 --- a/django-stubs/core/handlers/exception.pyi +++ b/django-stubs/core/handlers/exception.pyi @@ -1,4 +1,5 @@ -from typing import Any, Awaitable, Callable +from collections.abc import Callable +from typing import Any, Awaitable from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponseBase diff --git a/django-stubs/core/handlers/wsgi.pyi b/django-stubs/core/handlers/wsgi.pyi index b4b0117f8..e529a45bc 100644 --- a/django-stubs/core/handlers/wsgi.pyi +++ b/django-stubs/core/handlers/wsgi.pyi @@ -1,12 +1,13 @@ +from collections.abc import Callable, Sequence from io import BytesIO -from typing import Any, Callable, Dict, Sequence, Tuple, Type +from typing import Any from django.contrib.sessions.backends.base import SessionBase from django.core.handlers import base from django.http import HttpRequest from django.http.response import HttpResponseBase -_WSGIEnviron = Dict[str, Any] +_WSGIEnviron = dict[str, Any] class LimitedStream: stream: BytesIO @@ -24,12 +25,12 @@ class WSGIRequest(HttpRequest): def __init__(self, environ: _WSGIEnviron) -> None: ... class WSGIHandler(base.BaseHandler): - request_class: Type[WSGIRequest] + request_class: type[WSGIRequest] def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __call__( self, environ: _WSGIEnviron, - start_response: Callable[[str, Sequence[Tuple[str, str]]], None], + start_response: Callable[[str, Sequence[tuple[str, str]]], None], ) -> HttpResponseBase: ... def get_path_info(environ: _WSGIEnviron) -> str: ... diff --git a/django-stubs/core/mail/__init__.pyi b/django-stubs/core/mail/__init__.pyi index 6a103cc50..5d0560f55 100644 --- a/django-stubs/core/mail/__init__.pyi +++ b/django-stubs/core/mail/__init__.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, List, Sequence, Tuple +from collections.abc import Iterable, Sequence +from typing import Any from .message import DEFAULT_ATTACHMENT_MIME_TYPE as DEFAULT_ATTACHMENT_MIME_TYPE from .message import BadHeaderError as BadHeaderError @@ -23,7 +24,7 @@ def send_mail( html_message: str | None = ..., ) -> int: ... def send_mass_mail( - datatuple: Iterable[Tuple[str, str, str, List[str]]], + datatuple: Iterable[tuple[str, str, str, list[str]]], fail_silently: bool = ..., auth_user: str | None = ..., auth_password: str | None = ..., @@ -44,4 +45,4 @@ def mail_managers( html_message: str | None = ..., ) -> None: ... -outbox: List[EmailMessage] +outbox: list[EmailMessage] diff --git a/django-stubs/core/mail/backends/base.pyi b/django-stubs/core/mail/backends/base.pyi index 693b9ee3b..369e41c74 100644 --- a/django-stubs/core/mail/backends/base.pyi +++ b/django-stubs/core/mail/backends/base.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence from types import TracebackType -from typing import Any, Sequence, Type, TypeVar +from typing import Any, TypeVar from django.core.mail.message import EmailMessage @@ -13,7 +14,7 @@ class BaseEmailBackend: def __enter__(self: _T) -> _T: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... diff --git a/django-stubs/core/mail/message.pyi b/django-stubs/core/mail/message.pyi index 6de2c7dce..5f15d3759 100644 --- a/django-stubs/core/mail/message.pyi +++ b/django-stubs/core/mail/message.pyi @@ -1,3 +1,4 @@ +from collections.abc import Sequence from email import charset as Charset from email._policybase import Policy from email.message import Message @@ -5,7 +6,7 @@ from email.mime.base import MIMEBase from email.mime.message import MIMEMessage from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText -from typing import Any, Dict, List, Sequence, Set, Tuple, overload +from typing import Any, overload utf8_charset: Any utf8_charset_qp: Any @@ -14,24 +15,24 @@ RFC5322_EMAIL_LINE_LENGTH_LIMIT: int class BadHeaderError(ValueError): ... -ADDRESS_HEADERS: Set[str] +ADDRESS_HEADERS: set[str] -def forbid_multi_line_headers(name: str, val: str, encoding: str) -> Tuple[str, str]: ... -def sanitize_address(addr: Tuple[str, str] | str, encoding: str) -> str: ... +def forbid_multi_line_headers(name: str, val: str, encoding: str) -> tuple[str, str]: ... +def sanitize_address(addr: tuple[str, str] | str, encoding: str) -> str: ... class MIMEMixin: def as_string(self, unixfrom: bool = ..., linesep: str = "\n") -> str: ... def as_bytes(self, unixfrom: bool = ..., linesep: str = "\n") -> bytes: ... class SafeMIMEMessage(MIMEMixin, MIMEMessage): # type: ignore - defects: List[Any] + defects: list[Any] epilogue: Any policy: Policy preamble: Any def __setitem__(self, name: str, val: str) -> None: ... class SafeMIMEText(MIMEMixin, MIMEText): # type: ignore - defects: List[Any] + defects: list[Any] epilogue: None policy: Policy preamble: None @@ -39,11 +40,11 @@ class SafeMIMEText(MIMEMixin, MIMEText): # type: ignore def __init__(self, _text: str, _subtype: str = ..., _charset: str = ...) -> None: ... def __setitem__(self, name: str, val: str) -> None: ... def set_payload( - self, payload: List[Message] | str | bytes, charset: str | Charset.Charset | None = ... + self, payload: list[Message] | str | bytes, charset: str | Charset.Charset | None = ... ) -> None: ... class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): # type: ignore - defects: List[Any] + defects: list[Any] epilogue: None policy: Policy preamble: None @@ -60,22 +61,22 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): # type: ignore _AttachmentContent = bytes | EmailMessage | Message | SafeMIMEText | str _AttachmentTuple = ( - Tuple[str, _AttachmentContent] | Tuple[str | None, _AttachmentContent, str] | Tuple[str, _AttachmentContent, None] + tuple[str, _AttachmentContent] | tuple[str | None, _AttachmentContent, str] | tuple[str, _AttachmentContent, None] ) class EmailMessage: content_subtype: str mixed_subtype: str encoding: Any - to: List[str] - cc: List[Any] - bcc: List[Any] - reply_to: List[Any] + to: list[str] + cc: list[Any] + bcc: list[Any] + reply_to: list[Any] from_email: str subject: str body: str - attachments: List[Any] - extra_headers: Dict[Any, Any] + attachments: list[Any] + extra_headers: dict[Any, Any] connection: Any def __init__( self, @@ -86,14 +87,14 @@ class EmailMessage: bcc: Sequence[str] | None = ..., connection: Any | None = ..., attachments: Sequence[MIMEBase | _AttachmentTuple] | None = ..., - headers: Dict[str, str] | None = ..., + headers: dict[str, str] | None = ..., cc: Sequence[str] | None = ..., reply_to: Sequence[str] | None = ..., ) -> None: ... def get_connection(self, fail_silently: bool = ...) -> Any: ... # TODO: when typeshed gets more types for email.Message, move it to MIMEMessage, now it has too many false-positives def message(self) -> Any: ... - def recipients(self) -> List[str]: ... + def recipients(self) -> list[str]: ... def send(self, fail_silently: bool = ...) -> int: ... @overload def attach(self, filename: MIMEBase = ..., content: None = ..., mimetype: None = ...) -> None: ... @@ -105,7 +106,7 @@ class EmailMessage: class EmailMultiAlternatives(EmailMessage): alternative_subtype: str - alternatives: List[Tuple[_AttachmentContent, str]] + alternatives: list[tuple[_AttachmentContent, str]] def __init__( self, subject: str = ..., @@ -115,8 +116,8 @@ class EmailMultiAlternatives(EmailMessage): bcc: Sequence[str] | None = ..., connection: Any | None = ..., attachments: Sequence[MIMEBase | _AttachmentTuple] | None = ..., - headers: Dict[str, str] | None = ..., - alternatives: List[Tuple[_AttachmentContent, str]] | None = ..., + headers: dict[str, str] | None = ..., + alternatives: list[tuple[_AttachmentContent, str]] | None = ..., cc: Sequence[str] | None = ..., reply_to: Sequence[str] | None = ..., ) -> None: ... diff --git a/django-stubs/core/management/__init__.pyi b/django-stubs/core/management/__init__.pyi index d0a67f955..3a86f9992 100644 --- a/django-stubs/core/management/__init__.pyi +++ b/django-stubs/core/management/__init__.pyi @@ -1,21 +1,21 @@ -from typing import Any, Dict, List +from typing import Any from .base import BaseCommand as BaseCommand from .base import CommandError as CommandError -def find_commands(management_dir: str) -> List[str]: ... +def find_commands(management_dir: str) -> list[str]: ... def load_command_class(app_name: str, name: str) -> BaseCommand: ... -def get_commands() -> Dict[str, str]: ... +def get_commands() -> dict[str, str]: ... def call_command(command_name: BaseCommand | str, *args: Any, **options: Any) -> str: ... class ManagementUtility: - argv: List[str] + argv: list[str] prog_name: str settings_exception: Exception | None - def __init__(self, argv: List[str] | None = ...) -> None: ... + def __init__(self, argv: list[str] | None = ...) -> None: ... def main_help_text(self, commands_only: bool = ...) -> str: ... def fetch_command(self, subcommand: str) -> BaseCommand: ... def autocomplete(self) -> None: ... def execute(self) -> None: ... -def execute_from_command_line(argv: List[str] | None = ...) -> None: ... +def execute_from_command_line(argv: list[str] | None = ...) -> None: ... diff --git a/django-stubs/core/management/base.pyi b/django-stubs/core/management/base.pyi index b27fc54cd..cbd4bc53c 100644 --- a/django-stubs/core/management/base.pyi +++ b/django-stubs/core/management/base.pyi @@ -1,6 +1,7 @@ from argparse import ArgumentParser, HelpFormatter, Namespace +from collections.abc import Callable, Iterable, Sequence from io import TextIOBase -from typing import Any, Callable, Iterable, List, Sequence, Set, TextIO, Tuple +from typing import Any, TextIO from django.apps.config import AppConfig from django.core.management.color import Style @@ -24,7 +25,7 @@ def handle_default_options(options: Namespace) -> None: ... def no_translations(handle_func: Callable) -> Callable: ... class DjangoHelpFormatter(HelpFormatter): - show_last: Set[str] + show_last: set[str] def add_usage(self, usage: str | None, actions: Iterable[Any], *args: Any, **kwargs: Any) -> Any: ... def add_arguments(self, actions: Any) -> Any: ... @@ -47,8 +48,8 @@ class BaseCommand: output_transaction: bool requires_migrations_checks: bool requires_system_checks: _ListOrTuple[str] | Literal["__all__"] - base_stealth_options: Tuple[str, ...] - stealth_options: Tuple[str, ...] + base_stealth_options: tuple[str, ...] + stealth_options: tuple[str, ...] stdout: OutputWrapper stderr: OutputWrapper style: Style @@ -63,7 +64,7 @@ class BaseCommand: def create_parser(self, prog_name: str, subcommand: str, **kwargs: Any) -> CommandParser: ... def add_arguments(self, parser: CommandParser) -> None: ... def print_help(self, prog_name: str, subcommand: str) -> None: ... - def run_from_argv(self, argv: List[str]) -> None: ... + def run_from_argv(self, argv: list[str]) -> None: ... def execute(self, *args: Any, **options: Any) -> str | None: ... def check( self, diff --git a/django-stubs/core/management/commands/check.pyi b/django-stubs/core/management/commands/check.pyi index e50296dbf..de7918d51 100644 --- a/django-stubs/core/management/commands/check.pyi +++ b/django-stubs/core/management/commands/check.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from django.apps import apps as apps from django.core import checks as checks @@ -7,4 +7,4 @@ from django.core.management.base import BaseCommand as BaseCommand from django.core.management.base import CommandError as CommandError class Command(BaseCommand): - def handle(self, *app_labels: List[str], **options: Any) -> None: ... + def handle(self, *app_labels: list[str], **options: Any) -> None: ... diff --git a/django-stubs/core/management/commands/compilemessages.pyi b/django-stubs/core/management/commands/compilemessages.pyi index d702ff230..38da5fe28 100644 --- a/django-stubs/core/management/commands/compilemessages.pyi +++ b/django-stubs/core/management/commands/compilemessages.pyi @@ -1,6 +1,5 @@ import os from pathlib import Path -from typing import List, Tuple from django.core.management.base import BaseCommand as BaseCommand from django.core.management.base import CommandError as CommandError @@ -14,7 +13,7 @@ def is_writable(path: _PathCompatible) -> bool: ... class Command(BaseCommand): program: str - program_options: List[str] + program_options: list[str] verbosity: int has_errors: bool - def compile_messages(self, locations: List[Tuple[_PathCompatible, _PathCompatible]]) -> None: ... + def compile_messages(self, locations: list[tuple[_PathCompatible, _PathCompatible]]) -> None: ... diff --git a/django-stubs/core/management/commands/createcachetable.pyi b/django-stubs/core/management/commands/createcachetable.pyi index 3304498fc..211b0512a 100644 --- a/django-stubs/core/management/commands/createcachetable.pyi +++ b/django-stubs/core/management/commands/createcachetable.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from django.conf import settings as settings from django.core.cache import caches as caches @@ -14,5 +14,5 @@ from django.db import transaction as transaction class Command(BaseCommand): verbosity: int - def handle(self, *tablenames: List[str], **options: Any) -> None: ... + def handle(self, *tablenames: list[str], **options: Any) -> None: ... def create_table(self, database: str, tablename: str, dry_run: bool) -> None: ... diff --git a/django-stubs/core/management/commands/diffsettings.pyi b/django-stubs/core/management/commands/diffsettings.pyi index 791352eb3..7590990cd 100644 --- a/django-stubs/core/management/commands/diffsettings.pyi +++ b/django-stubs/core/management/commands/diffsettings.pyi @@ -1,13 +1,14 @@ -from typing import Any, Callable, Dict, List +from collections.abc import Callable +from typing import Any from django.core.management.base import BaseCommand as BaseCommand -def module_to_dict(module: Any, omittable: Callable[[str], bool] = ...) -> Dict[str, str]: ... +def module_to_dict(module: Any, omittable: Callable[[str], bool] = ...) -> dict[str, str]: ... class Command(BaseCommand): def output_hash( - self, user_settings: Dict[str, str], default_settings: Dict[str, str], **options: Any - ) -> List[str]: ... + self, user_settings: dict[str, str], default_settings: dict[str, str], **options: Any + ) -> list[str]: ... def output_unified( - self, user_settings: Dict[str, str], default_settings: Dict[str, str], **options: Any - ) -> List[str]: ... + self, user_settings: dict[str, str], default_settings: dict[str, str], **options: Any + ) -> list[str]: ... diff --git a/django-stubs/core/management/commands/flush.pyi b/django-stubs/core/management/commands/flush.pyi index b7127209b..3ea71fc29 100644 --- a/django-stubs/core/management/commands/flush.pyi +++ b/django-stubs/core/management/commands/flush.pyi @@ -1,5 +1,3 @@ -from typing import Tuple - from django.apps import apps as apps from django.core.management.base import BaseCommand as BaseCommand from django.core.management.base import CommandError as CommandError @@ -11,5 +9,5 @@ from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS from django.db import connections as connections class Command(BaseCommand): - stealth_options: Tuple[str] + stealth_options: tuple[str] style: Style diff --git a/django-stubs/core/management/commands/inspectdb.pyi b/django-stubs/core/management/commands/inspectdb.pyi index 50d988df7..fd712f938 100644 --- a/django-stubs/core/management/commands/inspectdb.pyi +++ b/django-stubs/core/management/commands/inspectdb.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, List, Tuple +from collections.abc import Iterable +from typing import Any from django.core.management.base import BaseCommand as BaseCommand from django.core.management.base import CommandError as CommandError @@ -8,15 +9,15 @@ from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.constants import LOOKUP_SEP as LOOKUP_SEP class Command(BaseCommand): - stealth_options: Tuple[str] + stealth_options: tuple[str] db_module: str - def handle_inspection(self, options: Dict[str, Any]) -> Iterable[str]: ... + def handle_inspection(self, options: dict[str, Any]) -> Iterable[str]: ... def normalize_col_name( - self, col_name: str, used_column_names: List[str], is_relation: bool - ) -> Tuple[str, Dict[str, str], List[str]]: ... + self, col_name: str, used_column_names: list[str], is_relation: bool + ) -> tuple[str, dict[str, str], list[str]]: ... def get_field_type( self, connection: BaseDatabaseWrapper, table_name: str, row: Any - ) -> Tuple[str, Dict[str, Any], List[str]]: ... + ) -> tuple[str, dict[str, Any], list[str]]: ... def get_meta( self, table_name: str, constraints: Any, column_to_field_name: Any, is_view: Any, is_partition: Any - ) -> List[str]: ... + ) -> list[str]: ... diff --git a/django-stubs/core/management/commands/loaddata.pyi b/django-stubs/core/management/commands/loaddata.pyi index a0852b1be..d39662701 100644 --- a/django-stubs/core/management/commands/loaddata.pyi +++ b/django-stubs/core/management/commands/loaddata.pyi @@ -1,5 +1,5 @@ import zipfile -from typing import List, Sequence, Set, Tuple, Type +from collections.abc import Sequence from django.apps.config import AppConfig from django.core.management.base import BaseCommand @@ -12,16 +12,16 @@ class Command(BaseCommand): using: str app_label: str verbosity: int - excluded_models: Set[Type[Model]] - excluded_apps: Set[AppConfig] + excluded_models: set[type[Model]] + excluded_apps: set[AppConfig] format: str missing_args_message: str def loaddata(self, fixture_labels: Sequence[str]) -> None: ... def load_label(self, fixture_label: str) -> None: ... - def find_fixtures(self, fixture_label: str) -> List[Tuple[str, str | None, str | None]]: ... + def find_fixtures(self, fixture_label: str) -> list[tuple[str, str | None, str | None]]: ... @property - def fixture_dirs(self) -> List[str]: ... - def parse_name(self, fixture_name: str) -> Tuple[str, str | None, str | None]: ... + def fixture_dirs(self) -> list[str]: ... + def parse_name(self, fixture_name: str) -> tuple[str, str | None, str | None]: ... class SingleZipReader(zipfile.ZipFile): # Incompatible override diff --git a/django-stubs/core/management/commands/makemessages.pyi b/django-stubs/core/management/commands/makemessages.pyi index 77775d596..b9461e841 100644 --- a/django-stubs/core/management/commands/makemessages.pyi +++ b/django-stubs/core/management/commands/makemessages.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Pattern, Type +from typing import Any, Pattern from django.core.management.base import BaseCommand @@ -34,9 +34,9 @@ def normalize_eols(raw_contents: str) -> str: ... def write_pot_file(potfile: str, msgs: str) -> None: ... class Command(BaseCommand): - translatable_file_class: Type[TranslatableFile] - build_file_class: Type[BuildFile] - msgmerge_options: List[str] - msguniq_options: List[str] - msgattrib_options: List[str] - xgettext_options: List[str] + translatable_file_class: type[TranslatableFile] + build_file_class: type[BuildFile] + msgmerge_options: list[str] + msguniq_options: list[str] + msgattrib_options: list[str] + xgettext_options: list[str] diff --git a/django-stubs/core/management/commands/makemigrations.pyi b/django-stubs/core/management/commands/makemigrations.pyi index 3e5ffa56d..ff66935c4 100644 --- a/django-stubs/core/management/commands/makemigrations.pyi +++ b/django-stubs/core/management/commands/makemigrations.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict +from typing import Any from django.apps import apps as apps from django.conf import settings as settings @@ -27,5 +27,5 @@ class Command(BaseCommand): empty: bool migration_name: str include_header: bool - def write_migration_files(self, changes: Dict[str, Any]) -> None: ... - def handle_merge(self, loader: MigrationLoader, conflicts: Dict[str, Any]) -> None: ... + def write_migration_files(self, changes: dict[str, Any]) -> None: ... + def handle_merge(self, loader: MigrationLoader, conflicts: dict[str, Any]) -> None: ... diff --git a/django-stubs/core/management/commands/migrate.pyi b/django-stubs/core/management/commands/migrate.pyi index 319ca5214..af3f423a4 100644 --- a/django-stubs/core/management/commands/migrate.pyi +++ b/django-stubs/core/management/commands/migrate.pyi @@ -1,4 +1,4 @@ -from typing import Any, Container, Tuple +from typing import Any, Container from django.apps import apps as apps from django.core.management.base import BaseCommand as BaseCommand @@ -26,4 +26,4 @@ class Command(BaseCommand): def migration_progress_callback(self, action: str, migration: Any | None = ..., fake: bool = ...) -> None: ... def sync_apps(self, connection: BaseDatabaseWrapper, app_labels: Container[str]) -> None: ... @staticmethod - def describe_operation(operation: Operation, backwards: bool) -> Tuple[str, bool]: ... + def describe_operation(operation: Operation, backwards: bool) -> tuple[str, bool]: ... diff --git a/django-stubs/core/management/commands/runserver.pyi b/django-stubs/core/management/commands/runserver.pyi index 90f167336..31ffcbf36 100644 --- a/django-stubs/core/management/commands/runserver.pyi +++ b/django-stubs/core/management/commands/runserver.pyi @@ -1,4 +1,4 @@ -from typing import Any, Type +from typing import Any from django.core.handlers.wsgi import WSGIHandler from django.core.management.base import BaseCommand @@ -9,7 +9,7 @@ class Command(BaseCommand): default_addr_ipv6: str default_port: str protocol: str - server_cls: Type[WSGIServer] + server_cls: type[WSGIServer] def run(self, **options: Any) -> None: ... def get_handler(self, *args: Any, **options: Any) -> WSGIHandler: ... def inner_run(self, *args: Any, **options: Any) -> None: ... diff --git a/django-stubs/core/management/commands/shell.pyi b/django-stubs/core/management/commands/shell.pyi index fe9bde31f..004b19128 100644 --- a/django-stubs/core/management/commands/shell.pyi +++ b/django-stubs/core/management/commands/shell.pyi @@ -1,11 +1,11 @@ -from typing import Any, List +from typing import Any from django.core.management import BaseCommand as BaseCommand from django.core.management import CommandError as CommandError from django.utils.datastructures import OrderedSet as OrderedSet class Command(BaseCommand): - shells: List[str] + shells: list[str] def ipython(self, options: Any) -> None: ... def bpython(self, options: Any) -> None: ... def python(self, options: Any) -> None: ... diff --git a/django-stubs/core/management/commands/showmigrations.pyi b/django-stubs/core/management/commands/showmigrations.pyi index d5594c621..24cb6dc43 100644 --- a/django-stubs/core/management/commands/showmigrations.pyi +++ b/django-stubs/core/management/commands/showmigrations.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from django.apps import apps as apps from django.core.management.base import BaseCommand as BaseCommand @@ -9,5 +9,5 @@ from django.db.migrations.loader import MigrationLoader as MigrationLoader class Command(BaseCommand): verbosity: int - def show_list(self, connection: BaseDatabaseWrapper, app_names: List[str] | None = ...) -> None: ... - def show_plan(self, connection: BaseDatabaseWrapper, app_names: List[str] | None = ...) -> None: ... + def show_list(self, connection: BaseDatabaseWrapper, app_names: list[str] | None = ...) -> None: ... + def show_plan(self, connection: BaseDatabaseWrapper, app_names: list[str] | None = ...) -> None: ... diff --git a/django-stubs/core/management/sql.pyi b/django-stubs/core/management/sql.pyi index 4cbb59b63..e2ca2eb60 100644 --- a/django-stubs/core/management/sql.pyi +++ b/django-stubs/core/management/sql.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from django.core.management.color import Style from django.db.backends.base.base import BaseDatabaseWrapper @@ -8,6 +8,6 @@ def sql_flush( connection: BaseDatabaseWrapper, reset_sequences: bool = ..., allow_cascade: bool = ..., -) -> List[str]: ... +) -> list[str]: ... def emit_pre_migrate_signal(verbosity: int, interactive: bool, db: str, **kwargs: Any) -> None: ... def emit_post_migrate_signal(verbosity: int, interactive: bool, db: str, **kwargs: Any) -> None: ... diff --git a/django-stubs/core/management/templates.pyi b/django-stubs/core/management/templates.pyi index d0c392128..a37f8f20a 100644 --- a/django-stubs/core/management/templates.pyi +++ b/django-stubs/core/management/templates.pyi @@ -1,11 +1,12 @@ from argparse import ArgumentParser -from typing import Any, Sequence, Tuple +from collections.abc import Sequence +from typing import Any from django.core.management.base import BaseCommand class TemplateCommand(BaseCommand): url_schemes: Sequence[str] - rewrite_template_suffixes: Sequence[Tuple[str, str]] + rewrite_template_suffixes: Sequence[tuple[str, str]] app_or_project: str a_or_an: str paths_to_remove: Sequence[Any] @@ -15,7 +16,7 @@ class TemplateCommand(BaseCommand): def handle_template(self, template: str | None, subdir: str | None) -> str: ... def validate_name(self, name: str, name_or_dir: str = ...) -> None: ... def download(self, url: str) -> str: ... - def splitext(self, the_path: str) -> Tuple[str, str]: ... + def splitext(self, the_path: str) -> tuple[str, str]: ... def extract(self, filename: str) -> str: ... def is_url(self, template: str) -> bool: ... def make_writeable(self, filename: str) -> None: ... diff --git a/django-stubs/core/management/utils.pyi b/django-stubs/core/management/utils.pyi index 664bc56dd..6df277f66 100644 --- a/django-stubs/core/management/utils.pyi +++ b/django-stubs/core/management/utils.pyi @@ -1,18 +1,19 @@ import os -from typing import Any, Iterable, List, Sequence, Set, Tuple, Type +from collections.abc import Iterable, Sequence +from typing import Any from django.apps.config import AppConfig from django.db.models.base import Model -def popen_wrapper(args: List[str], stdout_encoding: str = ...) -> Tuple[str, str, int]: ... -def handle_extensions(extensions: Iterable[str]) -> Set[str]: ... +def popen_wrapper(args: list[str], stdout_encoding: str = ...) -> tuple[str, str, int]: ... +def handle_extensions(extensions: Iterable[str]) -> set[str]: ... def find_command( cmd: str, path: str | Iterable[str] | None = ..., pathext: str | Iterable[str] | None = ..., ) -> str | None: ... def get_random_secret_key() -> str: ... -def parse_apps_and_model_labels(labels: Iterable[str]) -> Tuple[Set[Type[Model]], Set[AppConfig]]: ... +def parse_apps_and_model_labels(labels: Iterable[str]) -> tuple[set[type[Model]], set[AppConfig]]: ... def get_command_line_option(argv: Sequence[Any], option: Any) -> Any | None: ... -def normalize_path_patterns(patterns: Iterable[str]) -> List[str]: ... +def normalize_path_patterns(patterns: Iterable[str]) -> list[str]: ... def is_ignored_path(path: str | os.PathLike, ignore_patterns: Iterable[str]) -> bool: ... diff --git a/django-stubs/core/paginator.pyi b/django-stubs/core/paginator.pyi index 500161db5..9b34b97b4 100644 --- a/django-stubs/core/paginator.pyi +++ b/django-stubs/core/paginator.pyi @@ -1,4 +1,5 @@ -from typing import Generic, Iterable, Iterator, Protocol, Sequence, Sized, TypeVar, overload +from collections.abc import Iterable, Iterator, Sequence, Sized +from typing import Generic, Protocol, TypeVar, overload from django.db.models.base import Model from django.db.models.query import QuerySet diff --git a/django-stubs/core/serializers/__init__.pyi b/django-stubs/core/serializers/__init__.pyi index ec603cb6f..2349d006b 100644 --- a/django-stubs/core/serializers/__init__.pyi +++ b/django-stubs/core/serializers/__init__.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, List, Type +from collections.abc import Callable, Iterable, Iterator +from typing import Any from django.db.models.base import Model @@ -18,12 +19,12 @@ class BadSerializer: def __init__(self, exception: BaseException) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... -def register_serializer(format: str, serializer_module: str, serializers: Dict[str, Any] | None = ...) -> None: ... +def register_serializer(format: str, serializer_module: str, serializers: dict[str, Any] | None = ...) -> None: ... def unregister_serializer(format: str) -> None: ... -def get_serializer(format: str) -> Type[Serializer] | BadSerializer: ... -def get_serializer_formats() -> List[str]: ... -def get_public_serializer_formats() -> List[str]: ... -def get_deserializer(format: str) -> Callable | Type[Deserializer]: ... +def get_serializer(format: str) -> type[Serializer] | BadSerializer: ... +def get_serializer_formats() -> list[str]: ... +def get_public_serializer_formats() -> list[str]: ... +def get_deserializer(format: str) -> Callable | type[Deserializer]: ... def serialize(format: str, queryset: Iterable[Model], **options: Any) -> Any: ... def deserialize(format: str, stream_or_string: Any, **options: Any) -> Iterator[DeserializedObject]: ... -def sort_dependencies(app_list: Iterable[Any], allow_cycles: bool = ...) -> List[Type[Model]]: ... +def sort_dependencies(app_list: Iterable[Any], allow_cycles: bool = ...) -> list[type[Model]]: ... diff --git a/django-stubs/core/serializers/base.pyi b/django-stubs/core/serializers/base.pyi index 88d4c6bce..b1d2be05a 100644 --- a/django-stubs/core/serializers/base.pyi +++ b/django-stubs/core/serializers/base.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, Collection, Dict, Iterable, Sequence, Type +from collections.abc import Collection, Iterable, Sequence +from typing import IO, Any from django.db.models.base import Model from django.db.models.fields import Field @@ -30,9 +31,9 @@ class ProgressBar: class Serializer: internal_use_only: bool - progress_class: Type[ProgressBar] - stream_class: Type[IO[str]] - options: Dict[str, Any] + progress_class: type[ProgressBar] + stream_class: type[IO[str]] + options: dict[str, Any] stream: IO[str] selected_fields: Collection[str] | None use_natural_foreign_keys: bool @@ -60,7 +61,7 @@ class Serializer: def getvalue(self) -> bytes | str | None: ... class Deserializer: - options: Dict[str, Any] + options: dict[str, Any] stream: IO[str] | IO[bytes] def __init__(self, stream_or_string: bytes | str | IO[bytes] | IO[str], **options: Any) -> None: ... def __iter__(self) -> Deserializer: ... @@ -68,18 +69,18 @@ class Deserializer: class DeserializedObject: object: Any - m2m_data: Dict[str, Sequence[Any]] | None - deferred_fields: Dict[Field, Any] + m2m_data: dict[str, Sequence[Any]] | None + deferred_fields: dict[Field, Any] def __init__( self, obj: Model, - m2m_data: Dict[str, Sequence[Any]] | None = ..., - deferred_fields: Dict[Field, Any] | None = ..., + m2m_data: dict[str, Sequence[Any]] | None = ..., + deferred_fields: dict[Field, Any] | None = ..., ) -> None: ... def save(self, save_m2m: bool = ..., using: str | None = ..., **kwargs: Any) -> None: ... def save_deferred_fields(self, using: str | None = ...) -> None: ... -def build_instance(Model: Type[Model], data: Dict[str, Any], db: str) -> Model: ... +def build_instance(Model: type[Model], data: dict[str, Any], db: str) -> Model: ... def deserialize_m2m_values( field: ManyToManyField, field_value: Iterable[Any], using: str | None, handle_forward_references: bool ) -> Sequence[Any] | object: ... diff --git a/django-stubs/core/serializers/json.pyi b/django-stubs/core/serializers/json.pyi index 6618b041a..f50593482 100644 --- a/django-stubs/core/serializers/json.pyi +++ b/django-stubs/core/serializers/json.pyi @@ -1,11 +1,12 @@ import json -from typing import IO, Any, Dict, Iterator +from collections.abc import Iterator +from typing import IO, Any from django.core.serializers.base import DeserializedObject from django.core.serializers.python import Serializer as PythonSerializer class Serializer(PythonSerializer): - json_kwargs: Dict[str, Any] + json_kwargs: dict[str, Any] def Deserializer( stream_or_string: IO[bytes] | IO[str] | bytes | str, **options: Any diff --git a/django-stubs/core/serializers/jsonl.pyi b/django-stubs/core/serializers/jsonl.pyi index 764378eb6..9c7aa5536 100644 --- a/django-stubs/core/serializers/jsonl.pyi +++ b/django-stubs/core/serializers/jsonl.pyi @@ -1,10 +1,11 @@ -from typing import IO, Any, Dict, Iterator +from collections.abc import Iterator +from typing import IO, Any from django.core.serializers.base import DeserializedObject from django.core.serializers.python import Serializer as PythonSerializer class Serializer(PythonSerializer): - json_kwargs: Dict[str, Any] + json_kwargs: dict[str, Any] def Deserializer( stream_or_string: IO[bytes] | IO[str] | bytes | str, **options: Any diff --git a/django-stubs/core/serializers/python.pyi b/django-stubs/core/serializers/python.pyi index b8e9d1e42..c25c910ed 100644 --- a/django-stubs/core/serializers/python.pyi +++ b/django-stubs/core/serializers/python.pyi @@ -1,13 +1,14 @@ -from typing import Any, Dict, Iterator, List +from collections.abc import Iterator +from typing import Any from django.core.serializers import base from django.core.serializers.base import DeserializedObject from django.db.models.base import Model class Serializer(base.Serializer): - objects: List[Any] - def get_dump_object(self, obj: Model) -> Dict[str, Any]: ... + objects: list[Any] + def get_dump_object(self, obj: Model) -> dict[str, Any]: ... def Deserializer( - object_list: List[Dict[str, Any]], *, using: str = ..., ignorenonexistent: bool = ..., **options: Any + object_list: list[dict[str, Any]], *, using: str = ..., ignorenonexistent: bool = ..., **options: Any ) -> Iterator[DeserializedObject]: ... diff --git a/django-stubs/core/serializers/pyyaml.pyi b/django-stubs/core/serializers/pyyaml.pyi index 9c97d2485..d6a439850 100644 --- a/django-stubs/core/serializers/pyyaml.pyi +++ b/django-stubs/core/serializers/pyyaml.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, Iterator +from collections.abc import Iterator +from typing import IO, Any from django.core.serializers.base import DeserializedObject from django.core.serializers.python import Serializer as PythonSerializer diff --git a/django-stubs/core/servers/basehttp.pyi b/django-stubs/core/servers/basehttp.pyi index 82a1f68f9..e74c76357 100644 --- a/django-stubs/core/servers/basehttp.pyi +++ b/django-stubs/core/servers/basehttp.pyi @@ -1,6 +1,6 @@ import socketserver from io import BytesIO -from typing import Any, Dict +from typing import Any from wsgiref import simple_server from django.core.handlers.wsgi import WSGIHandler, WSGIRequest @@ -27,7 +27,7 @@ class WSGIRequestHandler(simple_server.WSGIRequestHandler): protocol_version: str def address_string(self) -> str: ... def log_message(self, format: str, *args: Any) -> None: ... - def get_environ(self) -> Dict[str, str]: ... + def get_environ(self) -> dict[str, str]: ... raw_requestline: bytes requestline: str request_version: str diff --git a/django-stubs/core/signing.pyi b/django-stubs/core/signing.pyi index 0b607cdfc..e1a29b77d 100644 --- a/django-stubs/core/signing.pyi +++ b/django-stubs/core/signing.pyi @@ -1,5 +1,5 @@ from datetime import timedelta -from typing import Any, Dict, Protocol, Type +from typing import Any, Protocol class BadSignature(Exception): ... class SignatureExpired(BadSignature): ... @@ -21,14 +21,14 @@ def dumps( obj: Any, key: bytes | str | None = ..., salt: str = ..., - serializer: Type[Serializer] = ..., + serializer: type[Serializer] = ..., compress: bool = ..., ) -> str: ... def loads( s: str, key: bytes | str | None = ..., salt: str = ..., - serializer: Type[Serializer] = ..., + serializer: type[Serializer] = ..., max_age: int | timedelta | None = ..., ) -> Any: ... @@ -50,13 +50,13 @@ class Signer: def sign_object( self, obj: Any, - serializer: Type[Serializer] = ..., + serializer: type[Serializer] = ..., compress: bool = ..., ) -> str: ... def unsign_object( self, signed_obj: str, - serializer: Type[Serializer] = ..., + serializer: type[Serializer] = ..., **kwargs: Any, ) -> Any: ... diff --git a/django-stubs/core/validators.pyi b/django-stubs/core/validators.pyi index 90d362ad8..22e386220 100644 --- a/django-stubs/core/validators.pyi +++ b/django-stubs/core/validators.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Collection, Sequence, Sized from decimal import Decimal from re import RegexFlag -from typing import Any, Callable, Collection, Dict, List, Pattern, Sequence, Sized, Tuple +from typing import Any, Pattern from django.core.files.base import File from django.utils.functional import _StrPromise @@ -75,8 +76,8 @@ def validate_ipv4_address(value: str) -> None: ... def validate_ipv6_address(value: str) -> None: ... def validate_ipv46_address(value: str) -> None: ... -_IPValidator = Tuple[List[Callable[[Any], None]], str] -ip_address_validator_map: Dict[str, _IPValidator] +_IPValidator = tuple[list[Callable[[Any], None]], str] +ip_address_validator_map: dict[str, _IPValidator] def ip_address_validators(protocol: str, unpack_ipv4: bool) -> _IPValidator: ... def int_list_validator( @@ -118,7 +119,7 @@ class MaxLengthValidator(BaseValidator): def clean(self, x: Sized) -> int: ... class DecimalValidator: - messages: Dict[str, str] + messages: dict[str, str] max_digits: int | None decimal_places: int | None def __init__(self, max_digits: int | None, decimal_places: int | None) -> None: ... diff --git a/django-stubs/db/backends/base/base.pyi b/django-stubs/db/backends/base/base.pyi index 639ba1460..b14db41e6 100644 --- a/django-stubs/db/backends/base/base.pyi +++ b/django-stubs/db/backends/base/base.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Generator, Iterator, MutableMapping from contextlib import contextmanager from datetime import tzinfo -from typing import Any, Callable, Dict, Generator, Iterator, List, MutableMapping, Set, Tuple, Type, TypeVar +from typing import Any, TypeVar from django.db.backends.base.client import BaseDatabaseClient from django.db.backends.base.creation import BaseDatabaseCreation @@ -12,42 +13,42 @@ from django.db.backends.base.validation import BaseDatabaseValidation from django.db.backends.utils import CursorDebugWrapper, CursorWrapper NO_DB_ALIAS: str -RAN_DB_VERSION_CHECK: Set[str] +RAN_DB_VERSION_CHECK: set[str] _T = TypeVar("_T", bound="BaseDatabaseWrapper") -_ExecuteWrapper = Callable[[Callable[[str, Any, bool, Dict[str, Any]], Any], str, Any, bool, Dict[str, Any]], Any] +_ExecuteWrapper = Callable[[Callable[[str, Any, bool, dict[str, Any]], Any], str, Any, bool, dict[str, Any]], Any] class BaseDatabaseWrapper: - data_types: Dict[str, str] - data_types_suffix: Dict[str, str] - data_type_check_constraints: Dict[str, str] + data_types: dict[str, str] + data_types_suffix: dict[str, str] + data_type_check_constraints: dict[str, str] vendor: str display_name: str - SchemaEditorClass: Type[BaseDatabaseSchemaEditor] - client_class: Type[BaseDatabaseClient] - creation_class: Type[BaseDatabaseCreation] - features_class: Type[BaseDatabaseFeatures] - introspection_class: Type[BaseDatabaseIntrospection] - ops_class: Type[BaseDatabaseOperations] - validation_class: Type[BaseDatabaseValidation] + SchemaEditorClass: type[BaseDatabaseSchemaEditor] + client_class: type[BaseDatabaseClient] + creation_class: type[BaseDatabaseCreation] + features_class: type[BaseDatabaseFeatures] + introspection_class: type[BaseDatabaseIntrospection] + ops_class: type[BaseDatabaseOperations] + validation_class: type[BaseDatabaseValidation] queries_limit: int connection: Any - settings_dict: Dict[str, Any] + settings_dict: dict[str, Any] alias: str queries_log: Any force_debug_cursor: bool autocommit: bool in_atomic_block: bool savepoint_state: int - savepoint_ids: List[str] + savepoint_ids: list[str] commit_on_exit: bool needs_rollback: bool close_at: float | None closed_in_transaction: bool errors_occurred: bool - run_on_commit: List[Tuple[Set[str], Callable[[], None]]] + run_on_commit: list[tuple[set[str], Callable[[], None]]] run_commit_hooks_on_set_autocommit_on: bool - execute_wrappers: List[_ExecuteWrapper] + execute_wrappers: list[_ExecuteWrapper] client: BaseDatabaseClient creation: BaseDatabaseCreation features: BaseDatabaseFeatures @@ -55,7 +56,7 @@ class BaseDatabaseWrapper: ops: BaseDatabaseOperations validation: BaseDatabaseValidation operators: MutableMapping[str, str] - def __init__(self, settings_dict: Dict[str, Any], alias: str = ...) -> None: ... + def __init__(self, settings_dict: dict[str, Any], alias: str = ...) -> None: ... def ensure_timezone(self) -> bool: ... @property def timezone(self) -> tzinfo | None: ... @@ -64,10 +65,10 @@ class BaseDatabaseWrapper: @property def queries_logged(self) -> bool: ... @property - def queries(self) -> List[Dict[str, str]]: ... - def get_database_version(self) -> Tuple[int, ...]: ... + def queries(self) -> list[dict[str, str]]: ... + def get_database_version(self) -> tuple[int, ...]: ... def check_database_version_supported(self) -> None: ... - def get_connection_params(self) -> Dict[str, Any]: ... + def get_connection_params(self) -> dict[str, Any]: ... def get_new_connection(self, conn_params: Any) -> Any: ... def init_connection_state(self) -> None: ... def create_cursor(self, name: Any | None = ...) -> Any: ... diff --git a/django-stubs/db/backends/base/client.pyi b/django-stubs/db/backends/base/client.pyi index 7ea1692d2..01178c58c 100644 --- a/django-stubs/db/backends/base/client.pyi +++ b/django-stubs/db/backends/base/client.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, Sequence, Tuple +from collections.abc import Iterable, Sequence +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper @@ -9,7 +10,7 @@ class BaseDatabaseClient: @classmethod def settings_to_cmd_args_env( cls, - settings_dict: Dict[str, Any], + settings_dict: dict[str, Any], parameters: Iterable[str], - ) -> Tuple[Sequence[str], Dict[str, str] | None]: ... + ) -> tuple[Sequence[str], dict[str, str] | None]: ... def runshell(self, parameters: Iterable[str]) -> None: ... diff --git a/django-stubs/db/backends/base/creation.pyi b/django-stubs/db/backends/base/creation.pyi index 9c410d55d..3d7b1f469 100644 --- a/django-stubs/db/backends/base/creation.pyi +++ b/django-stubs/db/backends/base/creation.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Tuple +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper @@ -10,11 +10,11 @@ class BaseDatabaseCreation: def create_test_db( self, verbosity: int = ..., autoclobber: bool = ..., serialize: bool = ..., keepdb: bool = ... ) -> str: ... - def set_as_test_mirror(self, primary_settings_dict: Dict[str, Dict[str, None] | int | str | None]) -> None: ... + def set_as_test_mirror(self, primary_settings_dict: dict[str, dict[str, None] | int | str | None]) -> None: ... def serialize_db_to_string(self) -> str: ... def deserialize_db_from_string(self, data: str) -> None: ... def clone_test_db(self, suffix: Any, verbosity: int = ..., autoclobber: bool = ..., keepdb: bool = ...) -> None: ... - def get_test_db_clone_settings(self, suffix: str) -> Dict[str, Any]: ... + def get_test_db_clone_settings(self, suffix: str) -> dict[str, Any]: ... def destroy_test_db( self, old_database_name: str | None = ..., @@ -23,4 +23,4 @@ class BaseDatabaseCreation: suffix: str | None = ..., ) -> None: ... def sql_table_creation_suffix(self) -> str: ... - def test_db_signature(self) -> Tuple[str, str, str, str]: ... + def test_db_signature(self) -> tuple[str, str, str, str]: ... diff --git a/django-stubs/db/backends/base/features.pyi b/django-stubs/db/backends/base/features.pyi index 53dc0a509..eb0369b88 100644 --- a/django-stubs/db/backends/base/features.pyi +++ b/django-stubs/db/backends/base/features.pyi @@ -1,11 +1,12 @@ -from typing import Any, Dict, Sequence, Set, Tuple, Type +from collections.abc import Sequence +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.base import Model from django.db.utils import DatabaseError class BaseDatabaseFeatures: - minimum_database_version: Tuple[int, ...] | None + minimum_database_version: tuple[int, ...] | None gis_enabled: bool allows_group_by_lob: bool allows_group_by_pk: bool @@ -54,7 +55,7 @@ class BaseDatabaseFeatures: supports_sequence_reset: bool can_introspect_default: bool can_introspect_foreign_keys: bool - introspected_field_types: Dict[str, str] + introspected_field_types: dict[str, str] supports_index_column_ordering: bool can_introspect_materialized_views: bool can_distinct_on_fields: bool @@ -72,7 +73,7 @@ class BaseDatabaseFeatures: supports_paramstyle_pyformat: bool requires_literal_defaults: bool connection_persists_old_columns: bool - closed_cursor_error_class: Type[DatabaseError] + closed_cursor_error_class: type[DatabaseError] has_case_insensitive_like: bool bare_select_suffix: str implied_column_null: bool @@ -96,7 +97,7 @@ class BaseDatabaseFeatures: create_test_procedure_without_params_sql: str | None create_test_procedure_with_int_param_sql: str | None supports_callproc_kwargs: bool - supported_explain_formats: Set[str] + supported_explain_formats: set[str] supports_default_in_lead_lag: bool supports_ignore_conflicts: bool supports_update_conflicts: bool @@ -120,14 +121,14 @@ class BaseDatabaseFeatures: supports_collation_on_charfield: bool supports_collation_on_textfield: bool supports_non_deterministic_collations: bool - test_collations: Dict[str, str | None] + test_collations: dict[str, str | None] test_now_utc_template: str | None - django_test_expected_failures: Set[str] - django_test_skips: Dict[str, Set[str]] + django_test_expected_failures: set[str] + django_test_skips: dict[str, set[str]] connection: BaseDatabaseWrapper def __init__(self, connection: BaseDatabaseWrapper) -> None: ... @property def supports_explaining_query_execution(self) -> bool: ... @property def supports_transactions(self) -> bool: ... - def allows_group_by_selected_pks_on_model(self, model: Type[Model]) -> bool: ... + def allows_group_by_selected_pks_on_model(self, model: type[Model]) -> bool: ... diff --git a/django-stubs/db/backends/base/introspection.pyi b/django-stubs/db/backends/base/introspection.pyi index a383630fe..46bfa697c 100644 --- a/django-stubs/db/backends/base/introspection.pyi +++ b/django-stubs/db/backends/base/introspection.pyi @@ -1,5 +1,6 @@ from collections import namedtuple -from typing import Any, Dict, Iterable, List, Set, Type +from collections.abc import Iterable +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.utils import CursorWrapper @@ -17,13 +18,13 @@ class BaseDatabaseIntrospection: def __init__(self, connection: BaseDatabaseWrapper) -> None: ... def get_field_type(self, data_type: str, description: FieldInfo) -> str: ... def identifier_converter(self, name: str) -> str: ... - def table_names(self, cursor: CursorWrapper | None = ..., include_views: bool = ...) -> List[str]: ... + def table_names(self, cursor: CursorWrapper | None = ..., include_views: bool = ...) -> list[str]: ... def get_table_list(self, cursor: CursorWrapper | None) -> Any: ... def get_table_description(self, cursor: CursorWrapper | None, table_name: str) -> Any: ... - def get_migratable_models(self) -> Iterable[Type[Model]]: ... - def django_table_names(self, only_existing: bool = ..., include_views: bool = ...) -> List[str]: ... - def installed_models(self, tables: List[str]) -> Set[Type[Model]]: ... - def sequence_list(self) -> List[Dict[str, str]]: ... + def get_migratable_models(self) -> Iterable[type[Model]]: ... + def django_table_names(self, only_existing: bool = ..., include_views: bool = ...) -> list[str]: ... + def installed_models(self, tables: list[str]) -> set[type[Model]]: ... + def sequence_list(self) -> list[dict[str, str]]: ... def get_sequences(self, cursor: CursorWrapper | None, table_name: str, table_fields: Any = ...) -> Any: ... def get_relations(self, cursor: CursorWrapper | None, table_name: str) -> Any: ... def get_key_columns(self, cursor: CursorWrapper | None, table_name: str) -> Any: ... diff --git a/django-stubs/db/backends/base/operations.pyi b/django-stubs/db/backends/base/operations.pyi index a5d10cbea..040fc8e37 100644 --- a/django-stubs/db/backends/base/operations.pyi +++ b/django-stubs/db/backends/base/operations.pyi @@ -1,8 +1,9 @@ +from collections.abc import Iterable, Sequence from datetime import date from datetime import datetime as real_datetime from datetime import time, timedelta from decimal import Decimal -from typing import Any, Dict, Iterable, List, Sequence, Tuple, Type +from typing import Any from django.core.management.color import Style from django.db.backends.base.base import BaseDatabaseWrapper @@ -14,9 +15,9 @@ from django.db.models.sql.compiler import SQLCompiler class BaseDatabaseOperations: compiler_module: str - integer_field_ranges: Dict[str, Tuple[int, int]] - set_operators: Dict[str, str] - cast_data_types: Dict[Any, Any] + integer_field_ranges: dict[str, tuple[int, int]] + set_operators: dict[str, str] + cast_data_types: dict[Any, Any] cast_char_field_without_max_length: Any PRECEDING: str FOLLOWING: str @@ -40,10 +41,10 @@ class BaseDatabaseOperations: def time_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None = ...) -> str: ... def time_extract_sql(self, lookup_type: str, field_name: str) -> str: ... def deferrable_sql(self) -> str: ... - def distinct_sql(self, fields: List[str], params: List[Any] | None) -> Tuple[List[str], List[str]]: ... + def distinct_sql(self, fields: list[str], params: list[Any] | None) -> tuple[list[str], list[str]]: ... def fetch_returned_insert_columns(self, cursor: Any, returning_params: Any) -> Any: ... def field_cast_sql(self, db_type: str | None, internal_type: str) -> str: ... - def force_no_ordering(self) -> List[Any]: ... + def force_no_ordering(self) -> list[Any]: ... def for_update_sql(self, nowait: bool = ..., skip_locked: bool = ..., of: Any = ..., no_key: bool = ...) -> str: ... def limit_offset_sql(self, low_mark: int, high_mark: int | None) -> str: ... def last_executed_query(self, cursor: Any, sql: Any, params: Any) -> str: ... @@ -53,10 +54,10 @@ class BaseDatabaseOperations: def max_name_length(self) -> int | None: ... def no_limit_value(self) -> str | None: ... def pk_default_value(self) -> str: ... - def prepare_sql_script(self, sql: Any) -> List[str]: ... + def prepare_sql_script(self, sql: Any) -> list[str]: ... def process_clob(self, value: str) -> str: ... def return_insert_columns(self, fields: Any) -> Any: ... - def compiler(self, compiler_name: str) -> Type[SQLCompiler]: ... + def compiler(self, compiler_name: str) -> type[SQLCompiler]: ... def quote_name(self, name: str) -> str: ... def regex_lookup(self, lookup_type: str) -> str: ... def savepoint_create_sql(self, sid: str) -> str: ... @@ -65,10 +66,10 @@ class BaseDatabaseOperations: def set_time_zone_sql(self) -> str: ... def sql_flush( self, style: Any, tables: Sequence[str], *, reset_sequences: bool = ..., allow_cascade: bool = ... - ) -> List[str]: ... + ) -> list[str]: ... def execute_sql_flush(self, sql_list: Iterable[str]) -> None: ... - def sequence_reset_by_name_sql(self, style: Style | None, sequences: List[Any]) -> List[Any]: ... - def sequence_reset_sql(self, style: Style, model_list: Sequence[Type[Model]]) -> List[Any]: ... + def sequence_reset_by_name_sql(self, style: Style | None, sequences: list[Any]) -> list[Any]: ... + def sequence_reset_sql(self, style: Style, model_list: Sequence[type[Model]]) -> list[Any]: ... def start_transaction_sql(self) -> str: ... def end_transaction_sql(self, success: bool = ...) -> str: ... def tablespace_sql(self, tablespace: str | None, inline: bool = ...) -> str: ... @@ -83,24 +84,24 @@ class BaseDatabaseOperations: self, value: Decimal | None, max_digits: int | None = ..., decimal_places: int | None = ... ) -> str | None: ... def adapt_ipaddressfield_value(self, value: str | None) -> str | None: ... - def year_lookup_bounds_for_date_field(self, value: int) -> List[str]: ... - def year_lookup_bounds_for_datetime_field(self, value: int) -> List[str]: ... - def get_db_converters(self, expression: Expression) -> List[Any]: ... + def year_lookup_bounds_for_date_field(self, value: int) -> list[str]: ... + def year_lookup_bounds_for_datetime_field(self, value: int) -> list[str]: ... + def get_db_converters(self, expression: Expression) -> list[Any]: ... def convert_durationfield_value( self, value: float | None, expression: Expression, connection: BaseDatabaseWrapper ) -> timedelta | None: ... def check_expression_support(self, expression: Any) -> None: ... def conditional_expression_supported_in_where_clause(self, expression: Any) -> bool: ... - def combine_expression(self, connector: str, sub_expressions: List[str]) -> str: ... + def combine_expression(self, connector: str, sub_expressions: list[str]) -> str: ... def combine_duration_expression(self, connector: Any, sub_expressions: Any) -> str: ... def binary_placeholder_sql(self, value: Case | None) -> str: ... def modify_insert_params(self, placeholder: str, params: Any) -> Any: ... - def integer_field_range(self, internal_type: Any) -> Tuple[int, int]: ... - def subtract_temporals(self, internal_type: Any, lhs: Any, rhs: Any) -> Tuple[str, Tuple[Any, ...]]: ... + def integer_field_range(self, internal_type: Any) -> tuple[int, int]: ... + def subtract_temporals(self, internal_type: Any, lhs: Any, rhs: Any) -> tuple[str, tuple[Any, ...]]: ... def window_frame_start(self, start: Any) -> str: ... def window_frame_end(self, end: Any) -> str: ... - def window_frame_rows_start_end(self, start: int | None = ..., end: int | None = ...) -> Tuple[str, str]: ... - def window_frame_range_start_end(self, start: int | None = ..., end: int | None = ...) -> Tuple[str, str]: ... + def window_frame_rows_start_end(self, start: int | None = ..., end: int | None = ...) -> tuple[str, str]: ... + def window_frame_range_start_end(self, start: int | None = ..., end: int | None = ...) -> tuple[str, str]: ... def explain_query_prefix(self, format: str | None = ..., **options: Any) -> str: ... def insert_statement(self, ignore_conflicts: bool = ...) -> str: ... def ignore_conflicts_suffix_sql(self, ignore_conflicts: Any | None = ...) -> str: ... diff --git a/django-stubs/db/backends/base/schema.pyi b/django-stubs/db/backends/base/schema.pyi index 3d35b31a9..1f1203a6e 100644 --- a/django-stubs/db/backends/base/schema.pyi +++ b/django-stubs/db/backends/base/schema.pyi @@ -1,6 +1,7 @@ +from collections.abc import Sequence from logging import Logger from types import TracebackType -from typing import Any, ContextManager, List, Sequence, Tuple, Type +from typing import Any, ContextManager from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.ddl_references import Statement @@ -50,39 +51,39 @@ class BaseDatabaseSchemaEditor(ContextManager[Any]): def __enter__(self) -> BaseDatabaseSchemaEditor: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... def execute(self, sql: Statement | str, params: Sequence[Any] | None = ...) -> None: ... def quote_name(self, name: str) -> str: ... - def table_sql(self, model: Type[Model]) -> Tuple[str, List[Any]]: ... + def table_sql(self, model: type[Model]) -> tuple[str, list[Any]]: ... def column_sql( - self, model: Type[Model], field: Field, include_default: bool = ... - ) -> Tuple[None, None] | Tuple[str, List[Any]]: ... + self, model: type[Model], field: Field, include_default: bool = ... + ) -> tuple[None, None] | tuple[str, list[Any]]: ... def skip_default(self, field: Any) -> bool: ... def prepare_default(self, value: Any) -> Any: ... def effective_default(self, field: Field) -> int | str: ... def quote_value(self, value: Any) -> str: ... - def create_model(self, model: Type[Model]) -> None: ... - def delete_model(self, model: Type[Model]) -> None: ... - def add_index(self, model: Type[Model], index: Index) -> None: ... - def remove_index(self, model: Type[Model], index: Index) -> None: ... + def create_model(self, model: type[Model]) -> None: ... + def delete_model(self, model: type[Model]) -> None: ... + def add_index(self, model: type[Model], index: Index) -> None: ... + def remove_index(self, model: type[Model], index: Index) -> None: ... def alter_unique_together( self, - model: Type[Model], + model: type[Model], old_unique_together: Sequence[Sequence[str]], new_unique_together: Sequence[Sequence[str]], ) -> None: ... def alter_index_together( self, - model: Type[Model], + model: type[Model], old_index_together: Sequence[Sequence[str]], new_index_together: Sequence[Sequence[str]], ) -> None: ... - def alter_db_table(self, model: Type[Model], old_db_table: str, new_db_table: str) -> None: ... + def alter_db_table(self, model: type[Model], old_db_table: str, new_db_table: str) -> None: ... def alter_db_tablespace(self, model: Any, old_db_tablespace: Any, new_db_tablespace: Any) -> None: ... def add_field(self, model: Any, field: Any) -> None: ... def remove_field(self, model: Any, field: Any) -> None: ... - def alter_field(self, model: Type[Model], old_field: Field, new_field: Field, strict: bool = ...) -> None: ... + def alter_field(self, model: type[Model], old_field: Field, new_field: Field, strict: bool = ...) -> None: ... def remove_procedure(self, procedure_name: Any, param_types: Any = ...) -> None: ... diff --git a/django-stubs/db/backends/base/validation.pyi b/django-stubs/db/backends/base/validation.pyi index db1a4a6de..6d1c8acb3 100644 --- a/django-stubs/db/backends/base/validation.pyi +++ b/django-stubs/db/backends/base/validation.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.fields import Field @@ -6,5 +6,5 @@ from django.db.models.fields import Field class BaseDatabaseValidation: connection: BaseDatabaseWrapper def __init__(self, connection: BaseDatabaseWrapper) -> None: ... - def check(self, **kwargs: Any) -> List[Any]: ... - def check_field(self, field: Field, **kwargs: Any) -> List[Any]: ... + def check(self, **kwargs: Any) -> list[Any]: ... + def check_field(self, field: Field, **kwargs: Any) -> list[Any]: ... diff --git a/django-stubs/db/backends/ddl_references.pyi b/django-stubs/db/backends/ddl_references.pyi index 469bbb898..923e1183c 100644 --- a/django-stubs/db/backends/ddl_references.pyi +++ b/django-stubs/db/backends/ddl_references.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Sequence +from collections.abc import Sequence +from typing import Any from typing_extensions import Protocol @@ -22,31 +23,31 @@ class Table(Reference): class TableColumns(Table): table: str - columns: List[str] - def __init__(self, table: str, columns: List[str]) -> None: ... + columns: list[str] + def __init__(self, table: str, columns: list[str]) -> None: ... def references_column(self, table: str, column: str) -> bool: ... def rename_column_references(self, table: str, old_column: str, new_column: str) -> None: ... class Columns(TableColumns): - columns: List[str] + columns: list[str] table: str quote_name: _QuoteCallable col_suffixes: Sequence[str] def __init__( - self, table: str, columns: List[str], quote_name: _QuoteCallable, col_suffixes: Sequence[str] = ... + self, table: str, columns: list[str], quote_name: _QuoteCallable, col_suffixes: Sequence[str] = ... ) -> None: ... class _NameCallable(Protocol): """Get rid of `cannot assign to method`""" - def __call__(self, __table: str, __columns: List[str], __suffix: str) -> str: ... + def __call__(self, __table: str, __columns: list[str], __suffix: str) -> str: ... class IndexName(TableColumns): - columns: List[str] + columns: list[str] table: str suffix: str create_index_name: _NameCallable - def __init__(self, table: str, columns: List[str], suffix: str, create_index_name: _NameCallable) -> None: ... + def __init__(self, table: str, columns: list[str], suffix: str, create_index_name: _NameCallable) -> None: ... class IndexColumns(Columns): opclasses: Any @@ -55,7 +56,7 @@ class IndexColumns(Columns): ) -> None: ... class ForeignKeyName(TableColumns): - columns: List[str] + columns: list[str] table: str to_reference: TableColumns suffix_template: str @@ -63,9 +64,9 @@ class ForeignKeyName(TableColumns): def __init__( self, from_table: str, - from_columns: List[str], + from_columns: list[str], to_table: str, - to_columns: List[str], + to_columns: list[str], suffix_template: str, create_fk_name: _NameCallable, ) -> None: ... @@ -76,7 +77,7 @@ class ForeignKeyName(TableColumns): class Statement(Reference): template: str - parts: Dict[str, Table] + parts: dict[str, Table] def __init__(self, template: str, **parts: Any) -> None: ... def references_table(self, table: str) -> bool: ... def references_column(self, table: str, column: str) -> bool: ... diff --git a/django-stubs/db/backends/mysql/base.pyi b/django-stubs/db/backends/mysql/base.pyi index fb8bc2e8f..af063131e 100644 --- a/django-stubs/db/backends/mysql/base.pyi +++ b/django-stubs/db/backends/mysql/base.pyi @@ -1,4 +1,5 @@ -from typing import Any, Container, Dict, Iterator, Tuple, Type +from collections.abc import Iterator +from typing import Any, Container from django.db.backends.base.base import BaseDatabaseWrapper as BaseDatabaseWrapper from typing_extensions import Literal @@ -31,12 +32,12 @@ class DatabaseWrapper(BaseDatabaseWrapper): validation: DatabaseValidation ops: DatabaseOperations - client_class: Type[DatabaseClient] - creation_class: Type[DatabaseCreation] - features_class: Type[DatabaseFeatures] - introspection_class: Type[DatabaseIntrospection] - ops_class: Type[DatabaseOperations] - validation_class: Type[DatabaseValidation] + client_class: type[DatabaseClient] + creation_class: type[DatabaseCreation] + features_class: type[DatabaseFeatures] + introspection_class: type[DatabaseIntrospection] + ops_class: type[DatabaseOperations] + validation_class: type[DatabaseValidation] vendor: str data_types: Any @@ -47,7 +48,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): Database: Any SchemaEditorClass: Any isolation_level: Any - def get_connection_params(self) -> Dict[str, Any]: ... + def get_connection_params(self) -> dict[str, Any]: ... def get_new_connection(self, conn_params: Any) -> Any: ... def init_connection_state(self) -> None: ... def create_cursor(self, name: Any | None = ...) -> CursorWrapper: ... @@ -59,13 +60,13 @@ class DatabaseWrapper(BaseDatabaseWrapper): @property def display_name(self) -> str: ... # type: ignore [override] @property - def data_type_check_constraints(self) -> Dict[str, str]: ... # type: ignore [override] + def data_type_check_constraints(self) -> dict[str, str]: ... # type: ignore [override] @property - def mysql_server_data(self) -> Dict[str, Any]: ... + def mysql_server_data(self) -> dict[str, Any]: ... @property def mysql_server_info(self) -> str: ... @property - def mysql_version(self) -> Tuple[int, ...]: ... + def mysql_version(self) -> tuple[int, ...]: ... @property def mysql_is_mariadb(self) -> bool: ... @property diff --git a/django-stubs/db/backends/mysql/client.pyi b/django-stubs/db/backends/mysql/client.pyi index 893189a0b..2bd059811 100644 --- a/django-stubs/db/backends/mysql/client.pyi +++ b/django-stubs/db/backends/mysql/client.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, List, Sequence, Tuple +from collections.abc import Iterable, Sequence +from typing import Any from django.db.backends.base.client import BaseDatabaseClient from django.db.backends.mysql.base import DatabaseWrapper @@ -9,6 +10,6 @@ class DatabaseClient(BaseDatabaseClient): @classmethod def settings_to_cmd_args_env( cls, - settings_dict: Dict[str, Any], + settings_dict: dict[str, Any], parameters: Iterable[str], - ) -> Tuple[List[str], Dict[str, str] | None]: ... + ) -> tuple[list[str], dict[str, str] | None]: ... diff --git a/django-stubs/db/backends/mysql/features.pyi b/django-stubs/db/backends/mysql/features.pyi index b38deb4ba..d10f0a822 100644 --- a/django-stubs/db/backends/mysql/features.pyi +++ b/django-stubs/db/backends/mysql/features.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Set +from typing import Any from django.db.backends.base.features import BaseDatabaseFeatures as BaseDatabaseFeatures from django.db.backends.mysql.base import DatabaseWrapper @@ -48,7 +48,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): @property def can_introspect_foreign_keys(self) -> bool: ... # type: ignore @property - def introspected_field_types(self) -> Dict[str, str]: ... # type: ignore [override] + def introspected_field_types(self) -> dict[str, str]: ... # type: ignore [override] @property def can_return_columns_from_insert(self) -> bool: ... # type: ignore @property @@ -70,7 +70,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): @property def supports_explain_analyze(self) -> bool: ... @property - def supported_explain_formats(self) -> Set[str]: ... # type: ignore + def supported_explain_formats(self) -> set[str]: ... # type: ignore @property def supports_transactions(self) -> bool: ... @property diff --git a/django-stubs/db/backends/mysql/operations.pyi b/django-stubs/db/backends/mysql/operations.pyi index 8dbba2472..1753677d6 100644 --- a/django-stubs/db/backends/mysql/operations.pyi +++ b/django-stubs/db/backends/mysql/operations.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Tuple +from typing import Any from django.db.backends.base.operations import BaseDatabaseOperations as BaseDatabaseOperations from django.db.backends.mysql.base import DatabaseWrapper @@ -6,8 +6,8 @@ from django.db.backends.mysql.base import DatabaseWrapper class DatabaseOperations(BaseDatabaseOperations): connection: DatabaseWrapper compiler_module: str - integer_field_ranges: Dict[str, Tuple[int, int]] - cast_data_types: Dict[str, str] + integer_field_ranges: dict[str, tuple[int, int]] + cast_data_types: dict[str, str] cast_char_field_without_max_length: str explain_prefix: str def date_extract_sql(self, lookup_type: str, field_name: str) -> Any: ... diff --git a/django-stubs/db/backends/oracle/base.pyi b/django-stubs/db/backends/oracle/base.pyi index 3ce823f75..149d4f10b 100644 --- a/django-stubs/db/backends/oracle/base.pyi +++ b/django-stubs/db/backends/oracle/base.pyi @@ -1,5 +1,6 @@ +from collections.abc import Generator, Iterator from contextlib import contextmanager -from typing import Any, Generator, Iterator, Type +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper as BaseDatabaseWrapper @@ -24,12 +25,12 @@ class DatabaseWrapper(BaseDatabaseWrapper): validation: DatabaseValidation ops: DatabaseOperations - client_class: Type[DatabaseClient] - creation_class: Type[DatabaseCreation] - features_class: Type[DatabaseFeatures] - introspection_class: Type[DatabaseIntrospection] - ops_class: Type[DatabaseOperations] - validation_class: Type[DatabaseValidation] + client_class: type[DatabaseClient] + creation_class: type[DatabaseCreation] + features_class: type[DatabaseFeatures] + introspection_class: type[DatabaseIntrospection] + ops_class: type[DatabaseOperations] + validation_class: type[DatabaseValidation] vendor: str display_name: str diff --git a/django-stubs/db/backends/oracle/client.pyi b/django-stubs/db/backends/oracle/client.pyi index 321e0250d..86e3a688f 100644 --- a/django-stubs/db/backends/oracle/client.pyi +++ b/django-stubs/db/backends/oracle/client.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, List, Tuple +from collections.abc import Iterable +from typing import Any from django.db.backends.base.client import BaseDatabaseClient as BaseDatabaseClient from django.db.backends.oracle.base import DatabaseWrapper @@ -8,8 +9,8 @@ class DatabaseClient(BaseDatabaseClient): executable_name: str wrapper_name: str @staticmethod - def connect_string(settings_dict: Dict[str, Any]) -> str: ... + def connect_string(settings_dict: dict[str, Any]) -> str: ... @classmethod def settings_to_cmd_args_env( - cls, settings_dict: Dict[str, Any], parameters: Iterable[str] - ) -> Tuple[List[str], None]: ... + cls, settings_dict: dict[str, Any], parameters: Iterable[str] + ) -> tuple[list[str], None]: ... diff --git a/django-stubs/db/backends/oracle/operations.pyi b/django-stubs/db/backends/oracle/operations.pyi index 23e0da20d..b8f0399ab 100644 --- a/django-stubs/db/backends/oracle/operations.pyi +++ b/django-stubs/db/backends/oracle/operations.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from django.db.backends.base.operations import BaseDatabaseOperations as BaseDatabaseOperations from django.db.backends.oracle.base import DatabaseWrapper @@ -17,7 +17,7 @@ class DatabaseOperations(BaseDatabaseOperations): def datetime_extract_sql(self, lookup_type: str, field_name: str, tzname: str | None) -> str: ... def datetime_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None) -> str: ... def time_trunc_sql(self, lookup_type: str, field_name: str, tzname: str | None = ...) -> str: ... - def get_db_converters(self, expression: Any) -> List[Any]: ... + def get_db_converters(self, expression: Any) -> list[Any]: ... def convert_textfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ... def convert_binaryfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ... def convert_booleanfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ... @@ -45,8 +45,8 @@ class DatabaseOperations(BaseDatabaseOperations): def quote_name(self, name: str) -> str: ... def regex_lookup(self, lookup_type: str) -> str: ... def return_insert_columns(self, fields: Any) -> Any: ... - def sequence_reset_by_name_sql(self, style: Any, sequences: Any) -> List[str]: ... - def sequence_reset_sql(self, style: Any, model_list: Any) -> List[str]: ... + def sequence_reset_by_name_sql(self, style: Any, sequences: Any) -> list[str]: ... + def sequence_reset_sql(self, style: Any, model_list: Any) -> list[str]: ... def start_transaction_sql(self) -> str: ... def tablespace_sql(self, tablespace: Any, inline: bool = ...) -> str: ... def adapt_datefield_value(self, value: Any) -> Any: ... diff --git a/django-stubs/db/backends/postgresql/base.pyi b/django-stubs/db/backends/postgresql/base.pyi index 8df163e6d..75e79b942 100644 --- a/django-stubs/db/backends/postgresql/base.pyi +++ b/django-stubs/db/backends/postgresql/base.pyi @@ -1,5 +1,5 @@ from io import IOBase -from typing import Any, Dict, Tuple, Type +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.utils import CursorDebugWrapper as BaseCursorDebugWrapper @@ -11,9 +11,9 @@ from .features import DatabaseFeatures from .introspection import DatabaseIntrospection from .operations import DatabaseOperations -def psycopg2_version() -> Tuple[int, ...]: ... +def psycopg2_version() -> tuple[int, ...]: ... -PSYCOPG2_VERSION: Tuple[int, ...] +PSYCOPG2_VERSION: tuple[int, ...] class DatabaseWrapper(BaseDatabaseWrapper): client: DatabaseClient @@ -22,15 +22,15 @@ class DatabaseWrapper(BaseDatabaseWrapper): introspection: DatabaseIntrospection ops: DatabaseOperations - client_class: Type[DatabaseClient] - creation_class: Type[DatabaseCreation] - features_class: Type[DatabaseFeatures] - introspection_class: Type[DatabaseIntrospection] - ops_class: Type[DatabaseOperations] + client_class: type[DatabaseClient] + creation_class: type[DatabaseCreation] + features_class: type[DatabaseFeatures] + introspection_class: type[DatabaseIntrospection] + ops_class: type[DatabaseOperations] - operators: Dict[str, str] + operators: dict[str, str] pattern_esc: str - pattern_ops: Dict[str, str] + pattern_ops: dict[str, str] # PostgreSQL backend-specific attributes. _named_cursor_idx: int diff --git a/django-stubs/db/backends/postgresql/client.pyi b/django-stubs/db/backends/postgresql/client.pyi index 29885c8d9..ba70d1bb4 100644 --- a/django-stubs/db/backends/postgresql/client.pyi +++ b/django-stubs/db/backends/postgresql/client.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, List, Tuple +from collections.abc import Iterable +from typing import Any from django.db.backends.base.client import BaseDatabaseClient from django.db.backends.postgresql.base import DatabaseWrapper @@ -8,6 +9,6 @@ class DatabaseClient(BaseDatabaseClient): executable_name: str @classmethod def settings_to_cmd_args_env( - cls, settings_dict: Dict[str, Any], parameters: Iterable[str] - ) -> Tuple[List[str], Dict[str, str] | None]: ... + cls, settings_dict: dict[str, Any], parameters: Iterable[str] + ) -> tuple[list[str], dict[str, str] | None]: ... def runshell(self, parameters: Iterable[str]) -> None: ... diff --git a/django-stubs/db/backends/sqlite3/base.pyi b/django-stubs/db/backends/sqlite3/base.pyi index bb5c7fb0e..b27143658 100644 --- a/django-stubs/db/backends/sqlite3/base.pyi +++ b/django-stubs/db/backends/sqlite3/base.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable from sqlite3 import dbapi2 as Database -from typing import Any, Callable, Type, TypeVar +from typing import Any, TypeVar from django.db.backends.base.base import BaseDatabaseWrapper @@ -20,11 +21,11 @@ class DatabaseWrapper(BaseDatabaseWrapper): introspection: DatabaseIntrospection ops: DatabaseOperations - client_class: Type[DatabaseClient] - creation_class: Type[DatabaseCreation] - features_class: Type[DatabaseFeatures] - introspection_class: Type[DatabaseIntrospection] - ops_class: Type[DatabaseOperations] + client_class: type[DatabaseClient] + creation_class: type[DatabaseCreation] + features_class: type[DatabaseFeatures] + introspection_class: type[DatabaseIntrospection] + ops_class: type[DatabaseOperations] def is_in_memory_db(self) -> bool: ... diff --git a/django-stubs/db/backends/sqlite3/client.pyi b/django-stubs/db/backends/sqlite3/client.pyi index 68a480572..4202b37e1 100644 --- a/django-stubs/db/backends/sqlite3/client.pyi +++ b/django-stubs/db/backends/sqlite3/client.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, List, Tuple +from collections.abc import Iterable +from typing import Any from django.db.backends.base.client import BaseDatabaseClient as BaseDatabaseClient from django.db.backends.sqlite3.base import DatabaseWrapper @@ -8,5 +9,5 @@ class DatabaseClient(BaseDatabaseClient): executable_name: str @classmethod def settings_to_cmd_args_env( - cls, settings_dict: Dict[str, Any], parameters: Iterable[str] - ) -> Tuple[List[str], None]: ... + cls, settings_dict: dict[str, Any], parameters: Iterable[str] + ) -> tuple[list[str], None]: ... diff --git a/django-stubs/db/backends/utils.pyi b/django-stubs/db/backends/utils.pyi index 20430bd33..c2bbfe08b 100644 --- a/django-stubs/db/backends/utils.pyi +++ b/django-stubs/db/backends/utils.pyi @@ -1,9 +1,10 @@ import datetime +from collections.abc import Generator, Iterator, Mapping, Sequence from contextlib import contextmanager from decimal import Decimal from logging import Logger from types import TracebackType -from typing import Any, Dict, Generator, Iterator, List, Mapping, Protocol, Sequence, Tuple, Type, overload +from typing import Any, Protocol, overload from uuid import UUID from typing_extensions import Literal @@ -30,8 +31,8 @@ _SQLType = ( | datetime.date | datetime.datetime | UUID - | Tuple[Any, ...] - | List[Any] + | tuple[Any, ...] + | list[Any] ) _ExecuteParameters = Sequence[_SQLType] | Mapping[str, _SQLType] | None @@ -41,16 +42,16 @@ class CursorWrapper: def __init__(self, cursor: Any, db: Any) -> None: ... WRAP_ERROR_ATTRS: Any def __getattr__(self, attr: str) -> Any: ... - def __iter__(self) -> Iterator[Tuple[Any, ...]]: ... + def __iter__(self) -> Iterator[tuple[Any, ...]]: ... def __enter__(self) -> CursorWrapper: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... def callproc( - self, procname: str, params: Sequence[Any] | None = ..., kparams: Dict[str, int] | None = ... + self, procname: str, params: Sequence[Any] | None = ..., kparams: dict[str, int] | None = ... ) -> Any: ... def execute(self, sql: _ExecuteQuery, params: _ExecuteParameters = ...) -> Any: ... def executemany(self, sql: _ExecuteQuery, param_list: Sequence[_ExecuteParameters]) -> Any: ... @@ -79,7 +80,7 @@ def typecast_time(s: str) -> datetime.time: ... def typecast_timestamp(s: None | Literal[""]) -> None: ... # type: ignore @overload def typecast_timestamp(s: str) -> datetime.datetime: ... -def split_identifier(identifier: str) -> Tuple[str, str]: ... +def split_identifier(identifier: str) -> tuple[str, str]: ... def truncate_name(identifier: str, length: int | None = ..., hash_len: int = ...) -> str: ... def format_number(value: Decimal | None, max_digits: int | None, decimal_places: int | None) -> str | None: ... def strip_quotes(table_name: str) -> str: ... diff --git a/django-stubs/db/migrations/autodetector.pyi b/django-stubs/db/migrations/autodetector.pyi index 953d41aea..931945734 100644 --- a/django-stubs/db/migrations/autodetector.pyi +++ b/django-stubs/db/migrations/autodetector.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, Iterable, List, Set, Tuple +from collections.abc import Callable, Iterable +from typing import Any from django.db.migrations.graph import MigrationGraph from django.db.migrations.migration import Migration @@ -11,30 +12,30 @@ class MigrationAutodetector: from_state: ProjectState to_state: ProjectState questioner: MigrationQuestioner - existing_apps: Set[Any] + existing_apps: set[Any] def __init__( self, from_state: ProjectState, to_state: ProjectState, questioner: MigrationQuestioner | None = ... ) -> None: ... def changes( self, graph: MigrationGraph, - trim_to_apps: Set[str] | None = ..., - convert_apps: Set[str] | None = ..., + trim_to_apps: set[str] | None = ..., + convert_apps: set[str] | None = ..., migration_name: str | None = ..., - ) -> Dict[str, List[Migration]]: ... + ) -> dict[str, list[Migration]]: ... def deep_deconstruct(self, obj: Any) -> Any: ... def only_relation_agnostic_fields( - self, fields: Dict[str, Field] - ) -> List[Tuple[str, List[Any], Dict[str, Callable | int | str]]]: ... - def check_dependency(self, operation: Operation, dependency: Tuple[str, str, str | None, bool | str]) -> bool: ... + self, fields: dict[str, Field] + ) -> list[tuple[str, list[Any], dict[str, Callable | int | str]]]: ... + def check_dependency(self, operation: Operation, dependency: tuple[str, str, str | None, bool | str]) -> bool: ... def add_operation( self, app_label: str, operation: Operation, - dependencies: Iterable[Tuple[str, str, str | None, bool | str]] | None = ..., + dependencies: Iterable[tuple[str, str, str | None, bool | str]] | None = ..., beginning: bool = ..., ) -> None: ... - def swappable_first_key(self, item: Tuple[str, str]) -> Tuple[str, str]: ... + def swappable_first_key(self, item: tuple[str, str]) -> tuple[str, str]: ... renamed_models: Any renamed_models_rel: Any def generate_renamed_models(self) -> None: ... @@ -57,7 +58,7 @@ class MigrationAutodetector: def generate_altered_order_with_respect_to(self) -> None: ... def generate_altered_managers(self) -> None: ... def arrange_for_graph( - self, changes: Dict[str, List[Migration]], graph: MigrationGraph, migration_name: str | None = ... - ) -> Dict[str, List[Migration]]: ... + self, changes: dict[str, list[Migration]], graph: MigrationGraph, migration_name: str | None = ... + ) -> dict[str, list[Migration]]: ... @classmethod def parse_number(cls, name: str) -> int: ... diff --git a/django-stubs/db/migrations/exceptions.pyi b/django-stubs/db/migrations/exceptions.pyi index 4590bdfbe..4f2099f1a 100644 --- a/django-stubs/db/migrations/exceptions.pyi +++ b/django-stubs/db/migrations/exceptions.pyi @@ -1,5 +1,3 @@ -from typing import Tuple - from django.db.migrations.migration import Migration from django.db.utils import DatabaseError @@ -13,8 +11,8 @@ class IrreversibleError(RuntimeError): ... class NodeNotFoundError(LookupError): message: str origin: Migration | None - node: Tuple[str, str] - def __init__(self, message: str, node: Tuple[str, str], origin: Migration | None = ...) -> None: ... + node: tuple[str, str] + def __init__(self, message: str, node: tuple[str, str], origin: Migration | None = ...) -> None: ... class MigrationSchemaMissing(DatabaseError): ... class InvalidMigrationPlan(ValueError): ... diff --git a/django-stubs/db/migrations/executor.pyi b/django-stubs/db/migrations/executor.pyi index 05f2cc192..13635726d 100644 --- a/django-stubs/db/migrations/executor.pyi +++ b/django-stubs/db/migrations/executor.pyi @@ -1,4 +1,4 @@ -from typing import List, Sequence, Set, Tuple +from collections.abc import Sequence from django.db.backends.base.base import BaseDatabaseWrapper from django.db.migrations.migration import Migration @@ -22,12 +22,12 @@ class MigrationExecutor: progress_callback: _ProgressCallbackT | None = ..., ) -> None: ... def migration_plan( - self, targets: Sequence[Tuple[str, str | None]] | Set[Tuple[str, str]], clean_start: bool = ... - ) -> List[Tuple[Migration, bool]]: ... + self, targets: Sequence[tuple[str, str | None]] | set[tuple[str, str]], clean_start: bool = ... + ) -> list[tuple[Migration, bool]]: ... def migrate( self, - targets: Sequence[Tuple[str, str | None]] | None, - plan: Sequence[Tuple[Migration, bool]] | None = ..., + targets: Sequence[tuple[str, str | None]] | None, + plan: Sequence[tuple[Migration, bool]] | None = ..., state: ProjectState | None = ..., fake: bool = ..., fake_initial: bool = ..., @@ -40,4 +40,4 @@ class MigrationExecutor: def check_replacements(self) -> None: ... def detect_soft_applied( self, project_state: ProjectState | None, migration: Migration - ) -> Tuple[bool, ProjectState]: ... + ) -> tuple[bool, ProjectState]: ... diff --git a/django-stubs/db/migrations/graph.pyi b/django-stubs/db/migrations/graph.pyi index cdab16d13..4f0afe7d7 100644 --- a/django-stubs/db/migrations/graph.pyi +++ b/django-stubs/db/migrations/graph.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Sequence, Set, Tuple +from collections.abc import Sequence +from typing import Any from django.db.migrations.migration import Migration, SwappableTuple from django.db.migrations.state import ProjectState @@ -6,12 +7,12 @@ from django.db.migrations.state import ProjectState RECURSION_DEPTH_WARNING: str class Node: - key: Tuple[str, str] - children: Set[Any] - parents: Set[Any] - def __init__(self, key: Tuple[str, str]) -> None: ... + key: tuple[str, str] + children: set[Any] + parents: set[Any] + def __init__(self, key: tuple[str, str]) -> None: ... def __eq__(self, other: Any) -> bool: ... - def __lt__(self, other: Tuple[str, str] | Node) -> bool: ... + def __lt__(self, other: tuple[str, str] | Node) -> bool: ... def __getitem__(self, item: int) -> str: ... def __hash__(self) -> int: ... def add_child(self, child: Node) -> None: ... @@ -20,36 +21,36 @@ class Node: class DummyNode(Node): origin: Any error_message: Any - def __init__(self, key: Tuple[str, str], origin: Migration | str, error_message: str) -> None: ... + def __init__(self, key: tuple[str, str], origin: Migration | str, error_message: str) -> None: ... def raise_error(self) -> None: ... class MigrationGraph: - node_map: Dict[Tuple[str, str], Node] - nodes: Dict[Tuple[str, str], Migration | None] + node_map: dict[tuple[str, str], Node] + nodes: dict[tuple[str, str], Migration | None] cached: bool def __init__(self) -> None: ... - def add_node(self, key: Tuple[str, str], migration: Migration | None) -> None: ... - def add_dummy_node(self, key: Tuple[str, str], origin: Migration | str, error_message: str) -> None: ... + def add_node(self, key: tuple[str, str], migration: Migration | None) -> None: ... + def add_dummy_node(self, key: tuple[str, str], origin: Migration | str, error_message: str) -> None: ... def add_dependency( self, migration: Migration | str | None, - child: Tuple[str, str], - parent: Tuple[str, str], + child: tuple[str, str], + parent: tuple[str, str], skip_validation: bool = ..., ) -> None: ... - def remove_replaced_nodes(self, replacement: Tuple[str, str], replaced: List[Tuple[str, str]]) -> None: ... - def remove_replacement_node(self, replacement: Tuple[str, str], replaced: List[Tuple[str, str]]) -> None: ... + def remove_replaced_nodes(self, replacement: tuple[str, str], replaced: list[tuple[str, str]]) -> None: ... + def remove_replacement_node(self, replacement: tuple[str, str], replaced: list[tuple[str, str]]) -> None: ... def validate_consistency(self) -> None: ... - def forwards_plan(self, target: Tuple[str, str]) -> List[Tuple[str, str]]: ... - def backwards_plan(self, target: Tuple[str, str]) -> List[Tuple[str, str]]: ... - def iterative_dfs(self, start: Any, forwards: bool = ...) -> List[Tuple[str, str]]: ... - def root_nodes(self, app: str | None = ...) -> List[Tuple[str, str]]: ... - def leaf_nodes(self, app: str | None = ...) -> List[Tuple[str, str]]: ... + def forwards_plan(self, target: tuple[str, str]) -> list[tuple[str, str]]: ... + def backwards_plan(self, target: tuple[str, str]) -> list[tuple[str, str]]: ... + def iterative_dfs(self, start: Any, forwards: bool = ...) -> list[tuple[str, str]]: ... + def root_nodes(self, app: str | None = ...) -> list[tuple[str, str]]: ... + def leaf_nodes(self, app: str | None = ...) -> list[tuple[str, str]]: ... def ensure_not_cyclic(self) -> None: ... def make_state( self, - nodes: None | Tuple[str, str] | Sequence[Tuple[str, str]] = ..., + nodes: None | tuple[str, str] | Sequence[tuple[str, str]] = ..., at_end: bool = ..., - real_apps: List[str] = ..., + real_apps: list[str] = ..., ) -> ProjectState: ... - def __contains__(self, node: Tuple[str, str]) -> bool: ... + def __contains__(self, node: tuple[str, str]) -> bool: ... diff --git a/django-stubs/db/migrations/loader.pyi b/django-stubs/db/migrations/loader.pyi index 8e4bcc4e2..7e6d8151b 100644 --- a/django-stubs/db/migrations/loader.pyi +++ b/django-stubs/db/migrations/loader.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Sequence, Set, Tuple +from collections.abc import Sequence +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.migrations.migration import Migration @@ -13,8 +14,8 @@ MIGRATIONS_MODULE_NAME: str class MigrationLoader: connection: BaseDatabaseWrapper | None - disk_migrations: Dict[Tuple[str, str], Migration] - applied_migrations: Dict[Tuple[str, str], Migration] + disk_migrations: dict[tuple[str, str], Migration] + applied_migrations: dict[tuple[str, str], Migration] ignore_no_migrations: bool def __init__( self, @@ -24,20 +25,20 @@ class MigrationLoader: replace_migrations: bool = ..., ) -> None: ... @classmethod - def migrations_module(cls, app_label: str) -> Tuple[str | None, bool]: ... - unmigrated_apps: Set[str] - migrated_apps: Set[str] + def migrations_module(cls, app_label: str) -> tuple[str | None, bool]: ... + unmigrated_apps: set[str] + migrated_apps: set[str] def load_disk(self) -> None: ... def get_migration(self, app_label: str, name_prefix: str) -> Migration: ... def get_migration_by_prefix(self, app_label: str, name_prefix: str) -> Migration: ... - def check_key(self, key: Tuple[str, str], current_app: str) -> Tuple[str, str] | None: ... - def add_internal_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ... - def add_external_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ... + def check_key(self, key: tuple[str, str], current_app: str) -> tuple[str, str] | None: ... + def add_internal_dependencies(self, key: tuple[str, str], migration: Migration) -> None: ... + def add_external_dependencies(self, key: tuple[str, str], migration: Migration) -> None: ... graph: Any replacements: Any def build_graph(self) -> None: ... def check_consistent_history(self, connection: BaseDatabaseWrapper) -> None: ... - def detect_conflicts(self) -> Dict[str, List[str]]: ... + def detect_conflicts(self) -> dict[str, list[str]]: ... def project_state( - self, nodes: Tuple[str, str] | Sequence[Tuple[str, str]] | None = ..., at_end: bool = ... + self, nodes: tuple[str, str] | Sequence[tuple[str, str]] | None = ..., at_end: bool = ... ) -> ProjectState: ... diff --git a/django-stubs/db/migrations/migration.pyi b/django-stubs/db/migrations/migration.pyi index 51e3c0e0b..a9292be9f 100644 --- a/django-stubs/db/migrations/migration.pyi +++ b/django-stubs/db/migrations/migration.pyi @@ -1,14 +1,12 @@ -from typing import List, Tuple - from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.migrations.operations.base import Operation from django.db.migrations.state import ProjectState class Migration: - operations: List[Operation] - dependencies: List[Tuple[str, str]] - run_before: List[Tuple[str, str]] - replaces: List[Tuple[str, str]] + operations: list[Operation] + dependencies: list[tuple[str, str]] + run_before: list[tuple[str, str]] + replaces: list[tuple[str, str]] initial: bool | None atomic: bool name: str @@ -22,8 +20,8 @@ class Migration: self, project_state: ProjectState, schema_editor: BaseDatabaseSchemaEditor, collect_sql: bool = ... ) -> ProjectState: ... -class SwappableTuple(Tuple[str, str]): +class SwappableTuple(tuple[str, str]): setting: str - def __new__(cls, value: Tuple[str, str], setting: str) -> SwappableTuple: ... + def __new__(cls, value: tuple[str, str], setting: str) -> SwappableTuple: ... def swappable_dependency(value: str) -> SwappableTuple: ... diff --git a/django-stubs/db/migrations/operations/base.pyi b/django-stubs/db/migrations/operations/base.pyi index 2f146bba8..90b8787ec 100644 --- a/django-stubs/db/migrations/operations/base.pyi +++ b/django-stubs/db/migrations/operations/base.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Sequence, Tuple, Type +from collections.abc import Sequence +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.base.schema import BaseDatabaseSchemaEditor @@ -10,9 +11,9 @@ class Operation: reduces_to_sql: bool atomic: bool elidable: bool - serialization_expand_args: List[str] - _constructor_args: Tuple[Sequence[Any], Dict[str, Any]] - def deconstruct(self) -> Tuple[str, Sequence[Any], Dict[str, Any]]: ... + serialization_expand_args: list[str] + _constructor_args: tuple[Sequence[Any], dict[str, Any]] + def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ... def state_forwards(self, app_label: str, state: ProjectState) -> None: ... def database_forwards( self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState @@ -23,7 +24,7 @@ class Operation: def describe(self) -> str: ... def references_model(self, name: str, app_label: str) -> bool: ... def references_field(self, model_name: str, name: str, app_label: str) -> bool: ... - def allow_migrate_model(self, connection_alias: BaseDatabaseWrapper | str, model: Type[Model]) -> bool: ... - def reduce(self, operation: Operation, app_label: str) -> bool | List[Operation]: ... + def allow_migrate_model(self, connection_alias: BaseDatabaseWrapper | str, model: type[Model]) -> bool: ... + def reduce(self, operation: Operation, app_label: str) -> bool | list[Operation]: ... @property def migration_name_fragment(self) -> str: ... diff --git a/django-stubs/db/migrations/operations/models.pyi b/django-stubs/db/migrations/operations/models.pyi index c360e191c..35e65b7b4 100644 --- a/django-stubs/db/migrations/operations/models.pyi +++ b/django-stubs/db/migrations/operations/models.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Sequence, Set, Tuple, Type +from collections.abc import Sequence +from typing import Any from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.migrations.operations.base import Operation @@ -16,17 +17,17 @@ class ModelOperation(Operation): def name_lower(self) -> str: ... class CreateModel(ModelOperation): - fields: List[Tuple[str, Field]] - options: Dict[str, Any] - bases: Sequence[Type[Model] | str] | None - managers: Sequence[Tuple[str, Manager]] | None + fields: list[tuple[str, Field]] + options: dict[str, Any] + bases: Sequence[type[Model] | str] | None + managers: Sequence[tuple[str, Manager]] | None def __init__( self, name: str, - fields: List[Tuple[str, Field]], - options: Dict[str, Any] | None = ..., - bases: Sequence[Type[Model] | str] | None = ..., - managers: Sequence[Tuple[str, Manager]] | None = ..., + fields: list[tuple[str, Field]], + options: dict[str, Any] | None = ..., + bases: Sequence[type[Model] | str] | None = ..., + managers: Sequence[tuple[str, Manager]] | None = ..., ) -> None: ... class DeleteModel(ModelOperation): ... @@ -54,8 +55,8 @@ class AlterTogetherOptionOperation(ModelOptionOperation): option_value: _OptionTogetherT | None, ) -> None: ... @property - def option_value(self) -> Set[Tuple[str, ...]] | None: ... - def deconstruct(self) -> Tuple[str, Sequence[Any], Dict[str, Any]]: ... + def option_value(self) -> set[tuple[str, ...]] | None: ... + def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ... def state_forwards(self, app_label: str, state: Any) -> None: ... def database_forwards( self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: Any, to_state: Any @@ -70,12 +71,12 @@ class AlterTogetherOptionOperation(ModelOptionOperation): class AlterUniqueTogether(AlterTogetherOptionOperation): option_name: str - unique_together: Set[Tuple[str, ...]] | None + unique_together: set[tuple[str, ...]] | None def __init__(self, name: str, unique_together: _OptionTogetherT | None) -> None: ... class AlterIndexTogether(AlterTogetherOptionOperation): option_name: str - index_together: Set[Tuple[str, ...]] | None + index_together: set[tuple[str, ...]] | None def __init__(self, name: str, index_together: _OptionTogetherT | None) -> None: ... class AlterOrderWithRespectTo(ModelOptionOperation): @@ -83,13 +84,13 @@ class AlterOrderWithRespectTo(ModelOptionOperation): def __init__(self, name: str, order_with_respect_to: str) -> None: ... class AlterModelOptions(ModelOptionOperation): - ALTER_OPTION_KEYS: List[str] - options: Dict[str, Any] - def __init__(self, name: str, options: Dict[str, Any]) -> None: ... + ALTER_OPTION_KEYS: list[str] + options: dict[str, Any] + def __init__(self, name: str, options: dict[str, Any]) -> None: ... class AlterModelManagers(ModelOptionOperation): - managers: Sequence[Tuple[str, Manager]] - def __init__(self, name: str, managers: Sequence[Tuple[str, Manager]]) -> None: ... + managers: Sequence[tuple[str, Manager]] + def __init__(self, name: str, managers: Sequence[tuple[str, Manager]]) -> None: ... class IndexOperation(Operation): option_name: str diff --git a/django-stubs/db/migrations/operations/special.pyi b/django-stubs/db/migrations/operations/special.pyi index 0597246a5..7fd380fb5 100644 --- a/django-stubs/db/migrations/operations/special.pyi +++ b/django-stubs/db/migrations/operations/special.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Mapping, Optional, Sequence, Tuple, Union +from collections.abc import Mapping, Sequence +from typing import Any, Optional, Union from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.migrations.state import StateApps @@ -16,17 +17,17 @@ class SeparateDatabaseAndState(Operation): class RunSQL(Operation): noop: Literal[""] - sql: Union[str, _ListOrTuple[Union[str, Tuple[str, Union[Dict[str, Any], Optional[_ListOrTuple[str]]]]]]] + sql: Union[str, _ListOrTuple[Union[str, tuple[str, Union[dict[str, Any], Optional[_ListOrTuple[str]]]]]]] reverse_sql: Optional[ - Union[str, _ListOrTuple[Union[str, Tuple[str, Union[Dict[str, Any], Optional[_ListOrTuple[str]]]]]]] + Union[str, _ListOrTuple[Union[str, tuple[str, Union[dict[str, Any], Optional[_ListOrTuple[str]]]]]]] ] state_operations: Sequence[Operation] hints: Mapping[str, Any] def __init__( self, - sql: Union[str, _ListOrTuple[Union[str, Tuple[str, Union[Dict[str, Any], Optional[_ListOrTuple[str]]]]]]], + sql: Union[str, _ListOrTuple[Union[str, tuple[str, Union[dict[str, Any], Optional[_ListOrTuple[str]]]]]]], reverse_sql: Optional[ - Union[str, _ListOrTuple[Union[str, Tuple[str, Union[Dict[str, Any], Optional[_ListOrTuple[str]]]]]]] + Union[str, _ListOrTuple[Union[str, tuple[str, Union[dict[str, Any], Optional[_ListOrTuple[str]]]]]]] ] = ..., state_operations: Sequence[Operation] = ..., hints: Mapping[str, Any] | None = ..., diff --git a/django-stubs/db/migrations/operations/utils.pyi b/django-stubs/db/migrations/operations/utils.pyi index 5bba18185..8fd2c2cd0 100644 --- a/django-stubs/db/migrations/operations/utils.pyi +++ b/django-stubs/db/migrations/operations/utils.pyi @@ -1,26 +1,26 @@ from collections import namedtuple -from typing import Iterator, Tuple, Type +from collections.abc import Iterator from django.db.migrations.state import ModelState, ProjectState from django.db.models import Field, Model from typing_extensions import Literal def resolve_relation( - model: str | Type[Model], app_label: str | None = ..., model_name: str | None = ... -) -> Tuple[str, str]: ... + model: str | type[Model], app_label: str | None = ..., model_name: str | None = ... +) -> tuple[str, str]: ... FieldReference = namedtuple("FieldReference", ["to", "through"]) def field_references( - model_tuple: Tuple[str, str], + model_tuple: tuple[str, str], field: Field, - reference_model_tuple: Tuple[str, str], + reference_model_tuple: tuple[str, str], reference_field_name: str | None = ..., reference_field: Field | None = ..., ) -> Literal[False] | FieldReference: ... def get_references( state: ProjectState, - model_tuple: Tuple[str, str], - field_tuple: Tuple[()] | Tuple[str, Field] = ..., -) -> Iterator[Tuple[ModelState, str, Field, FieldReference]]: ... -def field_is_referenced(state: ProjectState, model_tuple: Tuple[str, str], field_tuple: Tuple[str, Field]) -> bool: ... + model_tuple: tuple[str, str], + field_tuple: tuple[()] | tuple[str, Field] = ..., +) -> Iterator[tuple[ModelState, str, Field, FieldReference]]: ... +def field_is_referenced(state: ProjectState, model_tuple: tuple[str, str], field_tuple: tuple[str, Field]) -> bool: ... diff --git a/django-stubs/db/migrations/optimizer.pyi b/django-stubs/db/migrations/optimizer.pyi index a079b034b..b8022f171 100644 --- a/django-stubs/db/migrations/optimizer.pyi +++ b/django-stubs/db/migrations/optimizer.pyi @@ -1,7 +1,5 @@ -from typing import List - from django.db.migrations.operations.base import Operation class MigrationOptimizer: - def optimize(self, operations: List[Operation], app_label: str | None) -> List[Operation]: ... - def optimize_inner(self, operations: List[Operation], app_label: str | None) -> List[Operation]: ... + def optimize(self, operations: list[Operation], app_label: str | None) -> list[Operation]: ... + def optimize_inner(self, operations: list[Operation], app_label: str | None) -> list[Operation]: ... diff --git a/django-stubs/db/migrations/questioner.pyi b/django-stubs/db/migrations/questioner.pyi index f21dff694..542cd2ac6 100644 --- a/django-stubs/db/migrations/questioner.pyi +++ b/django-stubs/db/migrations/questioner.pyi @@ -1,16 +1,16 @@ -from typing import Any, Dict, Set +from typing import Any from django.db.migrations.state import ModelState from django.db.models.fields import Field class MigrationQuestioner: - defaults: Dict[str, Any] - specified_apps: Set[str] + defaults: dict[str, Any] + specified_apps: set[str] dry_run: bool | None def __init__( self, - defaults: Dict[str, bool] | None = ..., - specified_apps: Set[str] | None = ..., + defaults: dict[str, bool] | None = ..., + specified_apps: set[str] | None = ..., dry_run: bool | None = ..., ) -> None: ... def ask_initial(self, app_label: str) -> bool: ... diff --git a/django-stubs/db/migrations/recorder.pyi b/django-stubs/db/migrations/recorder.pyi index e515c199b..af95d9ce2 100644 --- a/django-stubs/db/migrations/recorder.pyi +++ b/django-stubs/db/migrations/recorder.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Tuple +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.base import Model @@ -15,7 +15,7 @@ class MigrationRecorder: def migration_qs(self) -> QuerySet: ... def has_table(self) -> bool: ... def ensure_schema(self) -> None: ... - def applied_migrations(self) -> Dict[Tuple[str, str], Migration]: ... + def applied_migrations(self) -> dict[tuple[str, str], Migration]: ... def record_applied(self, app: str, name: str) -> None: ... def record_unapplied(self, app: str, name: str) -> None: ... def flush(self) -> None: ... diff --git a/django-stubs/db/migrations/serializer.pyi b/django-stubs/db/migrations/serializer.pyi index 4dc563ed5..c20167b76 100644 --- a/django-stubs/db/migrations/serializer.pyi +++ b/django-stubs/db/migrations/serializer.pyi @@ -1,9 +1,10 @@ -from typing import Any, Callable, Dict, List, Set, Tuple, Type +from collections.abc import Callable +from typing import Any class BaseSerializer: value: Any def __init__(self, value: Any) -> None: ... - def serialize(self) -> Tuple[str, Set[str]]: ... + def serialize(self) -> tuple[str, set[str]]: ... class BaseSequenceSerializer(BaseSerializer): ... class BaseSimpleSerializer(BaseSerializer): ... @@ -14,8 +15,8 @@ class DecimalSerializer(BaseSerializer): ... class DeconstructableSerializer(BaseSerializer): @staticmethod def serialize_deconstructed( - path: str, args: List[Any], kwargs: Dict[str, Callable | int | str] - ) -> Tuple[str, Set[str]]: ... + path: str, args: list[Any], kwargs: dict[str, Callable | int | str] + ) -> tuple[str, set[str]]: ... class DictionarySerializer(BaseSerializer): ... class EnumSerializer(BaseSerializer): ... @@ -41,6 +42,6 @@ def serializer_factory(value: Any) -> BaseSerializer: ... class Serializer: @classmethod - def register(cls, type_: type, serializer: Type[BaseSerializer]) -> None: ... + def register(cls, type_: type, serializer: type[BaseSerializer]) -> None: ... @classmethod def unregister(cls, type_: type) -> None: ... diff --git a/django-stubs/db/migrations/state.pyi b/django-stubs/db/migrations/state.pyi index 0b02d20b8..6a211bc89 100644 --- a/django-stubs/db/migrations/state.pyi +++ b/django-stubs/db/migrations/state.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterator, Sequence from contextlib import contextmanager -from typing import Any, Dict, Iterator, List, Sequence, Set, Tuple, Type +from typing import Any from django.apps import AppConfig from django.apps.registry import Apps @@ -12,23 +13,23 @@ class AppConfigStub(AppConfig): ... class ModelState: name: str app_label: str - fields: Dict[str, Field] - options: Dict[str, Any] - bases: Sequence[Type[Model] | str] - managers: List[Tuple[str, Manager]] + fields: dict[str, Field] + options: dict[str, Any] + bases: Sequence[type[Model] | str] + managers: list[tuple[str, Manager]] def __init__( self, app_label: str, name: str, - fields: List[Tuple[str, Field]] | Dict[str, Field], - options: Dict[str, Any] | None = ..., - bases: Sequence[Type[Model] | str] | None = ..., - managers: List[Tuple[str, Manager]] | None = ..., + fields: list[tuple[str, Field]] | dict[str, Field], + options: dict[str, Any] | None = ..., + bases: Sequence[type[Model] | str] | None = ..., + managers: list[tuple[str, Manager]] | None = ..., ) -> None: ... def clone(self) -> ModelState: ... - def construct_managers(self) -> Iterator[Tuple[str, Manager]]: ... + def construct_managers(self) -> Iterator[tuple[str, Manager]]: ... @classmethod - def from_model(cls, model: Type[Model], exclude_rels: bool = ...) -> ModelState: ... + def from_model(cls, model: type[Model], exclude_rels: bool = ...) -> ModelState: ... # Removed in 3.2, but back in 4.0 # def get_field(self, field_name: str) -> Field: ... @property @@ -38,15 +39,15 @@ class ModelState: def get_constraint_by_name(self, name: str) -> Any: ... def __eq__(self, other: Any) -> bool: ... -def get_related_models_tuples(model: Type[Model]) -> Set[Tuple[str, str]]: ... -def get_related_models_recursive(model: Type[Model]) -> Set[Tuple[str, str]]: ... +def get_related_models_tuples(model: type[Model]) -> set[tuple[str, str]]: ... +def get_related_models_recursive(model: type[Model]) -> set[tuple[str, str]]: ... class ProjectState: is_delayed: bool - models: Dict[Any, Any] - real_apps: List[str] + models: dict[Any, Any] + real_apps: list[str] def __init__( - self, models: Dict[Tuple[str, str], ModelState] | None = ..., real_apps: List[str] | None = ... + self, models: dict[tuple[str, str], ModelState] | None = ..., real_apps: list[str] | None = ... ) -> None: ... def add_model(self, model_state: ModelState) -> None: ... @property @@ -58,17 +59,17 @@ class ProjectState: @classmethod def from_apps(cls, apps: Apps) -> ProjectState: ... def reload_model(self, app_label: str, model_name: str, delay: bool = ...) -> None: ... - def reload_models(self, models: List[Any], delay: bool = ...) -> None: ... + def reload_models(self, models: list[Any], delay: bool = ...) -> None: ... def remove_model(self, app_label: str, model_name: str) -> None: ... class StateApps(Apps): - real_models: List[ModelState] + real_models: list[ModelState] def __init__( - self, real_apps: List[str], models: Dict[Tuple[str, str], ModelState], ignore_swappable: bool = ... + self, real_apps: list[str], models: dict[tuple[str, str], ModelState], ignore_swappable: bool = ... ) -> None: ... @contextmanager def bulk_update(self) -> Iterator[None]: ... def clone(self) -> StateApps: ... - def render_multiple(self, model_states: List[ModelState]) -> None: ... - def register_model(self, app_label: str, model: Type[Model]) -> None: ... + def render_multiple(self, model_states: list[ModelState]) -> None: ... + def register_model(self, app_label: str, model: type[Model]) -> None: ... def unregister_model(self, app_label: str, model_name: str) -> None: ... diff --git a/django-stubs/db/migrations/writer.pyi b/django-stubs/db/migrations/writer.pyi index 8afb50914..edd58e6b1 100644 --- a/django-stubs/db/migrations/writer.pyi +++ b/django-stubs/db/migrations/writer.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Set, Tuple, Type +from typing import Any from django.db.migrations.migration import Migration from django.db.migrations.operations.base import Operation @@ -6,10 +6,10 @@ from django.db.migrations.serializer import BaseSerializer class OperationWriter: operation: Operation - buff: List[Any] + buff: list[Any] indentation: int def __init__(self, operation: Operation, indentation: int = ...) -> None: ... - def serialize(self) -> Tuple[str, Set[str]]: ... + def serialize(self) -> tuple[str, set[str]]: ... def indent(self) -> None: ... def unindent(self) -> None: ... def feed(self, line: str) -> None: ... @@ -27,9 +27,9 @@ class MigrationWriter: @property def path(self) -> str: ... @classmethod - def serialize(cls, value: Any) -> Tuple[str, Set[str]]: ... + def serialize(cls, value: Any) -> tuple[str, set[str]]: ... @classmethod - def register_serializer(cls, type_: type, serializer: Type[BaseSerializer]) -> None: ... + def register_serializer(cls, type_: type, serializer: type[BaseSerializer]) -> None: ... @classmethod def unregister_serializer(cls, type_: type) -> None: ... diff --git a/django-stubs/db/models/base.pyi b/django-stubs/db/models/base.pyi index 0d03dac40..26724afc5 100644 --- a/django-stubs/db/models/base.pyi +++ b/django-stubs/db/models/base.pyi @@ -1,4 +1,5 @@ -from typing import Any, Collection, Dict, Iterable, List, Sequence, Set, Tuple, Type, TypeVar +from collections.abc import Collection, Iterable, Sequence +from typing import Any, TypeVar from django.core.checks.messages import CheckMessage from django.core.exceptions import MultipleObjectsReturned as BaseMultipleObjectsReturned @@ -17,11 +18,11 @@ class ModelState: class ModelBase(type): @property - def objects(cls: Type[_Self]) -> BaseManager[_Self]: ... # type: ignore[misc] + def objects(cls: type[_Self]) -> BaseManager[_Self]: ... # type: ignore[misc] @property - def _default_manager(cls: Type[_Self]) -> BaseManager[_Self]: ... # type: ignore[misc] + def _default_manager(cls: type[_Self]) -> BaseManager[_Self]: ... # type: ignore[misc] @property - def _base_manager(cls: Type[_Self]) -> BaseManager[_Self]: ... # type: ignore[misc] + def _base_manager(cls: type[_Self]) -> BaseManager[_Self]: ... # type: ignore[misc] class Model(metaclass=ModelBase): class DoesNotExist(ObjectDoesNotExist): ... @@ -34,13 +35,13 @@ class Model(metaclass=ModelBase): @classmethod def add_to_class(cls, name: str, value: Any) -> Any: ... @classmethod - def from_db(cls: Type[_Self], db: str | None, field_names: Collection[str], values: Collection[Any]) -> _Self: ... - def delete(self, using: Any = ..., keep_parents: bool = ...) -> Tuple[int, Dict[str, int]]: ... + def from_db(cls: type[_Self], db: str | None, field_names: Collection[str], values: Collection[Any]) -> _Self: ... + def delete(self, using: Any = ..., keep_parents: bool = ...) -> tuple[int, dict[str, int]]: ... def full_clean(self, exclude: Iterable[str] | None = ..., validate_unique: bool = ...) -> None: ... def clean(self) -> None: ... def clean_fields(self, exclude: Collection[str] | None = ...) -> None: ... def validate_unique(self, exclude: Collection[str] | None = ...) -> None: ... - def unique_error_message(self, model_class: Type[_Self], unique_check: Sequence[str]) -> ValidationError: ... + def unique_error_message(self, model_class: type[_Self], unique_check: Sequence[str]) -> ValidationError: ... def save( self, force_insert: bool = ..., @@ -57,9 +58,9 @@ class Model(metaclass=ModelBase): update_fields: Iterable[str] | None = ..., ) -> None: ... def refresh_from_db(self: _Self, using: str | None = ..., fields: Sequence[str] | None = ...) -> None: ... - def get_deferred_fields(self) -> Set[str]: ... + def get_deferred_fields(self) -> set[str]: ... @classmethod - def check(cls, **kwargs: Any) -> List[CheckMessage]: ... + def check(cls, **kwargs: Any) -> list[CheckMessage]: ... def __getstate__(self) -> dict: ... -def model_unpickle(model_id: Tuple[str, str] | type[Model]) -> Model: ... +def model_unpickle(model_id: tuple[str, str] | type[Model]) -> Model: ... diff --git a/django-stubs/db/models/constraints.pyi b/django-stubs/db/models/constraints.pyi index 1de061595..c2a6d9829 100644 --- a/django-stubs/db/models/constraints.pyi +++ b/django-stubs/db/models/constraints.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence from enum import Enum -from typing import Any, Sequence, Tuple, Type, TypeVar, overload +from typing import Any, TypeVar, overload from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.models.base import Model @@ -15,9 +16,9 @@ class Deferrable(Enum): class BaseConstraint: name: str def __init__(self, name: str) -> None: ... - def constraint_sql(self, model: Type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ... - def create_sql(self, model: Type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ... - def remove_sql(self, model: Type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ... + def constraint_sql(self, model: type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ... + def create_sql(self, model: type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ... + def remove_sql(self, model: type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ... def deconstruct(self) -> Any: ... def clone(self: _T) -> _T: ... @@ -26,8 +27,8 @@ class CheckConstraint(BaseConstraint): def __init__(self, *, check: Q, name: str) -> None: ... class UniqueConstraint(BaseConstraint): - expressions: Tuple[Combinable, ...] - fields: Tuple[str, ...] + expressions: tuple[Combinable, ...] + fields: tuple[str, ...] condition: Q | None deferrable: Deferrable | None diff --git a/django-stubs/db/models/deletion.pyi b/django-stubs/db/models/deletion.pyi index f07acda35..23c8b7801 100644 --- a/django-stubs/db/models/deletion.pyi +++ b/django-stubs/db/models/deletion.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Collection, Dict, Iterable, Iterator, List, Sequence, Set, Tuple, Type +from collections.abc import Callable, Collection, Iterable, Iterator, Sequence +from typing import Any from django.db import IntegrityError from django.db.models.base import Model @@ -47,12 +48,12 @@ def SET(value: Any) -> Callable[..., Any]: ... def get_candidate_relations_to_delete(opts: Options) -> Iterable[Field]: ... class ProtectedError(IntegrityError): - protected_objects: Set[Model] - def __init__(self, msg: str, protected_objects: Set[Model]) -> None: ... + protected_objects: set[Model] + def __init__(self, msg: str, protected_objects: set[Model]) -> None: ... class RestrictedError(IntegrityError): - restricted_objects: Set[Model] - def __init__(self, msg: str, restricted_objects: Set[Model]) -> None: ... + restricted_objects: set[Model] + def __init__(self, msg: str, restricted_objects: set[Model]) -> None: ... class Collector: using: str @@ -65,15 +66,15 @@ class Collector: def add( self, objs: _IndexableCollection[Model], - source: Type[Model] | None = ..., + source: type[Model] | None = ..., nullable: bool = ..., reverse_dependency: bool = ..., - ) -> List[Model]: ... - def add_dependency(self, model: Type[Model], dependency: Type[Model], reverse_dependency: bool = ...) -> None: ... + ) -> list[Model]: ... + def add_dependency(self, model: type[Model], dependency: type[Model], reverse_dependency: bool = ...) -> None: ... def add_field_update(self, field: Field, value: Any, objs: _IndexableCollection[Model]) -> None: ... def add_restricted_objects(self, field: Field, objs: _IndexableCollection[Model]) -> None: ... - def clear_restricted_objects_from_set(self, model: Type[Model], objs: Set[Model]) -> None: ... - def clear_restricted_objects_from_queryset(self, model: Type[Model], qs: QuerySet[Model]) -> None: ... + def clear_restricted_objects_from_set(self, model: type[Model], objs: set[Model]) -> None: ... + def clear_restricted_objects_from_queryset(self, model: type[Model], qs: QuerySet[Model]) -> None: ... def can_fast_delete(self, objs: Model | Iterable[Model], from_field: Field | None = ...) -> bool: ... def get_del_batches( self, objs: _IndexableCollection[Model], fields: Iterable[Field] @@ -81,7 +82,7 @@ class Collector: def collect( self, objs: _IndexableCollection[Model | None], - source: Type[Model] | None = ..., + source: type[Model] | None = ..., nullable: bool = ..., collect_related: bool = ..., source_attr: str | None = ..., @@ -90,8 +91,8 @@ class Collector: fail_on_restricted: bool = ..., ) -> None: ... def related_objects( - self, related_model: Type[Model], related_fields: Iterable[Field], objs: _IndexableCollection[Model] + self, related_model: type[Model], related_fields: Iterable[Field], objs: _IndexableCollection[Model] ) -> QuerySet[Model]: ... - def instances_with_model(self) -> Iterator[Tuple[Type[Model], Model]]: ... + def instances_with_model(self) -> Iterator[tuple[type[Model], Model]]: ... def sort(self) -> None: ... - def delete(self) -> Tuple[int, Dict[str, int]]: ... + def delete(self) -> tuple[int, dict[str, int]]: ... diff --git a/django-stubs/db/models/enums.pyi b/django-stubs/db/models/enums.pyi index a90616c79..0e4c43d01 100644 --- a/django-stubs/db/models/enums.pyi +++ b/django-stubs/db/models/enums.pyi @@ -1,6 +1,6 @@ import enum import sys -from typing import Any, List, Tuple +from typing import Any if sys.version_info >= (3, 11): enum_property = enum.property @@ -8,10 +8,10 @@ else: enum_property = property class ChoicesMeta(enum.EnumMeta): - names: List[str] - choices: List[Tuple[Any, str]] - labels: List[str] - values: List[Any] + names: list[str] + choices: list[tuple[Any, str]] + labels: list[str] + values: list[Any] def __contains__(self, member: Any) -> bool: ... class Choices(enum.Enum, metaclass=ChoicesMeta): @@ -23,10 +23,10 @@ class Choices(enum.Enum, metaclass=ChoicesMeta): # fake class _IntegerChoicesMeta(ChoicesMeta): - names: List[str] - choices: List[Tuple[int, str]] - labels: List[str] - values: List[int] + names: list[str] + choices: list[tuple[int, str]] + labels: list[str] + values: list[int] class IntegerChoices(int, Choices, metaclass=_IntegerChoicesMeta): @enum_property @@ -34,10 +34,10 @@ class IntegerChoices(int, Choices, metaclass=_IntegerChoicesMeta): # fake class _TextChoicesMeta(ChoicesMeta): - names: List[str] - choices: List[Tuple[str, str]] - labels: List[str] - values: List[str] + names: list[str] + choices: list[tuple[str, str]] + labels: list[str] + values: list[str] class TextChoices(str, Choices, metaclass=_TextChoicesMeta): @enum_property diff --git a/django-stubs/db/models/expressions.pyi b/django-stubs/db/models/expressions.pyi index 8cd445533..ce6eb1615 100644 --- a/django-stubs/db/models/expressions.pyi +++ b/django-stubs/db/models/expressions.pyi @@ -1,6 +1,7 @@ import datetime +from collections.abc import Callable, Iterable, Iterator, Sequence from decimal import Decimal -from typing import Any, Callable, Dict, Iterable, Iterator, List, Sequence, Set, Tuple, Type, TypeVar +from typing import Any, TypeVar from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models import Q @@ -59,8 +60,8 @@ class BaseExpression: filterable: bool window_compatible: bool def __init__(self, output_field: Field | None = ...) -> None: ... - def get_db_converters(self, connection: BaseDatabaseWrapper) -> List[Callable]: ... - def get_source_expressions(self) -> List[Any]: ... + def get_db_converters(self, connection: BaseDatabaseWrapper) -> list[Callable]: ... + def get_source_expressions(self) -> list[Any]: ... def set_source_expressions(self, exprs: Sequence[Combinable]) -> None: ... @property def contains_aggregate(self) -> bool: ... @@ -72,7 +73,7 @@ class BaseExpression: self: _SelfB, query: Any = ..., allow_joins: bool = ..., - reuse: Set[str] | None = ..., + reuse: set[str] | None = ..., summarize: bool = ..., for_save: bool = ..., ) -> _SelfB: ... @@ -84,12 +85,12 @@ class BaseExpression: def output_field(self) -> Field: ... @property def convert_value(self) -> Callable: ... - def get_lookup(self, lookup: str) -> Type[Lookup] | None: ... - def get_transform(self, name: str) -> Type[Transform] | None: ... - def relabeled_clone(self: _SelfB, change_map: Dict[str | None, str]) -> _SelfB: ... + def get_lookup(self, lookup: str) -> type[Lookup] | None: ... + def get_transform(self, name: str) -> type[Transform] | None: ... + def relabeled_clone(self: _SelfB, change_map: dict[str | None, str]) -> _SelfB: ... def copy(self: _SelfB) -> _SelfB: ... - def get_group_by_cols(self: _SelfB, alias: str | None = ...) -> List[_SelfB]: ... - def get_source_fields(self) -> List[Field | None]: ... + def get_group_by_cols(self: _SelfB, alias: str | None = ...) -> list[_SelfB]: ... + def get_source_fields(self) -> list[Field | None]: ... def asc( self, *, @@ -123,7 +124,7 @@ class F(Combinable): self, query: Any = ..., allow_joins: bool = ..., - reuse: Set[str] | None = ..., + reuse: set[str] | None = ..., summarize: bool = ..., for_save: bool = ..., ) -> F: ... @@ -152,7 +153,7 @@ class OuterRef(F): class Subquery(BaseExpression, Combinable): template: str query: Query - extra: Dict[Any, Any] + extra: dict[Any, Any] def __init__(self, queryset: Query | QuerySet, output_field: Field | None = ..., **extra: Any) -> None: ... class Exists(Subquery): @@ -179,7 +180,7 @@ class Value(Expression): def __init__(self, value: Any, output_field: Field | None = ...) -> None: ... class RawSQL(Expression): - params: List[Any] + params: list[Any] sql: str def __init__(self, sql: str, params: Sequence[Any], output_field: Field | None = ...) -> None: ... @@ -189,8 +190,8 @@ class Func(SQLiteNumericMixin, Expression): template: str arg_joiner: str arity: int | None - source_expressions: List[Expression] - extra: Dict[Any, Any] + source_expressions: list[Expression] + extra: dict[Any, Any] def __init__(self, *expressions: Any, output_field: Field | None = ..., **extra: Any) -> None: ... class When(Expression): @@ -246,7 +247,7 @@ class WindowFrame(Expression): def __init__(self, start: int | None = ..., end: int | None = ...) -> None: ... def window_frame_start_end( self, connection: BaseDatabaseWrapper, start: int | None, end: int | None - ) -> Tuple[int, int]: ... + ) -> tuple[int, int]: ... class RowRange(WindowFrame): ... class ValueRange(WindowFrame): ... diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 76851c53e..0635dd5ef 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -1,9 +1,10 @@ import decimal import uuid +from collections.abc import Callable, Iterable, Sequence from datetime import date from datetime import datetime as real_datetime from datetime import time, timedelta -from typing import Any, Callable, Dict, Generic, Iterable, List, Sequence, Tuple, Type, TypeVar, overload +from typing import Any, Generic, TypeVar, overload from django.core import validators # due to weird mypy.stubtest error from django.core.checks import CheckMessage @@ -22,19 +23,19 @@ from typing_extensions import Protocol class Empty: ... class NOT_PROVIDED: ... -BLANK_CHOICE_DASH: List[Tuple[str, str]] +BLANK_CHOICE_DASH: list[tuple[str, str]] -_Choice = Tuple[Any, Any] -_ChoiceNamedGroup = Tuple[str, Iterable[_Choice]] +_Choice = tuple[Any, Any] +_ChoiceNamedGroup = tuple[str, Iterable[_Choice]] _FieldChoices = Iterable[_Choice | _ChoiceNamedGroup] _ChoicesList = Sequence[_Choice] | Sequence[_ChoiceNamedGroup] -_LimitChoicesTo = Q | Dict[str, Any] +_LimitChoicesTo = Q | dict[str, Any] class _ChoicesCallable(Protocol): def __call__(self) -> _FieldChoices: ... _AllLimitChoicesTo = _LimitChoicesTo | _ChoicesCallable -_ErrorMessagesT = Dict[str, Any] +_ErrorMessagesT = dict[str, Any] _T = TypeVar("_T", bound="Field") # __set__ value type @@ -112,13 +113,13 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): primary_key: bool remote_field: ForeignObjectRel | None is_relation: bool - related_model: Type[Model] | None + related_model: type[Model] | None one_to_many: bool | None one_to_one: bool | None many_to_many: bool | None many_to_one: bool | None max_length: int | None - model: Type[Model] + model: type[Model] name: str verbose_name: _StrOrPromise description: str | _Getter[str] @@ -137,11 +138,11 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): creation_counter: int auto_creation_counter: int default_validators: Sequence[validators._ValidatorCallable] - default_error_messages: Dict[str, str] + default_error_messages: dict[str, str] hidden: bool system_check_removed_details: Any | None system_check_deprecated_details: Any | None - non_db_attrs: Tuple[str, ...] + non_db_attrs: tuple[str, ...] def __init__( self, verbose_name: _StrOrPromise | None = ..., @@ -182,7 +183,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): def db_type_parameters(self, connection: BaseDatabaseWrapper) -> DictWrapper: ... def db_check(self, connection: BaseDatabaseWrapper) -> str | None: ... def db_type(self, connection: BaseDatabaseWrapper) -> str | None: ... - def db_parameters(self, connection: BaseDatabaseWrapper) -> Dict[str, str | None]: ... + def db_parameters(self, connection: BaseDatabaseWrapper) -> dict[str, str | None]: ... def pre_save(self, model_instance: Model, add: bool) -> Any: ... def get_prep_value(self, value: Any) -> Any: ... def get_db_prep_value(self, value: Any, connection: BaseDatabaseWrapper, prepared: bool = ...) -> Any: ... @@ -191,10 +192,10 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): # TODO: plugin support def formfield(self, form_class: Any | None = ..., choices_form_class: Any | None = ..., **kwargs: Any) -> Any: ... def save_form_data(self, instance: Model, data: Any) -> None: ... - def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ... + def contribute_to_class(self, cls: type[Model], name: str, private_only: bool = ...) -> None: ... def to_python(self, value: Any) -> Any: ... @property - def validators(self) -> List[validators._ValidatorCallable]: ... + def validators(self) -> list[validators._ValidatorCallable]: ... def run_validators(self, value: Any) -> None: ... def validate(self, value: Any, model_instance: Model | None) -> None: ... def clean(self, value: Any, model_instance: Model | None) -> Any: ... @@ -205,12 +206,12 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): limit_choices_to: _LimitChoicesTo | None = ..., ordering: Sequence[str] = ..., ) -> _ChoicesList: ... - def _get_flatchoices(self) -> List[_Choice]: ... + def _get_flatchoices(self) -> list[_Choice]: ... @property - def flatchoices(self) -> List[_Choice]: ... + def flatchoices(self) -> list[_Choice]: ... def has_default(self) -> bool: ... def get_default(self) -> Any: ... - def check(self, **kwargs: Any) -> List[CheckMessage]: ... + def check(self, **kwargs: Any) -> list[CheckMessage]: ... def get_col(self, alias: str, output_field: Field | None = ...) -> Col: ... @property def cached_col(self) -> Col: ... @@ -410,7 +411,7 @@ class GenericIPAddressField(Field[_ST, _GT]): _pyi_private_set_type: str | int | Callable[..., Any] | Combinable _pyi_private_get_type: str - default_error_messages: Dict[str, str] + default_error_messages: dict[str, str] unpack_ipv4: bool protocol: str def __init__( diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index 691186f0a..7888ac93c 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Iterable, Type, TypeVar, overload +from collections.abc import Callable, Iterable +from typing import Any, TypeVar, overload from django.core import validators # due to weird mypy.stubtest error from django.core.files.base import File @@ -32,7 +33,7 @@ class FieldFile(File): class FileDescriptor(DeferredAttribute): field: FileField def __set__(self, instance: Model, value: Any | None) -> None: ... - def __get__(self, instance: Model | None, cls: Type[Model] | None = ...) -> FieldFile | FileDescriptor: ... + def __get__(self, instance: Model | None, cls: type[Model] | None = ...) -> FieldFile | FileDescriptor: ... _T = TypeVar("_T", bound="Field") _M = TypeVar("_M", bound=Model, contravariant=True) diff --git a/django-stubs/db/models/fields/json.pyi b/django-stubs/db/models/fields/json.pyi index b48cbb234..63206bd86 100644 --- a/django-stubs/db/models/fields/json.pyi +++ b/django-stubs/db/models/fields/json.pyi @@ -1,5 +1,5 @@ import json -from typing import Any, Type +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models import lookups @@ -11,14 +11,14 @@ from . import Field from .mixins import CheckFieldDefaultMixin class JSONField(CheckFieldDefaultMixin, Field): - encoder: Type[json.JSONEncoder] | None - decoder: Type[json.JSONDecoder] | None + encoder: type[json.JSONEncoder] | None + decoder: type[json.JSONDecoder] | None def __init__( self, verbose_name: _StrOrPromise | None = ..., name: str | None = ..., - encoder: Type[json.JSONEncoder] | None = ..., - decoder: Type[json.JSONDecoder] | None = ..., + encoder: type[json.JSONEncoder] | None = ..., + decoder: type[json.JSONDecoder] | None = ..., **kwargs: Any ) -> None: ... diff --git a/django-stubs/db/models/fields/related.pyi b/django-stubs/db/models/fields/related.pyi index c182d07bc..eb8b05c2f 100644 --- a/django-stubs/db/models/fields/related.pyi +++ b/django-stubs/db/models/fields/related.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, Iterable, List, Sequence, Tuple, Type, TypeVar, overload +from collections.abc import Callable, Iterable, Sequence +from typing import Any, TypeVar, overload from uuid import UUID from django.core import validators # due to weird mypy.stubtest error @@ -28,7 +29,7 @@ _F = TypeVar("_F", bound=models.Field) RECURSIVE_RELATIONSHIP_CONSTANT: Literal["self"] -def resolve_relation(scope_model: Type[Model], relation: str | Type[Model]) -> str | Type[Model]: ... +def resolve_relation(scope_model: type[Model], relation: str | type[Model]) -> str | type[Model]: ... # __set__ value type _ST = TypeVar("_ST") @@ -43,16 +44,16 @@ class RelatedField(FieldCacheMixin, Field[_ST, _GT]): opts: Any remote_field: ForeignObjectRel - rel_class: Type[ForeignObjectRel] + rel_class: type[ForeignObjectRel] swappable: bool @property - def related_model(self) -> Type[Model]: ... # type: ignore - def get_forward_related_filter(self, obj: Model) -> Dict[str, int | UUID]: ... + def related_model(self) -> type[Model]: ... # type: ignore + def get_forward_related_filter(self, obj: Model) -> dict[str, int | UUID]: ... def get_reverse_related_filter(self, obj: Model) -> Q: ... @property def swappable_setting(self) -> str | None: ... def set_attributes_from_rel(self) -> None: ... - def do_related_class(self, other: Type[Model], cls: Type[Model]) -> None: ... + def do_related_class(self, other: type[Model], cls: type[Model]) -> None: ... def get_limit_choices_to(self) -> _LimitChoicesTo: ... def related_query_name(self) -> str: ... @property @@ -60,13 +61,13 @@ class RelatedField(FieldCacheMixin, Field[_ST, _GT]): class ForeignObject(RelatedField[_ST, _GT]): remote_field: ForeignObjectRel - rel_class: Type[ForeignObjectRel] + rel_class: type[ForeignObjectRel] from_fields: Sequence[str] to_fields: Sequence[str | None] # None occurs in ForeignKey, where to_field defaults to None swappable: bool def __init__( self, - to: Type[Model] | str, + to: type[Model] | str, on_delete: Callable[..., None], from_fields: Sequence[str], to_fields: Sequence[str], @@ -96,25 +97,25 @@ class ForeignObject(RelatedField[_ST, _GT]): validators: Iterable[validators._ValidatorCallable] = ..., error_messages: _ErrorMessagesT | None = ..., ) -> None: ... - def resolve_related_fields(self) -> List[Tuple[Field, Field]]: ... + def resolve_related_fields(self) -> list[tuple[Field, Field]]: ... @property - def related_fields(self) -> List[Tuple[Field, Field]]: ... + def related_fields(self) -> list[tuple[Field, Field]]: ... @property - def reverse_related_fields(self) -> List[Tuple[Field, Field]]: ... + def reverse_related_fields(self) -> list[tuple[Field, Field]]: ... @property - def local_related_fields(self) -> Tuple[Field, ...]: ... + def local_related_fields(self) -> tuple[Field, ...]: ... @property - def foreign_related_fields(self) -> Tuple[Field, ...]: ... + def foreign_related_fields(self) -> tuple[Field, ...]: ... class ForeignKey(ForeignObject[_ST, _GT]): _pyi_private_set_type: Any | Combinable _pyi_private_get_type: Any remote_field: ManyToOneRel - rel_class: Type[ManyToOneRel] + rel_class: type[ManyToOneRel] def __init__( self, - to: Type[Model] | str, + to: type[Model] | str, on_delete: Callable[..., None], related_name: str | None = ..., related_query_name: str | None = ..., @@ -160,10 +161,10 @@ class OneToOneField(ForeignKey[_ST, _GT]): _pyi_private_get_type: Any remote_field: OneToOneRel - rel_class: Type[OneToOneRel] + rel_class: type[OneToOneRel] def __init__( self, - to: Type[Model] | str, + to: type[Model] | str, on_delete: Any, to_field: str | None = ..., *, @@ -218,16 +219,16 @@ class ManyToManyField(RelatedField[_ST, _GT]): one_to_one: Literal[False] remote_field: ManyToManyRel - rel_class: Type[ManyToManyRel] + rel_class: type[ManyToManyRel] def __init__( self, - to: Type[Model] | str, + to: type[Model] | str, related_name: str | None = ..., related_query_name: str | None = ..., limit_choices_to: _AllLimitChoicesTo | None = ..., symmetrical: bool | None = ..., - through: str | Type[Model] | None = ..., - through_fields: Tuple[str, str] | None = ..., + through: str | type[Model] | None = ..., + through_fields: tuple[str, str] | None = ..., db_constraint: bool = ..., db_table: str | None = ..., swappable: bool = ..., @@ -263,9 +264,9 @@ class ManyToManyField(RelatedField[_ST, _GT]): # non-Model instances @overload def __get__(self: _F, instance: Any, owner: Any) -> _F: ... - def get_path_info(self, filtered_relation: FilteredRelation | None = ...) -> List[PathInfo]: ... - def get_reverse_path_info(self, filtered_relation: FilteredRelation | None = ...) -> List[PathInfo]: ... - def contribute_to_related_class(self, cls: Type[Model], related: RelatedField) -> None: ... + def get_path_info(self, filtered_relation: FilteredRelation | None = ...) -> list[PathInfo]: ... + def get_reverse_path_info(self, filtered_relation: FilteredRelation | None = ...) -> list[PathInfo]: ... + def contribute_to_related_class(self, cls: type[Model], related: RelatedField) -> None: ... def m2m_db_table(self) -> str: ... def m2m_column_name(self) -> str: ... def m2m_reverse_name(self) -> str: ... @@ -273,4 +274,4 @@ class ManyToManyField(RelatedField[_ST, _GT]): def m2m_target_field_name(self) -> str: ... def m2m_reverse_target_field_name(self) -> str: ... -def create_many_to_many_intermediary_model(field: ManyToManyField, klass: Type[Model]) -> Type[Model]: ... +def create_many_to_many_intermediary_model(field: ManyToManyField, klass: type[Model]) -> type[Model]: ... diff --git a/django-stubs/db/models/fields/related_descriptors.pyi b/django-stubs/db/models/fields/related_descriptors.pyi index cb962fcd1..17fd95b0f 100644 --- a/django-stubs/db/models/fields/related_descriptors.pyi +++ b/django-stubs/db/models/fields/related_descriptors.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Generic, List, Tuple, Type, TypeVar +from collections.abc import Callable +from typing import Any, Generic, TypeVar from django.core.exceptions import ObjectDoesNotExist from django.db.models.base import Model @@ -19,18 +20,18 @@ class ForwardManyToOneDescriptor: field: ForeignKey def __init__(self, field_with_rel: ForeignKey) -> None: ... @property - def RelatedObjectDoesNotExist(self) -> Type[ObjectDoesNotExist]: ... + def RelatedObjectDoesNotExist(self) -> type[ObjectDoesNotExist]: ... def is_cached(self, instance: Model) -> bool: ... def get_queryset(self, **hints: Any) -> QuerySet: ... def get_prefetch_queryset( - self, instances: List[Model], queryset: QuerySet | None = ... - ) -> Tuple[QuerySet, Callable, Callable, bool, str, bool]: ... + self, instances: list[Model], queryset: QuerySet | None = ... + ) -> tuple[QuerySet, Callable, Callable, bool, str, bool]: ... def get_object(self, instance: Model) -> Model: ... def __get__( - self, instance: Model | None, cls: Type[Model] | None = ... + self, instance: Model | None, cls: type[Model] | None = ... ) -> Model | ForwardManyToOneDescriptor | None: ... def __set__(self, instance: Model, value: Model | None) -> None: ... - def __reduce__(self) -> Tuple[Callable, Tuple[Type[Model], str]]: ... + def __reduce__(self) -> tuple[Callable, tuple[type[Model], str]]: ... class ForwardOneToOneDescriptor(ForwardManyToOneDescriptor): field: OneToOneField @@ -40,26 +41,26 @@ class ReverseOneToOneDescriptor: related: OneToOneRel def __init__(self, related: OneToOneRel) -> None: ... @property - def RelatedObjectDoesNotExist(self) -> Type[ObjectDoesNotExist]: ... + def RelatedObjectDoesNotExist(self) -> type[ObjectDoesNotExist]: ... def is_cached(self, instance: Model) -> bool: ... def get_queryset(self, **hints: Any) -> QuerySet: ... def get_prefetch_queryset( - self, instances: List[Model], queryset: QuerySet | None = ... - ) -> Tuple[QuerySet, Callable, Callable, bool, str, bool]: ... - def __get__(self, instance: Model | None, cls: Type[Model] | None = ...) -> Model | ReverseOneToOneDescriptor: ... + self, instances: list[Model], queryset: QuerySet | None = ... + ) -> tuple[QuerySet, Callable, Callable, bool, str, bool]: ... + def __get__(self, instance: Model | None, cls: type[Model] | None = ...) -> Model | ReverseOneToOneDescriptor: ... def __set__(self, instance: Model, value: Model | None) -> None: ... - def __reduce__(self) -> Tuple[Callable, Tuple[Type[Model], str]]: ... + def __reduce__(self) -> tuple[Callable, tuple[type[Model], str]]: ... class ReverseManyToOneDescriptor: rel: ManyToOneRel field: ForeignKey def __init__(self, rel: ManyToOneRel) -> None: ... @property - def related_manager_cls(self) -> Type[RelatedManager]: ... - def __get__(self, instance: Model | None, cls: Type[Model] | None = ...) -> ReverseManyToOneDescriptor: ... - def __set__(self, instance: Model, value: List[Model]) -> Any: ... + def related_manager_cls(self) -> type[RelatedManager]: ... + def __get__(self, instance: Model | None, cls: type[Model] | None = ...) -> ReverseManyToOneDescriptor: ... + def __set__(self, instance: Model, value: list[Model]) -> Any: ... -def create_reverse_many_to_one_manager(superclass: Type, rel: Any) -> Type[RelatedManager]: ... +def create_reverse_many_to_one_manager(superclass: type, rel: Any) -> type[RelatedManager]: ... class ManyToManyDescriptor(ReverseManyToOneDescriptor): field: ManyToManyField # type: ignore[assignment] @@ -67,12 +68,12 @@ class ManyToManyDescriptor(ReverseManyToOneDescriptor): reverse: bool def __init__(self, rel: ManyToManyRel, reverse: bool = ...) -> None: ... @property - def through(self) -> Type[Model]: ... + def through(self) -> type[Model]: ... @property - def related_manager_cls(self) -> Type[Any]: ... # ManyRelatedManager + def related_manager_cls(self) -> type[Any]: ... # ManyRelatedManager # fake class _ForwardManyToManyManager(Generic[_T]): def all(self) -> QuerySet: ... -def create_forward_many_to_many_manager(superclass: Type, rel: Any, reverse: Any) -> _ForwardManyToManyManager: ... +def create_forward_many_to_many_manager(superclass: type, rel: Any, reverse: Any) -> _ForwardManyToManyManager: ... diff --git a/django-stubs/db/models/fields/related_lookups.pyi b/django-stubs/db/models/fields/related_lookups.pyi index 3b32cbf9d..f97a1a032 100644 --- a/django-stubs/db/models/fields/related_lookups.pyi +++ b/django-stubs/db/models/fields/related_lookups.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, List, Mapping, Tuple, Type +from collections.abc import Iterable, Mapping +from typing import Any from django.db.models.fields import Field from django.db.models.lookups import ( @@ -15,20 +16,20 @@ from django.db.models.lookups import ( class MultiColSource: alias: str field: Field - sources: Tuple[Field, Field] - targets: Tuple[Field, Field] + sources: tuple[Field, Field] + targets: tuple[Field, Field] contains_aggregate: bool output_field: Field def __init__( - self, alias: str, targets: Tuple[Field, Field], sources: Tuple[Field, Field], field: Field + self, alias: str, targets: tuple[Field, Field], sources: tuple[Field, Field], field: Field ) -> None: ... def relabeled_clone(self, relabels: Mapping[str, str]) -> MultiColSource: ... - def get_lookup(self, lookup: str) -> Type[Lookup] | None: ... + def get_lookup(self, lookup: str) -> type[Lookup] | None: ... -def get_normalized_value(value: Any, lhs: Any) -> Tuple[Any, ...]: ... +def get_normalized_value(value: Any, lhs: Any) -> tuple[Any, ...]: ... class RelatedIn(In): - bilateral_transforms: List[Any] + bilateral_transforms: list[Any] lhs: Any rhs: Any def get_prep_lookup(self) -> Iterable[Any]: ... diff --git a/django-stubs/db/models/fields/reverse_related.pyi b/django-stubs/db/models/fields/reverse_related.pyi index 65807e856..8274f773f 100644 --- a/django-stubs/db/models/fields/reverse_related.pyi +++ b/django-stubs/db/models/fields/reverse_related.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, List, Sequence, Tuple, Type +from collections.abc import Callable, Sequence +from typing import Any from django.db.models.base import Model from django.db.models.fields import AutoField, Field, _AllLimitChoicesTo, _ChoicesList, _LimitChoicesTo @@ -23,7 +24,7 @@ class ForeignObjectRel(FieldCacheMixin): is_relation: bool null: bool field: ForeignObject - model: Type[Model] + model: type[Model] related_name: str | None related_query_name: str | None limit_choices_to: _AllLimitChoicesTo | None @@ -35,7 +36,7 @@ class ForeignObjectRel(FieldCacheMixin): def __init__( self, field: ForeignObject, - to: Type[Model] | str, + to: type[Model] | str, related_name: str | None = ..., related_query_name: str | None = ..., limit_choices_to: _AllLimitChoicesTo | None = ..., @@ -51,7 +52,7 @@ class ForeignObjectRel(FieldCacheMixin): @property def target_field(self) -> AutoField: ... @property - def related_model(self) -> Type[Model]: ... + def related_model(self) -> type[Model]: ... @property def many_to_many(self) -> bool: ... @property @@ -60,7 +61,7 @@ class ForeignObjectRel(FieldCacheMixin): def one_to_many(self) -> bool: ... @property def one_to_one(self) -> bool: ... - def get_lookup(self, lookup_name: str) -> Type[Lookup] | None: ... + def get_lookup(self, lookup_name: str) -> type[Lookup] | None: ... def get_internal_type(self) -> str: ... @property def db_type(self) -> Any: ... @@ -74,20 +75,20 @@ class ForeignObjectRel(FieldCacheMixin): ordering: Sequence[str] = ..., ) -> _ChoicesList: ... def is_hidden(self) -> bool: ... - def get_joining_columns(self) -> Tuple: ... + def get_joining_columns(self) -> tuple: ... def get_extra_restriction( - self, where_class: Type[WhereNode], alias: str, related_alias: str + self, where_class: type[WhereNode], alias: str, related_alias: str ) -> StartsWith | WhereNode | None: ... def set_field_name(self) -> None: ... - def get_accessor_name(self, model: Type[Model] | None = ...) -> str | None: ... - def get_path_info(self, filtered_relation: FilteredRelation | None = ...) -> List[PathInfo]: ... + def get_accessor_name(self, model: type[Model] | None = ...) -> str | None: ... + def get_path_info(self, filtered_relation: FilteredRelation | None = ...) -> list[PathInfo]: ... class ManyToOneRel(ForeignObjectRel): field: ForeignKey def __init__( self, field: ForeignKey, - to: Type[Model] | str, + to: type[Model] | str, field_name: str, related_name: str | None = ..., related_query_name: str | None = ..., @@ -102,7 +103,7 @@ class OneToOneRel(ManyToOneRel): def __init__( self, field: OneToOneField, - to: Type[Model] | str, + to: type[Model] | str, field_name: str | None, related_name: str | None = ..., related_query_name: str | None = ..., @@ -113,19 +114,19 @@ class OneToOneRel(ManyToOneRel): class ManyToManyRel(ForeignObjectRel): field: ManyToManyField # type: ignore - through: Type[Model] | None - through_fields: Tuple[str, str] | None + through: type[Model] | None + through_fields: tuple[str, str] | None db_constraint: bool def __init__( self, field: ManyToManyField, - to: Type[Model] | str, + to: type[Model] | str, related_name: str | None = ..., related_query_name: str | None = ..., limit_choices_to: _AllLimitChoicesTo | None = ..., symmetrical: bool = ..., - through: Type[Model] | str | None = ..., - through_fields: Tuple[str, str] | None = ..., + through: type[Model] | str | None = ..., + through_fields: tuple[str, str] | None = ..., db_constraint: bool = ..., ) -> None: ... def get_related_field(self) -> Field: ... diff --git a/django-stubs/db/models/functions/text.pyi b/django-stubs/db/models/functions/text.pyi index 14631e4f6..dedbf6971 100644 --- a/django-stubs/db/models/functions/text.pyi +++ b/django-stubs/db/models/functions/text.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Tuple +from typing import Any from django.db import models from django.db.backends.base.base import BaseDatabaseWrapper diff --git a/django-stubs/db/models/indexes.pyi b/django-stubs/db/models/indexes.pyi index 4bdb37a2a..fe370f0df 100644 --- a/django-stubs/db/models/indexes.pyi +++ b/django-stubs/db/models/indexes.pyi @@ -1,4 +1,5 @@ -from typing import Any, List, Sequence, Set, Tuple, Type +from collections.abc import Sequence +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.base.schema import BaseDatabaseSchemaEditor @@ -9,11 +10,11 @@ from django.db.models.query_utils import Q from django.db.models.sql.compiler import SQLCompiler, _AsSqlType class Index: - model: Type[Model] + model: type[Model] suffix: str max_name_length: int fields: Sequence[str] - fields_orders: Sequence[Tuple[str, str]] + fields_orders: Sequence[tuple[str, str]] name: str db_tablespace: str | None opclasses: Sequence[str] @@ -33,12 +34,12 @@ class Index: @property def contains_expressions(self) -> bool: ... def create_sql( - self, model: Type[Model], schema_editor: BaseDatabaseSchemaEditor, using: str = ..., **kwargs: Any + self, model: type[Model], schema_editor: BaseDatabaseSchemaEditor, using: str = ..., **kwargs: Any ) -> Statement: ... - def remove_sql(self, model: Type[Model], schema_editor: BaseDatabaseSchemaEditor, **kwargs: Any) -> str: ... + def remove_sql(self, model: type[Model], schema_editor: BaseDatabaseSchemaEditor, **kwargs: Any) -> str: ... def deconstruct(self) -> Any: ... def clone(self) -> Index: ... - def set_name_with_model(self, model: Type[Model]) -> None: ... + def set_name_with_model(self, model: type[Model]) -> None: ... class IndexExpression(Func): template: str @@ -50,7 +51,7 @@ class IndexExpression(Func): self, query: Any | None = ..., allow_joins: bool = ..., - reuse: Set[str] | None = ..., + reuse: set[str] | None = ..., summarize: bool = ..., for_save: bool = ..., ) -> IndexExpression: ... diff --git a/django-stubs/db/models/lookups.pyi b/django-stubs/db/models/lookups.pyi index 9c694a5b1..78f6a19bb 100644 --- a/django-stubs/db/models/lookups.pyi +++ b/django-stubs/db/models/lookups.pyi @@ -1,4 +1,5 @@ -from typing import Any, Generic, Iterable, List, Mapping, Tuple, Type, TypeVar +from collections.abc import Iterable, Mapping +from typing import Any, Generic, TypeVar from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.expressions import Expression, Func @@ -16,14 +17,14 @@ class Lookup(Generic[_T]): can_use_none_as_rhs: bool lhs: Any rhs: Any - bilateral_transforms: List[Type[Transform]] + bilateral_transforms: list[type[Transform]] def __init__(self, lhs: Any, rhs: Any) -> None: ... def apply_bilateral_transforms(self, value: Expression) -> Expression: ... def batch_process_rhs( self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, rhs: OrderedSet | None = ... - ) -> Tuple[List[str], List[str]]: ... - def get_source_expressions(self) -> List[Expression]: ... - def set_source_expressions(self, new_exprs: List[Expression]) -> None: ... + ) -> tuple[list[str], list[str]]: ... + def get_source_expressions(self) -> list[Expression]: ... + def set_source_expressions(self, new_exprs: list[Expression]) -> None: ... def get_prep_lookup(self) -> Any: ... def get_db_prep_lookup(self, value: _ParamT, connection: BaseDatabaseWrapper) -> _AsSqlType: ... def process_lhs( @@ -32,7 +33,7 @@ class Lookup(Generic[_T]): def process_rhs(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... def rhs_is_direct_value(self) -> bool: ... def relabeled_clone(self: _L, relabels: Mapping[str, str]) -> _L: ... - def get_group_by_cols(self, alias: str | None = ...) -> List[Expression]: ... + def get_group_by_cols(self, alias: str | None = ...) -> list[Expression]: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... def as_oracle(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... @property @@ -42,13 +43,13 @@ class Lookup(Generic[_T]): @property def is_summary(self) -> bool: ... @property - def identity(self) -> Tuple[Type[Lookup], Any, Any]: ... + def identity(self) -> tuple[type[Lookup], Any, Any]: ... class Transform(RegisterLookupMixin, Func): bilateral: bool @property def lhs(self) -> Expression: ... - def get_bilateral_transforms(self) -> List[Type[Transform]]: ... + def get_bilateral_transforms(self) -> list[type[Transform]]: ... class BuiltinLookup(Lookup[_T]): def process_lhs( @@ -103,24 +104,24 @@ class Regex(BuiltinLookup[str]): ... class IRegex(Regex): ... class YearLookup(Lookup): - def year_lookup_bounds(self, connection: BaseDatabaseWrapper, year: int) -> List[str]: ... + def year_lookup_bounds(self, connection: BaseDatabaseWrapper, year: int) -> list[str]: ... def get_direct_rhs_sql(self, connection: BaseDatabaseWrapper, rhs: str) -> str: ... def get_bound_params(self, start: Any, finish: Any) -> Any: ... class YearExact(YearLookup, Exact[_T]): - def get_bound_params(self, start: Any, finish: Any) -> Tuple[Any, Any]: ... + def get_bound_params(self, start: Any, finish: Any) -> tuple[Any, Any]: ... class YearGt(YearLookup, GreaterThan[_T]): - def get_bound_params(self, start: Any, finish: Any) -> Tuple[Any]: ... + def get_bound_params(self, start: Any, finish: Any) -> tuple[Any]: ... class YearGte(YearLookup, GreaterThanOrEqual[_T]): - def get_bound_params(self, start: Any, finish: Any) -> Tuple[Any]: ... + def get_bound_params(self, start: Any, finish: Any) -> tuple[Any]: ... class YearLt(YearLookup, LessThan[_T]): - def get_bound_params(self, start: Any, finish: Any) -> Tuple[Any]: ... + def get_bound_params(self, start: Any, finish: Any) -> tuple[Any]: ... class YearLte(YearLookup, LessThanOrEqual[_T]): - def get_bound_params(self, start: Any, finish: Any) -> Tuple[Any]: ... + def get_bound_params(self, start: Any, finish: Any) -> tuple[Any]: ... class UUIDTextMixin: rhs: Any diff --git a/django-stubs/db/models/manager.pyi b/django-stubs/db/models/manager.pyi index f471ada24..a989f2971 100644 --- a/django-stubs/db/models/manager.pyi +++ b/django-stubs/db/models/manager.pyi @@ -1,20 +1,6 @@ import datetime -from typing import ( - Any, - Collection, - Dict, - Generic, - Iterable, - Iterator, - List, - MutableMapping, - NoReturn, - Sequence, - Tuple, - Type, - TypeVar, - overload, -) +from collections.abc import Collection, Iterable, Iterator, MutableMapping, Sequence +from typing import Any, Generic, NoReturn, TypeVar, overload from django.db.models import Combinable from django.db.models.base import Model @@ -30,19 +16,19 @@ class BaseManager(Generic[_T]): auto_created: bool use_in_migrations: bool name: str - model: Type[_T] + model: type[_T] _db: str | None def __init__(self) -> None: ... def deconstruct( self, - ) -> Tuple[bool, str | None, str | None, Tuple[Any, ...] | None, Dict[str, Any] | None]: ... - def check(self, **kwargs: Any) -> List[Any]: ... + ) -> tuple[bool, str | None, str | None, tuple[Any, ...] | None, dict[str, Any] | None]: ... + def check(self, **kwargs: Any) -> list[Any]: ... @classmethod - def from_queryset(cls, queryset_class: Type[QuerySet], class_name: str | None = ...) -> Any: ... + def from_queryset(cls, queryset_class: type[QuerySet], class_name: str | None = ...) -> Any: ... @classmethod - def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ... - def contribute_to_class(self, cls: Type[Model], name: str) -> None: ... - def db_manager(self: _M, using: str | None = ..., hints: Dict[str, Model] | None = ...) -> _M: ... + def _get_queryset_methods(cls, queryset_class: type) -> dict[str, Any]: ... + def contribute_to_class(self, cls: type[Model], name: str) -> None: ... + def db_manager(self: _M, using: str | None = ..., hints: dict[str, Model] | None = ...) -> _M: ... @property def db(self) -> str: ... def get_queryset(self) -> QuerySet[_T]: ... @@ -50,8 +36,8 @@ class BaseManager(Generic[_T]): # rather than a self-type (_QS), since Manager's QuerySet-like methods return QuerySets and not Managers. def iterator(self, chunk_size: int = ...) -> Iterator[_T]: ... async def aiterator(self, chunk_size: int = ...) -> Iterator[_T]: ... - def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ... - async def aaggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ... + def aggregate(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ... + async def aaggregate(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ... def get(self, *args: Any, **kwargs: Any) -> _T: ... async def aget(self, *args: Any, **kwargs: Any) -> _T: ... def create(self, **kwargs: Any) -> _T: ... @@ -64,7 +50,7 @@ class BaseManager(Generic[_T]): update_conflicts: bool = ..., update_fields: Collection[str] | None = ..., unique_fields: Collection[str] | None = ..., - ) -> List[_T]: ... + ) -> list[_T]: ... async def abulk_create( self, objs: Iterable[_T], @@ -73,17 +59,17 @@ class BaseManager(Generic[_T]): update_conflicts: bool = ..., update_fields: Collection[str] | None = ..., unique_fields: Collection[str] | None = ..., - ) -> List[_T]: ... + ) -> list[_T]: ... def bulk_update(self, objs: Iterable[_T], fields: Sequence[str], batch_size: int | None = ...) -> int: ... async def abulk_update(self, objs: Iterable[_T], fields: Sequence[str], batch_size: int | None = ...) -> int: ... - def get_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> Tuple[_T, bool]: ... + def get_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> tuple[_T, bool]: ... async def aget_or_create( self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any - ) -> Tuple[_T, bool]: ... - def update_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> Tuple[_T, bool]: ... + ) -> tuple[_T, bool]: ... + def update_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> tuple[_T, bool]: ... async def aupdate_or_create( self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any - ) -> Tuple[_T, bool]: ... + ) -> tuple[_T, bool]: ... def earliest(self, *fields: Any, field_name: Any | None = ...) -> _T: ... async def aearliest(self, *fields: Any, field_name: Any | None = ...) -> _T: ... def latest(self, *fields: Any, field_name: Any | None = ...) -> _T: ... @@ -92,10 +78,10 @@ class BaseManager(Generic[_T]): async def afirst(self) -> _T | None: ... def last(self) -> _T | None: ... async def alast(self) -> _T | None: ... - def in_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ... - async def ain_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ... - def delete(self) -> Tuple[int, Dict[str, int]]: ... - async def adelete(self) -> Tuple[int, Dict[str, int]]: ... + def in_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> dict[Any, _T]: ... + async def ain_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> dict[Any, _T]: ... + def delete(self) -> tuple[int, dict[str, int]]: ... + async def adelete(self) -> tuple[int, dict[str, int]]: ... def update(self, **kwargs: Any) -> int: ... async def aupdate(self, **kwargs: Any) -> int: ... def exists(self) -> bool: ... @@ -108,11 +94,11 @@ class BaseManager(Generic[_T]): self, raw_query: str, params: Any = ..., - translations: Dict[str, str] | None = ..., + translations: dict[str, str] | None = ..., using: str | None = ..., ) -> RawQuerySet: ... # The type of values may be overridden to be more specific in the mypy plugin, depending on the fields param - def values(self, *fields: str | Combinable, **expressions: Any) -> ValuesQuerySet[_T, Dict[str, Any]]: ... + def values(self, *fields: str | Combinable, **expressions: Any) -> ValuesQuerySet[_T, dict[str, Any]]: ... # The type of values_list may be overridden to be more specific in the mypy plugin, depending on the fields param def values_list( self, *fields: str | Combinable, flat: bool = ..., named: bool = ... @@ -143,10 +129,10 @@ class BaseManager(Generic[_T]): # extra() return type won't be supported any time soon def extra( self, - select: Dict[str, Any] | None = ..., - where: List[str] | None = ..., - params: List[Any] | None = ..., - tables: List[str] | None = ..., + select: dict[str, Any] | None = ..., + where: list[str] | None = ..., + params: list[Any] | None = ..., + tables: list[str] | None = ..., order_by: Sequence[str] | None = ..., select_params: Sequence[Any] | None = ..., ) -> QuerySet[Any]: ... @@ -161,7 +147,7 @@ class Manager(BaseManager[_T]): ... # Fake to make ManyToMany work class RelatedManager(Manager[_T]): - related_val: Tuple[int, ...] + related_val: tuple[int, ...] def add(self, *objs: _T | int, bulk: bool = ...) -> None: ... def remove(self, *objs: _T | int, bulk: bool = ...) -> None: ... def set(self, objs: QuerySet[_T] | Iterable[_T | int], *, bulk: bool = ..., clear: bool = ...) -> None: ... @@ -172,9 +158,9 @@ class ManagerDescriptor: manager: BaseManager def __init__(self, manager: BaseManager) -> None: ... @overload - def __get__(self, instance: None, cls: Type[Model] | None = ...) -> BaseManager: ... + def __get__(self, instance: None, cls: type[Model] | None = ...) -> BaseManager: ... @overload - def __get__(self, instance: Model, cls: Type[Model] | None = ...) -> NoReturn: ... + def __get__(self, instance: Model, cls: type[Model] | None = ...) -> NoReturn: ... class EmptyManager(Manager[_T]): - def __init__(self, model: Type[_T]) -> None: ... + def __init__(self, model: type[_T]) -> None: ... diff --git a/django-stubs/db/models/options.pyi b/django-stubs/db/models/options.pyi index dc693029e..2c3d8c3e1 100644 --- a/django-stubs/db/models/options.pyi +++ b/django-stubs/db/models/options.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Generic, Iterable, List, Sequence, Set, Tuple, Type, TypeVar, Union, overload +from collections.abc import Iterable, Sequence +from typing import Any, Generic, TypeVar, Union, overload from django.apps.config import AppConfig from django.apps.registry import Apps @@ -18,16 +19,16 @@ from typing_extensions import Literal PROXY_PARENTS: object EMPTY_RELATION_TREE: Any IMMUTABLE_WARNING: str -DEFAULT_NAMES: Tuple[str, ...] +DEFAULT_NAMES: tuple[str, ...] -_OptionTogetherT = Union[_ListOrTuple[Union[_ListOrTuple[str], str]], Set[Tuple[str, ...]]] +_OptionTogetherT = Union[_ListOrTuple[Union[_ListOrTuple[str], str]], set[tuple[str, ...]]] @overload -def normalize_together(option_together: _ListOrTuple[_ListOrTuple[str] | str]) -> Tuple[Tuple[str, ...], ...]: ... +def normalize_together(option_together: _ListOrTuple[_ListOrTuple[str] | str]) -> tuple[tuple[str, ...], ...]: ... # Any other value will be returned unchanged, but probably only set is semantically allowed @overload -def normalize_together(option_together: Set[Tuple[str, ...]]) -> Set[Tuple[str, ...]]: ... +def normalize_together(option_together: set[tuple[str, ...]]) -> set[tuple[str, ...]]: ... _T = TypeVar("_T") @@ -36,14 +37,14 @@ def make_immutable_fields_list(name: str, data: Iterable[_T]) -> ImmutableList[_ _M = TypeVar("_M", bound="Model") class Options(Generic[_M]): - constraints: List[BaseConstraint] - FORWARD_PROPERTIES: Set[str] - REVERSE_PROPERTIES: Set[str] + constraints: list[BaseConstraint] + FORWARD_PROPERTIES: set[str] + REVERSE_PROPERTIES: set[str] default_apps: Any - local_fields: List[Field] - local_many_to_many: List[ManyToManyField] - private_fields: List[Any] - local_managers: List[Manager] + local_fields: list[Field] + local_many_to_many: list[ManyToManyField] + private_fields: list[Any] + local_managers: list[Manager] base_manager_name: str | None default_manager_name: str | None model_name: str | None @@ -51,18 +52,18 @@ class Options(Generic[_M]): verbose_name_plural: _StrOrPromise | None db_table: str ordering: Sequence[str] | None - indexes: List[Any] - unique_together: Sequence[Tuple[str]] # Are always normalized - index_together: Sequence[Tuple[str]] # Are always normalized + indexes: list[Any] + unique_together: Sequence[tuple[str]] # Are always normalized + index_together: Sequence[tuple[str]] # Are always normalized select_on_save: bool default_permissions: Sequence[str] - permissions: List[Any] + permissions: list[Any] object_name: str | None app_label: str get_latest_by: Sequence[str] | None order_with_respect_to: str | None db_tablespace: str - required_db_features: List[str] + required_db_features: list[str] required_db_vendor: Literal["sqlite", "postgresql", "mysql", "oracle"] | None meta: type | None pk: Field | None @@ -70,16 +71,16 @@ class Options(Generic[_M]): abstract: bool managed: bool proxy: bool - proxy_for_model: Type[Model] | None - concrete_model: Type[Model] | None + proxy_for_model: type[Model] | None + concrete_model: type[Model] | None swappable: str | None - parents: Dict[Type[Model], GenericForeignKey | Field] + parents: dict[type[Model], GenericForeignKey | Field] auto_created: bool - related_fkey_lookups: List[Any] + related_fkey_lookups: list[Any] apps: Apps default_related_name: str | None - model: Type[Model] - original_attrs: Dict[str, Any] + model: type[Model] + original_attrs: dict[str, Any] def __init__(self, meta: type | None, app_label: str | None = ...) -> None: ... @property def label(self) -> str: ... @@ -89,23 +90,23 @@ class Options(Generic[_M]): def app_config(self) -> AppConfig: ... @property def installed(self) -> bool: ... - def contribute_to_class(self, cls: Type[Model], name: str) -> None: ... + def contribute_to_class(self, cls: type[Model], name: str) -> None: ... def add_manager(self, manager: Manager) -> None: ... def add_field(self, field: GenericForeignKey | Field[Any, Any], private: bool = ...) -> None: ... # if GenericForeignKey is passed as argument, it has primary_key = True set before def setup_pk(self, field: GenericForeignKey | Field[Any, Any]) -> None: ... - def setup_proxy(self, target: Type[Model]) -> None: ... + def setup_proxy(self, target: type[Model]) -> None: ... def can_migrate(self, connection: BaseDatabaseWrapper | str) -> bool: ... @property def verbose_name_raw(self) -> str: ... @property def swapped(self) -> str | None: ... @property - def fields_map(self) -> Dict[str, Field[Any, Any] | ForeignObjectRel]: ... + def fields_map(self) -> dict[str, Field[Any, Any] | ForeignObjectRel]: ... @property def managers(self) -> ImmutableList[Manager]: ... @property - def managers_map(self) -> Dict[str, Manager]: ... + def managers_map(self) -> dict[str, Manager]: ... @property def base_manager(self) -> Manager: ... @property @@ -113,15 +114,15 @@ class Options(Generic[_M]): @property def fields(self) -> ImmutableList[Field[Any, Any]]: ... def get_field(self, field_name: str) -> Field | ForeignObjectRel | GenericForeignKey: ... - def get_base_chain(self, model: Type[Model]) -> List[Type[Model]]: ... - def get_parent_list(self) -> List[Type[Model]]: ... - def get_ancestor_link(self, ancestor: Type[Model]) -> OneToOneField | None: ... - def get_path_to_parent(self, parent: Type[Model]) -> List[PathInfo]: ... - def get_path_from_parent(self, parent: Type[Model]) -> List[PathInfo]: ... + def get_base_chain(self, model: type[Model]) -> list[type[Model]]: ... + def get_parent_list(self) -> list[type[Model]]: ... + def get_ancestor_link(self, ancestor: type[Model]) -> OneToOneField | None: ... + def get_path_to_parent(self, parent: type[Model]) -> list[PathInfo]: ... + def get_path_from_parent(self, parent: type[Model]) -> list[PathInfo]: ... def get_fields( self, include_parents: bool = ..., include_hidden: bool = ... - ) -> List[Field[Any, Any] | ForeignObjectRel | GenericForeignKey]: ... + ) -> list[Field[Any, Any] | ForeignObjectRel | GenericForeignKey]: ... @property - def total_unique_constraints(self) -> List[UniqueConstraint]: ... + def total_unique_constraints(self) -> list[UniqueConstraint]: ... @property - def db_returning_fields(self) -> List[Field[Any, Any]]: ... + def db_returning_fields(self) -> list[Field[Any, Any]]: ... diff --git a/django-stubs/db/models/query.pyi b/django-stubs/db/models/query.pyi index f6989b52c..d358d8aac 100644 --- a/django-stubs/db/models/query.pyi +++ b/django-stubs/db/models/query.pyi @@ -1,23 +1,6 @@ import datetime -from typing import ( - Any, - AsyncIterator, - Collection, - Dict, - Generic, - Iterable, - Iterator, - List, - MutableMapping, - NamedTuple, - Reversible, - Sequence, - Sized, - Tuple, - Type, - TypeVar, - overload, -) +from collections.abc import AsyncIterator, Collection, Iterable, Iterator, MutableMapping, Reversible, Sequence, Sized +from typing import Any, Generic, NamedTuple, TypeVar, overload from django.db.models import Manager from django.db.models.base import Model @@ -59,30 +42,30 @@ class FlatValuesListIterable(BaseIterable[_Row]): def __iter__(self) -> Iterator[_Row]: ... class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): - model: Type[_T] + model: type[_T] query: Query - _iterable_class: Type[BaseIterable] + _iterable_class: type[BaseIterable] def __init__( self, - model: Type[Model] | None = ..., + model: type[Model] | None = ..., query: Query | None = ..., using: str | None = ..., - hints: Dict[str, Model] | None = ..., + hints: dict[str, Model] | None = ..., ) -> None: ... @classmethod def as_manager(cls) -> Manager[Any]: ... def __len__(self) -> int: ... def __bool__(self) -> bool: ... - def __class_getitem__(cls: Type[_QS], item: Type[_T]) -> Type[_QS]: ... - def __getstate__(self) -> Dict[str, Any]: ... + def __class_getitem__(cls: type[_QS], item: type[_T]) -> type[_QS]: ... + def __getstate__(self) -> dict[str, Any]: ... # Technically, the other QuerySet must be of the same type _T, but _T is covariant def __and__(self: _QS, other: _QuerySet[_T, _Row]) -> _QS: ... def __or__(self: _QS, other: _QuerySet[_T, _Row]) -> _QS: ... # IMPORTANT: When updating any of the following methods' signatures, please ALSO modify # the corresponding method in BaseManager. def iterator(self, chunk_size: int = ...) -> Iterator[_Row]: ... - def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ... - async def aaggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ... + def aggregate(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ... + async def aaggregate(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ... def get(self, *args: Any, **kwargs: Any) -> _Row: ... async def aget(self, *args: Any, **kwargs: Any) -> _Row: ... def create(self, **kwargs: Any) -> _T: ... @@ -95,7 +78,7 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): update_conflicts: bool = ..., update_fields: Collection[str] | None = ..., unique_fields: Collection[str] | None = ..., - ) -> List[_T]: ... + ) -> list[_T]: ... async def abulk_create( self, objs: Iterable[_T], @@ -104,17 +87,17 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): update_conflicts: bool = ..., update_fields: Collection[str] | None = ..., unique_fields: Collection[str] | None = ..., - ) -> List[_T]: ... + ) -> list[_T]: ... def bulk_update(self, objs: Iterable[_T], fields: Iterable[str], batch_size: int | None = ...) -> int: ... async def abulk_update(self, objs: Iterable[_T], fields: Iterable[str], batch_size: int | None = ...) -> int: ... - def get_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> Tuple[_T, bool]: ... + def get_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> tuple[_T, bool]: ... async def aget_or_create( self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any - ) -> Tuple[_T, bool]: ... - def update_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> Tuple[_T, bool]: ... + ) -> tuple[_T, bool]: ... + def update_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> tuple[_T, bool]: ... async def aupdate_or_create( self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any - ) -> Tuple[_T, bool]: ... + ) -> tuple[_T, bool]: ... def earliest(self, *fields: Any, field_name: Any | None = ...) -> _Row: ... async def aearliest(self, *fields: Any, field_name: Any | None = ...) -> _Row: ... def latest(self, *fields: Any, field_name: Any | None = ...) -> _Row: ... @@ -123,10 +106,10 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): async def afirst(self) -> _Row | None: ... def last(self) -> _Row | None: ... async def alast(self) -> _Row | None: ... - def in_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ... - async def ain_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ... - def delete(self) -> Tuple[int, Dict[str, int]]: ... - async def adelete(self) -> Tuple[int, Dict[str, int]]: ... + def in_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> dict[Any, _T]: ... + async def ain_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> dict[Any, _T]: ... + def delete(self) -> tuple[int, dict[str, int]]: ... + async def adelete(self) -> tuple[int, dict[str, int]]: ... def update(self, **kwargs: Any) -> int: ... async def aupdate(self, **kwargs: Any) -> int: ... def exists(self) -> bool: ... @@ -139,11 +122,11 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): self, raw_query: str, params: Any = ..., - translations: Dict[str, str] | None = ..., + translations: dict[str, str] | None = ..., using: str | None = ..., ) -> RawQuerySet: ... # The type of values may be overridden to be more specific in the mypy plugin, depending on the fields param - def values(self, *fields: str | Combinable, **expressions: Any) -> _QuerySet[_T, Dict[str, Any]]: ... + def values(self, *fields: str | Combinable, **expressions: Any) -> _QuerySet[_T, dict[str, Any]]: ... # The type of values_list may be overridden to be more specific in the mypy plugin, depending on the fields param def values_list(self, *fields: str | Combinable, flat: bool = ..., named: bool = ...) -> _QuerySet[_T, Any]: ... def dates(self, field_name: str, kind: str, order: str = ...) -> _QuerySet[_T, datetime.date]: ... @@ -172,7 +155,7 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): # extra() return type won't be supported any time soon def extra( self, - select: Dict[str, Any] | None = ..., + select: dict[str, Any] | None = ..., where: Sequence[str] | None = ..., params: Sequence[Any] | None = ..., tables: Sequence[str] | None = ..., @@ -202,12 +185,12 @@ class RawQuerySet(Iterable[_T], Sized): def __init__( self, raw_query: RawQuery | str, - model: Type[Model] | None = ..., + model: type[Model] | None = ..., query: Query | None = ..., - params: Tuple[Any] = ..., - translations: Dict[str, str] | None = ..., + params: tuple[Any] = ..., + translations: dict[str, str] | None = ..., using: str = ..., - hints: Dict[str, Model] | None = ..., + hints: dict[str, Model] | None = ..., ) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... @@ -219,15 +202,15 @@ class RawQuerySet(Iterable[_T], Sized): @overload def __getitem__(self, k: slice) -> RawQuerySet[_T]: ... @property - def columns(self) -> List[str]: ... + def columns(self) -> list[str]: ... @property def db(self) -> str: ... def iterator(self) -> Iterator[_T]: ... async def aiterator(self) -> Iterator[_T]: ... @property - def model_fields(self) -> Dict[str, str]: ... + def model_fields(self) -> dict[str, str]: ... def prefetch_related(self, *lookups: Any) -> RawQuerySet[_T]: ... - def resolve_model_init_order(self) -> Tuple[List[str], List[int], List[Tuple[str, int]]]: ... + def resolve_model_init_order(self) -> tuple[list[str], list[int], list[tuple[str, int]]]: ... def using(self, alias: str | None) -> RawQuerySet[_T]: ... _QuerySetAny = _QuerySet @@ -240,14 +223,14 @@ class Prefetch: queryset: QuerySet | None to_attr: str | None def __init__(self, lookup: str, queryset: QuerySet | None = ..., to_attr: str | None = ...) -> None: ... - def __getstate__(self) -> Dict[str, Any]: ... + def __getstate__(self) -> dict[str, Any]: ... def add_prefix(self, prefix: str) -> None: ... def get_current_prefetch_to(self, level: int) -> str: ... - def get_current_to_attr(self, level: int) -> Tuple[str, str]: ... + def get_current_to_attr(self, level: int) -> tuple[str, str]: ... def get_current_queryset(self, level: int) -> QuerySet | None: ... def prefetch_related_objects(model_instances: Iterable[_T], *related_lookups: str | Prefetch) -> None: ... -def get_prefetcher(instance: Model, through_attr: str, to_attr: str) -> Tuple[Any, Any, bool, bool]: ... +def get_prefetcher(instance: Model, through_attr: str, to_attr: str) -> tuple[Any, Any, bool, bool]: ... class InstanceCheckMeta(type): ... class EmptyQuerySet(metaclass=InstanceCheckMeta): ... diff --git a/django-stubs/db/models/query_utils.pyi b/django-stubs/db/models/query_utils.pyi index e45eb9e65..b52f33865 100644 --- a/django-stubs/db/models/query_utils.pyi +++ b/django-stubs/db/models/query_utils.pyi @@ -1,5 +1,6 @@ from collections import namedtuple -from typing import Any, Collection, Dict, Iterable, Iterator, List, Mapping, Sequence, Set, Tuple, Type, TypeVar +from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence +from typing import Any, TypeVar from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.base import Model @@ -19,7 +20,7 @@ PathInfo = namedtuple( class InvalidQuery(Exception): ... -def subclasses(cls: Type[RegisterLookupMixin]) -> Iterator[Type[RegisterLookupMixin]]: ... +def subclasses(cls: type[RegisterLookupMixin]) -> Iterator[type[RegisterLookupMixin]]: ... class Q(tree.Node): AND: str @@ -36,32 +37,32 @@ class Q(tree.Node): self, query: Query = ..., allow_joins: bool = ..., - reuse: Set[str] | None = ..., + reuse: set[str] | None = ..., summarize: bool = ..., for_save: bool = ..., ) -> WhereNode: ... - def deconstruct(self) -> Tuple[str, Tuple, Dict[str, str]]: ... + def deconstruct(self) -> tuple[str, tuple, dict[str, str]]: ... class DeferredAttribute: field_name: str field: Field def __init__(self, field: Field) -> None: ... -_R = TypeVar("_R", bound=Type) +_R = TypeVar("_R", bound=type) class RegisterLookupMixin: - class_lookups: List[Dict[Any, Any]] + class_lookups: list[dict[Any, Any]] lookup_name: str @classmethod - def get_lookups(cls) -> Dict[str, Any]: ... - def get_lookup(self, lookup_name: str) -> Type[Lookup] | None: ... - def get_transform(self, lookup_name: str) -> Type[Transform] | None: ... + def get_lookups(cls) -> dict[str, Any]: ... + def get_lookup(self, lookup_name: str) -> type[Lookup] | None: ... + def get_transform(self, lookup_name: str) -> type[Transform] | None: ... @staticmethod - def merge_dicts(dicts: Iterable[Dict[str, Any]]) -> Dict[str, Any]: ... + def merge_dicts(dicts: Iterable[dict[str, Any]]) -> dict[str, Any]: ... @classmethod def register_lookup(cls, lookup: _R, lookup_name: str | None = ...) -> _R: ... @classmethod - def _unregister_lookup(cls, lookup: Type[Lookup], lookup_name: str | None = ...) -> None: ... + def _unregister_lookup(cls, lookup: type[Lookup], lookup_name: str | None = ...) -> None: ... def select_related_descend( field: Field, @@ -75,14 +76,14 @@ _E = TypeVar("_E", bound=BaseExpression) def refs_expression( lookup_parts: Sequence[str], annotations: Mapping[str, _E] -) -> Tuple[Literal[False] | _E, Sequence[str]]: ... -def check_rel_lookup_compatibility(model: Type[Model], target_opts: Any, field: FieldCacheMixin) -> bool: ... +) -> tuple[Literal[False] | _E, Sequence[str]]: ... +def check_rel_lookup_compatibility(model: type[Model], target_opts: Any, field: FieldCacheMixin) -> bool: ... class FilteredRelation: relation_name: str alias: str | None condition: Q - path: List[str] + path: list[str] def __init__(self, relation_name: str, *, condition: Q = ...) -> None: ... def clone(self) -> FilteredRelation: ... def resolve_expression(self, *args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/db/models/signals.pyi b/django-stubs/db/models/signals.pyi index 03519a98c..13cb3c252 100644 --- a/django-stubs/db/models/signals.pyi +++ b/django-stubs/db/models/signals.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Type +from collections.abc import Callable +from typing import Any from django.apps.registry import Apps from django.db.models.base import Model @@ -10,7 +11,7 @@ class ModelSignal(Signal): def connect( # type: ignore self, receiver: Callable, - sender: Type[Model] | str | None = ..., + sender: type[Model] | str | None = ..., weak: bool = ..., dispatch_uid: str | None = ..., apps: Apps | None = ..., @@ -18,7 +19,7 @@ class ModelSignal(Signal): def disconnect( # type: ignore self, receiver: Callable | None = ..., - sender: Type[Model] | str | None = ..., + sender: type[Model] | str | None = ..., dispatch_uid: str | None = ..., apps: Apps | None = ..., ) -> bool | None: ... diff --git a/django-stubs/db/models/sql/compiler.pyi b/django-stubs/db/models/sql/compiler.pyi index 9dd9451b5..a38344582 100644 --- a/django-stubs/db/models/sql/compiler.pyi +++ b/django-stubs/db/models/sql/compiler.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterable, Iterator, Sequence from datetime import date, datetime from decimal import Decimal -from typing import Any, Callable, Dict, Iterable, Iterator, List, Sequence, Set, Tuple, Type, overload +from typing import Any, overload from uuid import UUID from django.db.backends.base.base import BaseDatabaseWrapper @@ -12,8 +13,8 @@ from django.db.models.sql.subqueries import AggregateQuery, DeleteQuery, InsertQ from typing_extensions import Literal _ParamT = str | int -_ParamsT = List[_ParamT] -_AsSqlType = Tuple[str, _ParamsT] +_ParamsT = list[_ParamT] +_AsSqlType = tuple[str, _ParamsT] class SQLCompiler: query: Query @@ -30,63 +31,63 @@ class SQLCompiler: has_extra_select: Any def pre_sql_setup( self, - ) -> Tuple[ - List[Tuple[Expression, _AsSqlType, None]], - List[Tuple[Expression, Tuple[str, _ParamsT, bool]]], - List[_AsSqlType], + ) -> tuple[ + list[tuple[Expression, _AsSqlType, None]], + list[tuple[Expression, tuple[str, _ParamsT, bool]]], + list[_AsSqlType], ]: ... def get_group_by( self, - select: List[Tuple[BaseExpression, _AsSqlType, str | None]], - order_by: List[Tuple[Expression, Tuple[str, _ParamsT, bool]]], - ) -> List[_AsSqlType]: ... + select: list[tuple[BaseExpression, _AsSqlType, str | None]], + order_by: list[tuple[Expression, tuple[str, _ParamsT, bool]]], + ) -> list[_AsSqlType]: ... def collapse_group_by( - self, expressions: List[Expression], having: List[Expression] | Tuple - ) -> List[Expression]: ... + self, expressions: list[Expression], having: list[Expression] | tuple + ) -> list[Expression]: ... def get_select( self, - ) -> Tuple[List[Tuple[Expression, _AsSqlType, str | None]], Dict[str, Any] | None, Dict[str, int],]: ... - def get_order_by(self) -> List[Tuple[Expression, Tuple[str, _ParamsT, bool]]]: ... + ) -> tuple[list[tuple[Expression, _AsSqlType, str | None]], dict[str, Any] | None, dict[str, int],]: ... + def get_order_by(self) -> list[tuple[Expression, tuple[str, _ParamsT, bool]]]: ... def get_extra_select( self, - order_by: List[Tuple[Expression, Tuple[str, _ParamsT, bool]]], - select: List[Tuple[Expression, _AsSqlType, str | None]], - ) -> List[Tuple[Expression, _AsSqlType, None]]: ... + order_by: list[tuple[Expression, tuple[str, _ParamsT, bool]]], + select: list[tuple[Expression, _AsSqlType, str | None]], + ) -> list[tuple[Expression, _AsSqlType, None]]: ... def quote_name_unless_alias(self, name: str) -> str: ... def compile(self, node: BaseExpression) -> _AsSqlType: ... - def get_combinator_sql(self, combinator: str, all: bool) -> Tuple[List[str], List[int] | List[str]]: ... + def get_combinator_sql(self, combinator: str, all: bool) -> tuple[list[str], list[int] | list[str]]: ... def as_sql(self, with_limits: bool = ..., with_col_aliases: bool = ...) -> _AsSqlType: ... def get_default_columns( - self, start_alias: str | None = ..., opts: Any | None = ..., from_parent: Type[Model] | None = ... - ) -> List[Expression]: ... - def get_distinct(self) -> Tuple[List[Any], List[Any]]: ... + self, start_alias: str | None = ..., opts: Any | None = ..., from_parent: type[Model] | None = ... + ) -> list[Expression]: ... + def get_distinct(self) -> tuple[list[Any], list[Any]]: ... def find_ordering_name( self, name: str, opts: Any, alias: str | None = ..., default_order: str = ..., - already_seen: Set[Tuple[Tuple[Tuple[str, str]] | None, Tuple[Tuple[str, str]]]] | None = ..., - ) -> List[Tuple[Expression, bool]]: ... - def get_from_clause(self) -> Tuple[List[str], _ParamsT]: ... + already_seen: set[tuple[tuple[tuple[str, str]] | None, tuple[tuple[str, str]]]] | None = ..., + ) -> list[tuple[Expression, bool]]: ... + def get_from_clause(self) -> tuple[list[str], _ParamsT]: ... def get_related_selections( self, - select: List[Tuple[Expression, str | None]], + select: list[tuple[Expression, str | None]], opts: Any | None = ..., root_alias: str | None = ..., cur_depth: int = ..., - requested: Dict[str, Dict[str, Dict[str, Dict[Any, Any]]]] | None = ..., + requested: dict[str, dict[str, dict[str, dict[Any, Any]]]] | None = ..., restricted: bool | None = ..., - ) -> List[Dict[str, Any]]: ... - def get_select_for_update_of_arguments(self) -> List[Any]: ... - def deferred_to_columns(self) -> Dict[Type[Model], Set[str]]: ... - def get_converters(self, expressions: List[Expression]) -> Dict[int, Tuple[List[Callable], Expression]]: ... + ) -> list[dict[str, Any]]: ... + def get_select_for_update_of_arguments(self) -> list[Any]: ... + def deferred_to_columns(self) -> dict[type[Model], set[str]]: ... + def get_converters(self, expressions: list[Expression]) -> dict[int, tuple[list[Callable], Expression]]: ... def apply_converters( - self, rows: Iterable[Iterable[Any]], converters: Dict[int, Tuple[List[Callable], Expression]] - ) -> Iterator[List[None | date | datetime | float | Decimal | UUID | bytes | str]]: ... + self, rows: Iterable[Iterable[Any]], converters: dict[int, tuple[list[Callable], Expression]] + ) -> Iterator[list[None | date | datetime | float | Decimal | UUID | bytes | str]]: ... def results_iter( self, - results: Iterable[List[Sequence[Any]]] | None = ..., + results: Iterable[list[Sequence[Any]]] | None = ..., tuple_expected: bool = ..., chunked_fetch: bool = ..., chunk_size: int = ..., @@ -107,8 +108,8 @@ class SQLCompiler: @overload def execute_sql( self, result_type: Literal["multi"] = ..., chunked_fetch: bool = ..., chunk_size: int = ... - ) -> Iterable[List[Sequence[Any]]] | None: ... - def as_subquery_condition(self, alias: str, columns: List[str], compiler: SQLCompiler) -> _AsSqlType: ... + ) -> Iterable[list[Sequence[Any]]] | None: ... + def as_subquery_condition(self, alias: str, columns: list[str], compiler: SQLCompiler) -> _AsSqlType: ... def explain_query(self) -> Iterator[str]: ... class SQLInsertCompiler(SQLCompiler): @@ -118,11 +119,11 @@ class SQLInsertCompiler(SQLCompiler): def field_as_sql(self, field: Any, val: Any) -> _AsSqlType: ... def prepare_value(self, field: Any, value: Any) -> Any: ... def pre_save_val(self, field: Any, obj: Any) -> Any: ... - def assemble_as_sql(self, fields: Any, value_rows: Any) -> Tuple[List[List[str]], List[List[Any]]]: ... - def as_sql(self) -> List[_AsSqlType]: ... # type: ignore + def assemble_as_sql(self, fields: Any, value_rows: Any) -> tuple[list[list[str]], list[list[Any]]]: ... + def as_sql(self) -> list[_AsSqlType]: ... # type: ignore def execute_sql( # type: ignore self, returning_fields: Sequence[str] | None = ... - ) -> List[Tuple[Any]]: ... # 1-tuple + ) -> list[tuple[Any]]: ... # 1-tuple class SQLDeleteCompiler(SQLCompiler): query: DeleteQuery @@ -145,4 +146,4 @@ class SQLAggregateCompiler(SQLCompiler): def cursor_iter( cursor: CursorWrapper, sentinel: Any, col_count: int | None, itersize: int -) -> Iterator[List[Sequence[Any]]]: ... +) -> Iterator[list[Sequence[Any]]]: ... diff --git a/django-stubs/db/models/sql/constants.pyi b/django-stubs/db/models/sql/constants.pyi index 8e9df3f7d..36c2cda05 100644 --- a/django-stubs/db/models/sql/constants.pyi +++ b/django-stubs/db/models/sql/constants.pyi @@ -1,4 +1,4 @@ -from typing import Dict, Pattern, Tuple +from typing import Pattern from typing_extensions import Final, Literal @@ -10,7 +10,7 @@ CURSOR: Literal["cursor"] NO_RESULTS: Literal["no results"] ORDER_PATTERN: Pattern -ORDER_DIR: Dict[str, Tuple[str, str]] +ORDER_DIR: dict[str, tuple[str, str]] INNER: Literal["INNER JOIN"] LOUTER: Literal["LEFT OUTER JOIN"] diff --git a/django-stubs/db/models/sql/datastructures.pyi b/django-stubs/db/models/sql/datastructures.pyi index 57c6a90c1..fde898b1e 100644 --- a/django-stubs/db/models/sql/datastructures.pyi +++ b/django-stubs/db/models/sql/datastructures.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Tuple +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.fields.mixins import FieldCacheMixin @@ -7,8 +7,8 @@ from django.db.models.sql.compiler import SQLCompiler, _AsSqlType class MultiJoin(Exception): level: int - names_with_path: List[Tuple[str, List[PathInfo]]] - def __init__(self, names_pos: int, path_with_names: List[Tuple[str, List[PathInfo]]]) -> None: ... + names_with_path: list[tuple[str, list[PathInfo]]] + def __init__(self, names_pos: int, path_with_names: list[tuple[str, list[PathInfo]]]) -> None: ... class Empty: ... @@ -17,7 +17,7 @@ class Join: parent_alias: str table_alias: str | None join_type: str - join_cols: Tuple + join_cols: tuple join_field: FieldCacheMixin nullable: bool filtered_relation: FilteredRelation | None @@ -32,7 +32,7 @@ class Join: filtered_relation: FilteredRelation | None = ..., ) -> None: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... - def relabeled_clone(self, change_map: Dict[str | None, str]) -> Join: ... + def relabeled_clone(self, change_map: dict[str | None, str]) -> Join: ... def equals(self, other: BaseTable | Join, with_filtered_relation: bool) -> bool: ... def demote(self) -> Join: ... def promote(self) -> Join: ... @@ -45,5 +45,5 @@ class BaseTable: table_alias: str | None def __init__(self, table_name: str, alias: str | None) -> None: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... - def relabeled_clone(self, change_map: Dict[str | None, str]) -> BaseTable: ... + def relabeled_clone(self, change_map: dict[str | None, str]) -> BaseTable: ... def equals(self, other: Join, with_filtered_relation: bool) -> bool: ... diff --git a/django-stubs/db/models/sql/query.pyi b/django-stubs/db/models/sql/query.pyi index a269c5010..eb03b2dc9 100644 --- a/django-stubs/db/models/sql/query.pyi +++ b/django-stubs/db/models/sql/query.pyi @@ -1,6 +1,7 @@ import collections from collections import namedtuple -from typing import Any, Callable, Dict, FrozenSet, Iterable, Iterator, List, Sequence, Set, Tuple, Type +from collections.abc import Callable, Iterable, Iterator, Sequence +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.utils import CursorWrapper @@ -22,111 +23,111 @@ class RawQuery: params: Any sql: str using: str - extra_select: Dict[Any, Any] - annotation_select: Dict[Any, Any] + extra_select: dict[Any, Any] + annotation_select: dict[Any, Any] cursor: CursorWrapper | None def __init__(self, sql: str, using: str, params: Any = ...) -> None: ... def chain(self, using: str) -> RawQuery: ... def clone(self, using: str) -> RawQuery: ... - def get_columns(self) -> List[str]: ... + def get_columns(self) -> list[str]: ... def __iter__(self) -> Iterator[Any]: ... @property - def params_type(self) -> None | Type[Dict] | Type[Tuple]: ... + def params_type(self) -> None | type[dict] | type[tuple]: ... class Query(BaseExpression): - related_ids: List[int] | None - related_updates: Dict[Type[Model], List[Tuple[Field, None, int | str]]] - values: List[Any] + related_ids: list[int] | None + related_updates: dict[type[Model], list[tuple[Field, None, int | str]]] + values: list[Any] alias_prefix: str - subq_aliases: FrozenSet[Any] + subq_aliases: frozenset[Any] compiler: str - model: Type[Model] | None - alias_refcount: Dict[str, int] - alias_map: Dict[str, BaseTable | Join] - external_aliases: Dict[str, bool] - table_map: Dict[str, List[str]] + model: type[Model] | None + alias_refcount: dict[str, int] + alias_map: dict[str, BaseTable | Join] + external_aliases: dict[str, bool] + table_map: dict[str, list[str]] default_cols: bool default_ordering: bool standard_ordering: bool - used_aliases: Set[str] + used_aliases: set[str] filter_is_sticky: bool subquery: bool group_by: None | Sequence[Combinable] | Sequence[str] | Literal[True] order_by: Sequence[Any] distinct: bool - distinct_fields: Tuple[str, ...] + distinct_fields: tuple[str, ...] select: Sequence[BaseExpression] select_for_update: bool select_for_update_nowait: bool select_for_update_skip_locked: bool - select_for_update_of: Tuple + select_for_update_of: tuple select_for_no_key_update: bool - select_related: Dict[str, Any] | bool + select_related: dict[str, Any] | bool max_depth: int - values_select: Tuple - annotation_select_mask: Set[str] | None + values_select: tuple + annotation_select_mask: set[str] | None combinator: str | None combinator_all: bool - combined_queries: Tuple - extra_select_mask: Set[str] | None - extra_tables: Tuple + combined_queries: tuple + extra_select_mask: set[str] | None + extra_tables: tuple extra_order_by: Sequence[Any] - deferred_loading: Tuple[Set[str] | FrozenSet[str], bool] + deferred_loading: tuple[set[str] | frozenset[str], bool] explain_query: bool explain_format: str | None - explain_options: Dict[str, int] + explain_options: dict[str, int] high_mark: int | None low_mark: int - extra: Dict[str, Any] - annotations: Dict[str, Expression] - def __init__(self, model: Type[Model] | None, where: Type[WhereNode] = ..., alias_cols: bool = ...) -> None: ... + extra: dict[str, Any] + annotations: dict[str, Expression] + def __init__(self, model: type[Model] | None, where: type[WhereNode] = ..., alias_cols: bool = ...) -> None: ... @property def output_field(self) -> Field: ... @property def has_select_fields(self) -> bool: ... @property def base_table(self) -> str: ... - def sql_with_params(self) -> Tuple[str, Tuple]: ... - def __deepcopy__(self, memo: Dict[int, Any]) -> Query: ... + def sql_with_params(self) -> tuple[str, tuple]: ... + def __deepcopy__(self, memo: dict[int, Any]) -> Query: ... def get_compiler(self, using: str | None = ..., connection: BaseDatabaseWrapper | None = ...) -> SQLCompiler: ... def get_meta(self) -> Options: ... def clone(self) -> Query: ... - def chain(self, klass: Type[Query] | None = ...) -> Query: ... - def relabeled_clone(self, change_map: Dict[str | None, str]) -> Query: ... + def chain(self, klass: type[Query] | None = ...) -> Query: ... + def relabeled_clone(self, change_map: dict[str | None, str]) -> Query: ... def get_count(self, using: str) -> int: ... def has_filters(self) -> WhereNode: ... def has_results(self, using: str) -> bool: ... def explain(self, using: str, format: str | None = ..., **options: Any) -> str: ... def combine(self, rhs: Query, connector: str) -> None: ... - def deferred_to_data(self, target: Dict[Any, Any], callback: Callable) -> None: ... + def deferred_to_data(self, target: dict[Any, Any], callback: Callable) -> None: ... def ref_alias(self, alias: str) -> None: ... def unref_alias(self, alias: str, amount: int = ...) -> None: ... def promote_joins(self, aliases: Iterable[str]) -> None: ... def demote_joins(self, aliases: Iterable[str]) -> None: ... - def reset_refcounts(self, to_counts: Dict[str, int]) -> None: ... - def change_aliases(self, change_map: Dict[str | None, str]) -> None: ... + def reset_refcounts(self, to_counts: dict[str, int]) -> None: ... + def change_aliases(self, change_map: dict[str | None, str]) -> None: ... def bump_prefix(self, outer_query: Query) -> None: ... def get_initial_alias(self) -> str: ... def count_active_tables(self) -> int: ... def resolve_expression(self, query: Query, *args: Any, **kwargs: Any) -> Query: ... # type: ignore - def resolve_lookup_value(self, value: Any, can_reuse: Set[str] | None, allow_joins: bool) -> Any: ... - def solve_lookup_type(self, lookup: str) -> Tuple[Sequence[str], Sequence[str], Expression | Literal[False]]: ... + def resolve_lookup_value(self, value: Any, can_reuse: set[str] | None, allow_joins: bool) -> Any: ... + def solve_lookup_type(self, lookup: str) -> tuple[Sequence[str], Sequence[str], Expression | Literal[False]]: ... def build_filter( self, - filter_expr: Q | Expression | Dict[str, str] | Tuple[str, Any], + filter_expr: Q | Expression | dict[str, str] | tuple[str, Any], branch_negated: bool = ..., current_negated: bool = ..., - can_reuse: Set[str] | None = ..., + can_reuse: set[str] | None = ..., allow_joins: bool = ..., split_subq: bool = ..., reuse_with_filtered_relation: bool = ..., check_filterable: bool = ..., - ) -> Tuple[WhereNode, Iterable[str]]: ... - def add_filter(self, filter_clause: Tuple[str, Any]) -> None: ... + ) -> tuple[WhereNode, Iterable[str]]: ... + def add_filter(self, filter_clause: tuple[str, Any]) -> None: ... def add_q(self, q_object: Q) -> None: ... - def build_where(self, filter_expr: Q | Expression | Dict[str, str] | Tuple[str, Any]) -> WhereNode: ... + def build_where(self, filter_expr: Q | Expression | dict[str, str] | tuple[str, Any]) -> WhereNode: ... def build_filtered_relation_q( - self, q_object: Q, reuse: Set[str], branch_negated: bool = ..., current_negated: bool = ... + self, q_object: Q, reuse: set[str], branch_negated: bool = ..., current_negated: bool = ... ) -> WhereNode: ... def add_filtered_relation(self, filtered_relation: FilteredRelation, alias: str) -> None: ... def setup_joins( @@ -134,22 +135,22 @@ class Query(BaseExpression): names: Sequence[str], opts: Any, alias: str, - can_reuse: Set[str] | None = ..., + can_reuse: set[str] | None = ..., allow_many: bool = ..., reuse_with_filtered_relation: bool = ..., ) -> JoinInfo: ... def trim_joins( - self, targets: Tuple[Field, ...], joins: List[str], path: List[PathInfo] - ) -> Tuple[Tuple[Field, ...], str, List[str]]: ... + self, targets: tuple[Field, ...], joins: list[str], path: list[PathInfo] + ) -> tuple[tuple[Field, ...], str, list[str]]: ... def resolve_ref( - self, name: str, allow_joins: bool = ..., reuse: Set[str] | None = ..., summarize: bool = ... + self, name: str, allow_joins: bool = ..., reuse: set[str] | None = ..., summarize: bool = ... ) -> Expression: ... def split_exclude( self, - filter_expr: Tuple[str, Any], - can_reuse: Set[str], - names_with_path: List[Tuple[str, List[PathInfo]]], - ) -> Tuple[WhereNode, Iterable[str]]: ... + filter_expr: tuple[str, Any], + can_reuse: set[str], + names_with_path: list[tuple[str, list[PathInfo]]], + ) -> tuple[WhereNode, Iterable[str]]: ... def set_empty(self) -> None: ... def is_empty(self) -> bool: ... def set_limits(self, low: int | None = ..., high: int | None = ...) -> None: ... @@ -160,7 +161,7 @@ class Query(BaseExpression): def can_filter(self) -> bool: ... def clear_select_clause(self) -> None: ... def clear_select_fields(self) -> None: ... - def set_select(self, cols: List[Expression]) -> None: ... + def set_select(self, cols: list[Expression]) -> None: ... def add_distinct_fields(self, *field_names: Any) -> None: ... def add_fields(self, field_names: Iterable[str], allow_m2m: bool = ...) -> None: ... def add_ordering(self, *ordering: str | OrderBy) -> None: ... @@ -169,7 +170,7 @@ class Query(BaseExpression): def add_select_related(self, fields: Iterable[str]) -> None: ... def add_extra( self, - select: Dict[str, Any] | None, + select: dict[str, Any] | None, select_params: Iterable[Any] | None, where: Sequence[str] | None, params: Sequence[str] | None, @@ -179,19 +180,19 @@ class Query(BaseExpression): def clear_deferred_loading(self) -> None: ... def add_deferred_loading(self, field_names: Iterable[str]) -> None: ... def add_immediate_loading(self, field_names: Iterable[str]) -> None: ... - def get_loaded_field_names(self) -> Dict[Type[Model], Set[str]]: ... + def get_loaded_field_names(self) -> dict[type[Model], set[str]]: ... def get_loaded_field_names_cb( - self, target: Dict[Type[Model], Set[str]], model: Type[Model], fields: Set[Field] + self, target: dict[type[Model], set[str]], model: type[Model], fields: set[Field] ) -> None: ... def set_annotation_mask(self, names: Iterable[str] | None) -> None: ... def append_annotation_mask(self, names: Iterable[str]) -> None: ... def set_extra_mask(self, names: Iterable[str] | None) -> None: ... def set_values(self, fields: Iterable[str] | None) -> None: ... @property - def annotation_select(self) -> Dict[str, Any]: ... + def annotation_select(self) -> dict[str, Any]: ... @property - def extra_select(self) -> Dict[str, Any]: ... - def trim_start(self, names_with_path: List[Tuple[str, List[PathInfo]]]) -> Tuple[str, bool]: ... + def extra_select(self) -> dict[str, Any]: ... + def trim_start(self, names_with_path: list[tuple[str, list[PathInfo]]]) -> tuple[str, bool]: ... def is_nullable(self, field: Field) -> bool: ... def check_filterable(self, expression: Any) -> None: ... def build_lookup(self, lookups: Sequence[str], lhs: Expression | Query, rhs: Any) -> Lookup: ... @@ -205,4 +206,4 @@ class JoinPromoter: votes: collections.Counter def __init__(self, connector: str, num_children: int, negated: bool) -> None: ... def add_votes(self, votes: Iterable[str]) -> None: ... - def update_join_types(self, query: Query) -> Set[str]: ... + def update_join_types(self, query: Query) -> set[str]: ... diff --git a/django-stubs/db/models/sql/subqueries.pyi b/django-stubs/db/models/sql/subqueries.pyi index 5d3cd1988..d3c3e024d 100644 --- a/django-stubs/db/models/sql/subqueries.pyi +++ b/django-stubs/db/models/sql/subqueries.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, List, Tuple, Type +from collections.abc import Iterable +from typing import Any from django.db.models.base import Model from django.db.models.expressions import Case @@ -8,35 +9,35 @@ from django.db.models.sql.query import Query from django.db.models.sql.where import WhereNode class DeleteQuery(Query): - select: Tuple - where_class: Type[WhereNode] + select: tuple + where_class: type[WhereNode] where: WhereNode def do_query(self, table: str, where: WhereNode, using: str) -> int: ... - def delete_batch(self, pk_list: List[int] | List[str], using: str) -> int: ... + def delete_batch(self, pk_list: list[int] | list[str], using: str) -> int: ... class UpdateQuery(Query): - select: Tuple - where_class: Type[WhereNode] + select: tuple + where_class: type[WhereNode] def __init__(self, *args: Any, **kwargs: Any) -> None: ... where: WhereNode - def update_batch(self, pk_list: List[int], values: Dict[str, int | None], using: str) -> None: ... - def add_update_values(self, values: Dict[str, Any]) -> None: ... - def add_update_fields(self, values_seq: List[Tuple[Field, Type[Model] | None, Case]]) -> None: ... - def add_related_update(self, model: Type[Model], field: Field, value: int | str) -> None: ... - def get_related_updates(self) -> List[UpdateQuery]: ... + def update_batch(self, pk_list: list[int], values: dict[str, int | None], using: str) -> None: ... + def add_update_values(self, values: dict[str, Any]) -> None: ... + def add_update_fields(self, values_seq: list[tuple[Field, type[Model] | None, Case]]) -> None: ... + def add_related_update(self, model: type[Model], field: Field, value: int | str) -> None: ... + def get_related_updates(self) -> list[UpdateQuery]: ... class InsertQuery(Query): - select: Tuple + select: tuple where: WhereNode - where_class: Type[WhereNode] + where_class: type[WhereNode] fields: Iterable[Field] - objs: List[Model] + objs: list[Model] raw: bool def __init__(self, *args: Any, ignore_conflicts: bool = ..., **kwargs: Any) -> None: ... - def insert_values(self, fields: Iterable[Field], objs: List[Model], raw: bool = ...) -> None: ... + def insert_values(self, fields: Iterable[Field], objs: list[Model], raw: bool = ...) -> None: ... class AggregateQuery(Query): - select: Tuple - sub_params: Tuple + select: tuple + sub_params: tuple where: WhereNode - where_class: Type[WhereNode] + where_class: type[WhereNode] diff --git a/django-stubs/db/models/sql/where.pyi b/django-stubs/db/models/sql/where.pyi index a904a837a..aa959b518 100644 --- a/django-stubs/db/models/sql/where.pyi +++ b/django-stubs/db/models/sql/where.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Sequence, Tuple +from collections.abc import Sequence +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.expressions import Expression @@ -15,12 +16,12 @@ class WhereNode(tree.Node): default: str resolved: bool conditional: bool - def split_having(self, negated: bool = ...) -> Tuple[WhereNode | None, WhereNode | None]: ... + def split_having(self, negated: bool = ...) -> tuple[WhereNode | None, WhereNode | None]: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> Any: ... - def get_group_by_cols(self, alias: str | None = ...) -> List[Expression]: ... - def relabel_aliases(self, change_map: Dict[str | None, str]) -> None: ... + def get_group_by_cols(self, alias: str | None = ...) -> list[Expression]: ... + def relabel_aliases(self, change_map: dict[str | None, str]) -> None: ... def clone(self) -> WhereNode: ... - def relabeled_clone(self, change_map: Dict[str | None, str]) -> WhereNode: ... + def relabeled_clone(self, change_map: dict[str | None, str]) -> WhereNode: ... def resolve_expression(self, *args: Any, **kwargs: Any) -> WhereNode: ... @property def contains_aggregate(self) -> bool: ... @@ -47,8 +48,8 @@ class ExtraWhere: class SubqueryConstraint: contains_aggregate: bool alias: str - columns: List[str] - targets: List[str] + columns: list[str] + targets: list[str] query_object: Query - def __init__(self, alias: str, columns: List[str], targets: List[str], query_object: Query) -> None: ... + def __init__(self, alias: str, columns: list[str], targets: list[str], query_object: Query) -> None: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... diff --git a/django-stubs/db/models/utils.pyi b/django-stubs/db/models/utils.pyi index acfd0aaf2..c3c2ceae5 100644 --- a/django-stubs/db/models/utils.pyi +++ b/django-stubs/db/models/utils.pyi @@ -1,8 +1,9 @@ -from typing import Any, Iterable, Iterator, MutableMapping, NamedTuple, Tuple, Type +from collections.abc import Iterable, Iterator, MutableMapping +from typing import Any, NamedTuple from django.db.models.base import Model -def make_model_tuple(model: Type[Model] | str | Tuple[str, str]) -> Tuple[str, str]: ... -def resolve_callables(mapping: MutableMapping[str, Any]) -> Iterator[Tuple[str, Any]]: ... +def make_model_tuple(model: type[Model] | str | tuple[str, str]) -> tuple[str, str]: ... +def resolve_callables(mapping: MutableMapping[str, Any]) -> Iterator[tuple[str, Any]]: ... def unpickle_named_row(names: Iterable[str], values: Iterable[Any]) -> NamedTuple: ... -def create_namedtuple_class(*names: str) -> Type[NamedTuple]: ... +def create_namedtuple_class(*names: str) -> type[NamedTuple]: ... diff --git a/django-stubs/db/transaction.pyi b/django-stubs/db/transaction.pyi index d93405813..346fd2d44 100644 --- a/django-stubs/db/transaction.pyi +++ b/django-stubs/db/transaction.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterator from contextlib import contextmanager from types import TracebackType -from typing import Any, Callable, Iterator, Type, TypeVar, overload +from typing import Any, TypeVar, overload from django.db import ProgrammingError @@ -33,7 +34,7 @@ class Atomic: def __enter__(self) -> None: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... diff --git a/django-stubs/db/utils.pyi b/django-stubs/db/utils.pyi index d327cfdde..23dabe0d4 100644 --- a/django-stubs/db/utils.pyi +++ b/django-stubs/db/utils.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable from types import TracebackType -from typing import Any, Dict, Iterable, List, Type +from typing import Any from django.apps import AppConfig from django.db.backends.base.base import BaseDatabaseWrapper @@ -25,7 +26,7 @@ class DatabaseErrorWrapper: def __enter__(self) -> None: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... @@ -34,7 +35,7 @@ def load_backend(backend_name: str) -> Any: ... class ConnectionHandler(BaseConnectionHandler[BaseDatabaseWrapper]): @property - def databases(self) -> Dict[str, Dict[str, Any]]: ... + def databases(self) -> dict[str, dict[str, Any]]: ... def ensure_defaults(self, alias: str) -> None: ... def prepare_test_settings(self, alias: str) -> None: ... def create_connection(self, alias: str) -> BaseDatabaseWrapper: ... @@ -43,12 +44,12 @@ class ConnectionHandler(BaseConnectionHandler[BaseDatabaseWrapper]): class ConnectionRouter: def __init__(self, routers: Iterable[Any] | None = ...) -> None: ... @property - def routers(self) -> List[Any]: ... - def db_for_read(self, model: Type[Model], **hints: Any) -> str: ... - def db_for_write(self, model: Type[Model], **hints: Any) -> str: ... + def routers(self) -> list[Any]: ... + def db_for_read(self, model: type[Model], **hints: Any) -> str: ... + def db_for_write(self, model: type[Model], **hints: Any) -> str: ... def allow_relation(self, obj1: Model, obj2: Model, **hints: Any) -> bool: ... def allow_migrate(self, db: str, app_label: str, **hints: Any) -> bool: ... - def allow_migrate_model(self, db: str, model: Type[Model]) -> bool: ... + def allow_migrate_model(self, db: str, model: type[Model]) -> bool: ... def get_migratable_models( self, app_config: AppConfig, db: str, include_auto_created: bool = ... - ) -> List[Type[Model]]: ... + ) -> list[type[Model]]: ... diff --git a/django-stubs/dispatch/dispatcher.pyi b/django-stubs/dispatch/dispatcher.pyi index bb1fcb2bb..7b70e8684 100644 --- a/django-stubs/dispatch/dispatcher.pyi +++ b/django-stubs/dispatch/dispatcher.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, List, Tuple +from collections.abc import Callable +from typing import Any NONE_ID: Any NO_RECEIVERS: Any @@ -9,7 +10,7 @@ class Signal: lock: Any use_caching: Any sender_receivers_cache: Any - def __init__(self, providing_args: List[str] = ..., use_caching: bool = ...) -> None: ... + def __init__(self, providing_args: list[str] = ..., use_caching: bool = ...) -> None: ... def connect( self, receiver: Callable, sender: object | None = ..., weak: bool = ..., dispatch_uid: str | None = ... ) -> None: ... @@ -17,7 +18,7 @@ class Signal: self, receiver: Callable | None = ..., sender: object | None = ..., dispatch_uid: str | None = ... ) -> bool: ... def has_listeners(self, sender: Any = ...) -> bool: ... - def send(self, sender: Any, **named: Any) -> List[Tuple[Callable, str | None]]: ... - def send_robust(self, sender: Any, **named: Any) -> List[Tuple[Callable, Exception | str]]: ... + def send(self, sender: Any, **named: Any) -> list[tuple[Callable, str | None]]: ... + def send_robust(self, sender: Any, **named: Any) -> list[tuple[Callable, Exception | str]]: ... -def receiver(signal: List[Signal] | Signal, **kwargs: Any) -> Callable: ... +def receiver(signal: list[Signal] | Signal, **kwargs: Any) -> Callable: ... diff --git a/django-stubs/forms/boundfield.pyi b/django-stubs/forms/boundfield.pyi index 31ba7e192..0864e66d8 100644 --- a/django-stubs/forms/boundfield.pyi +++ b/django-stubs/forms/boundfield.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, Iterator, List, overload +from collections.abc import Iterable, Iterator +from typing import Any, overload from django.forms.fields import Field from django.forms.forms import BaseForm @@ -8,7 +9,7 @@ from django.forms.widgets import Widget from django.utils.functional import _StrOrPromise from django.utils.safestring import SafeString -_AttrsT = Dict[str, str | bool] +_AttrsT = dict[str, str | bool] class BoundField: form: BaseForm @@ -21,14 +22,14 @@ class BoundField: help_text: _StrOrPromise def __init__(self, form: BaseForm, field: Field, name: str) -> None: ... @property - def subwidgets(self) -> List[BoundWidget]: ... + def subwidgets(self) -> list[BoundWidget]: ... def __bool__(self) -> bool: ... def __iter__(self) -> Iterator[BoundWidget]: ... def __len__(self) -> int: ... @overload def __getitem__(self, idx: int | str) -> BoundWidget: ... @overload - def __getitem__(self, idx: slice) -> List[BoundWidget]: ... + def __getitem__(self, idx: slice) -> list[BoundWidget]: ... @property def errors(self) -> ErrorList: ... def as_widget( @@ -58,9 +59,9 @@ class BoundField: class BoundWidget: parent_widget: Widget - data: Dict[str, Any] + data: dict[str, Any] renderer: BaseRenderer - def __init__(self, parent_widget: Widget, data: Dict[str, Any], renderer: BaseRenderer) -> None: ... + def __init__(self, parent_widget: Widget, data: dict[str, Any], renderer: BaseRenderer) -> None: ... def tag(self, wrap_label: bool = ...) -> SafeString: ... @property def template_name(self) -> str: ... diff --git a/django-stubs/forms/fields.pyi b/django-stubs/forms/fields.pyi index 55ca32365..14684a072 100644 --- a/django-stubs/forms/fields.pyi +++ b/django-stubs/forms/fields.pyi @@ -1,6 +1,7 @@ import datetime +from collections.abc import Collection, Iterator, Sequence from decimal import Decimal -from typing import Any, Collection, Dict, Iterator, List, Pattern, Protocol, Sequence, Tuple, Type +from typing import Any, Pattern, Protocol from uuid import UUID from django.core.files import File @@ -26,8 +27,8 @@ class Field: label: _StrOrPromise | None required: bool widget: _ClassLevelWidgetT - hidden_widget: Type[Widget] - default_validators: List[_ValidatorCallable] + hidden_widget: type[Widget] + default_validators: list[_ValidatorCallable] default_error_messages: _ErrorMessagesT empty_values: Sequence[Any] show_hidden_initial: bool @@ -36,13 +37,13 @@ class Field: label_suffix: str | None localize: bool error_messages: _ErrorMessagesT - validators: List[_ValidatorCallable] + validators: list[_ValidatorCallable] max_length: int | None def __init__( self, *, required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -59,7 +60,7 @@ class Field: def run_validators(self, value: Any) -> None: ... def clean(self, value: Any) -> Any: ... def bound_data(self, data: Any, initial: Any) -> Any: ... - def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... + def widget_attrs(self, widget: Widget) -> dict[str, Any]: ... def has_changed(self, initial: Any | None, data: Any | None) -> bool: ... def get_bound_field(self, form: BaseForm, field_name: str) -> BoundField: ... def deconstruct(self) -> Any: ... @@ -77,7 +78,7 @@ class CharField(Field): strip: bool = ..., empty_value: str | None = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -89,7 +90,7 @@ class CharField(Field): label_suffix: str | None = ..., ) -> None: ... def to_python(self, value: Any | None) -> str | None: ... - def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... + def widget_attrs(self, widget: Widget) -> dict[str, Any]: ... class IntegerField(Field): max_value: int | None @@ -101,7 +102,7 @@ class IntegerField(Field): max_value: int | None = ..., min_value: int | None = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -113,7 +114,7 @@ class IntegerField(Field): label_suffix: str | None = ..., ) -> None: ... def to_python(self, value: Any | None) -> int | None: ... - def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... + def widget_attrs(self, widget: Widget) -> dict[str, Any]: ... class FloatField(IntegerField): def __init__( @@ -122,7 +123,7 @@ class FloatField(IntegerField): max_value: int | float | None = ..., min_value: int | float | None = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -135,7 +136,7 @@ class FloatField(IntegerField): ) -> None: ... def to_python(self, value: Any | None) -> float | None: ... # type: ignore def validate(self, value: float) -> None: ... - def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... + def widget_attrs(self, widget: Widget) -> dict[str, Any]: ... class DecimalField(IntegerField): decimal_places: int | None @@ -148,7 +149,7 @@ class DecimalField(IntegerField): max_digits: int | None = ..., decimal_places: int | None = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -161,7 +162,7 @@ class DecimalField(IntegerField): ) -> None: ... def to_python(self, value: Any | None) -> Decimal | None: ... # type: ignore def validate(self, value: Decimal) -> None: ... - def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... + def widget_attrs(self, widget: Widget) -> dict[str, Any]: ... class BaseTemporalField(Field): input_formats: Any @@ -170,7 +171,7 @@ class BaseTemporalField(Field): *, input_formats: Any | None = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -214,7 +215,7 @@ class RegexField(CharField): strip: bool = ..., empty_value: str | None = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -235,7 +236,7 @@ class EmailField(CharField): strip: bool = ..., empty_value: str | None = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -255,7 +256,7 @@ class FileField(Field): max_length: int | None = ..., allow_empty_file: bool = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -273,7 +274,7 @@ class FileField(Field): class ImageField(FileField): def to_python(self, data: File | None) -> File | None: ... - def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ... + def widget_attrs(self, widget: Widget) -> dict[str, Any]: ... class URLField(CharField): def __init__( @@ -284,7 +285,7 @@ class URLField(CharField): strip: bool = ..., empty_value: str | None = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -322,7 +323,7 @@ class ChoiceField(Field): *, choices: _FieldChoices | _ChoicesCallable = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -352,7 +353,7 @@ class TypedChoiceField(ChoiceField): empty_value: str | None = ..., choices: _FieldChoices | _ChoicesCallable = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -366,21 +367,21 @@ class TypedChoiceField(ChoiceField): def clean(self, value: Any) -> Any: ... class MultipleChoiceField(ChoiceField): - def to_python(self, value: Any | None) -> List[str]: ... + def to_python(self, value: Any | None) -> list[str]: ... def validate(self, value: Any) -> None: ... def has_changed(self, initial: Collection[Any] | None, data: Collection[Any] | None) -> bool: ... class TypedMultipleChoiceField(MultipleChoiceField): coerce: _CoerceCallable - empty_value: List[Any] | None + empty_value: list[Any] | None def __init__( self, *, coerce: _CoerceCallable = ..., - empty_value: List[Any] | None = ..., + empty_value: list[Any] | None = ..., choices: _FieldChoices | _ChoicesCallable = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -401,7 +402,7 @@ class ComboField(Field): fields: Sequence[Field], *, required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -423,7 +424,7 @@ class MultiValueField(Field): *, require_all_fields: bool = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -456,7 +457,7 @@ class FilePathField(ChoiceField): allow_folders: bool = ..., choices: _FieldChoices | _ChoicesCallable = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -477,7 +478,7 @@ class SplitDateTimeField(MultiValueField): fields: Sequence[Field] = ..., require_all_fields: bool = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -488,7 +489,7 @@ class SplitDateTimeField(MultiValueField): disabled: bool = ..., label_suffix: str | None = ..., ) -> None: ... - def compress(self, data_list: Tuple[datetime.date, datetime.time] | None) -> datetime.datetime | None: ... + def compress(self, data_list: tuple[datetime.date, datetime.time] | None) -> datetime.datetime | None: ... class GenericIPAddressField(CharField): unpack_ipv4: bool @@ -498,7 +499,7 @@ class GenericIPAddressField(CharField): protocol: str = ..., unpack_ipv4: bool = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -522,7 +523,7 @@ class SlugField(CharField): strip: bool = ..., empty_value: str | None = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., diff --git a/django-stubs/forms/forms.pyi b/django-stubs/forms/forms.pyi index c8c6e11ca..ab8049184 100644 --- a/django-stubs/forms/forms.pyi +++ b/django-stubs/forms/forms.pyi @@ -1,4 +1,5 @@ -from typing import Any, ClassVar, Dict, Iterable, Iterator, List, Mapping, Sequence, Type +from collections.abc import Iterable, Iterator, Mapping, Sequence +from typing import Any, ClassVar from django.core.exceptions import ValidationError as ValidationError from django.forms.boundfield import BoundField @@ -13,7 +14,7 @@ class DeclarativeFieldsMetaclass(MediaDefiningClass): ... class BaseForm: class Meta: fields: Sequence[str] - default_renderer: BaseRenderer | Type[BaseRenderer] | None + default_renderer: BaseRenderer | type[BaseRenderer] | None field_order: Iterable[str] | None use_required_attribute: bool is_bound: bool @@ -21,13 +22,13 @@ class BaseForm: files: _FilesT auto_id: bool | str initial: Mapping[str, Any] - error_class: Type[ErrorList] + error_class: type[ErrorList] prefix: str | None label_suffix: str empty_permitted: bool - fields: Dict[str, Field] + fields: dict[str, Field] renderer: BaseRenderer - cleaned_data: Dict[str, Any] + cleaned_data: dict[str, Any] def __init__( self, data: _DataT | None = ..., @@ -35,7 +36,7 @@ class BaseForm: auto_id: bool | str = ..., prefix: str | None = ..., initial: Mapping[str, Any] | None = ..., - error_class: Type[ErrorList] = ..., + error_class: type[ErrorList] = ..., label_suffix: str | None = ..., empty_permitted: bool = ..., field_order: Iterable[str] | None = ..., @@ -57,15 +58,15 @@ class BaseForm: def add_error(self, field: str | None, error: ValidationError | str) -> None: ... def has_error(self, field: str | None, code: str | None = ...) -> bool: ... def full_clean(self) -> None: ... - def clean(self) -> Dict[str, Any] | None: ... + def clean(self) -> dict[str, Any] | None: ... def has_changed(self) -> bool: ... @property - def changed_data(self) -> List[str]: ... + def changed_data(self) -> list[str]: ... @property def media(self) -> Media: ... def is_multipart(self) -> bool: ... - def hidden_fields(self) -> List[BoundField]: ... - def visible_fields(self) -> List[BoundField]: ... + def hidden_fields(self) -> list[BoundField]: ... + def visible_fields(self) -> list[BoundField]: ... def get_initial_for_field(self, field: Field, field_name: str) -> Any: ... def _html_output( self, @@ -77,5 +78,5 @@ class BaseForm: ) -> SafeString: ... class Form(BaseForm): - base_fields: ClassVar[Dict[str, Field]] - declared_fields: ClassVar[Dict[str, Field]] + base_fields: ClassVar[dict[str, Field]] + declared_fields: ClassVar[dict[str, Field]] diff --git a/django-stubs/forms/formsets.pyi b/django-stubs/forms/formsets.pyi index f95f0bc2a..47c82bbca 100644 --- a/django-stubs/forms/formsets.pyi +++ b/django-stubs/forms/formsets.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Generic, Iterator, List, Mapping, Sequence, Sized, Type, TypeVar +from collections.abc import Iterator, Mapping, Sequence, Sized +from typing import Any, Generic, TypeVar from django.forms.forms import BaseForm, Form from django.forms.utils import ErrorList, _DataT, _FilesT @@ -18,12 +19,12 @@ DEFAULT_MAX_NUM: int _F = TypeVar("_F", bound=BaseForm) class ManagementForm(Form): - cleaned_data: Dict[str, int | None] + cleaned_data: dict[str, int | None] def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def clean(self) -> Dict[str, int | None]: ... + def clean(self) -> dict[str, int | None]: ... class BaseFormSet(Generic[_F], Sized): - form: Type[_F] + form: type[_F] extra: int can_order: bool can_delete: bool @@ -40,9 +41,9 @@ class BaseFormSet(Generic[_F], Sized): data: _DataT files: _FilesT initial: Sequence[Mapping[str, Any]] | None - form_kwargs: Dict[str, Any] - error_class: Type[ErrorList] - ordering_widget: Type[Widget] + form_kwargs: dict[str, Any] + error_class: type[ErrorList] + ordering_widget: type[Widget] def __init__( self, data: _DataT | None = ..., @@ -50,8 +51,8 @@ class BaseFormSet(Generic[_F], Sized): auto_id: str = ..., prefix: str | None = ..., initial: Sequence[Mapping[str, Any]] | None = ..., - error_class: Type[ErrorList] = ..., - form_kwargs: Dict[str, Any] | None = ..., + error_class: type[ErrorList] = ..., + form_kwargs: dict[str, Any] | None = ..., error_messages: Mapping[str, str] | None = ..., ) -> None: ... def __iter__(self) -> Iterator[_F]: ... @@ -63,27 +64,27 @@ class BaseFormSet(Generic[_F], Sized): def total_form_count(self) -> int: ... def initial_form_count(self) -> int: ... @property - def forms(self) -> List[_F]: ... - def get_form_kwargs(self, index: int | None) -> Dict[str, Any]: ... + def forms(self) -> list[_F]: ... + def get_form_kwargs(self, index: int | None) -> dict[str, Any]: ... @property - def initial_forms(self) -> List[_F]: ... + def initial_forms(self) -> list[_F]: ... @property - def extra_forms(self) -> List[_F]: ... + def extra_forms(self) -> list[_F]: ... @property def empty_form(self) -> _F: ... @property - def cleaned_data(self) -> List[Dict[str, Any]]: ... + def cleaned_data(self) -> list[dict[str, Any]]: ... @property - def deleted_forms(self) -> List[_F]: ... + def deleted_forms(self) -> list[_F]: ... @property - def ordered_forms(self) -> List[_F]: ... + def ordered_forms(self) -> list[_F]: ... @classmethod def get_default_prefix(cls) -> str: ... @classmethod - def get_ordering_widget(cls) -> Type[Widget]: ... + def get_ordering_widget(cls) -> type[Widget]: ... def non_form_errors(self) -> ErrorList: ... @property - def errors(self) -> List[ErrorList]: ... + def errors(self) -> list[ErrorList]: ... def total_error_count(self) -> int: ... def is_valid(self) -> bool: ... def full_clean(self) -> None: ... @@ -99,8 +100,8 @@ class BaseFormSet(Generic[_F], Sized): def as_ul(self) -> SafeString: ... def formset_factory( - form: Type[_F], - formset: Type[BaseFormSet[_F]] = ..., + form: type[_F], + formset: type[BaseFormSet[_F]] = ..., extra: int = ..., can_order: bool = ..., can_delete: bool = ..., @@ -110,5 +111,5 @@ def formset_factory( validate_min: bool = ..., absolute_max: int | None = ..., can_delete_extra: bool = ..., -) -> Type[BaseFormSet[_F]]: ... +) -> type[BaseFormSet[_F]]: ... def all_valid(formsets: Sequence[BaseFormSet[_F]]) -> bool: ... diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index 3fe96acd6..12a5420b2 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -1,22 +1,5 @@ -from typing import ( - Any, - Callable, - ClassVar, - Collection, - Container, - Dict, - Generic, - Iterator, - List, - Mapping, - Sequence, - Tuple, - Type, - TypeAlias, - TypeVar, - Union, - overload, -) +from collections.abc import Callable, Collection, Iterator, Mapping, Sequence +from typing import Any, ClassVar, Container, Generic, TypeAlias, TypeVar, Union, overload from uuid import UUID from django.db import models @@ -39,10 +22,10 @@ from typing_extensions import Literal ALL_FIELDS: Literal["__all__"] _Fields: TypeAlias = Union[_ListOrTuple[str], Literal["__all__"]] # https://github.com/python/mypy/issues/12211 -_Widgets = Dict[str, Union[Type[Widget], Widget]] -_Labels = Dict[str, str] -_HelpTexts = Dict[str, str] -_ErrorMessages = Dict[str, Dict[str, str]] +_Widgets = dict[str, Union[type[Widget], Widget]] +_Labels = dict[str, str] +_HelpTexts = dict[str, str] +_ErrorMessages = dict[str, dict[str, str]] _FormFieldCallback = Callable[[models.Field], Field] _M = TypeVar("_M", bound=Model) @@ -51,10 +34,10 @@ _ParentM = TypeVar("_ParentM", bound=Model) def construct_instance( form: BaseForm, instance: _M, fields: Container[str] | None = ..., exclude: Container[str] | None = ... ) -> _M: ... -def model_to_dict(instance: Model, fields: _Fields | None = ..., exclude: _Fields | None = ...) -> Dict[str, Any]: ... +def model_to_dict(instance: Model, fields: _Fields | None = ..., exclude: _Fields | None = ...) -> dict[str, Any]: ... def apply_limit_choices_to_to_formfield(formfield: Field) -> None: ... def fields_for_model( - model: Type[Model], + model: type[Model], fields: _Fields | None = ..., exclude: _Fields | None = ..., widgets: _Widgets | None = ..., @@ -63,13 +46,13 @@ def fields_for_model( labels: _Labels | None = ..., help_texts: _HelpTexts | None = ..., error_messages: _ErrorMessages | None = ..., - field_classes: Mapping[str, Type[Field]] | None = ..., + field_classes: Mapping[str, type[Field]] | None = ..., *, apply_limit_choices_to: bool = ..., -) -> Dict[str, Any]: ... +) -> dict[str, Any]: ... class ModelFormOptions(Generic[_M]): - model: Type[_M] + model: type[_M] fields: _Fields | None exclude: _Fields | None widgets: _Widgets | None @@ -77,7 +60,7 @@ class ModelFormOptions(Generic[_M]): labels: _Labels | None help_texts: _HelpTexts | None error_messages: _ErrorMessages | None - field_classes: Dict[str, Type[Field]] | None + field_classes: dict[str, type[Field]] | None def __init__(self, options: type | None = ...) -> None: ... class ModelFormMetaclass(DeclarativeFieldsMetaclass): ... @@ -92,7 +75,7 @@ class BaseModelForm(Generic[_M], BaseForm): auto_id: bool | str = ..., prefix: str | None = ..., initial: Mapping[str, Any] | None = ..., - error_class: Type[ErrorList] = ..., + error_class: type[ErrorList] = ..., label_suffix: str | None = ..., empty_permitted: bool = ..., instance: _M | None = ..., @@ -104,11 +87,11 @@ class BaseModelForm(Generic[_M], BaseForm): def save_m2m(self) -> None: ... class ModelForm(BaseModelForm[_M], metaclass=ModelFormMetaclass): - base_fields: ClassVar[Dict[str, Field]] + base_fields: ClassVar[dict[str, Field]] def modelform_factory( - model: Type[_M], - form: Type[ModelForm[_M]] = ..., + model: type[_M], + form: type[ModelForm[_M]] = ..., fields: _Fields | None = ..., exclude: _Fields | None = ..., formfield_callback: _FormFieldCallback | None = ..., @@ -117,16 +100,16 @@ def modelform_factory( labels: _Labels | None = ..., help_texts: _HelpTexts | None = ..., error_messages: _ErrorMessages | None = ..., - field_classes: Mapping[str, Type[Field]] | None = ..., -) -> Type[ModelForm[_M]]: ... + field_classes: Mapping[str, type[Field]] | None = ..., +) -> type[ModelForm[_M]]: ... _ModelFormT = TypeVar("_ModelFormT", bound=ModelForm) class BaseModelFormSet(Generic[_M, _ModelFormT], BaseFormSet[_ModelFormT]): - model: Type[_M] + model: type[_M] unique_fields: Collection[str] queryset: QuerySet[_M] | None - initial_extra: Sequence[Dict[str, Any]] | None + initial_extra: Sequence[dict[str, Any]] | None def __init__( self, data: _DataT | None = ..., @@ -135,7 +118,7 @@ class BaseModelFormSet(Generic[_M, _ModelFormT], BaseFormSet[_ModelFormT]): prefix: str | None = ..., queryset: QuerySet[_M] | None = ..., *, - initial: Sequence[Dict[str, Any]] | None = ..., + initial: Sequence[dict[str, Any]] | None = ..., **kwargs: Any, ) -> None: ... def initial_form_count(self) -> int: ... @@ -143,26 +126,26 @@ class BaseModelFormSet(Generic[_M, _ModelFormT], BaseFormSet[_ModelFormT]): def save_new(self, form: _ModelFormT, commit: bool = ...) -> _M: ... def save_existing(self, form: _ModelFormT, instance: _M, commit: bool = ...) -> _M: ... def delete_existing(self, obj: _M, commit: bool = ...) -> None: ... - saved_forms: List[_ModelFormT] + saved_forms: list[_ModelFormT] def save_m2m(self) -> None: ... - def save(self, commit: bool = ...) -> List[_M]: ... + def save(self, commit: bool = ...) -> list[_M]: ... def clean(self) -> None: ... def validate_unique(self) -> None: ... def get_unique_error_message(self, unique_check: Sequence[str]) -> str: ... - def get_date_error_message(self, date_check: Tuple[str, Literal["date", "year", "month"], str, str]) -> str: ... + def get_date_error_message(self, date_check: tuple[str, Literal["date", "year", "month"], str, str]) -> str: ... def get_form_error(self) -> str: ... - changed_objects: List[Tuple[_M, List[str]]] - deleted_objects: List[_M] - def save_existing_objects(self, commit: bool = ...) -> List[_M]: ... - new_objects: List[_M] - def save_new_objects(self, commit: bool = ...) -> List[_M]: ... + changed_objects: list[tuple[_M, list[str]]] + deleted_objects: list[_M] + def save_existing_objects(self, commit: bool = ...) -> list[_M]: ... + new_objects: list[_M] + def save_new_objects(self, commit: bool = ...) -> list[_M]: ... def add_fields(self, form: _ModelFormT, index: int | None) -> None: ... def modelformset_factory( - model: Type[_M], - form: Type[_ModelFormT] = ..., + model: type[_M], + form: type[_ModelFormT] = ..., formfield_callback: _FormFieldCallback | None = ..., - formset: Type[BaseModelFormSet] = ..., + formset: type[BaseModelFormSet] = ..., extra: int = ..., can_delete: bool = ..., can_order: bool = ..., @@ -177,10 +160,10 @@ def modelformset_factory( error_messages: _ErrorMessages | None = ..., min_num: int | None = ..., validate_min: bool = ..., - field_classes: Mapping[str, Type[Field]] | None = ..., + field_classes: Mapping[str, type[Field]] | None = ..., absolute_max: int | None = ..., can_delete_extra: bool = ..., -) -> Type[BaseModelFormSet[_M, _ModelFormT]]: ... +) -> type[BaseModelFormSet[_M, _ModelFormT]]: ... class BaseInlineFormSet(Generic[_M, _ParentM, _ModelFormT], BaseModelFormSet[_M, _ModelFormT]): instance: _ParentM @@ -205,10 +188,10 @@ class BaseInlineFormSet(Generic[_M, _ParentM, _ModelFormT], BaseModelFormSet[_M, def get_unique_error_message(self, unique_check: Sequence[str]) -> str: ... def inlineformset_factory( - parent_model: Type[_ParentM], - model: Type[_M], - form: Type[_ModelFormT] = ..., - formset: Type[BaseInlineFormSet] = ..., + parent_model: type[_ParentM], + model: type[_M], + form: type[_ModelFormT] = ..., + formset: type[BaseInlineFormSet] = ..., fk_name: str | None = ..., fields: _Fields | None = ..., exclude: _Fields | None = ..., @@ -225,10 +208,10 @@ def inlineformset_factory( error_messages: _ErrorMessages | None = ..., min_num: int | None = ..., validate_min: bool = ..., - field_classes: Mapping[str, Type[Field]] | None = ..., + field_classes: Mapping[str, type[Field]] | None = ..., absolute_max: int | None = ..., can_delete_extra: bool = ..., -) -> Type[BaseInlineFormSet[_M, _ParentM, _ModelFormT]]: ... +) -> type[BaseInlineFormSet[_M, _ParentM, _ModelFormT]]: ... class InlineForeignKeyField(Field): disabled: bool @@ -236,7 +219,7 @@ class InlineForeignKeyField(Field): required: bool show_hidden_initial: bool widget: _ClassLevelWidgetT - default_error_messages: Dict[str, str] + default_error_messages: dict[str, str] parent_instance: Model pk_field: bool to_field: str | None @@ -259,20 +242,20 @@ class ModelChoiceIterator: field: ModelChoiceField queryset: QuerySet def __init__(self, field: ModelChoiceField) -> None: ... - def __iter__(self) -> Iterator[Tuple[ModelChoiceIteratorValue | str, str]]: ... + def __iter__(self) -> Iterator[tuple[ModelChoiceIteratorValue | str, str]]: ... def __len__(self) -> int: ... def __bool__(self) -> bool: ... - def choice(self, obj: Model) -> Tuple[ModelChoiceIteratorValue, str]: ... + def choice(self, obj: Model) -> tuple[ModelChoiceIteratorValue, str]: ... class ModelChoiceField(ChoiceField): disabled: bool - error_messages: Dict[str, str] + error_messages: dict[str, str] help_text: _StrOrPromise required: bool show_hidden_initial: bool - validators: List[Any] - default_error_messages: Dict[str, str] - iterator: Type[ModelChoiceIterator] + validators: list[Any] + default_error_messages: dict[str, str] + iterator: type[ModelChoiceIterator] empty_label: _StrOrPromise | None queryset: QuerySet[models.Model] | None limit_choices_to: _AllLimitChoicesTo | None @@ -283,7 +266,7 @@ class ModelChoiceField(ChoiceField): *, empty_label: _StrOrPromise | None = ..., required: bool = ..., - widget: Widget | Type[Widget] | None = ..., + widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., @@ -310,20 +293,20 @@ class ModelMultipleChoiceField(ModelChoiceField): required: bool show_hidden_initial: bool widget: _ClassLevelWidgetT - hidden_widget: Type[Widget] - default_error_messages: Dict[str, str] + hidden_widget: type[Widget] + default_error_messages: dict[str, str] def __init__(self, queryset: None | Manager[Model] | QuerySet[Model], **kwargs: Any) -> None: ... - def to_python(self, value: Any) -> List[Model]: ... # type: ignore[override] + def to_python(self, value: Any) -> list[Model]: ... # type: ignore[override] def clean(self, value: Any) -> QuerySet[Model]: ... def prepare_value(self, value: Any) -> Any: ... def has_changed(self, initial: Collection[Any] | None, data: Collection[Any] | None) -> bool: ... # type: ignore -def modelform_defines_fields(form_class: Type[ModelForm]) -> bool: ... +def modelform_defines_fields(form_class: type[ModelForm]) -> bool: ... @overload def _get_foreign_key( # type: ignore - parent_model: Type[Model], model: Type[Model], fk_name: str | None = ..., can_fail: Literal[True] = ... + parent_model: type[Model], model: type[Model], fk_name: str | None = ..., can_fail: Literal[True] = ... ) -> ForeignKey | None: ... @overload def _get_foreign_key( - parent_model: Type[Model], model: Type[Model], fk_name: str | None = ..., can_fail: Literal[False] = ... + parent_model: type[Model], model: type[Model], fk_name: str | None = ..., can_fail: Literal[False] = ... ) -> ForeignKey: ... diff --git a/django-stubs/forms/renderers.pyi b/django-stubs/forms/renderers.pyi index afa9ef106..d8d759409 100644 --- a/django-stubs/forms/renderers.pyi +++ b/django-stubs/forms/renderers.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Type +from typing import Any from django.http import HttpRequest from django.template.backends.base import BaseEngine @@ -10,7 +10,7 @@ def get_default_renderer() -> BaseRenderer: ... class BaseRenderer: def get_template(self, template_name: str) -> Any: ... - def render(self, template_name: str, context: Dict[str, Any], request: HttpRequest | None = ...) -> str: ... + def render(self, template_name: str, context: dict[str, Any], request: HttpRequest | None = ...) -> str: ... class EngineMixin: def get_template(self, template_name: str) -> Any: ... @@ -18,11 +18,11 @@ class EngineMixin: def engine(self) -> BaseEngine: ... class DjangoTemplates(EngineMixin, BaseRenderer): - backend: Type[DjangoTemplatesR] + backend: type[DjangoTemplatesR] class Jinja2(EngineMixin, BaseRenderer): @property - def backend(self) -> Type[Jinja2R]: ... + def backend(self) -> type[Jinja2R]: ... class TemplatesSetting(BaseRenderer): def get_template(self, template_name: str) -> Template | None: ... diff --git a/django-stubs/forms/utils.pyi b/django-stubs/forms/utils.pyi index d9d879c3e..e4566eaf0 100644 --- a/django-stubs/forms/utils.pyi +++ b/django-stubs/forms/utils.pyi @@ -1,6 +1,7 @@ from collections import UserList +from collections.abc import Iterable, Mapping, Sequence from datetime import datetime -from typing import Any, Dict, Iterable, List, Mapping, Sequence +from typing import Any from django.core.exceptions import ValidationError from django.core.files.uploadedfile import UploadedFile @@ -11,25 +12,25 @@ _DataT = Mapping[str, Any] _FilesT = MultiValueDict[str, UploadedFile] def pretty_name(name: str) -> str: ... -def flatatt(attrs: Dict[str, Any]) -> SafeString: ... +def flatatt(attrs: dict[str, Any]) -> SafeString: ... class ErrorDict(dict): - def as_data(self) -> Dict[str, List[ValidationError]]: ... - def get_json_data(self, escape_html: bool = ...) -> Dict[str, Any]: ... + def as_data(self) -> dict[str, list[ValidationError]]: ... + def get_json_data(self, escape_html: bool = ...) -> dict[str, Any]: ... def as_json(self, escape_html: bool = ...) -> str: ... def as_ul(self) -> str: ... def as_text(self) -> str: ... class ErrorList(UserList): - data: List[ValidationError | str] + data: list[ValidationError | str] error_class: str def __init__( self, initlist: ErrorList | Sequence[str | Exception] | None = ..., error_class: str | None = ..., ) -> None: ... - def as_data(self) -> List[ValidationError]: ... - def get_json_data(self, escape_html: bool = ...) -> List[Dict[str, str]]: ... + def as_data(self) -> list[ValidationError]: ... + def get_json_data(self, escape_html: bool = ...) -> list[dict[str, str]]: ... def as_json(self, escape_html: bool = ...) -> str: ... def as_ul(self) -> str: ... def as_text(self) -> str: ... diff --git a/django-stubs/forms/widgets.pyi b/django-stubs/forms/widgets.pyi index 598920e37..09b331864 100644 --- a/django-stubs/forms/widgets.pyi +++ b/django-stubs/forms/widgets.pyi @@ -1,5 +1,6 @@ import datetime -from typing import Any, Dict, Iterable, Iterator, List, Mapping, Sequence, Tuple, Type +from collections.abc import Iterable, Iterator, Mapping, Sequence +from typing import Any from django.core.files.base import File from django.db.models.fields import _FieldChoices @@ -10,7 +11,7 @@ from django.utils.functional import _Getter from django.utils.safestring import SafeString from typing_extensions import Literal, Protocol -_OptAttrs = Dict[str, Any] +_OptAttrs = dict[str, Any] class MediaOrderConflictWarning(RuntimeWarning): ... @@ -18,16 +19,16 @@ class Media: def __init__( self, media: type | None = ..., - css: Dict[str, Sequence[str]] | None = ..., + css: dict[str, Sequence[str]] | None = ..., js: Sequence[str] | None = ..., ) -> None: ... def render(self) -> SafeString: ... - def render_js(self) -> List[SafeString]: ... + def render_js(self) -> list[SafeString]: ... def render_css(self) -> Iterable[SafeString]: ... def absolute_path(self, path: str) -> str: ... def __getitem__(self, name: str) -> Media: ... @staticmethod - def merge(*lists: Iterable[Any]) -> List[Any]: ... + def merge(*lists: Iterable[Any]) -> list[Any]: ... def __add__(self, other: Media) -> Media: ... class MediaDefiningClass(type): ... @@ -43,13 +44,13 @@ class Widget(metaclass=MediaDefiningClass): def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... @property def is_hidden(self) -> bool: ... - def subwidgets(self, name: str, value: Any, attrs: _OptAttrs = ...) -> Iterator[Dict[str, Any]]: ... + def subwidgets(self, name: str, value: Any, attrs: _OptAttrs = ...) -> Iterator[dict[str, Any]]: ... def format_value(self, value: Any) -> str | None: ... - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... def render( self, name: str, value: Any, attrs: _OptAttrs | None = ..., renderer: BaseRenderer | None = ... ) -> SafeString: ... - def build_attrs(self, base_attrs: _OptAttrs, extra_attrs: _OptAttrs | None = ...) -> Dict[str, Any]: ... + def build_attrs(self, base_attrs: _OptAttrs, extra_attrs: _OptAttrs | None = ...) -> dict[str, Any]: ... def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... def id_for_label(self, id_: str) -> str: ... @@ -80,7 +81,7 @@ class PasswordInput(Input): input_type: str template_name: str def __init__(self, attrs: _OptAttrs | None = ..., render_value: bool = ...) -> None: ... - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... class HiddenInput(Input): choices: _FieldChoices @@ -109,7 +110,7 @@ class ClearableFileInput(FileInput): def clear_checkbox_name(self, name: str) -> str: ... def clear_checkbox_id(self, name: str) -> str: ... def is_initial(self, value: File | str | None) -> bool: ... - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... @@ -156,12 +157,12 @@ class ChoiceWidget(Widget): option_inherits_attrs: bool choices: _FieldChoices def __init__(self, attrs: _OptAttrs | None = ..., choices: _FieldChoices = ...) -> None: ... - def subwidgets(self, name: str, value: Any, attrs: _OptAttrs = ...) -> Iterator[Dict[str, Any]]: ... - def options(self, name: str, value: List[str], attrs: _OptAttrs | None = ...) -> Iterator[Dict[str, Any]]: ... + def subwidgets(self, name: str, value: Any, attrs: _OptAttrs = ...) -> Iterator[dict[str, Any]]: ... + def options(self, name: str, value: list[str], attrs: _OptAttrs | None = ...) -> Iterator[dict[str, Any]]: ... def optgroups( - self, name: str, value: List[str], attrs: _OptAttrs | None = ... - ) -> List[Tuple[str | None, List[Dict[str, Any]], int | None]]: ... - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... + self, name: str, value: list[str], attrs: _OptAttrs | None = ... + ) -> list[tuple[str | None, list[dict[str, Any]], int | None]]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... def create_option( self, name: str, @@ -171,10 +172,10 @@ class ChoiceWidget(Widget): index: int, subindex: int | None = ..., attrs: _OptAttrs | None = ..., - ) -> Dict[str, Any]: ... + ) -> dict[str, Any]: ... def id_for_label(self, id_: str, index: str = ...) -> str: ... def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ... - def format_value(self, value: Any) -> List[str]: ... # type: ignore + def format_value(self, value: Any) -> list[str]: ... # type: ignore class Select(ChoiceWidget): input_type: str | None @@ -183,7 +184,7 @@ class Select(ChoiceWidget): add_id_index: bool checked_attribute: Any option_inherits_attrs: bool - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... def use_required_attribute(self, initial: Any) -> bool: ... class NullBooleanSelect(Select): @@ -216,14 +217,14 @@ class MultiWidget(Widget): widgets: Sequence[Widget] def __init__( self, - widgets: Dict[str, Widget | Type[Widget]] | Sequence[Widget | Type[Widget]], + widgets: dict[str, Widget | type[Widget]] | Sequence[Widget | type[Widget]], attrs: _OptAttrs | None = ..., ) -> None: ... @property def is_hidden(self) -> bool: ... - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... def id_for_label(self, id_: str) -> str: ... - def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> List[Any]: ... + def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> list[Any]: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... def decompress(self, value: Any) -> Any | None: ... media: _Getter[Media] @@ -233,16 +234,16 @@ class MultiWidget(Widget): class SplitDateTimeWidget(MultiWidget): supports_microseconds: bool template_name: str - widgets: Tuple[DateInput, TimeInput] + widgets: tuple[DateInput, TimeInput] def __init__( self, attrs: _OptAttrs | None = ..., date_format: str | None = ..., time_format: str | None = ..., - date_attrs: Dict[str, str] | None = ..., - time_attrs: Dict[str, str] | None = ..., + date_attrs: dict[str, str] | None = ..., + time_attrs: dict[str, str] | None = ..., ) -> None: ... - def decompress(self, value: Any) -> Tuple[datetime.date | None, datetime.time | None]: ... + def decompress(self, value: Any) -> tuple[datetime.date | None, datetime.time | None]: ... class SplitHiddenDateTimeWidget(SplitDateTimeWidget): template_name: str @@ -251,24 +252,24 @@ class SplitHiddenDateTimeWidget(SplitDateTimeWidget): attrs: _OptAttrs | None = ..., date_format: str | None = ..., time_format: str | None = ..., - date_attrs: Dict[str, str] | None = ..., - time_attrs: Dict[str, str] | None = ..., + date_attrs: dict[str, str] | None = ..., + time_attrs: dict[str, str] | None = ..., ) -> None: ... class SelectDateWidget(Widget): - none_value: Tuple[Literal[""], str] + none_value: tuple[Literal[""], str] month_field: str day_field: str year_field: str template_name: str input_type: str - select_widget: Type[ChoiceWidget] + select_widget: type[ChoiceWidget] date_re: Any years: Iterable[int | str] months: Mapping[int, str] - year_none_value: Tuple[Literal[""], str] - month_none_value: Tuple[Literal[""], str] - day_none_value: Tuple[Literal[""], str] + year_none_value: tuple[Literal[""], str] + month_none_value: tuple[Literal[""], str] + day_none_value: tuple[Literal[""], str] def __init__( self, attrs: _OptAttrs | None = ..., @@ -276,8 +277,8 @@ class SelectDateWidget(Widget): months: Mapping[int, str] | None = ..., empty_label: str | _ListOrTuple[str] | None = ..., ) -> None: ... - def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> Dict[str, Any]: ... - def format_value(self, value: Any) -> Dict[str, str | int | None]: ... # type: ignore + def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ... + def format_value(self, value: Any) -> dict[str, str | int | None]: ... # type: ignore def id_for_label(self, id_: str) -> str: ... def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> str | None | Any: ... def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ... diff --git a/django-stubs/http/cookie.pyi b/django-stubs/http/cookie.pyi index e2dc91dd1..4e5654e6c 100644 --- a/django-stubs/http/cookie.pyi +++ b/django-stubs/http/cookie.pyi @@ -1,5 +1,5 @@ -from typing import Any, Dict +from typing import Any SimpleCookie: Any -def parse_cookie(cookie: str) -> Dict[str, str]: ... +def parse_cookie(cookie: str) -> dict[str, str]: ... diff --git a/django-stubs/http/multipartparser.pyi b/django-stubs/http/multipartparser.pyi index b344f0d7c..830e784f6 100644 --- a/django-stubs/http/multipartparser.pyi +++ b/django-stubs/http/multipartparser.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, Dict, Iterator, List, Mapping, Tuple +from collections.abc import Iterator, Mapping +from typing import IO, Any from django.http.request import QueryDict from django.utils.datastructures import ImmutableList, MultiValueDict @@ -16,11 +17,11 @@ class MultiPartParser: self, META: Mapping[str, Any], input_data: IO[bytes], - upload_handlers: List[Any] | ImmutableList[Any], + upload_handlers: list[Any] | ImmutableList[Any], encoding: str | None = ..., ) -> None: ... - def parse(self) -> Tuple[QueryDict, MultiValueDict]: ... - def handle_file_complete(self, old_field_name: str, counters: List[int]) -> None: ... + def parse(self) -> tuple[QueryDict, MultiValueDict]: ... + def handle_file_complete(self, old_field_name: str, counters: list[int]) -> None: ... def sanitize_file_name(self, file_name: str) -> str | None: ... class LazyStream: @@ -53,6 +54,6 @@ class BoundaryIter: class Parser: def __init__(self, stream: LazyStream, boundary: bytes) -> None: ... - def __iter__(self) -> Iterator[Tuple[str, Dict[str, Tuple[str, Dict[str, bytes | str]]], LazyStream]]: ... + def __iter__(self) -> Iterator[tuple[str, dict[str, tuple[str, dict[str, bytes | str]]], LazyStream]]: ... -def parse_header(line: bytes) -> Tuple[str, Dict[str, bytes]]: ... +def parse_header(line: bytes) -> tuple[str, dict[str, bytes]]: ... diff --git a/django-stubs/http/request.pyi b/django-stubs/http/request.pyi index 541da24c1..ac849e7dc 100644 --- a/django-stubs/http/request.pyi +++ b/django-stubs/http/request.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, Mapping from io import BytesIO -from typing import Any, BinaryIO, Dict, Iterable, List, Mapping, NoReturn, Pattern, Set, Tuple, Type, TypeVar, overload +from typing import Any, BinaryIO, NoReturn, Pattern, TypeVar, overload from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import AnonymousUser @@ -16,11 +17,11 @@ host_validation_re: Pattern[str] class UnreadablePostError(OSError): ... class RawPostDataException(Exception): ... -UploadHandlerList = List[uploadhandler.FileUploadHandler] | ImmutableList[uploadhandler.FileUploadHandler] +UploadHandlerList = list[uploadhandler.FileUploadHandler] | ImmutableList[uploadhandler.FileUploadHandler] class HttpHeaders(CaseInsensitiveMapping[str]): HTTP_PREFIX: str - UNPREFIXED_HEADERS: Set[str] + UNPREFIXED_HEADERS: set[str] def __init__(self, environ: Mapping[str, Any]) -> None: ... @classmethod def parse_header_name(cls, header: str) -> str | None: ... @@ -28,15 +29,15 @@ class HttpHeaders(CaseInsensitiveMapping[str]): class HttpRequest(BytesIO): GET: _ImmutableQueryDict POST: _ImmutableQueryDict - COOKIES: Dict[str, str] - META: Dict[str, Any] + COOKIES: dict[str, str] + META: dict[str, Any] FILES: MultiValueDict[str, uploadedfile.UploadedFile] path: str path_info: str method: str | None resolver_match: ResolverMatch | None content_type: str | None - content_params: Dict[str, str] | None + content_params: dict[str, str] | None _stream: BinaryIO # Attributes added by optional parts of Django # django.contrib.admin views: @@ -80,11 +81,11 @@ class HttpRequest(BytesIO): @upload_handlers.setter def upload_handlers(self, upload_handlers: UploadHandlerList) -> None: ... @property - def accepted_types(self) -> List[MediaType]: ... + def accepted_types(self) -> list[MediaType]: ... def __repr__(self) -> str: ... def parse_file_upload( self, META: Mapping[str, Any], post_data: BinaryIO - ) -> Tuple[QueryDict, MultiValueDict[str, uploadedfile.UploadedFile]]: ... + ) -> tuple[QueryDict, MultiValueDict[str, uploadedfile.UploadedFile]]: ... @property def headers(self) -> HttpHeaders: ... @property @@ -131,7 +132,7 @@ class QueryDict(MultiValueDict[str, str]): ) -> None: ... @classmethod def fromkeys( # type: ignore - cls: Type[_Q], + cls: type[_Q], iterable: Iterable[bytes | str], value: str | bytes = ..., mutable: bool = ..., @@ -144,14 +145,14 @@ class QueryDict(MultiValueDict[str, str]): def __setitem__(self, key: str | bytes, value: str | bytes) -> None: ... def __delitem__(self, key: str | bytes) -> None: ... def setlist(self, key: str | bytes, list_: Iterable[str | bytes]) -> None: ... - def setlistdefault(self, key: str | bytes, default_list: List[str] | None = ...) -> List[str]: ... + def setlistdefault(self, key: str | bytes, default_list: list[str] | None = ...) -> list[str]: ... def appendlist(self, key: str | bytes, value: str | bytes) -> None: ... # Fake signature (because *args is used in source, but it fails with more that 1 argument) @overload def pop(self, __key: str | bytes) -> str: ... @overload def pop(self, __key: str | bytes, __default: str | _Z = ...) -> str | _Z: ... - def popitem(self) -> Tuple[str, str]: ... + def popitem(self) -> tuple[str, str]: ... def clear(self) -> None: ... def setdefault(self, key: str | bytes, default: str | bytes | None = ...) -> str: ... def copy(self) -> QueryDict: ... @@ -165,7 +166,7 @@ class _ImmutableQueryDict(QueryDict): def __setitem__(self, key: str | bytes, value: str | bytes) -> NoReturn: ... def __delitem__(self, key: str | bytes) -> NoReturn: ... def setlist(self, key: str | bytes, list_: Iterable[str | bytes]) -> NoReturn: ... - def setlistdefault(self, key: str | bytes, default_list: List[str] | None = ...) -> NoReturn: ... + def setlistdefault(self, key: str | bytes, default_list: list[str] | None = ...) -> NoReturn: ... def appendlist(self, key: str | bytes, value: str | bytes) -> NoReturn: ... # Fake signature (because *args is used in source, but it fails with more that 1 argument) @overload @@ -181,12 +182,12 @@ class _ImmutableQueryDict(QueryDict): # was created by Django, there is no chance to hit `List[object]` (empty list) # edge case. def __getitem__(self, key: str) -> str: ... - def dict(self) -> Dict[str, str]: ... # type: ignore[override] + def dict(self) -> dict[str, str]: ... # type: ignore[override] class MediaType: main_type: str sub_type: str - params: Dict[str, bytes] + params: dict[str, bytes] def __init__(self, media_type_raw_line: str) -> None: ... @property def is_all_types(self) -> bool: ... @@ -196,5 +197,5 @@ class MediaType: def bytes_to_text(s: None, encoding: str) -> None: ... @overload def bytes_to_text(s: bytes | str, encoding: str) -> str: ... -def split_domain_port(host: str) -> Tuple[str, str]: ... +def split_domain_port(host: str) -> tuple[str, str]: ... def validate_host(host: str, allowed_hosts: Iterable[str]) -> bool: ... diff --git a/django-stubs/http/response.pyi b/django-stubs/http/response.pyi index 80df78c19..714a5ef6e 100644 --- a/django-stubs/http/response.pyi +++ b/django-stubs/http/response.pyi @@ -1,7 +1,8 @@ import datetime +from collections.abc import Iterable, Iterator from io import BytesIO from json import JSONEncoder -from typing import Any, Dict, Iterable, Iterator, List, Tuple, Type, TypeVar, overload, type_check_only +from typing import Any, TypeVar, overload, type_check_only from django.http.cookie import SimpleCookie from django.utils.datastructures import CaseInsensitiveMapping, _PropertyDescriptor @@ -12,11 +13,11 @@ class BadHeaderError(ValueError): ... _Z = TypeVar("_Z") class ResponseHeaders(CaseInsensitiveMapping[str]): - def __init__(self, data: Dict[str, str]) -> None: ... + def __init__(self, data: dict[str, str]) -> None: ... def _convert_to_charset(self, value: bytes | str | int, charset: str, mime_encode: bool = ...) -> str: ... def __delitem__(self, key: str) -> None: ... def __setitem__(self, key: str, value: str | bytes | int) -> None: ... - def pop(self, key: str, default: _Z = ...) -> _Z | Tuple[str, str]: ... + def pop(self, key: str, default: _Z = ...) -> _Z | tuple[str, str]: ... def setdefault(self, key: str, value: str | bytes | int) -> None: ... class HttpResponseBase: @@ -31,7 +32,7 @@ class HttpResponseBase: status: int | None = ..., reason: str | None = ..., charset: str | None = ..., - headers: Dict[str, str] | None = ..., + headers: dict[str, str] | None = ..., ) -> None: ... @property def reason_phrase(self) -> str: ... @@ -48,7 +49,7 @@ class HttpResponseBase: def __getitem__(self, header: str) -> str: ... def has_header(self, header: str) -> bool: ... def __contains__(self, header: str) -> bool: ... - def items(self) -> Iterable[Tuple[str, str]]: ... + def items(self) -> Iterable[tuple[str, str]]: ... @overload def get(self, header: str, alternate: str) -> str: ... @overload @@ -118,7 +119,7 @@ class FileResponse(StreamingHttpResponse): def set_headers(self, filelike: BytesIO) -> None: ... class HttpResponseRedirectBase(HttpResponse): - allowed_schemes: List[str] + allowed_schemes: list[str] def __init__(self, redirect_to: str, *args: Any, **kwargs: Any) -> None: ... @property def url(self) -> str: ... @@ -144,8 +145,8 @@ class JsonResponse(HttpResponse): def __init__( self, data: Any, - encoder: Type[JSONEncoder] = ..., + encoder: type[JSONEncoder] = ..., safe: bool = ..., - json_dumps_params: Dict[str, Any] | None = ..., + json_dumps_params: dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... diff --git a/django-stubs/middleware/cache.pyi b/django-stubs/middleware/cache.pyi index be9de09b0..642a96fb8 100644 --- a/django-stubs/middleware/cache.pyi +++ b/django-stubs/middleware/cache.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable +from collections.abc import Callable +from typing import Any from django.core.cache import BaseCache from django.http.request import HttpRequest diff --git a/django-stubs/middleware/csrf.pyi b/django-stubs/middleware/csrf.pyi index 0f354518a..b39fb9504 100644 --- a/django-stubs/middleware/csrf.pyi +++ b/django-stubs/middleware/csrf.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable from logging import Logger -from typing import Any, Callable, Dict, Tuple +from typing import Any from django.http.request import HttpRequest from django.http.response import HttpResponseBase, HttpResponseForbidden @@ -23,7 +24,7 @@ def rotate_token(request: HttpRequest) -> None: ... class CsrfViewMiddleware(MiddlewareMixin): def process_request(self, request: HttpRequest) -> None: ... def process_view( - self, request: HttpRequest, callback: Callable | None, callback_args: Tuple, callback_kwargs: Dict[str, Any] + self, request: HttpRequest, callback: Callable | None, callback_args: tuple, callback_kwargs: dict[str, Any] ) -> HttpResponseForbidden | None: ... def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ... diff --git a/django-stubs/middleware/security.pyi b/django-stubs/middleware/security.pyi index a1bb853b9..7277bc5fc 100644 --- a/django-stubs/middleware/security.pyi +++ b/django-stubs/middleware/security.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponsePermanentRedirect @@ -12,6 +12,6 @@ class SecurityMiddleware(MiddlewareMixin): xss_filter: bool redirect: bool redirect_host: str | None - redirect_exempt: List[Any] + redirect_exempt: list[Any] def process_request(self, request: HttpRequest) -> HttpResponsePermanentRedirect | None: ... def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ... diff --git a/django-stubs/shortcuts.pyi b/django-stubs/shortcuts.pyi index 57e5a6117..40422d9c8 100644 --- a/django-stubs/shortcuts.pyi +++ b/django-stubs/shortcuts.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, List, Mapping, Protocol, Sequence, Type, TypeVar, overload +from collections.abc import Callable, Mapping, Sequence +from typing import Any, Protocol, TypeVar, overload from django.db.models import Manager, QuerySet from django.db.models.base import Model @@ -35,6 +36,6 @@ def redirect( _T = TypeVar("_T", bound=Model) -def get_object_or_404(klass: Type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> _T: ... -def get_list_or_404(klass: Type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> List[_T]: ... +def get_object_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> _T: ... +def get_list_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> list[_T]: ... def resolve_url(to: Callable | Model | str, *args: Any, **kwargs: Any) -> str: ... diff --git a/django-stubs/template/backends/base.pyi b/django-stubs/template/backends/base.pyi index ee2a9d4bc..83437b387 100644 --- a/django-stubs/template/backends/base.pyi +++ b/django-stubs/template/backends/base.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterator, List, Mapping, Protocol, Tuple +from collections.abc import Iterator, Mapping +from typing import Any, Protocol from django.http.request import HttpRequest from django.template import TemplateDoesNotExist @@ -7,7 +8,7 @@ from django.utils.safestring import SafeString class BaseEngine: name: str - dirs: List[str] + dirs: list[str] app_dirs: bool def __init__(self, params: Mapping[str, Any]) -> None: ... @property @@ -15,12 +16,12 @@ class BaseEngine: def from_string(self, template_code: str) -> _EngineTemplate: ... def get_template(self, template_name: str) -> _EngineTemplate: ... @property - def template_dirs(self) -> Tuple[str]: ... + def template_dirs(self) -> tuple[str]: ... def iter_template_filenames(self, template_name: str) -> Iterator[str]: ... class _EngineTemplate(Protocol): def render( self, - context: Context | Dict[str, Any] | None = ..., + context: Context | dict[str, Any] | None = ..., request: HttpRequest | None = ..., ) -> SafeString: ... diff --git a/django-stubs/template/backends/django.pyi b/django-stubs/template/backends/django.pyi index 968e01e44..64a7bee4d 100644 --- a/django-stubs/template/backends/django.pyi +++ b/django-stubs/template/backends/django.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterator, NoReturn +from collections.abc import Iterator +from typing import Any, NoReturn from django.template.engine import Engine from django.template.exceptions import TemplateDoesNotExist @@ -7,10 +8,10 @@ from .base import BaseEngine class DjangoTemplates(BaseEngine): engine: Engine - def __init__(self, params: Dict[str, Any]) -> None: ... - def get_templatetag_libraries(self, custom_libraries: Dict[str, str]) -> Dict[str, str]: ... + def __init__(self, params: dict[str, Any]) -> None: ... + def get_templatetag_libraries(self, custom_libraries: dict[str, str]) -> dict[str, str]: ... def copy_exception(exc: TemplateDoesNotExist, backend: DjangoTemplates | None = ...) -> TemplateDoesNotExist: ... def reraise(exc: TemplateDoesNotExist, backend: DjangoTemplates) -> NoReturn: ... -def get_installed_libraries() -> Dict[str, str]: ... +def get_installed_libraries() -> dict[str, str]: ... def get_package_libraries(pkg: Any) -> Iterator[str]: ... diff --git a/django-stubs/template/backends/dummy.pyi b/django-stubs/template/backends/dummy.pyi index 5eb6283e6..3a6109dc6 100644 --- a/django-stubs/template/backends/dummy.pyi +++ b/django-stubs/template/backends/dummy.pyi @@ -1,14 +1,14 @@ import string -from typing import Any, Dict, List, Tuple +from typing import Any from django.http.request import HttpRequest from .base import BaseEngine class TemplateStrings(BaseEngine): - template_dirs: Tuple[str] - def __init__(self, params: Dict[str, Dict[Any, Any] | List[Any] | bool | str]) -> None: ... + template_dirs: tuple[str] + def __init__(self, params: dict[str, dict[Any, Any] | list[Any] | bool | str]) -> None: ... class Template(string.Template): template: str - def render(self, context: Dict[str, str] | None = ..., request: HttpRequest | None = ...) -> str: ... + def render(self, context: dict[str, str] | None = ..., request: HttpRequest | None = ...) -> str: ... diff --git a/django-stubs/template/backends/jinja2.pyi b/django-stubs/template/backends/jinja2.pyi index 46d150008..49d5bdc11 100644 --- a/django-stubs/template/backends/jinja2.pyi +++ b/django-stubs/template/backends/jinja2.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, List +from collections.abc import Callable +from typing import Any from django.template.exceptions import TemplateSyntaxError @@ -6,14 +7,14 @@ from .base import BaseEngine class Jinja2(BaseEngine): env: Any - context_processors: List[str] - def __init__(self, params: Dict[str, Any]) -> None: ... + context_processors: list[str] + def __init__(self, params: dict[str, Any]) -> None: ... @property - def template_context_processors(self) -> List[Callable]: ... + def template_context_processors(self) -> list[Callable]: ... class Origin: name: str template_name: str | None def __init__(self, name: str, template_name: str | None) -> None: ... -def get_exception_info(exception: TemplateSyntaxError) -> Dict[str, Any]: ... +def get_exception_info(exception: TemplateSyntaxError) -> dict[str, Any]: ... diff --git a/django-stubs/template/base.pyi b/django-stubs/template/base.pyi index 7e05f256a..937b4de8a 100644 --- a/django-stubs/template/base.pyi +++ b/django-stubs/template/base.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from enum import Enum from logging import Logger -from typing import Any, Callable, Dict, Iterable, Iterator, List, Mapping, Pattern, Sequence, Tuple, Type +from typing import Any, Pattern from django.template.context import Context as Context from django.template.engine import Engine @@ -32,8 +33,8 @@ class TokenType(Enum): class VariableDoesNotExist(Exception): msg: str - params: Tuple[Dict[str, str] | str] - def __init__(self, msg: str, params: Tuple[Dict[str, str] | str] = ...) -> None: ... + params: tuple[dict[str, str] | str] + def __init__(self, msg: str, params: tuple[dict[str, str] | str] = ...) -> None: ... class Origin: name: str @@ -57,9 +58,9 @@ class Template: engine: Engine | None = ..., ) -> None: ... def __iter__(self) -> Iterator[Node]: ... - def render(self, context: Context | Dict[str, Any] | None) -> SafeString: ... + def render(self, context: Context | dict[str, Any] | None) -> SafeString: ... def compile_nodelist(self) -> NodeList: ... - def get_exception_info(self, exception: Exception, token: Token) -> Dict[str, Any]: ... + def get_exception_info(self, exception: Exception, token: Token) -> dict[str, Any]: ... def linebreak_iter(template_source: str) -> Iterator[int]: ... @@ -67,40 +68,40 @@ class Token: contents: str token_type: TokenType lineno: int | None - position: Tuple[int, int] | None + position: tuple[int, int] | None def __init__( self, token_type: TokenType, contents: str, - position: Tuple[int, int] | None = ..., + position: tuple[int, int] | None = ..., lineno: int | None = ..., ) -> None: ... - def split_contents(self) -> List[str]: ... + def split_contents(self) -> list[str]: ... class Lexer: template_string: str verbatim: bool | str def __init__(self, template_string: str) -> None: ... - def tokenize(self) -> List[Token]: ... - def create_token(self, token_string: str, position: Tuple[int, int] | None, lineno: int, in_tag: bool) -> Token: ... + def tokenize(self) -> list[Token]: ... + def create_token(self, token_string: str, position: tuple[int, int] | None, lineno: int, in_tag: bool) -> Token: ... class DebugLexer(Lexer): template_string: str verbatim: bool | str - def tokenize(self) -> List[Token]: ... + def tokenize(self) -> list[Token]: ... class Parser: - tokens: List[Token] | str - tags: Dict[str, Callable] - filters: Dict[str, Callable] - command_stack: List[Tuple[str, Token]] - libraries: Dict[str, Library] + tokens: list[Token] | str + tags: dict[str, Callable] + filters: dict[str, Callable] + command_stack: list[tuple[str, Token]] + libraries: dict[str, Library] origin: Origin | None def __init__( self, - tokens: List[Token] | str, - libraries: Dict[str, Library] | None = ..., - builtins: List[Library] | None = ..., + tokens: list[Token] | str, + libraries: dict[str, Library] | None = ..., + builtins: list[Library] | None = ..., origin: Origin | None = ..., ) -> None: ... def parse(self, parse_until: Iterable[str] | None = ...) -> NodeList: ... @@ -122,20 +123,20 @@ filter_re: Pattern[str] class FilterExpression: token: str - filters: List[Any] + filters: list[Any] var: Any def __init__(self, token: str, parser: Parser) -> None: ... def resolve(self, context: Context, ignore_failures: bool = ...) -> Any: ... @staticmethod - def args_check(name: str, func: Callable, provided: List[Tuple[bool, Any]]) -> bool: ... + def args_check(name: str, func: Callable, provided: list[tuple[bool, Any]]) -> bool: ... class Variable: - var: Dict[Any, Any] | str + var: dict[Any, Any] | str literal: SafeString | float | None - lookups: Tuple[str] | None + lookups: tuple[str] | None translate: bool message_context: str | None - def __init__(self, var: Dict[Any, Any] | str) -> None: ... + def __init__(self, var: dict[Any, Any] | str) -> None: ... def resolve(self, context: Mapping[str, Mapping[str, Any]] | Context | int | str) -> Any: ... class Node: @@ -146,12 +147,12 @@ class Node: def render(self, context: Context) -> str: ... def render_annotated(self, context: Context) -> int | str: ... def __iter__(self) -> Iterator[Node]: ... - def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ... + def get_nodes_by_type(self, nodetype: type[Node]) -> list[Node]: ... -class NodeList(List[Node]): +class NodeList(list[Node]): contains_nontext: bool def render(self, context: Context) -> SafeString: ... - def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ... + def get_nodes_by_type(self, nodetype: type[Node]) -> list[Node]: ... class TextNode(Node): s: str @@ -165,4 +166,4 @@ class VariableNode(Node): kwarg_re: Pattern[str] -def token_kwargs(bits: Sequence[str], parser: Parser, support_legacy: bool = ...) -> Dict[str, FilterExpression]: ... +def token_kwargs(bits: Sequence[str], parser: Parser, support_legacy: bool = ...) -> dict[str, FilterExpression]: ... diff --git a/django-stubs/template/context.pyi b/django-stubs/template/context.pyi index 9a3ccd9a5..a89e4b57c 100644 --- a/django-stubs/template/context.pyi +++ b/django-stubs/template/context.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterable, Iterator from contextlib import contextmanager from types import TracebackType -from typing import Any, Callable, Dict, Iterable, Iterator, List, Type, TypeVar +from typing import Any, TypeVar from django.http.request import HttpRequest from django.template.base import Node, Origin, Template @@ -8,7 +9,7 @@ from django.template.defaulttags import IfChangedNode from django.template.loader_tags import IncludeNode _ContextKeys = int | str | Node -_ContextValues = Dict[str, Any] | "Context" +_ContextValues = dict[str, Any] | "Context" _ContextCopy = TypeVar("_ContextCopy", bound="BaseContext") class ContextPopException(Exception): ... @@ -19,7 +20,7 @@ class ContextDict(dict): def __enter__(self) -> ContextDict: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... @@ -36,9 +37,9 @@ class BaseContext(Iterable[Any]): def __delitem__(self, key: _ContextKeys) -> None: ... def __contains__(self, key: _ContextKeys) -> bool: ... def get(self, key: _ContextKeys, otherwise: Any | None = ...) -> Any | None: ... - def setdefault(self, key: _ContextKeys, default: List[Origin] | int | None = ...) -> List[Origin] | int | None: ... + def setdefault(self, key: _ContextKeys, default: list[Origin] | int | None = ...) -> list[Origin] | int | None: ... def new(self, values: _ContextValues | None = ...) -> Context: ... - def flatten(self) -> Dict[_ContextKeys, Dict[_ContextKeys, Type[Any] | str] | int | str | None]: ... + def flatten(self) -> dict[_ContextKeys, dict[_ContextKeys, type[Any] | str] | int | str | None]: ... class Context(BaseContext): dicts: Any @@ -53,17 +54,17 @@ class Context(BaseContext): ) -> None: ... @contextmanager def bind_template(self, template: Template) -> Iterator[None]: ... - def update(self, other_dict: Dict[str, Any] | Context) -> ContextDict: ... + def update(self, other_dict: dict[str, Any] | Context) -> ContextDict: ... class RenderContext(BaseContext): - dicts: List[Dict[IncludeNode | str, str]] + dicts: list[dict[IncludeNode | str, str]] template: Template | None @contextmanager def push_state(self, template: Template, isolated_context: bool = ...) -> Iterator[None]: ... class RequestContext(Context): autoescape: bool - dicts: List[Dict[str, str]] + dicts: list[dict[str, str]] render_context: RenderContext template_name: str | None use_l10n: bool | None @@ -72,8 +73,8 @@ class RequestContext(Context): def __init__( self, request: HttpRequest, - dict_: Dict[str, Any] | None = ..., - processors: List[Callable] | None = ..., + dict_: dict[str, Any] | None = ..., + processors: list[Callable] | None = ..., use_l10n: bool | None = ..., use_tz: bool | None = ..., autoescape: bool = ..., diff --git a/django-stubs/template/context_processors.pyi b/django-stubs/template/context_processors.pyi index 4460cba6c..15020b8c8 100644 --- a/django-stubs/template/context_processors.pyi +++ b/django-stubs/template/context_processors.pyi @@ -1,14 +1,15 @@ -from typing import Callable, Dict, List, Tuple, TypeVar +from collections.abc import Callable +from typing import TypeVar from django.http.request import HttpRequest from django.utils.functional import SimpleLazyObject _R = TypeVar("_R", bound=HttpRequest) -def csrf(request: HttpRequest) -> Dict[str, SimpleLazyObject]: ... -def debug(request: HttpRequest) -> Dict[str, Callable | bool]: ... -def i18n(request: HttpRequest) -> Dict[str, List[Tuple[str, str]] | bool | str]: ... -def tz(request: HttpRequest) -> Dict[str, str]: ... -def static(request: HttpRequest) -> Dict[str, str]: ... -def media(request: HttpRequest) -> Dict[str, str]: ... -def request(request: _R) -> Dict[str, _R]: ... +def csrf(request: HttpRequest) -> dict[str, SimpleLazyObject]: ... +def debug(request: HttpRequest) -> dict[str, Callable | bool]: ... +def i18n(request: HttpRequest) -> dict[str, list[tuple[str, str]] | bool | str]: ... +def tz(request: HttpRequest) -> dict[str, str]: ... +def static(request: HttpRequest) -> dict[str, str]: ... +def media(request: HttpRequest) -> dict[str, str]: ... +def request(request: _R) -> dict[str, _R]: ... diff --git a/django-stubs/template/defaultfilters.pyi b/django-stubs/template/defaultfilters.pyi index d973a5448..d0a29e474 100644 --- a/django-stubs/template/defaultfilters.pyi +++ b/django-stubs/template/defaultfilters.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable from datetime import date as _date from datetime import datetime from datetime import time as _time -from typing import Any, Callable, Dict, List +from typing import Any from django.utils.html import escape as escape # noqa: F401 from django.utils.safestring import SafeString @@ -12,12 +13,12 @@ def stringfilter(func: Callable) -> Callable: ... def addslashes(value: str) -> str: ... def capfirst(value: str) -> str: ... def escapejs_filter(value: str) -> SafeString: ... -def json_script(value: Dict[str, str], element_id: SafeString) -> SafeString: ... +def json_script(value: dict[str, str], element_id: SafeString) -> SafeString: ... def floatformat(text: Any | None, arg: int | str = ...) -> str: ... def iriencode(value: str) -> str: ... def linenumbers(value: str, autoescape: bool = ...) -> SafeString: ... def lower(value: str) -> str: ... -def make_list(value: str) -> List[str]: ... +def make_list(value: str) -> list[str]: ... def slugify(value: str) -> SafeString: ... def stringformat(value: Any, arg: str) -> str: ... def title(value: str) -> str: ... @@ -40,16 +41,16 @@ def force_escape(value: str) -> SafeString: ... def linebreaks_filter(value: str, autoescape: bool = ...) -> SafeString: ... def linebreaksbr(value: str, autoescape: bool = ...) -> SafeString: ... def safe(value: str) -> SafeString: ... -def safeseq(value: List[str]) -> List[SafeString]: ... +def safeseq(value: list[str]) -> list[SafeString]: ... def striptags(value: str) -> str: ... def dictsort(value: Any, arg: int | str) -> Any: ... def dictsortreversed(value: Any, arg: int | str) -> Any: ... def first(value: Any) -> Any: ... def join(value: Any, arg: str, autoescape: bool = ...) -> Any: ... -def last(value: List[str]) -> str: ... +def last(value: list[str]) -> str: ... def length(value: Any) -> int: ... def length_is(value: Any | None, arg: SafeString | int) -> bool | str: ... -def random(value: List[str]) -> str: ... +def random(value: list[str]) -> str: ... def slice_filter(value: Any, arg: str | int) -> Any: ... def unordered_list(value: Any, autoescape: bool = ...) -> Any: ... def add(value: Any, arg: Any) -> Any: ... diff --git a/django-stubs/template/defaulttags.pyi b/django-stubs/template/defaulttags.pyi index 10aaa9f76..a9c708c49 100644 --- a/django-stubs/template/defaulttags.pyi +++ b/django-stubs/template/defaulttags.pyi @@ -1,6 +1,7 @@ from collections import namedtuple +from collections.abc import Iterator, Sequence from datetime import date as real_date -from typing import Any, Dict, Iterator, List, Sequence, Tuple +from typing import Any from django.template.base import FilterExpression, Parser, Token from django.template.context import Context @@ -21,11 +22,11 @@ class CommentNode(Node): ... class CsrfTokenNode(Node): ... class CycleNode(Node): - cyclevars: List[FilterExpression] + cyclevars: list[FilterExpression] variable_name: str | None silent: bool def __init__( - self, cyclevars: List[FilterExpression], variable_name: str | None = ..., silent: bool = ... + self, cyclevars: list[FilterExpression], variable_name: str | None = ..., silent: bool = ... ) -> None: ... def reset(self, context: Context) -> None: ... @@ -37,24 +38,24 @@ class FilterNode(Node): def __init__(self, filter_expr: FilterExpression, nodelist: NodeList) -> None: ... class FirstOfNode(Node): - vars: List[FilterExpression] + vars: list[FilterExpression] asvar: str | None - def __init__(self, variables: List[FilterExpression], asvar: str | None = ...) -> None: ... + def __init__(self, variables: list[FilterExpression], asvar: str | None = ...) -> None: ... class ForNode(Node): - loopvars: List[str] | str + loopvars: list[str] | str sequence: FilterExpression | str child_nodelists: Any is_reversed: bool - nodelist_loop: List[str] | NodeList - nodelist_empty: List[str] | NodeList + nodelist_loop: list[str] | NodeList + nodelist_empty: list[str] | NodeList def __init__( self, - loopvars: List[str] | str, + loopvars: list[str] | str, sequence: FilterExpression | str, is_reversed: bool, - nodelist_loop: List[str] | NodeList, - nodelist_empty: List[str] | NodeList | None = ..., + nodelist_loop: list[str] | NodeList, + nodelist_empty: list[str] | NodeList | None = ..., ) -> None: ... class IfChangedNode(Node): @@ -64,8 +65,8 @@ class IfChangedNode(Node): def __init__(self, nodelist_true: NodeList, nodelist_false: NodeList, *varlist: Any) -> None: ... class IfEqualNode(Node): - nodelist_false: List[Any] | NodeList - nodelist_true: List[Any] | NodeList + nodelist_false: list[Any] | NodeList + nodelist_true: list[Any] | NodeList var1: FilterExpression | str var2: FilterExpression | str child_nodelists: Any @@ -74,14 +75,14 @@ class IfEqualNode(Node): self, var1: FilterExpression | str, var2: FilterExpression | str, - nodelist_true: List[Any] | NodeList, - nodelist_false: List[Any] | NodeList, + nodelist_true: list[Any] | NodeList, + nodelist_false: list[Any] | NodeList, negate: bool, ) -> None: ... class IfNode(Node): - conditions_nodelists: List[Tuple[TemplateLiteral | None, NodeList]] - def __init__(self, conditions_nodelists: List[Tuple[TemplateLiteral | None, NodeList]]) -> None: ... + conditions_nodelists: list[tuple[TemplateLiteral | None, NodeList]] + def __init__(self, conditions_nodelists: list[tuple[TemplateLiteral | None, NodeList]]) -> None: ... def __iter__(self) -> Iterator[Node]: ... @property def nodelist(self) -> NodeList: ... @@ -99,7 +100,7 @@ class RegroupNode(Node): target: FilterExpression var_name: str def __init__(self, target: FilterExpression, expression: FilterExpression, var_name: str) -> None: ... - def resolve_expression(self, obj: Dict[str, real_date], context: Context) -> int | str: ... + def resolve_expression(self, obj: dict[str, real_date], context: Context) -> int | str: ... class LoadNode(Node): ... @@ -123,14 +124,14 @@ class TemplateTagNode(Node): class URLNode(Node): view_name: FilterExpression - args: List[FilterExpression] - kwargs: Dict[str, FilterExpression] + args: list[FilterExpression] + kwargs: dict[str, FilterExpression] asvar: str | None def __init__( self, view_name: FilterExpression, - args: List[FilterExpression], - kwargs: Dict[str, FilterExpression], + args: list[FilterExpression], + kwargs: dict[str, FilterExpression], asvar: str | None, ) -> None: ... @@ -153,13 +154,13 @@ class WidthRatioNode(Node): class WithNode(Node): nodelist: NodeList - extra_context: Dict[str, Any] + extra_context: dict[str, Any] def __init__( self, var: str | None, name: str | None, nodelist: NodeList | Sequence[Node], - extra_context: Dict[str, Any] | None = ..., + extra_context: dict[str, Any] | None = ..., ) -> None: ... def autoescape(parser: Parser, token: Token) -> AutoEscapeControlNode: ... @@ -182,7 +183,7 @@ class TemplateLiteral(Literal): class TemplateIfParser(IfParser): current_token: TemplateLiteral pos: int - tokens: List[TemplateLiteral] + tokens: list[TemplateLiteral] error_class: Any template_parser: Parser def __init__(self, parser: Parser, *args: Any, **kwargs: Any) -> None: ... @@ -190,7 +191,7 @@ class TemplateIfParser(IfParser): def do_if(parser: Parser, token: Token) -> IfNode: ... def ifchanged(parser: Parser, token: Token) -> IfChangedNode: ... def find_library(parser: Parser, name: str) -> Library: ... -def load_from_library(library: Library, label: str, names: List[str]) -> Library: ... +def load_from_library(library: Library, label: str, names: list[str]) -> Library: ... def load(parser: Parser, token: Token) -> LoadNode: ... def lorem(parser: Parser, token: Token) -> LoremNode: ... def now(parser: Parser, token: Token) -> NowNode: ... diff --git a/django-stubs/template/engine.pyi b/django-stubs/template/engine.pyi index 03077e51d..749b69110 100644 --- a/django-stubs/template/engine.pyi +++ b/django-stubs/template/engine.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, List, Sequence, Tuple +from collections.abc import Callable, Sequence +from typing import Any from django.template.base import Origin from django.template.library import Library @@ -11,45 +12,45 @@ _Loader = Any class Engine: default_builtins: Any - dirs: List[str] + dirs: list[str] app_dirs: bool autoescape: bool - context_processors: List[str] | Tuple[str] + context_processors: list[str] | tuple[str] debug: bool loaders: Sequence[_Loader] string_if_invalid: str file_charset: str - libraries: Dict[str, str] - template_libraries: Dict[str, Library] - builtins: List[str] - template_builtins: List[Library] + libraries: dict[str, str] + template_libraries: dict[str, Library] + builtins: list[str] + template_builtins: list[Library] def __init__( self, - dirs: List[str] | None = ..., + dirs: list[str] | None = ..., app_dirs: bool = ..., - context_processors: List[str] | Tuple[str] | None = ..., + context_processors: list[str] | tuple[str] | None = ..., debug: bool = ..., loaders: Sequence[_Loader] | None = ..., string_if_invalid: str = ..., file_charset: str = ..., - libraries: Dict[str, str] | None = ..., - builtins: List[str] | None = ..., + libraries: dict[str, str] | None = ..., + builtins: list[str] | None = ..., autoescape: bool = ..., ) -> None: ... @staticmethod def get_default() -> Engine: ... @property def template_context_processors(self) -> Sequence[Callable]: ... - def get_template_builtins(self, builtins: List[str]) -> List[Library]: ... - def get_template_libraries(self, libraries: Dict[str, str]) -> Dict[str, Library]: ... + def get_template_builtins(self, builtins: list[str]) -> list[Library]: ... + def get_template_libraries(self, libraries: dict[str, str]) -> dict[str, Library]: ... @property - def template_loaders(self) -> List[Loader]: ... - def get_template_loaders(self, template_loaders: Sequence[_Loader]) -> List[Loader]: ... + def template_loaders(self) -> list[Loader]: ... + def get_template_loaders(self, template_loaders: Sequence[_Loader]) -> list[Loader]: ... def find_template_loader(self, loader: _Loader) -> Loader: ... def find_template( - self, name: str, dirs: None = ..., skip: List[Origin] | None = ... - ) -> Tuple[Template, Origin]: ... + self, name: str, dirs: None = ..., skip: list[Origin] | None = ... + ) -> tuple[Template, Origin]: ... def from_string(self, template_code: str) -> Template: ... def get_template(self, template_name: str) -> Template: ... - def render_to_string(self, template_name: str, context: Dict[str, Any] | None = ...) -> SafeString: ... - def select_template(self, template_name_list: List[str]) -> Template: ... + def render_to_string(self, template_name: str, context: dict[str, Any] | None = ...) -> SafeString: ... + def select_template(self, template_name_list: list[str]) -> Template: ... diff --git a/django-stubs/template/exceptions.pyi b/django-stubs/template/exceptions.pyi index a90eea536..d608be04e 100644 --- a/django-stubs/template/exceptions.pyi +++ b/django-stubs/template/exceptions.pyi @@ -1,18 +1,16 @@ -from typing import List, Tuple - from django.template.backends.base import BaseEngine from django.template.base import Origin class TemplateDoesNotExist(Exception): backend: BaseEngine | None - tried: List[Tuple[Origin, str]] - chain: List[TemplateDoesNotExist] + tried: list[tuple[Origin, str]] + chain: list[TemplateDoesNotExist] def __init__( self, msg: Origin | str, - tried: List[Tuple[Origin, str]] | None = ..., + tried: list[tuple[Origin, str]] | None = ..., backend: BaseEngine | None = ..., - chain: List[TemplateDoesNotExist] | None = ..., + chain: list[TemplateDoesNotExist] | None = ..., ) -> None: ... class TemplateSyntaxError(Exception): ... diff --git a/django-stubs/template/library.pyi b/django-stubs/template/library.pyi index 9e0b078fd..927918e2c 100644 --- a/django-stubs/template/library.pyi +++ b/django-stubs/template/library.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Collection, Dict, Iterable, List, Mapping, Sequence, Sized, Tuple, TypeVar, overload +from collections.abc import Callable, Collection, Iterable, Mapping, Sequence, Sized +from typing import Any, TypeVar, overload from django.template.base import FilterExpression, Origin, Parser, Token from django.template.context import Context @@ -11,8 +12,8 @@ class InvalidTemplateLibrary(Exception): ... _C = TypeVar("_C", bound=Callable[..., Any]) class Library: - filters: Dict[str, Callable] - tags: Dict[str, Callable] + filters: dict[str, Callable] + tags: dict[str, Callable] def __init__(self) -> None: ... @overload def tag(self, name: _C) -> _C: ... @@ -48,15 +49,15 @@ class TagHelperNode(Node): self, func: Callable, takes_context: bool | None, - args: List[FilterExpression], - kwargs: Dict[str, FilterExpression], + args: list[FilterExpression], + kwargs: dict[str, FilterExpression], ) -> None: ... - def get_resolved_arguments(self, context: Context) -> Tuple[List[int], Dict[str, SafeString | int]]: ... + def get_resolved_arguments(self, context: Context) -> tuple[list[int], dict[str, SafeString | int]]: ... class SimpleNode(TagHelperNode): - args: List[FilterExpression] + args: list[FilterExpression] func: Callable - kwargs: Dict[str, FilterExpression] + kwargs: dict[str, FilterExpression] origin: Origin takes_context: bool | None token: Token @@ -65,15 +66,15 @@ class SimpleNode(TagHelperNode): self, func: Callable, takes_context: bool | None, - args: List[FilterExpression], - kwargs: Dict[str, FilterExpression], + args: list[FilterExpression], + kwargs: dict[str, FilterExpression], target_var: str | None, ) -> None: ... class InclusionNode(TagHelperNode): - args: List[FilterExpression] + args: list[FilterExpression] func: Callable - kwargs: Dict[str, FilterExpression] + kwargs: dict[str, FilterExpression] origin: Origin takes_context: bool | None token: Token @@ -82,8 +83,8 @@ class InclusionNode(TagHelperNode): self, func: Callable, takes_context: bool | None, - args: List[FilterExpression], - kwargs: Dict[str, FilterExpression], + args: list[FilterExpression], + kwargs: dict[str, FilterExpression], filename: Template | str | None, ) -> None: ... @@ -98,5 +99,5 @@ def parse_bits( kwonly_defaults: Mapping[str, int] | None, takes_context: bool | None, name: str, -) -> Tuple[List[FilterExpression], Dict[str, FilterExpression]]: ... +) -> tuple[list[FilterExpression], dict[str, FilterExpression]]: ... def import_library(name: str) -> Library: ... diff --git a/django-stubs/template/loader.pyi b/django-stubs/template/loader.pyi index b0d3d1907..4722c686c 100644 --- a/django-stubs/template/loader.pyi +++ b/django-stubs/template/loader.pyi @@ -1,4 +1,5 @@ -from typing import Any, Mapping, Sequence +from collections.abc import Mapping, Sequence +from typing import Any from django.http.request import HttpRequest from django.template.exceptions import TemplateDoesNotExist as TemplateDoesNotExist # noqa: F401 diff --git a/django-stubs/template/loader_tags.pyi b/django-stubs/template/loader_tags.pyi index 44d7a14ab..f83385e47 100644 --- a/django-stubs/template/loader_tags.pyi +++ b/django-stubs/template/loader_tags.pyi @@ -1,5 +1,5 @@ import collections -from typing import Any, Dict, List +from typing import Any from django.template.base import FilterExpression, NodeList, Origin, Parser, Token from django.template.context import Context @@ -13,7 +13,7 @@ BLOCK_CONTEXT_KEY: str class BlockContext: blocks: collections.defaultdict def __init__(self) -> None: ... - def add_blocks(self, blocks: Dict[str, BlockNode]) -> None: ... + def add_blocks(self, blocks: dict[str, BlockNode]) -> None: ... def pop(self, name: str) -> BlockNode: ... def push(self, name: str, block: BlockNode) -> None: ... def get_block(self, name: str) -> BlockNode: ... @@ -36,10 +36,10 @@ class ExtendsNode(Node): context_key: str nodelist: NodeList parent_name: FilterExpression | Node - template_dirs: List[Any] | None - blocks: Dict[str, BlockNode] + template_dirs: list[Any] | None + blocks: dict[str, BlockNode] def __init__( - self, nodelist: NodeList, parent_name: FilterExpression | Node, template_dirs: List[Any] | None = ... + self, nodelist: NodeList, parent_name: FilterExpression | Node, template_dirs: list[Any] | None = ... ) -> None: ... def find_template(self, template_name: str, context: Context) -> Template: ... def get_parent(self, context: Context) -> Template: ... @@ -50,7 +50,7 @@ class IncludeNode(Node): token: Token context_key: str template: FilterExpression - extra_context: Dict[str, FilterExpression] + extra_context: dict[str, FilterExpression] isolated_context: bool def __init__( self, diff --git a/django-stubs/template/loaders/base.pyi b/django-stubs/template/loaders/base.pyi index 9679413f5..17068da28 100644 --- a/django-stubs/template/loaders/base.pyi +++ b/django-stubs/template/loaders/base.pyi @@ -1,12 +1,13 @@ -from typing import Any, Dict, Iterable, List +from collections.abc import Iterable +from typing import Any from django.template.base import Origin, Template from django.template.engine import Engine class Loader: engine: Engine - get_template_cache: Dict[str, Any] + get_template_cache: dict[str, Any] def __init__(self, engine: Engine) -> None: ... - def get_template(self, template_name: str, skip: List[Origin] | None = ...) -> Template: ... + def get_template(self, template_name: str, skip: list[Origin] | None = ...) -> Template: ... def get_template_sources(self, template_name: str) -> Iterable[Origin]: ... def reset(self) -> None: ... diff --git a/django-stubs/template/loaders/cached.pyi b/django-stubs/template/loaders/cached.pyi index 3f18142ff..34a4593bd 100644 --- a/django-stubs/template/loaders/cached.pyi +++ b/django-stubs/template/loaders/cached.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Sequence +from collections.abc import Sequence +from typing import Any from django.template.base import Origin from django.template.engine import Engine @@ -6,9 +7,9 @@ from django.template.engine import Engine from .base import Loader as BaseLoader class Loader(BaseLoader): - template_cache: Dict[str, Any] - loaders: List[BaseLoader] + template_cache: dict[str, Any] + loaders: list[BaseLoader] def __init__(self, engine: Engine, loaders: Sequence[Any]) -> None: ... def get_contents(self, origin: Origin) -> str: ... - def cache_key(self, template_name: str, skip: List[Origin] | None = ...) -> str: ... - def generate_hash(self, values: List[str]) -> str: ... + def cache_key(self, template_name: str, skip: list[Origin] | None = ...) -> str: ... + def generate_hash(self, values: list[str]) -> str: ... diff --git a/django-stubs/template/loaders/filesystem.pyi b/django-stubs/template/loaders/filesystem.pyi index 51aa3f437..741bc8420 100644 --- a/django-stubs/template/loaders/filesystem.pyi +++ b/django-stubs/template/loaders/filesystem.pyi @@ -1,5 +1,5 @@ +from collections.abc import Iterator from pathlib import Path -from typing import Iterator, List from django.template.base import Origin from django.template.engine import Engine @@ -7,8 +7,8 @@ from django.template.engine import Engine from .base import Loader as BaseLoader class Loader(BaseLoader): - dirs: List[str | Path] | None - def __init__(self, engine: Engine, dirs: List[str | Path] | None = ...) -> None: ... - def get_dirs(self) -> List[str | Path]: ... + dirs: list[str | Path] | None + def __init__(self, engine: Engine, dirs: list[str | Path] | None = ...) -> None: ... + def get_dirs(self) -> list[str | Path]: ... def get_contents(self, origin: Origin) -> str: ... def get_template_sources(self, template_name: str) -> Iterator[Origin]: ... diff --git a/django-stubs/template/loaders/locmem.pyi b/django-stubs/template/loaders/locmem.pyi index 35d332a3f..339906e6b 100644 --- a/django-stubs/template/loaders/locmem.pyi +++ b/django-stubs/template/loaders/locmem.pyi @@ -1,11 +1,9 @@ -from typing import Dict - from django.template.base import Origin from django.template.engine import Engine from .base import Loader as BaseLoader class Loader(BaseLoader): - templates_dict: Dict[str, str] - def __init__(self, engine: Engine, templates_dict: Dict[str, str]) -> None: ... + templates_dict: dict[str, str] + def __init__(self, engine: Engine, templates_dict: dict[str, str]) -> None: ... def get_contents(self, origin: Origin) -> str: ... diff --git a/django-stubs/template/response.pyi b/django-stubs/template/response.pyi index 9e8b06814..21833fba0 100644 --- a/django-stubs/template/response.pyi +++ b/django-stubs/template/response.pyi @@ -1,6 +1,7 @@ import functools +from collections.abc import Callable, Iterator, Sequence from http.cookies import SimpleCookie -from typing import Any, Callable, Dict, Iterator, List, Sequence, Union +from typing import Any, Union from django.core.handlers.wsgi import WSGIRequest from django.http import HttpResponse @@ -21,20 +22,20 @@ class SimpleTemplateResponse(HttpResponse): status_code: int rendering_attrs: Any template_name: _TemplateForResponseT - context_data: Dict[str, Any] | None + context_data: dict[str, Any] | None using: str | None def __init__( self, template: _TemplateForResponseT, - context: Dict[str, Any] | None = ..., + context: dict[str, Any] | None = ..., content_type: str | None = ..., status: int | None = ..., charset: str | None = ..., using: str | None = ..., - headers: Dict[str, Any] | None = ..., + headers: dict[str, Any] | None = ..., ) -> None: ... def resolve_template(self, template: Sequence[str] | Template | str) -> Template: ... - def resolve_context(self, context: Dict[str, Any] | None) -> Dict[str, Any] | None: ... + def resolve_context(self, context: dict[str, Any] | None) -> dict[str, Any] | None: ... @property def rendered_content(self) -> str: ... def add_post_render_callback(self, callback: Callable) -> None: ... @@ -47,14 +48,14 @@ class TemplateResponse(SimpleTemplateResponse): client: Client closed: bool context: RequestContext - context_data: Dict[str, Any] | None + context_data: dict[str, Any] | None cookies: SimpleCookie[str] csrf_cookie_set: bool json: functools.partial _request: HttpRequest status_code: int template_name: _TemplateForResponseT - templates: List[Template] + templates: list[Template] using: str | None wsgi_request: WSGIRequest rendering_attrs: Any @@ -62,10 +63,10 @@ class TemplateResponse(SimpleTemplateResponse): self, request: HttpRequest, template: _TemplateForResponseT, - context: Dict[str, Any] | None = ..., + context: dict[str, Any] | None = ..., content_type: str | None = ..., status: int | None = ..., charset: str | None = ..., using: str | None = ..., - headers: Dict[str, Any] | None = ..., + headers: dict[str, Any] | None = ..., ) -> None: ... diff --git a/django-stubs/template/smartif.pyi b/django-stubs/template/smartif.pyi index 610d20463..5a46f7a3f 100644 --- a/django-stubs/template/smartif.pyi +++ b/django-stubs/template/smartif.pyi @@ -1,8 +1,8 @@ -from typing import Any, Dict, List, Type +from typing import Any from django.template.defaulttags import TemplateLiteral -_Token = List[int] | int | str +_Token = list[int] | int | str class TokenBase: id: Any @@ -13,8 +13,8 @@ class TokenBase: def led(self, left: Any, parser: Any) -> None: ... def display(self) -> Any: ... -def infix(bp: Any, func: Any) -> Type[TokenBase]: ... -def prefix(bp: Any, func: Any) -> Type[TokenBase]: ... +def infix(bp: Any, func: Any) -> type[TokenBase]: ... +def prefix(bp: Any, func: Any) -> type[TokenBase]: ... OPERATORS: Any @@ -24,7 +24,7 @@ class Literal(TokenBase): value: _Token | None def __init__(self, value: _Token | None) -> None: ... def display(self) -> str: ... - def eval(self, context: Dict[Any, Any]) -> _Token | None: ... + def eval(self, context: dict[Any, Any]) -> _Token | None: ... class EndToken(TokenBase): lbp: int @@ -35,7 +35,7 @@ class IfParser: tokens: Any pos: int current_token: Any - def __init__(self, tokens: List[_Token | None]) -> None: ... + def __init__(self, tokens: list[_Token | None]) -> None: ... def translate_token(self, token: _Token | None) -> Literal: ... def next_token(self) -> Literal: ... def parse(self) -> TemplateLiteral: ... diff --git a/django-stubs/template/utils.pyi b/django-stubs/template/utils.pyi index cf23f12db..4aaf8059f 100644 --- a/django-stubs/template/utils.pyi +++ b/django-stubs/template/utils.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterator, List, Tuple +from collections.abc import Iterator +from typing import Any from django.core.exceptions import ImproperlyConfigured from django.template.backends.base import BaseEngine @@ -6,11 +7,11 @@ from django.template.backends.base import BaseEngine class InvalidTemplateEngineError(ImproperlyConfigured): ... class EngineHandler: - def __init__(self, templates: List[Dict[str, Any]] = ...) -> None: ... + def __init__(self, templates: list[dict[str, Any]] = ...) -> None: ... @property - def templates(self) -> Dict[str, Any]: ... + def templates(self) -> dict[str, Any]: ... def __getitem__(self, alias: str) -> BaseEngine: ... def __iter__(self) -> Iterator[Any]: ... - def all(self) -> List[BaseEngine]: ... + def all(self) -> list[BaseEngine]: ... -def get_app_template_dirs(dirname: str) -> Tuple: ... +def get_app_template_dirs(dirname: str) -> tuple: ... diff --git a/django-stubs/templatetags/cache.pyi b/django-stubs/templatetags/cache.pyi index 17cda82c4..83167db76 100644 --- a/django-stubs/templatetags/cache.pyi +++ b/django-stubs/templatetags/cache.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from django.template import Node from django.template.base import FilterExpression, NodeList, Parser, Token @@ -9,14 +9,14 @@ class CacheNode(Node): nodelist: NodeList expire_time_var: FilterExpression fragment_name: str - vary_on: List[FilterExpression] + vary_on: list[FilterExpression] cache_name: FilterExpression | None def __init__( self, nodelist: NodeList, expire_time_var: FilterExpression, fragment_name: str, - vary_on: List[FilterExpression], + vary_on: list[FilterExpression], cache_name: FilterExpression | None, ) -> None: ... diff --git a/django-stubs/templatetags/i18n.pyi b/django-stubs/templatetags/i18n.pyi index 5c24c7167..39b312e72 100644 --- a/django-stubs/templatetags/i18n.pyi +++ b/django-stubs/templatetags/i18n.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Tuple +from typing import Any from django.template import Node from django.template.base import FilterExpression, NodeList, Parser, Token @@ -49,9 +49,9 @@ class TranslateNode(Node): def render(self, context: Context) -> str: ... class BlockTranslateNode(Node): - extra_context: Dict[str, FilterExpression] - singular: List[Token] - plural: List[Token] + extra_context: dict[str, FilterExpression] + singular: list[Token] + plural: list[Token] countervar: str | None counter: FilterExpression | None message_context: FilterExpression | None @@ -59,9 +59,9 @@ class BlockTranslateNode(Node): asvar: str | None def __init__( self, - extra_context: Dict[str, FilterExpression], - singular: List[Token], - plural: List[Token] = ..., + extra_context: dict[str, FilterExpression], + singular: list[Token], + plural: list[Token] = ..., countervar: str | None = ..., counter: FilterExpression | None = ..., message_context: FilterExpression | None = ..., @@ -69,7 +69,7 @@ class BlockTranslateNode(Node): asvar: str | None = ..., tag_name: str = ..., ) -> None: ... - def render_token_list(self, tokens: List[Token]) -> Tuple[str, List[str]]: ... + def render_token_list(self, tokens: list[Token]) -> tuple[str, list[str]]: ... def render(self, context: Context, nested: bool = ...) -> str: ... class LanguageNode(Node): diff --git a/django-stubs/templatetags/l10n.pyi b/django-stubs/templatetags/l10n.pyi index f9d53178a..bbbf1d99a 100644 --- a/django-stubs/templatetags/l10n.pyi +++ b/django-stubs/templatetags/l10n.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from django.template import Node from django.template.base import Parser, Token @@ -9,8 +9,8 @@ def localize(value: Any) -> str: ... def unlocalize(value: Any) -> str: ... class LocalizeNode(Node): - nodelist: List[Node] + nodelist: list[Node] use_l10n: bool - def __init__(self, nodelist: List[Node], use_l10n: bool) -> None: ... + def __init__(self, nodelist: list[Node], use_l10n: bool) -> None: ... def localize_tag(parser: Parser, token: Token) -> LocalizeNode: ... diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index 42a5ca7a2..8c6392f81 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -1,22 +1,8 @@ +from collections.abc import Callable, Iterable, Iterator from io import BytesIO from json import JSONEncoder from types import TracebackType -from typing import ( - Any, - Awaitable, - Callable, - Dict, - Generic, - Iterable, - Iterator, - List, - NoReturn, - Pattern, - Tuple, - Type, - TypeVar, - overload, -) +from typing import Any, Awaitable, Generic, NoReturn, Pattern, TypeVar, overload from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.sessions.backends.base import SessionBase @@ -38,7 +24,7 @@ JSON_CONTENT_TYPE_RE: Pattern class RedirectCycleError(Exception): last_response: HttpResponseBase - redirect_chain: List[Tuple[str, int]] + redirect_chain: list[tuple[str, int]] def __init__(self, message: str, last_response: HttpResponseBase) -> None: ... class FakePayload: @@ -62,29 +48,29 @@ class _ASGIResponse(HttpResponseBase): class ClientHandler(BaseHandler): enforce_csrf_checks: bool def __init__(self, enforce_csrf_checks: bool = ..., *args: Any, **kwargs: Any) -> None: ... - def __call__(self, environ: Dict[str, Any]) -> _WSGIResponse: ... + def __call__(self, environ: dict[str, Any]) -> _WSGIResponse: ... class AsyncClientHandler(BaseHandler): enforce_csrf_checks: bool def __init__(self, enforce_csrf_checks: bool = ..., *args: Any, **kwargs: Any) -> None: ... - async def __call__(self, scope: Dict[str, Any]) -> _ASGIResponse: ... + async def __call__(self, scope: dict[str, Any]) -> _ASGIResponse: ... -def encode_multipart(boundary: str, data: Dict[str, Any]) -> bytes: ... -def encode_file(boundary: str, key: str, file: Any) -> List[bytes]: ... +def encode_multipart(boundary: str, data: dict[str, Any]) -> bytes: ... +def encode_file(boundary: str, key: str, file: Any) -> list[bytes]: ... class _RequestFactory(Generic[_T]): - json_encoder: Type[JSONEncoder] - defaults: Dict[str, str] + json_encoder: type[JSONEncoder] + defaults: dict[str, str] cookies: SimpleCookie errors: BytesIO - def __init__(self, *, json_encoder: Type[JSONEncoder] = ..., **defaults: Any) -> None: ... + def __init__(self, *, json_encoder: type[JSONEncoder] = ..., **defaults: Any) -> None: ... def request(self, **request: Any) -> _T: ... def get(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> _T: ... def post(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> _T: ... def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> _T: ... def trace(self, path: str, secure: bool = ..., **extra: Any) -> _T: ... def options( - self, path: str, data: Dict[str, str] | str = ..., content_type: str = ..., secure: bool = ..., **extra: Any + self, path: str, data: dict[str, str] | str = ..., content_type: str = ..., secure: bool = ..., **extra: Any ) -> _T: ... def put(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> _T: ... def patch(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> _T: ... @@ -106,25 +92,25 @@ class AsyncRequestFactory(_AsyncRequestFactory[ASGIRequest]): ... # fakes to distinguish WSGIRequest and ASGIRequest class _MonkeyPatchedWSGIResponse(_WSGIResponse): def json(self) -> Any: ... - request: Dict[str, Any] + request: dict[str, Any] client: Client - templates: List[Template] - context: ContextList | Dict[str, Any] + templates: list[Template] + context: ContextList | dict[str, Any] content: bytes resolver_match: ResolverMatch class _MonkeyPatchedWSGIResponseRedirect(_MonkeyPatchedWSGIResponse): - redirect_chain: List[Tuple[str, int]] + redirect_chain: list[tuple[str, int]] class _MonkeyPatchedASGIResponse(_ASGIResponse): def json(self) -> Any: ... - request: Dict[str, Any] + request: dict[str, Any] client: AsyncClient - templates: List[Template] - context: ContextList | Dict[str, Any] + templates: list[Template] + context: ContextList | dict[str, Any] content: bytes resolver_match: ResolverMatch - redirect_chain: List[Tuple[str, int]] + redirect_chain: list[tuple[str, int]] class ClientMixin: def store_exc_info(self, **kwargs: Any) -> None: ... @@ -138,7 +124,7 @@ class ClientMixin: class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]): handler: ClientHandler raise_request_exception: bool - exc_info: Tuple[Type[BaseException], BaseException, TracebackType] | None + exc_info: tuple[type[BaseException], BaseException, TracebackType] | None def __init__( self, enforce_csrf_checks: bool = ..., raise_request_exception: bool = ..., **defaults: Any ) -> None: ... diff --git a/django-stubs/test/html.pyi b/django-stubs/test/html.pyi index c35b2d588..a67d9ea48 100644 --- a/django-stubs/test/html.pyi +++ b/django-stubs/test/html.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence from html.parser import HTMLParser -from typing import Any, List, Sequence, Tuple, TypeVar +from typing import Any, TypeVar _Self = TypeVar("_Self") @@ -7,12 +8,12 @@ WHITESPACE: Any def normalize_whitespace(string: str) -> str: ... -_ElementAttribute = Tuple[str, str | None] +_ElementAttribute = tuple[str, str | None] class Element: name: str | None - attributes: List[_ElementAttribute] - children: List[Any] + attributes: list[_ElementAttribute] + children: list[Any] def __init__(self, name: str | None, attributes: Sequence[_ElementAttribute]) -> None: ... def append(self, element: Element | str) -> None: ... def finalize(self) -> None: ... diff --git a/django-stubs/test/runner.pyi b/django-stubs/test/runner.pyi index 7c4f73bee..c3b85acb2 100644 --- a/django-stubs/test/runner.pyi +++ b/django-stubs/test/runner.pyi @@ -1,8 +1,9 @@ import logging from argparse import ArgumentParser +from collections.abc import Iterator, Sequence from contextlib import contextmanager from io import StringIO -from typing import Any, Dict, Iterator, List, Sequence, Set, Tuple, Type +from typing import Any from unittest import TestCase, TestLoader, TestSuite, TextTestResult, TextTestRunner from django.db.backends.base.base import BaseDatabaseWrapper @@ -15,14 +16,14 @@ class DebugSQLTextTestResult(TextTestResult): buffer: bool descriptions: bool dots: bool - expectedFailures: List[Any] + expectedFailures: list[Any] failfast: bool shouldStop: bool showAll: bool - skipped: List[Any] + skipped: list[Any] tb_locals: bool testsRun: int - unexpectedSuccesses: List[Any] + unexpectedSuccesses: list[Any] logger: logging.Logger # typeshed thinks it's TextIO, but unittest wraps it with _WritelnDecorator # adding `writeln` method @@ -39,7 +40,7 @@ class DebugSQLTextTestResult(TextTestResult): class PDBDebugResult(TextTestResult): ... class RemoteTestResult: - events: List[Any] + events: list[Any] failfast: bool shouldStop: bool testsRun: int @@ -76,23 +77,23 @@ class ParallelTestSuite(TestSuite): init_worker: Any run_subsuite: Any runner_class: Any - subsuites: List[TestSuite] + subsuites: list[TestSuite] processes: int failfast: bool buffer: bool initial_settings: Any serialized_contents: Any def __init__( - self, subsuites: List[TestSuite], processes: int, failfast: bool = ..., buffer: bool = ... + self, subsuites: list[TestSuite], processes: int, failfast: bool = ..., buffer: bool = ... ) -> None: ... def run(self, result: Any) -> Any: ... # type: ignore[override] class DiscoverRunner: - test_suite: Type[TestSuite] - parallel_test_suite: Type[ParallelTestSuite] - test_runner: Type[TextTestRunner] + test_suite: type[TestSuite] + parallel_test_suite: type[ParallelTestSuite] + test_runner: type[TextTestRunner] test_loader: TestLoader - reorder_by: Tuple[SimpleTestCase, ...] + reorder_by: tuple[SimpleTestCase, ...] pattern: str | None top_level: str | None verbosity: int @@ -103,11 +104,11 @@ class DiscoverRunner: debug_mode: bool debug_sql: bool parallel: int - tags: Set[str] - exclude_tags: Set[str] + tags: set[str] + exclude_tags: set[str] pdb: bool buffer: bool - test_name_patterns: Set[str] | None + test_name_patterns: set[str] | None time_keeper: TimeKeeperProtocol shuffle: int | Literal[False] logger: logging.Logger | None @@ -123,9 +124,9 @@ class DiscoverRunner: debug_mode: bool = ..., debug_sql: bool = ..., parallel: int = ..., - tags: List[str] | None = ..., - exclude_tags: List[str] | None = ..., - test_name_patterns: List[str] | None = ..., + tags: list[str] | None = ..., + exclude_tags: list[str] | None = ..., + test_name_patterns: list[str] | None = ..., pdb: bool = ..., buffer: bool = ..., enable_faulthandler: bool = ..., @@ -143,28 +144,28 @@ class DiscoverRunner: def setup_shuffler(self) -> None: ... @contextmanager def load_with_patterns(self) -> Iterator[None]: ... - def load_tests_for_label(self, label: str, discover_kwargs: Dict[str, str]) -> TestSuite: ... + def load_tests_for_label(self, label: str, discover_kwargs: dict[str, str]) -> TestSuite: ... def build_suite( - self, test_labels: Sequence[str] = ..., extra_tests: List[Any] | None = ..., **kwargs: Any + self, test_labels: Sequence[str] = ..., extra_tests: list[Any] | None = ..., **kwargs: Any ) -> TestSuite: ... - def setup_databases(self, **kwargs: Any) -> List[Tuple[BaseDatabaseWrapper, str, bool]]: ... - def get_resultclass(self) -> Type[TextTestResult] | None: ... - def get_test_runner_kwargs(self) -> Dict[str, Any]: ... - def run_checks(self, databases: Set[str]) -> None: ... + def setup_databases(self, **kwargs: Any) -> list[tuple[BaseDatabaseWrapper, str, bool]]: ... + def get_resultclass(self) -> type[TextTestResult] | None: ... + def get_test_runner_kwargs(self) -> dict[str, Any]: ... + def run_checks(self, databases: set[str]) -> None: ... def run_suite(self, suite: TestSuite, **kwargs: Any) -> TextTestResult: ... - def teardown_databases(self, old_config: List[Tuple[BaseDatabaseWrapper, str, bool]], **kwargs: Any) -> None: ... + def teardown_databases(self, old_config: list[tuple[BaseDatabaseWrapper, str, bool]], **kwargs: Any) -> None: ... def teardown_test_environment(self, **kwargs: Any) -> None: ... def suite_result(self, suite: TestSuite, result: TextTestResult, **kwargs: Any) -> int: ... - def _get_databases(self, suite: TestSuite) -> Set[str]: ... - def get_databases(self, suite: TestSuite) -> Set[str]: ... - def run_tests(self, test_labels: List[str], extra_tests: List[Any] | None = ..., **kwargs: Any) -> int: ... + def _get_databases(self, suite: TestSuite) -> set[str]: ... + def get_databases(self, suite: TestSuite) -> set[str]: ... + def run_tests(self, test_labels: list[str], extra_tests: list[Any] | None = ..., **kwargs: Any) -> int: ... def is_discoverable(label: str) -> bool: ... def reorder_suite( - suite: TestSuite, classes: Tuple[Type[TestCase], Type[SimpleTestCase]], reverse: bool = ... + suite: TestSuite, classes: tuple[type[TestCase], type[SimpleTestCase]], reverse: bool = ... ) -> TestSuite: ... def partition_suite_by_type( - suite: TestSuite, classes: Tuple[Type[TestCase], Type[SimpleTestCase]], bins: List[OrderedSet], reverse: bool = ... + suite: TestSuite, classes: tuple[type[TestCase], type[SimpleTestCase]], bins: list[OrderedSet], reverse: bool = ... ) -> None: ... -def partition_suite_by_case(suite: Any) -> List[Any]: ... -def filter_tests_by_tags(suite: TestSuite, tags: Set[str], exclude_tags: Set[str]) -> TestSuite: ... +def partition_suite_by_case(suite: Any) -> list[Any]: ... +def filter_tests_by_tags(suite: TestSuite, tags: set[str], exclude_tags: set[str]) -> TestSuite: ... diff --git a/django-stubs/test/selenium.pyi b/django-stubs/test/selenium.pyi index ea88de243..ffed31dd9 100644 --- a/django-stubs/test/selenium.pyi +++ b/django-stubs/test/selenium.pyi @@ -1,5 +1,6 @@ +from collections.abc import Generator from contextlib import contextmanager -from typing import Any, Generator, Type +from typing import Any from django.test import LiveServerTestCase @@ -7,7 +8,7 @@ class SeleniumTestCaseBase: browsers: Any browser: Any @classmethod - def import_webdriver(cls, browser: Any) -> Type[Any]: ... # Type[WebDriver] + def import_webdriver(cls, browser: Any) -> type[Any]: ... # Type[WebDriver] def create_webdriver(self) -> Any: ... # WebDriver class SeleniumTestCase(LiveServerTestCase): diff --git a/django-stubs/test/testcases.pyi b/django-stubs/test/testcases.pyi index c2e970cd2..478bfc0b2 100644 --- a/django-stubs/test/testcases.pyi +++ b/django-stubs/test/testcases.pyi @@ -1,24 +1,10 @@ import threading import unittest +from collections.abc import Callable, Collection, Generator, Iterable, Iterator, Mapping, Sequence from contextlib import contextmanager from datetime import date from types import TracebackType -from typing import ( - Any, - Callable, - Collection, - Dict, - Generator, - Iterable, - Iterator, - List, - Mapping, - Sequence, - Set, - Tuple, - Type, - overload, -) +from typing import Any, overload from django.core.exceptions import ImproperlyConfigured from django.core.handlers.wsgi import WSGIHandler @@ -48,8 +34,8 @@ class _AssertNumQueriesContext(CaptureQueriesContext): class _AssertTemplateUsedContext: test_case: SimpleTestCase template_name: str - rendered_templates: List[Template] - rendered_template_names: List[str] + rendered_templates: list[Template] + rendered_template_names: list[str] context: ContextList def __init__(self, test_case: Any, template_name: Any) -> None: ... def on_template_render(self, sender: Any, signal: Any, template: Any, context: Any, **kwargs: Any) -> None: ... @@ -58,7 +44,7 @@ class _AssertTemplateUsedContext: def __enter__(self) -> _AssertTemplateUsedContext: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... @@ -72,13 +58,13 @@ class _DatabaseFailure: def __call__(self) -> None: ... class SimpleTestCase(unittest.TestCase): - client_class: Type[Client] + client_class: type[Client] client: Client - async_client_class: Type[AsyncClient] + async_client_class: type[AsyncClient] async_client: AsyncClient allow_database_queries: bool # TODO: str -> Literal['__all__'] - databases: Set[str] | str + databases: set[str] | str def __call__(self, result: unittest.TestResult | None = ...) -> None: ... def settings(self, **kwargs: Any) -> Any: ... def modify_settings(self, **kwargs: Any) -> Any: ... @@ -119,7 +105,7 @@ class SimpleTestCase(unittest.TestCase): self, form: Form, field: str | None, - errors: List[str] | str, + errors: list[str] | str, msg_prefix: str = ..., ) -> None: ... @overload @@ -128,7 +114,7 @@ class SimpleTestCase(unittest.TestCase): response: HttpResponseBase, form: str, field: str | None, - errors: List[str] | str, + errors: list[str] | str, msg_prefix: str = ..., ) -> None: ... @overload @@ -137,7 +123,7 @@ class SimpleTestCase(unittest.TestCase): formset: BaseFormSet, form_index: int | None, field: str | None, - errors: List[str] | str, + errors: list[str] | str, msg_prefix: str = ..., ) -> None: ... @overload @@ -147,7 +133,7 @@ class SimpleTestCase(unittest.TestCase): formset: str, form_index: int | None, field: str | None, - errors: List[str] | str, + errors: list[str] | str, msg_prefix: str = ..., ) -> None: ... def assertTemplateUsed( @@ -161,16 +147,16 @@ class SimpleTestCase(unittest.TestCase): self, response: HttpResponseBase | str = ..., template_name: str | None = ..., msg_prefix: str = ... ) -> _AssertTemplateNotUsedContext | None: ... def assertRaisesMessage( - self, expected_exception: Type[Exception], expected_message: str, *args: Any, **kwargs: Any + self, expected_exception: type[Exception], expected_message: str, *args: Any, **kwargs: Any ) -> Any: ... def assertWarnsMessage( - self, expected_warning: Type[Exception], expected_message: str, *args: Any, **kwargs: Any + self, expected_warning: type[Exception], expected_message: str, *args: Any, **kwargs: Any ) -> Any: ... def assertFieldOutput( self, - fieldclass: Type[EmailField], - valid: Dict[str, str], - invalid: Dict[str, List[str]], + fieldclass: type[EmailField], + valid: dict[str, str], + invalid: dict[str, list[str]], field_args: Iterable[Any] | None = ..., field_kwargs: Mapping[str, Any] | None = ..., empty_value: str = ..., @@ -181,13 +167,13 @@ class SimpleTestCase(unittest.TestCase): def assertJSONEqual( self, raw: str, - expected_data: Dict[str, Any] | List[Any] | str | int | float | bool | None, + expected_data: dict[str, Any] | list[Any] | str | int | float | bool | None, msg: str | None = ..., ) -> None: ... def assertJSONNotEqual( self, raw: str, - expected_data: Dict[str, Any] | List[Any] | str | int | float | bool | None, + expected_data: dict[str, Any] | list[Any] | str | int | float | bool | None, msg: str | None = ..., ) -> None: ... def assertXMLEqual(self, xml1: str, xml2: str, msg: str | None = ...) -> None: ... @@ -201,9 +187,9 @@ class TransactionTestCase(SimpleTestCase): serialized_rollback: bool def assertQuerysetEqual( self, - qs: Iterator[Any] | List[Model] | QuerySet | RawQuerySet, + qs: Iterator[Any] | list[Model] | QuerySet | RawQuerySet, values: Collection[Any], - transform: Callable[[Model], Any] | Type[str] = ..., + transform: Callable[[Model], Any] | type[str] = ..., ordered: bool = ..., msg: str | None = ..., ) -> None: ... @@ -221,13 +207,13 @@ class TestCase(TransactionTestCase): @contextmanager def captureOnCommitCallbacks( cls, *, using: str = ..., execute: bool = ... - ) -> Generator[List[Callable[[], Any]], None, None]: ... + ) -> Generator[list[Callable[[], Any]], None, None]: ... class CheckCondition: - conditions: Sequence[Tuple[Callable, str]] - def __init__(self, *conditions: Tuple[Callable, str]) -> None: ... + conditions: Sequence[tuple[Callable, str]] + def __init__(self, *conditions: tuple[Callable, str]) -> None: ... def add_condition(self, condition: Callable, reason: str) -> CheckCondition: ... - def __get__(self, instance: None, cls: Type[TransactionTestCase] | None = ...) -> bool: ... + def __get__(self, instance: None, cls: type[TransactionTestCase] | None = ...) -> bool: ... def skipIfDBFeature(*features: Any) -> Callable: ... def skipUnlessDBFeature(*features: Any) -> Callable: ... @@ -255,13 +241,13 @@ class LiveServerThread(threading.Thread): port: int is_ready: threading.Event error: ImproperlyConfigured | None - static_handler: Type[WSGIHandler] - connections_override: Dict[str, BaseDatabaseWrapper] + static_handler: type[WSGIHandler] + connections_override: dict[str, BaseDatabaseWrapper] def __init__( self, host: str, - static_handler: Type[WSGIHandler], - connections_override: Dict[str, BaseDatabaseWrapper] = ..., + static_handler: type[WSGIHandler], + connections_override: dict[str, BaseDatabaseWrapper] = ..., port: int = ..., ) -> None: ... httpd: ThreadedWSGIServer @@ -270,7 +256,7 @@ class LiveServerThread(threading.Thread): class LiveServerTestCase(TransactionTestCase): host: str port: int - server_thread_class: Type[Any] + server_thread_class: type[Any] server_thread: Any static_handler: Any @classproperty diff --git a/django-stubs/test/utils.pyi b/django-stubs/test/utils.pyi index af7219e65..e824be661 100644 --- a/django-stubs/test/utils.pyi +++ b/django-stubs/test/utils.pyi @@ -1,24 +1,11 @@ import decimal +from collections.abc import Callable, Iterable, Iterator, Mapping from contextlib import contextmanager from decimal import Decimal from io import StringIO from logging import Logger from types import TracebackType -from typing import ( - Any, - Callable, - ContextManager, - Dict, - Iterable, - Iterator, - List, - Mapping, - Protocol, - Set, - Tuple, - Type, - TypeVar, -) +from typing import Any, ContextManager, Protocol, TypeVar from django.apps.registry import Apps from django.conf import LazySettings, Settings @@ -30,7 +17,7 @@ from django.test.runner import DiscoverRunner from django.test.testcases import SimpleTestCase from typing_extensions import SupportsIndex -_TestClass = Type[SimpleTestCase] +_TestClass = type[SimpleTestCase] _DecoratedTest = Callable | _TestClass _C = TypeVar("_C", bound=Callable) # Any callable @@ -41,17 +28,17 @@ class Approximate: places: int def __init__(self, val: Decimal | float, places: int = ...) -> None: ... -class ContextList(List[Dict[str, Any]]): +class ContextList(list[dict[str, Any]]): def __getitem__(self, key: str | SupportsIndex | slice) -> Any: ... def get(self, key: str, default: Any | None = ...) -> Any: ... def __contains__(self, key: object) -> bool: ... - def keys(self) -> Set[str]: ... + def keys(self) -> set[str]: ... class _TestState: ... def setup_test_environment(debug: bool | None = ...) -> None: ... def teardown_test_environment() -> None: ... -def get_runner(settings: LazySettings, test_runner_class: str | None = ...) -> Type[DiscoverRunner]: ... +def get_runner(settings: LazySettings, test_runner_class: str | None = ...) -> type[DiscoverRunner]: ... class TestContextDecorator: attr_name: str | None @@ -62,7 +49,7 @@ class TestContextDecorator: def __enter__(self) -> Apps | None: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... @@ -71,7 +58,7 @@ class TestContextDecorator: def __call__(self, decorated: _DecoratedTest) -> Any: ... class override_settings(TestContextDecorator): - options: Dict[str, Any] + options: dict[str, Any] def __init__(self, **kwargs: Any) -> None: ... wrapped: Settings def save_options(self, test_func: _DecoratedTest) -> None: ... @@ -79,18 +66,18 @@ class override_settings(TestContextDecorator): class modify_settings(override_settings): wrapped: Settings - operations: List[Tuple[str, Dict[str, List[str] | str]]] + operations: list[tuple[str, dict[str, list[str] | str]]] def __init__(self, *args: Any, **kwargs: Any) -> None: ... def save_options(self, test_func: _DecoratedTest) -> None: ... - options: Dict[str, List[Tuple[str, str] | str]] + options: dict[str, list[tuple[str, str] | str]] class override_system_checks(TestContextDecorator): registry: CheckRegistry - new_checks: List[Callable] - deployment_checks: List[Callable] | None - def __init__(self, new_checks: List[Callable], deployment_checks: List[Callable] | None = ...) -> None: ... - old_checks: Set[Callable] - old_deployment_checks: Set[Callable] + new_checks: list[Callable] + deployment_checks: list[Callable] | None + def __init__(self, new_checks: list[Callable], deployment_checks: list[Callable] | None = ...) -> None: ... + old_checks: set[Callable] + old_deployment_checks: set[Callable] class CaptureQueriesContext: connection: BaseDatabaseWrapper @@ -98,21 +85,21 @@ class CaptureQueriesContext: initial_queries: int final_queries: int | None def __init__(self, connection: BaseDatabaseWrapper) -> None: ... - def __iter__(self) -> Iterator[Dict[str, str]]: ... - def __getitem__(self, index: int) -> Dict[str, str]: ... + def __iter__(self) -> Iterator[dict[str, str]]: ... + def __getitem__(self, index: int) -> dict[str, str]: ... def __len__(self) -> int: ... @property - def captured_queries(self) -> List[Dict[str, str]]: ... + def captured_queries(self) -> list[dict[str, str]]: ... def __enter__(self) -> CaptureQueriesContext: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... class ignore_warnings(TestContextDecorator): - ignore_kwargs: Dict[str, Any] + ignore_kwargs: dict[str, Any] filter_func: Callable def __init__(self, **kwargs: Any) -> None: ... catch_warnings: ContextManager[list | None] @@ -135,7 +122,7 @@ class LoggingCaptureMixin: def tearDown(self) -> None: ... class isolate_apps(TestContextDecorator): - installed_apps: Tuple[str] + installed_apps: tuple[str] def __init__(self, *installed_apps: Any, **kwargs: Any) -> None: ... old_apps: Apps @@ -151,7 +138,7 @@ def freeze_time(t: float) -> Iterator[None]: ... def tag(*tags: str) -> Callable[[_C], _C]: ... _Signature = str -_TestDatabase = Tuple[str, List[str]] +_TestDatabase = tuple[str, list[str]] class TimeKeeperProtocol(Protocol): @contextmanager @@ -159,11 +146,11 @@ class TimeKeeperProtocol(Protocol): def print_results(self) -> None: ... def dependency_ordered( - test_databases: Iterable[Tuple[_Signature, _TestDatabase]], dependencies: Mapping[str, List[str]] -) -> List[Tuple[_Signature, _TestDatabase]]: ... + test_databases: Iterable[tuple[_Signature, _TestDatabase]], dependencies: Mapping[str, list[str]] +) -> list[tuple[_Signature, _TestDatabase]]: ... def get_unique_databases_and_mirrors( - aliases: Set[str] | None = ..., -) -> Tuple[Dict[_Signature, _TestDatabase], Dict[str, Any]]: ... + aliases: set[str] | None = ..., +) -> tuple[dict[_Signature, _TestDatabase], dict[str, Any]]: ... def setup_databases( verbosity: int, interactive: bool, @@ -174,12 +161,12 @@ def setup_databases( parallel: int = ..., aliases: Mapping[str, Any] | None = ..., **kwargs: Any -) -> List[Tuple[BaseDatabaseWrapper, str, bool]]: ... +) -> list[tuple[BaseDatabaseWrapper, str, bool]]: ... def teardown_databases( - old_config: Iterable[Tuple[Any, str, bool]], verbosity: int, parallel: int = ..., keepdb: bool = ... + old_config: Iterable[tuple[Any, str, bool]], verbosity: int, parallel: int = ..., keepdb: bool = ... ) -> None: ... def require_jinja2(test_func: _C) -> _C: ... @contextmanager def register_lookup( - field: Type[RegisterLookupMixin], *lookups: Type[Lookup | Transform], lookup_name: str | None = ... + field: type[RegisterLookupMixin], *lookups: type[Lookup | Transform], lookup_name: str | None = ... ) -> Iterator[None]: ... diff --git a/django-stubs/urls/base.pyi b/django-stubs/urls/base.pyi index e5c72a134..95e1c38b4 100644 --- a/django-stubs/urls/base.pyi +++ b/django-stubs/urls/base.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, Sequence +from collections.abc import Callable, Sequence +from typing import Any from django.urls.resolvers import ResolverMatch from typing_extensions import Literal @@ -8,7 +9,7 @@ def reverse( viewname: Callable | str | None, urlconf: str | None = ..., args: Sequence[Any] | None = ..., - kwargs: Dict[str, Any] | None = ..., + kwargs: dict[str, Any] | None = ..., current_app: str | None = ..., ) -> str: ... diff --git a/django-stubs/urls/conf.pyi b/django-stubs/urls/conf.pyi index e46a1232d..780189e7e 100644 --- a/django-stubs/urls/conf.pyi +++ b/django-stubs/urls/conf.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Sequence from types import ModuleType -from typing import Any, Callable, Dict, Sequence, Tuple, overload +from typing import Any, overload from django.urls import URLPattern, URLResolver, _AnyURL @@ -10,28 +11,28 @@ _URLConf = str | ModuleType | Sequence[_AnyURL] def include( arg: _URLConf | tuple[_URLConf, str], namespace: str | None = ... -) -> Tuple[Sequence[URLResolver | URLPattern], str | None, str | None]: ... +) -> tuple[Sequence[URLResolver | URLPattern], str | None, str | None]: ... # path() @overload def path( - route: str, view: Callable[..., HttpResponseBase], kwargs: Dict[str, Any] = ..., name: str = ... + route: str, view: Callable[..., HttpResponseBase], kwargs: dict[str, Any] = ..., name: str = ... ) -> URLPattern: ... @overload -def path(route: str, view: IncludedURLConf, kwargs: Dict[str, Any] = ..., name: str = ...) -> URLResolver: ... +def path(route: str, view: IncludedURLConf, kwargs: dict[str, Any] = ..., name: str = ...) -> URLResolver: ... @overload def path( - route: str, view: Sequence[URLResolver | str], kwargs: Dict[str, Any] = ..., name: str = ... + route: str, view: Sequence[URLResolver | str], kwargs: dict[str, Any] = ..., name: str = ... ) -> URLResolver: ... # re_path() @overload def re_path( - route: str, view: Callable[..., HttpResponseBase], kwargs: Dict[str, Any] = ..., name: str = ... + route: str, view: Callable[..., HttpResponseBase], kwargs: dict[str, Any] = ..., name: str = ... ) -> URLPattern: ... @overload -def re_path(route: str, view: IncludedURLConf, kwargs: Dict[str, Any] = ..., name: str = ...) -> URLResolver: ... +def re_path(route: str, view: IncludedURLConf, kwargs: dict[str, Any] = ..., name: str = ...) -> URLResolver: ... @overload def re_path( - route: str, view: Sequence[URLResolver | str], kwargs: Dict[str, Any] = ..., name: str = ... + route: str, view: Sequence[URLResolver | str], kwargs: dict[str, Any] = ..., name: str = ... ) -> URLResolver: ... diff --git a/django-stubs/urls/converters.pyi b/django-stubs/urls/converters.pyi index 2a4e54ed6..b8fb3ad16 100644 --- a/django-stubs/urls/converters.pyi +++ b/django-stubs/urls/converters.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Type +from typing import Any from uuid import UUID class IntConverter: @@ -19,9 +19,9 @@ class UUIDConverter: class SlugConverter(StringConverter): ... class PathConverter(StringConverter): ... -DEFAULT_CONVERTERS: Dict[str, Any] -REGISTERED_CONVERTERS: Dict[str, Any] +DEFAULT_CONVERTERS: dict[str, Any] +REGISTERED_CONVERTERS: dict[str, Any] -def register_converter(converter: Type[Any], type_name: str) -> None: ... -def get_converters() -> Dict[str, Any]: ... +def register_converter(converter: type[Any], type_name: str) -> None: ... +def get_converters() -> dict[str, Any]: ... def get_converter(raw_converter: str) -> Any: ... diff --git a/django-stubs/urls/resolvers.pyi b/django-stubs/urls/resolvers.pyi index f8d86d894..d894137be 100644 --- a/django-stubs/urls/resolvers.pyi +++ b/django-stubs/urls/resolvers.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterator, Sequence from types import ModuleType -from typing import Any, Callable, Dict, Iterator, List, Pattern, Sequence, Tuple, Type, overload +from typing import Any, Pattern, overload from django.core.checks.messages import CheckMessage from django.urls import _AnyURL @@ -8,12 +9,12 @@ from django.utils.datastructures import MultiValueDict class ResolverMatch: func: Callable - args: Tuple[Any, ...] - kwargs: Dict[str, Any] + args: tuple[Any, ...] + kwargs: dict[str, Any] url_name: str | None - app_names: List[str] + app_names: list[str] app_name: str - namespaces: List[str] + namespaces: list[str] namespace: str view_name: str route: str @@ -22,11 +23,11 @@ class ResolverMatch: def __init__( self, func: Callable, - args: Tuple[Any, ...], - kwargs: Dict[str, Any], + args: tuple[Any, ...], + kwargs: dict[str, Any], url_name: str | None = ..., - app_names: List[str | None] | None = ..., - namespaces: List[str | None] | None = ..., + app_names: list[str | None] | None = ..., + namespaces: list[str | None] | None = ..., route: str | None = ..., tried: Any | None = ..., ) -> None: ... @@ -35,7 +36,7 @@ class ResolverMatch: def __iter__(self) -> Iterator[Any]: ... def get_resolver(urlconf: str | None = ...) -> URLResolver: ... -def get_ns_resolver(ns_pattern: str, resolver: URLResolver, converters: Tuple) -> URLResolver: ... +def get_ns_resolver(ns_pattern: str, resolver: URLResolver, converters: tuple) -> URLResolver: ... _Pattern = RegexPattern | RoutePattern | LocalePrefixPattern @@ -43,9 +44,9 @@ class LocaleRegexDescriptor: attr: str def __init__(self, attr: Any) -> None: ... @overload - def __get__(self, instance: None, cls: Type[_Pattern] = ...) -> LocaleRegexDescriptor: ... + def __get__(self, instance: None, cls: type[_Pattern] = ...) -> LocaleRegexDescriptor: ... @overload - def __get__(self, instance: _Pattern, cls: Type[_Pattern] = ...) -> Pattern[str]: ... + def __get__(self, instance: _Pattern, cls: type[_Pattern] = ...) -> Pattern[str]: ... class CheckURLMixin: def describe(self) -> str: ... @@ -53,44 +54,44 @@ class CheckURLMixin: class RegexPattern(CheckURLMixin): regex: LocaleRegexDescriptor name: str | None - converters: Dict[Any, Any] + converters: dict[Any, Any] def __init__(self, regex: str, name: str | None = ..., is_endpoint: bool = ...) -> None: ... - def match(self, path: str) -> Tuple[str, Tuple, Dict[str, str]] | None: ... - def check(self) -> List[CheckMessage]: ... + def match(self, path: str) -> tuple[str, tuple, dict[str, str]] | None: ... + def check(self) -> list[CheckMessage]: ... class RoutePattern(CheckURLMixin): regex: LocaleRegexDescriptor name: str | None - converters: Dict[str, UUIDConverter] + converters: dict[str, UUIDConverter] def __init__(self, route: str, name: str | None = ..., is_endpoint: bool = ...) -> None: ... - def match(self, path: str) -> Tuple[str, Tuple, Dict[str, int | str]] | None: ... - def check(self) -> List[CheckMessage]: ... + def match(self, path: str) -> tuple[str, tuple, dict[str, int | str]] | None: ... + def check(self) -> list[CheckMessage]: ... class LocalePrefixPattern: prefix_default_language: bool - converters: Dict[Any, Any] + converters: dict[Any, Any] def __init__(self, prefix_default_language: bool = ...) -> None: ... @property def regex(self) -> Pattern[str]: ... @property def language_prefix(self) -> str: ... - def match(self, path: str) -> Tuple[str, Tuple, Dict[str, Any]] | None: ... - def check(self) -> List[CheckMessage]: ... + def match(self, path: str) -> tuple[str, tuple, dict[str, Any]] | None: ... + def check(self) -> list[CheckMessage]: ... def describe(self) -> str: ... class URLPattern: pattern: _Pattern callback: Callable - default_args: Dict[str, str] | None + default_args: dict[str, str] | None name: str | None def __init__( self, pattern: _Pattern, callback: Callable, - default_args: Dict[str, str] | None = ..., + default_args: dict[str, str] | None = ..., name: str | None = ..., ) -> None: ... - def check(self) -> List[CheckMessage]: ... + def check(self) -> list[CheckMessage]: ... def resolve(self, path: str) -> ResolverMatch | None: ... @property def lookup_str(self) -> str: ... @@ -99,7 +100,7 @@ class URLResolver: pattern: _Pattern urlconf_name: str | None | Sequence[_AnyURL] callback: None - default_kwargs: Dict[str, Any] + default_kwargs: dict[str, Any] namespace: str | None app_name: str | None _local: Any @@ -108,20 +109,20 @@ class URLResolver: self, pattern: _Pattern, urlconf_name: str | None | Sequence[_AnyURL], - default_kwargs: Dict[str, Any] | None = ..., + default_kwargs: dict[str, Any] | None = ..., app_name: str | None = ..., namespace: str | None = ..., ) -> None: ... @property def reverse_dict(self) -> MultiValueDict: ... @property - def namespace_dict(self) -> Dict[str, Tuple[str, URLResolver]]: ... + def namespace_dict(self) -> dict[str, tuple[str, URLResolver]]: ... @property - def app_dict(self) -> Dict[str, List[str]]: ... + def app_dict(self) -> dict[str, list[str]]: ... @property def urlconf_module(self) -> ModuleType | None | Sequence[_AnyURL]: ... @property - def url_patterns(self) -> List[_AnyURL]: ... + def url_patterns(self) -> list[_AnyURL]: ... def resolve(self, path: str) -> ResolverMatch: ... def resolve_error_handler(self, view_type: int) -> Callable: ... def reverse(self, lookup_view: str, *args: Any, **kwargs: Any) -> str: ... diff --git a/django-stubs/urls/utils.pyi b/django-stubs/urls/utils.pyi index f92d5b271..bfd09c115 100644 --- a/django-stubs/urls/utils.pyi +++ b/django-stubs/urls/utils.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Tuple +from collections.abc import Callable def get_callable(lookup_view: Callable | str) -> Callable: ... -def get_mod_func(callback: str) -> Tuple[str, str]: ... +def get_mod_func(callback: str) -> tuple[str, str]: ... diff --git a/django-stubs/utils/archive.pyi b/django-stubs/utils/archive.pyi index cb58491a8..4c82e23d1 100644 --- a/django-stubs/utils/archive.pyi +++ b/django-stubs/utils/archive.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, Sequence from types import TracebackType -from typing import Any, Dict, Iterable, Sequence, Type +from typing import Any class ArchiveException(Exception): ... class UnrecognizedArchiveFormat(ArchiveException): ... @@ -11,7 +12,7 @@ class Archive: def __enter__(self) -> Archive: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, ) -> None: ... @@ -38,4 +39,4 @@ class ZipArchive(BaseArchive): def extract(self, to_path: str) -> None: ... def close(self) -> None: ... -extension_map: Dict[str, Type[BaseArchive]] +extension_map: dict[str, type[BaseArchive]] diff --git a/django-stubs/utils/asyncio.pyi b/django-stubs/utils/asyncio.pyi index 7e6c55e0c..ed9f47504 100644 --- a/django-stubs/utils/asyncio.pyi +++ b/django-stubs/utils/asyncio.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, TypeVar, overload +from collections.abc import Callable +from typing import Any, TypeVar, overload _C = TypeVar("_C", bound=Callable) diff --git a/django-stubs/utils/autoreload.pyi b/django-stubs/utils/autoreload.pyi index 1c259eb07..740c74be1 100644 --- a/django-stubs/utils/autoreload.pyi +++ b/django-stubs/utils/autoreload.pyi @@ -1,7 +1,8 @@ import threading import types +from collections.abc import Callable, Iterable, Iterator from pathlib import Path -from typing import Any, Callable, Dict, FrozenSet, Iterable, Iterator, List, Set, Tuple +from typing import Any from django.apps.registry import Apps from django.dispatch import Signal @@ -19,19 +20,19 @@ def is_django_path(path: _PathCompatible) -> bool: ... def check_errors(fn: Callable[_P, Any]) -> Callable[_P, None]: ... def raise_last_exception() -> None: ... def ensure_echo_on() -> None: ... -def iter_all_python_module_files() -> Set[Path]: ... +def iter_all_python_module_files() -> set[Path]: ... def iter_modules_and_files( modules: Iterable[types.ModuleType], extra_files: Iterable[_PathCompatible] -) -> FrozenSet[Path]: ... +) -> frozenset[Path]: ... def common_roots(paths: Iterable[Path]) -> Iterable[Path]: ... def sys_path_directories() -> Iterator[Path]: ... -def get_child_arguments() -> List[str]: ... +def get_child_arguments() -> list[str]: ... def trigger_reload(filename: str) -> None: ... def restart_with_reloader() -> int: ... class BaseReloader: - extra_files: Set[Path] - directory_globs: Dict[Path, Set[str]] + extra_files: set[Path] + directory_globs: dict[Path, set[str]] def __init__(self) -> None: ... def watch_dir(self, path: _PathCompatible, glob: str) -> None: ... def watched_files(self, include_globs: bool = ...) -> Iterator[Path]: ... @@ -48,7 +49,7 @@ class BaseReloader: class StatReloader(BaseReloader): SLEEP_TIME: int - def snapshot_files(self) -> Iterator[Tuple[Path, float]]: ... + def snapshot_files(self) -> Iterator[tuple[Path, float]]: ... @classmethod def check_availability(cls) -> bool: ... @@ -60,7 +61,7 @@ class WatchmanReloader(BaseReloader): def __init__(self) -> None: ... @property def client(self) -> Any: ... - def watched_roots(self, watched_files: Iterable[Path]) -> FrozenSet[Path]: ... + def watched_roots(self, watched_files: Iterable[Path]) -> frozenset[Path]: ... def update_watches(self) -> None: ... def request_processed(self, **kwargs: Any) -> None: ... def check_server_status(self, inner_ex: BaseException | None = ...) -> bool: ... diff --git a/django-stubs/utils/baseconv.pyi b/django-stubs/utils/baseconv.pyi index db6b26239..0505c9377 100644 --- a/django-stubs/utils/baseconv.pyi +++ b/django-stubs/utils/baseconv.pyi @@ -1,5 +1,3 @@ -from typing import Tuple - BASE2_ALPHABET: str BASE16_ALPHABET: str BASE56_ALPHABET: str @@ -14,7 +12,7 @@ class BaseConverter: def __init__(self, digits: str, sign: str = ...) -> None: ... def encode(self, i: int) -> str: ... def decode(self, s: str) -> int: ... - def convert(self, number: int | str, from_digits: str, to_digits: str, sign: str) -> Tuple[int, str]: ... + def convert(self, number: int | str, from_digits: str, to_digits: str, sign: str) -> tuple[int, str]: ... base2: BaseConverter base16: BaseConverter diff --git a/django-stubs/utils/cache.pyi b/django-stubs/utils/cache.pyi index b30ecd842..50fdeee7a 100644 --- a/django-stubs/utils/cache.pyi +++ b/django-stubs/utils/cache.pyi @@ -1,4 +1,4 @@ -from typing import Any, Tuple +from typing import Any from django.core.cache.backends.base import BaseCache from django.http.request import HttpRequest @@ -17,7 +17,7 @@ def get_conditional_response( ) -> HttpResponse | None: ... def patch_response_headers(response: HttpResponseBase, cache_timeout: int | None = ...) -> None: ... def add_never_cache_headers(response: HttpResponseBase) -> None: ... -def patch_vary_headers(response: HttpResponseBase, newheaders: Tuple[str]) -> None: ... +def patch_vary_headers(response: HttpResponseBase, newheaders: tuple[str]) -> None: ... def has_vary_header(response: HttpResponse, header_query: str) -> bool: ... def get_cache_key( request: HttpRequest, key_prefix: str | None = ..., method: str = ..., cache: BaseCache | None = ... diff --git a/django-stubs/utils/connection.pyi b/django-stubs/utils/connection.pyi index 79205cc00..0368b72e5 100644 --- a/django-stubs/utils/connection.pyi +++ b/django-stubs/utils/connection.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Generic, Iterator, Mapping, Sequence, Type, TypeVar +from collections.abc import Iterator, Mapping, Sequence +from typing import Any, Generic, TypeVar class ConnectionProxy: def __init__(self, connections: Mapping[str, Any], alias: str) -> None: ... @@ -14,12 +15,12 @@ _T = TypeVar("_T") class BaseConnectionHandler(Generic[_T]): settings_name: str | None - exception_class: Type[Exception] + exception_class: type[Exception] thread_critical: bool def __init__(self, settings: Any | None = ...) -> None: ... @property - def settings(self) -> Dict[str, Any]: ... - def configure_settings(self, settings: Dict[str, Any] | None) -> Dict[str, Any]: ... + def settings(self) -> dict[str, Any]: ... + def configure_settings(self, settings: dict[str, Any] | None) -> dict[str, Any]: ... def create_connection(self, alias: str) -> _T: ... def __getitem__(self, alias: str) -> _T: ... def __setitem__(self, key: str, value: _T) -> None: ... diff --git a/django-stubs/utils/crypto.pyi b/django-stubs/utils/crypto.pyi index 68d7c82ac..c0eb7e74a 100644 --- a/django-stubs/utils/crypto.pyi +++ b/django-stubs/utils/crypto.pyi @@ -1,5 +1,5 @@ +from collections.abc import Callable from hmac import HMAC -from typing import Callable using_sysrandom: bool RANDOM_STRING_CHARS: str diff --git a/django-stubs/utils/datastructures.pyi b/django-stubs/utils/datastructures.pyi index 5873e61d3..ad9cdfbba 100644 --- a/django-stubs/utils/datastructures.pyi +++ b/django-stubs/utils/datastructures.pyi @@ -1,17 +1,5 @@ -from typing import ( - Any, - Collection, - Dict, - Generic, - Iterable, - Iterator, - List, - Mapping, - MutableSet, - Tuple, - TypeVar, - overload, -) +from collections.abc import Collection, Iterable, Iterator, Mapping +from typing import Any, Generic, MutableSet, TypeVar, overload from typing_extensions import Protocol @@ -22,7 +10,7 @@ _I = TypeVar("_I", covariant=True) # Unfortunately, there's often check `if isinstance(var, (list, tuple))` in django # codebase. So we need sometimes to declare exactly list or tuple. -_ListOrTuple = List[_K] | Tuple[_K, ...] | Tuple[()] +_ListOrTuple = list[_K] | tuple[_K, ...] | tuple[()] class _PropertyDescriptor(Generic[_K, _V]): """ @@ -55,7 +43,7 @@ class _IndexableCollection(Protocol[_I], Collection[_I]): def __getitem__(self: _IC, index: slice) -> _IC: ... class OrderedSet(MutableSet[_K]): - dict: Dict[_K, None] + dict: dict[_K, None] def __init__(self, iterable: Iterable[_K] | None = ...) -> None: ... def __contains__(self, item: object) -> bool: ... def __iter__(self) -> Iterator[_K]: ... @@ -69,34 +57,34 @@ class MultiValueDictKeyError(KeyError): ... _D = TypeVar("_D", bound="MultiValueDict") -class MultiValueDict(Dict[_K, _V]): +class MultiValueDict(dict[_K, _V]): @overload - def __init__(self, key_to_list_mapping: Mapping[_K, List[_V] | None] = ...) -> None: ... + def __init__(self, key_to_list_mapping: Mapping[_K, list[_V] | None] = ...) -> None: ... @overload - def __init__(self, key_to_list_mapping: Iterable[Tuple[_K, List[_V]]] = ...) -> None: ... + def __init__(self, key_to_list_mapping: Iterable[tuple[_K, list[_V]]] = ...) -> None: ... @overload def get(self, key: _K) -> _V | None: ... @overload def get(self, key: _K, default: _Z = ...) -> _V | _Z: ... - def getlist(self, key: _K, default: _Z = ...) -> List[_V] | _Z: ... - def setlist(self, key: _K, list_: List[_V]) -> None: ... + def getlist(self, key: _K, default: _Z = ...) -> list[_V] | _Z: ... + def setlist(self, key: _K, list_: list[_V]) -> None: ... def setdefault(self, key: _K, default: _V = ...) -> _V: ... - def setlistdefault(self, key: _K, default_list: List[_V] | None = ...) -> List[_V]: ... + def setlistdefault(self, key: _K, default_list: list[_V] | None = ...) -> list[_V]: ... def appendlist(self, key: _K, value: _V) -> None: ... - def items(self) -> Iterator[Tuple[_K, _V | List[object]]]: ... # type: ignore - def lists(self) -> Iterable[Tuple[_K, List[_V]]]: ... - def dict(self) -> Dict[_K, _V | List[object]]: ... + def items(self) -> Iterator[tuple[_K, _V | list[object]]]: ... # type: ignore + def lists(self) -> Iterable[tuple[_K, list[_V]]]: ... + def dict(self) -> dict[_K, _V | list[object]]: ... def copy(self: _D) -> _D: ... - def __getitem__(self, key: _K) -> _V | List[object]: ... # type: ignore + def __getitem__(self, key: _K) -> _V | list[object]: ... # type: ignore def __setitem__(self, key: _K, value: _V) -> None: ... # These overrides are needed to convince mypy that this isn't an abstract class def __delitem__(self, item: _K) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_K]: ... # Fake to make `values` work properly - def values(self) -> Iterator[_V | List[object]]: ... # type: ignore[override] + def values(self) -> Iterator[_V | list[object]]: ... # type: ignore[override] -class ImmutableList(Tuple[_V, ...]): +class ImmutableList(tuple[_V, ...]): warning: str def __new__(cls, *args: Any, warning: str = ..., **kwargs: Any) -> ImmutableList: ... def complain(self, *args: Any, **kwargs: Any) -> None: ... @@ -106,20 +94,20 @@ class _ItemCallable(Protocol[_V]): def __call__(self, __value: _V) -> _V: ... -class DictWrapper(Dict[str, _V]): +class DictWrapper(dict[str, _V]): func: _ItemCallable[_V] prefix: str @overload def __init__(self, data: Mapping[str, _V], func: _ItemCallable[_V], prefix: str) -> None: ... @overload - def __init__(self, data: Iterable[Tuple[str, _V]], func: _ItemCallable[_V], prefix: str) -> None: ... + def __init__(self, data: Iterable[tuple[str, _V]], func: _ItemCallable[_V], prefix: str) -> None: ... def __getitem__(self, key: str) -> _V: ... _T = TypeVar("_T", bound="CaseInsensitiveMapping") class CaseInsensitiveMapping(Mapping[str, _V]): - _store: Dict[str, Tuple[str, _V]] - def __init__(self, data: Mapping[str, _V] | Iterable[Tuple[str, _V]]) -> None: ... + _store: dict[str, tuple[str, _V]] + def __init__(self, data: Mapping[str, _V] | Iterable[tuple[str, _V]]) -> None: ... def __getitem__(self, key: str) -> _V: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[str]: ... diff --git a/django-stubs/utils/dates.pyi b/django-stubs/utils/dates.pyi index 2e46b9267..61b1e64fb 100644 --- a/django-stubs/utils/dates.pyi +++ b/django-stubs/utils/dates.pyi @@ -1,8 +1,6 @@ -from typing import Dict - -WEEKDAYS: Dict[int, str] -WEEKDAYS_ABBR: Dict[int, str] -MONTHS: Dict[int, str] -MONTHS_3: Dict[int, str] -MONTHS_AP: Dict[int, str] -MONTHS_ALT: Dict[int, str] +WEEKDAYS: dict[int, str] +WEEKDAYS_ABBR: dict[int, str] +MONTHS: dict[int, str] +MONTHS_3: dict[int, str] +MONTHS_AP: dict[int, str] +MONTHS_ALT: dict[int, str] diff --git a/django-stubs/utils/deconstruct.pyi b/django-stubs/utils/deconstruct.pyi index 9198d95ec..067112efc 100644 --- a/django-stubs/utils/deconstruct.pyi +++ b/django-stubs/utils/deconstruct.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, TypeVar, overload +from collections.abc import Callable +from typing import Any, TypeVar, overload _T = TypeVar("_T") _TCallable = TypeVar("_TCallable", bound=Callable[..., Any]) diff --git a/django-stubs/utils/decorators.pyi b/django-stubs/utils/decorators.pyi index f458ecb08..7cbab1393 100644 --- a/django-stubs/utils/decorators.pyi +++ b/django-stubs/utils/decorators.pyi @@ -1,4 +1,5 @@ -from typing import Callable, Iterable, Type, TypeVar +from collections.abc import Callable, Iterable +from typing import TypeVar from django.utils.deprecation import MiddlewareMixin from django.utils.functional import classproperty as classproperty @@ -12,7 +13,7 @@ class classonlymethod(classmethod): ... def method_decorator(decorator: Callable | Iterable[Callable], name: str = ...) -> Callable[[_T], _T]: ... def decorator_from_middleware_with_args(middleware_class: type) -> Callable: ... def decorator_from_middleware(middleware_class: type) -> Callable: ... -def make_middleware_decorator(middleware_class: Type[MiddlewareMixin]) -> Callable: ... +def make_middleware_decorator(middleware_class: type[MiddlewareMixin]) -> Callable: ... def sync_and_async_middleware(func: _CallableType) -> _CallableType: ... def sync_only_middleware(func: _CallableType) -> _CallableType: ... def async_only_middleware(func: _CallableType) -> _CallableType: ... diff --git a/django-stubs/utils/deprecation.pyi b/django-stubs/utils/deprecation.pyi index fe4c5fe7b..6f6b79364 100644 --- a/django-stubs/utils/deprecation.pyi +++ b/django-stubs/utils/deprecation.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Protocol, Type +from collections.abc import Callable +from typing import Any, Protocol from django.http.request import HttpRequest from django.http.response import HttpResponse @@ -12,19 +13,19 @@ class warn_about_renamed_method: class_name: str old_method_name: str new_method_name: str - deprecation_warning: Type[DeprecationWarning] + deprecation_warning: type[DeprecationWarning] def __init__( - self, class_name: str, old_method_name: str, new_method_name: str, deprecation_warning: Type[DeprecationWarning] + self, class_name: str, old_method_name: str, new_method_name: str, deprecation_warning: type[DeprecationWarning] ) -> None: ... def __call__(self, f: Callable) -> Callable: ... class RenameMethodsBase(type): renamed_methods: Any - def __new__(cls, name: Any, bases: Any, attrs: Any) -> Type: ... + def __new__(cls, name: Any, bases: Any, attrs: Any) -> type: ... class DeprecationInstanceCheck(type): alternative: str - deprecation_warning: Type[Warning] + deprecation_warning: type[Warning] def __instancecheck__(self, instance: Any) -> bool: ... class GetResponseCallable(Protocol): diff --git a/django-stubs/utils/feedgenerator.pyi b/django-stubs/utils/feedgenerator.pyi index afd1b3b63..28192bd0c 100644 --- a/django-stubs/utils/feedgenerator.pyi +++ b/django-stubs/utils/feedgenerator.pyi @@ -1,5 +1,5 @@ import datetime -from typing import Any, Dict, List, Tuple +from typing import Any from xml.sax import ContentHandler def rfc2822_date(date: datetime.date) -> str: ... @@ -7,8 +7,8 @@ def rfc3339_date(date: datetime.date) -> str: ... def get_tag_uri(url: str, date: datetime.date | None) -> str: ... class SyndicationFeed: - feed: Dict[str, Any] - items: List[Dict[str, Any]] + feed: dict[str, Any] + items: list[dict[str, Any]] def __init__( self, title: str, @@ -19,7 +19,7 @@ class SyndicationFeed: author_name: str | None = ..., author_link: str | None = ..., subtitle: str | None = ..., - categories: Tuple[str, str] | None = ..., + categories: tuple[str, str] | None = ..., feed_url: str | None = ..., feed_copyright: str | None = ..., feed_guid: str | None = ..., @@ -38,18 +38,18 @@ class SyndicationFeed: comments: str | None = ..., unique_id: str | None = ..., unique_id_is_permalink: bool | None = ..., - categories: Tuple | None = ..., + categories: tuple | None = ..., item_copyright: str | None = ..., ttl: int | None = ..., updateddate: datetime.datetime | None = ..., - enclosures: List[Enclosure] | None = ..., + enclosures: list[Enclosure] | None = ..., **kwargs: Any ) -> None: ... def num_items(self) -> int: ... - def root_attributes(self) -> Dict[Any, Any]: ... + def root_attributes(self) -> dict[Any, Any]: ... def add_root_elements(self, handler: ContentHandler) -> None: ... - def item_attributes(self, item: Dict[str, Any]) -> Dict[Any, Any]: ... - def add_item_elements(self, handler: ContentHandler, item: Dict[str, Any]) -> None: ... + def item_attributes(self, item: dict[str, Any]) -> dict[Any, Any]: ... + def add_item_elements(self, handler: ContentHandler, item: dict[str, Any]) -> None: ... def write(self, outfile: Any, encoding: Any) -> None: ... def writeString(self, encoding: str) -> str: ... def latest_post_date(self) -> datetime.datetime: ... diff --git a/django-stubs/utils/formats.pyi b/django-stubs/utils/formats.pyi index 02c100029..5943bd307 100644 --- a/django-stubs/utils/formats.pyi +++ b/django-stubs/utils/formats.pyi @@ -1,16 +1,17 @@ import types +from collections.abc import Iterator from datetime import date from datetime import datetime as builtin_datetime from datetime import time from decimal import Decimal -from typing import Any, Dict, FrozenSet, Iterator, List, TypeVar, overload +from typing import Any, TypeVar, overload -ISO_INPUT_FORMATS: Dict[str, List[str]] -FORMAT_SETTINGS: FrozenSet[str] +ISO_INPUT_FORMATS: dict[str, list[str]] +FORMAT_SETTINGS: frozenset[str] def reset_format_cache() -> None: ... -def iter_format_modules(lang: str, format_module_path: List[str] | str | None = ...) -> Iterator[types.ModuleType]: ... -def get_format_modules(lang: str | None = ..., reverse: bool = ...) -> List[types.ModuleType]: ... +def iter_format_modules(lang: str, format_module_path: list[str] | str | None = ...) -> Iterator[types.ModuleType]: ... +def get_format_modules(lang: str | None = ..., reverse: bool = ...) -> list[types.ModuleType]: ... def get_format(format_type: str, lang: str | None = ..., use_l10n: bool | None = ...) -> Any: ... get_format_lazy: Any diff --git a/django-stubs/utils/functional.pyi b/django-stubs/utils/functional.pyi index 16ec3f902..b4e8fdcfe 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Sequence from functools import wraps as wraps # noqa: F401 -from typing import Any, Callable, Generic, List, Sequence, Tuple, Type, TypeVar, overload +from typing import Any, Generic, TypeVar, overload from django.db.models.base import Model from typing_extensions import Protocol, SupportsIndex @@ -11,15 +12,15 @@ class cached_property(Generic[_T]): name: str def __init__(self, func: Callable[..., _T], name: str = ...) -> None: ... @overload - def __get__(self, instance: None, cls: Type[Any] = ...) -> "cached_property[_T]": ... + def __get__(self, instance: None, cls: type[Any] = ...) -> "cached_property[_T]": ... @overload - def __get__(self, instance: object, cls: Type[Any] = ...) -> _T: ... + def __get__(self, instance: object, cls: type[Any] = ...) -> _T: ... # Promise is only subclassed by a proxy class defined in the lazy function # so it makes sense for it to have all the methods available in that proxy class class Promise: def __init__(self, args: Any, kw: Any) -> None: ... - def __reduce__(self) -> Tuple[Any, Tuple[Any]]: ... + def __reduce__(self) -> tuple[Any, tuple[Any]]: ... def __lt__(self, other: Any) -> bool: ... def __mod__(self, rhs: Any) -> Any: ... def __add__(self, other: Any) -> Any: ... @@ -60,7 +61,7 @@ class LazyObject: __getattr__: Callable def __setattr__(self, name: str, value: Any) -> None: ... def __delattr__(self, name: str) -> None: ... - def __reduce__(self) -> Tuple[Callable, Tuple[Model]]: ... + def __reduce__(self) -> tuple[Callable, tuple[Model]]: ... def __copy__(self) -> LazyObject: ... __bytes__: Callable __bool__: Callable @@ -83,8 +84,8 @@ class SimpleLazyObject(LazyObject): _PartitionMember = TypeVar("_PartitionMember") def partition( - predicate: Callable[[_PartitionMember], int | bool], values: List[_PartitionMember] -) -> Tuple[List[_PartitionMember], List[_PartitionMember]]: ... + predicate: Callable[[_PartitionMember], int | bool], values: list[_PartitionMember] +) -> tuple[list[_PartitionMember], list[_PartitionMember]]: ... _Get = TypeVar("_Get", covariant=True) _Self = TypeVar("_Self") @@ -92,7 +93,7 @@ _Self = TypeVar("_Self") class classproperty(Generic[_Get]): fget: Callable[[_Self], _Get] | None def __init__(self, method: Callable[[_Self], _Get] | None = ...) -> None: ... - def __get__(self, instance: _Self | None, cls: Type[_Self] = ...) -> _Get: ... + def __get__(self, instance: _Self | None, cls: type[_Self] = ...) -> _Get: ... def getter(self, method: Callable[[_Self], _Get]) -> classproperty[_Get]: ... class _Getter(Protocol[_Get]): @@ -103,6 +104,6 @@ class _Getter(Protocol[_Get]): """ @overload - def __get__(self: _Self, __instance: None, __typeobj: Type[Any] | None) -> _Self: ... + def __get__(self: _Self, __instance: None, __typeobj: type[Any] | None) -> _Self: ... @overload - def __get__(self, __instance: Any, __typeobj: Type[Any] | None) -> _Get: ... + def __get__(self, __instance: Any, __typeobj: type[Any] | None) -> _Get: ... diff --git a/django-stubs/utils/html.pyi b/django-stubs/utils/html.pyi index 9e3e8c3ca..37ba8878d 100644 --- a/django-stubs/utils/html.pyi +++ b/django-stubs/utils/html.pyi @@ -1,11 +1,12 @@ +from collections.abc import Iterable from html.parser import HTMLParser -from typing import Any, Iterable, List, Pattern, Tuple, Type +from typing import Any, Pattern from django.utils.safestring import SafeString TRAILING_PUNCTUATION_CHARS: str -WRAPPING_PUNCTUATION: List[Tuple[str, str]] -DOTS: List[str] +WRAPPING_PUNCTUATION: list[tuple[str, str]] +DOTS: list[str] word_split_re: Pattern[str] simple_url_re: Pattern[str] simple_url_2_re: Pattern[str] @@ -31,4 +32,4 @@ def strip_spaces_between_tags(value: str) -> str: ... def smart_urlquote(url: str) -> str: ... def urlize(text: str, trim_url_limit: int | None = ..., nofollow: bool = ..., autoescape: bool = ...) -> str: ... def avoid_wrapping(value: str) -> str: ... -def html_safe(klass: Type) -> Type: ... +def html_safe(klass: type) -> type: ... diff --git a/django-stubs/utils/http.pyi b/django-stubs/utils/http.pyi index ae3df78fc..db25f83df 100644 --- a/django-stubs/utils/http.pyi +++ b/django-stubs/utils/http.pyi @@ -1,7 +1,8 @@ -from typing import Any, Iterable, List, Pattern, Tuple +from collections.abc import Iterable +from typing import Any, Pattern ETAG_MATCH: Pattern[str] -MONTHS: List[str] +MONTHS: list[str] RFC1123_DATE: Pattern[str] RFC850_DATE: Pattern[str] ASCTIME_DATE: Pattern[str] @@ -20,7 +21,7 @@ def base36_to_int(s: str) -> int: ... def int_to_base36(i: int) -> str: ... def urlsafe_base64_encode(s: bytes) -> str: ... def urlsafe_base64_decode(s: str) -> bytes: ... -def parse_etags(etag_str: str) -> List[str]: ... +def parse_etags(etag_str: str) -> list[str]: ... def quote_etag(etag_str: str) -> str: ... def is_same_domain(host: str, pattern: str) -> bool: ... def url_has_allowed_host_and_scheme( @@ -35,5 +36,5 @@ def parse_qsl( errors: str = ..., max_num_fields: int | None = ..., separator: str = ..., -) -> List[Tuple[str, str]]: ... +) -> list[tuple[str, str]]: ... def escape_leading_slashes(url: str) -> str: ... diff --git a/django-stubs/utils/inspect.pyi b/django-stubs/utils/inspect.pyi index 9f9509124..1a2baa509 100644 --- a/django-stubs/utils/inspect.pyi +++ b/django-stubs/utils/inspect.pyi @@ -1,7 +1,8 @@ -from typing import Any, Callable, List, Tuple +from collections.abc import Callable +from typing import Any -def get_func_args(func: Callable[..., Any]) -> List[str]: ... -def get_func_full_args(func: Callable[..., Any]) -> List[Tuple[str, str] | Tuple[str]]: ... +def get_func_args(func: Callable[..., Any]) -> list[str]: ... +def get_func_full_args(func: Callable[..., Any]) -> list[tuple[str, str] | tuple[str]]: ... def func_accepts_kwargs(func: Callable[..., Any]) -> bool: ... def func_accepts_var_args(func: Callable[..., Any]) -> bool: ... def method_has_no_args(meth: Callable[..., Any]) -> bool: ... diff --git a/django-stubs/utils/jslex.pyi b/django-stubs/utils/jslex.pyi index 5804ba220..5c19477f1 100644 --- a/django-stubs/utils/jslex.pyi +++ b/django-stubs/utils/jslex.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterator, List, Tuple +from collections.abc import Iterator +from typing import Any class Tok: num: int @@ -12,15 +13,15 @@ def literals(choices: str, prefix: str = ..., suffix: str = ...) -> str: ... class Lexer: regexes: Any - toks: Dict[str, Tok] + toks: dict[str, Tok] state: str - def __init__(self, states: Dict[str, List[Tok]], first: str) -> None: ... - def lex(self, text: str) -> Iterator[Tuple[str, str]]: ... + def __init__(self, states: dict[str, list[Tok]], first: str) -> None: ... + def lex(self, text: str) -> Iterator[tuple[str, str]]: ... class JsLexer(Lexer): - both_before: List[Tok] - both_after: List[Tok] - states: Dict[str, List[Tok]] + both_before: list[Tok] + both_after: list[Tok] + states: dict[str, list[Tok]] def __init__(self) -> None: ... def prepare_js_for_gettext(js: str) -> str: ... diff --git a/django-stubs/utils/log.pyi b/django-stubs/utils/log.pyi index c1831b411..b17b9db52 100644 --- a/django-stubs/utils/log.pyi +++ b/django-stubs/utils/log.pyi @@ -1,6 +1,7 @@ import logging.config +from collections.abc import Callable from logging import Logger, LogRecord -from typing import Any, Callable, Dict +from typing import Any from django.core.management.color import Style from django.http import HttpRequest, HttpResponse @@ -8,7 +9,7 @@ from django.http import HttpRequest, HttpResponse request_logger: Logger DEFAULT_LOGGING: Any -def configure_logging(logging_config: str, logging_settings: Dict[str, Any]) -> None: ... +def configure_logging(logging_config: str, logging_settings: dict[str, Any]) -> None: ... class AdminEmailHandler(logging.Handler): include_html: bool diff --git a/django-stubs/utils/lorem_ipsum.pyi b/django-stubs/utils/lorem_ipsum.pyi index 1f9d9b32e..634da70a9 100644 --- a/django-stubs/utils/lorem_ipsum.pyi +++ b/django-stubs/utils/lorem_ipsum.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any COMMON_P: str WORDS: Any @@ -6,5 +6,5 @@ COMMON_WORDS: Any def sentence() -> str: ... def paragraph() -> str: ... -def paragraphs(count: int, common: bool = ...) -> List[str]: ... +def paragraphs(count: int, common: bool = ...) -> list[str]: ... def words(count: int, common: bool = ...) -> str: ... diff --git a/django-stubs/utils/numberformat.pyi b/django-stubs/utils/numberformat.pyi index 18959df5b..2152a3be8 100644 --- a/django-stubs/utils/numberformat.pyi +++ b/django-stubs/utils/numberformat.pyi @@ -1,5 +1,5 @@ +from collections.abc import Iterable from decimal import Decimal -from typing import Iterable def format( number: Decimal | float | str, diff --git a/django-stubs/utils/regex_helper.pyi b/django-stubs/utils/regex_helper.pyi index f529d2a71..a361359cf 100644 --- a/django-stubs/utils/regex_helper.pyi +++ b/django-stubs/utils/regex_helper.pyi @@ -1,4 +1,5 @@ -from typing import Iterator, List, Mapping, Pattern, Tuple, Type, TypeVar +from collections.abc import Iterator, Mapping +from typing import Pattern, TypeVar ESCAPE_MAPPINGS: Mapping[str, str | None] @@ -6,14 +7,14 @@ class Choice(list): ... class Group(list): ... class NonCapture(list): ... -def normalize(pattern: str) -> List[Tuple[str, List[str]]]: ... -def next_char(input_iter: Iterator[str]) -> Iterator[Tuple[str, bool]]: ... -def walk_to_end(ch: str, input_iter: Iterator[Tuple[str, bool]]) -> None: ... -def get_quantifier(ch: str, input_iter: Iterator[Tuple[str, bool]]) -> Tuple[int, str | None]: ... -def contains(source: Group | NonCapture | str, inst: Type[Group]) -> bool: ... +def normalize(pattern: str) -> list[tuple[str, list[str]]]: ... +def next_char(input_iter: Iterator[str]) -> Iterator[tuple[str, bool]]: ... +def walk_to_end(ch: str, input_iter: Iterator[tuple[str, bool]]) -> None: ... +def get_quantifier(ch: str, input_iter: Iterator[tuple[str, bool]]) -> tuple[int, str | None]: ... +def contains(source: Group | NonCapture | str, inst: type[Group]) -> bool: ... def flatten_result( - source: List[Choice | Group | str] | Group | NonCapture | None, -) -> Tuple[List[str], List[List[str]]]: ... + source: list[Choice | Group | str] | Group | NonCapture | None, +) -> tuple[list[str], list[list[str]]]: ... # Returns SimpleLazyObject, but we can safely ignore it _P = TypeVar("_P", str, bytes) diff --git a/django-stubs/utils/safestring.pyi b/django-stubs/utils/safestring.pyi index a41eaad96..ac3ab3311 100644 --- a/django-stubs/utils/safestring.pyi +++ b/django-stubs/utils/safestring.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, TypeVar, overload +from collections.abc import Callable +from typing import Any, TypeVar, overload _SD = TypeVar("_SD", bound="SafeData") diff --git a/django-stubs/utils/termcolors.pyi b/django-stubs/utils/termcolors.pyi index 66a7a089f..b466c6a57 100644 --- a/django-stubs/utils/termcolors.pyi +++ b/django-stubs/utils/termcolors.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, Mapping, Sequence, Tuple +from collections.abc import Callable, Mapping, Sequence +from typing import Any color_names: Sequence foreground: Mapping[str, str] @@ -7,7 +8,7 @@ RESET: str opt_dict: Mapping[str, str] def colorize(text: str | None = ..., opts: Sequence[str] = ..., **kwargs: Any) -> str: ... -def make_style(opts: Tuple = ..., **kwargs: Any) -> Callable: ... +def make_style(opts: tuple = ..., **kwargs: Any) -> Callable: ... NOCOLOR_PALETTE: str DARK_PALETTE: str @@ -15,4 +16,4 @@ LIGHT_PALETTE: str PALETTES: Any DEFAULT_PALETTE: str -def parse_color_setting(config_string: str) -> Dict[str, Dict[str, Tuple[str, ...] | str]] | None: ... +def parse_color_setting(config_string: str) -> dict[str, dict[str, tuple[str, ...] | str]] | None: ... diff --git a/django-stubs/utils/text.pyi b/django-stubs/utils/text.pyi index 4c270fc9d..424a4c4b9 100644 --- a/django-stubs/utils/text.pyi +++ b/django-stubs/utils/text.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterable, Iterator from io import BytesIO -from typing import Callable, Iterable, Iterator, List, Pattern +from typing import Pattern from django.db.models.base import Model from django.utils.functional import SimpleLazyObject @@ -22,13 +23,13 @@ class Truncator(SimpleLazyObject): def words(self, num: int, truncate: str | None = ..., html: bool = ...) -> str: ... def get_valid_filename(name: str) -> str: ... -def get_text_list(list_: List[str], last_word: str = ...) -> str: ... +def get_text_list(list_: list[str], last_word: str = ...) -> str: ... def normalize_newlines(text: str) -> str: ... def phone2numeric(phone: str) -> str: ... def compress_string(s: bytes) -> bytes: ... class StreamingBuffer(BytesIO): - vals: List[bytes] + vals: list[bytes] def read(self) -> bytes: ... # type: ignore def compress_sequence(sequence: Iterable[bytes]) -> Iterator[bytes]: ... diff --git a/django-stubs/utils/timesince.pyi b/django-stubs/utils/timesince.pyi index a04afe54f..1195080ee 100644 --- a/django-stubs/utils/timesince.pyi +++ b/django-stubs/utils/timesince.pyi @@ -1,14 +1,14 @@ from datetime import date -from typing import Any, Dict +from typing import Any -TIME_STRINGS: Dict[str, str] +TIME_STRINGS: dict[str, str] TIMESINCE_CHUNKS: Any def timesince( d: date, now: date | None = ..., reversed: bool = ..., - time_strings: Dict[str, str] | None = ..., + time_strings: dict[str, str] | None = ..., depth: int = ..., ) -> str: ... -def timeuntil(d: date, now: date | None = ..., time_strings: Dict[str, str] | None = ..., depth: int = ...) -> str: ... +def timeuntil(d: date, now: date | None = ..., time_strings: dict[str, str] | None = ..., depth: int = ...) -> str: ... diff --git a/django-stubs/utils/timezone.pyi b/django-stubs/utils/timezone.pyi index bb1944cc4..ab555d238 100644 --- a/django-stubs/utils/timezone.pyi +++ b/django-stubs/utils/timezone.pyi @@ -6,7 +6,7 @@ from datetime import timedelta as timedelta from datetime import timezone from datetime import tzinfo as tzinfo from types import TracebackType -from typing import Any, Type, overload +from typing import Any, overload import pytz from pytz import BaseTzInfo @@ -36,7 +36,7 @@ class override(ContextDecorator): def __enter__(self) -> None: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... diff --git a/django-stubs/utils/topological_sort.pyi b/django-stubs/utils/topological_sort.pyi index 35f8b9381..057ffe49e 100644 --- a/django-stubs/utils/topological_sort.pyi +++ b/django-stubs/utils/topological_sort.pyi @@ -1,6 +1,7 @@ -from typing import Any, Dict, Iterable, Iterator, List, Set +from collections.abc import Iterable, Iterator +from typing import Any class CyclicDependencyError(ValueError): ... -def topological_sort_as_sets(dependency_graph: Dict[Any, Any]) -> Iterator[Set[Any]]: ... -def stable_topological_sort(nodes: Iterable[Any], dependency_graph: Dict[Any, Any]) -> List[Any]: ... +def topological_sort_as_sets(dependency_graph: dict[Any, Any]) -> Iterator[set[Any]]: ... +def stable_topological_sort(nodes: Iterable[Any], dependency_graph: dict[Any, Any]) -> list[Any]: ... diff --git a/django-stubs/utils/translation/__init__.pyi b/django-stubs/utils/translation/__init__.pyi index b4b7840a5..edd9b9e2f 100644 --- a/django-stubs/utils/translation/__init__.pyi +++ b/django-stubs/utils/translation/__init__.pyi @@ -1,7 +1,8 @@ import functools +from collections.abc import Callable from contextlib import ContextDecorator from types import TracebackType -from typing import Any, Callable, Type +from typing import Any from django.http.request import HttpRequest from django.utils.functional import _StrPromise @@ -58,7 +59,7 @@ class override(ContextDecorator): def __enter__(self) -> None: ... def __exit__( self, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... diff --git a/django-stubs/utils/translation/trans_real.pyi b/django-stubs/utils/translation/trans_real.pyi index 9e2901144..085ffdcb9 100644 --- a/django-stubs/utils/translation/trans_real.pyi +++ b/django-stubs/utils/translation/trans_real.pyi @@ -1,6 +1,7 @@ import gettext as gettext_module +from collections.abc import Iterator from gettext import NullTranslations -from typing import Any, Dict, Iterator, List, Pattern, Protocol, Tuple, TypeVar +from typing import Any, Pattern, Protocol, TypeVar from django.http.request import HttpRequest from typing_extensions import Literal @@ -15,16 +16,16 @@ class _PluralCallable(Protocol): def reset_cache(**kwargs: Any) -> None: ... -_KeyT = str | Tuple[str, int] +_KeyT = str | tuple[str, int] _Z = TypeVar("_Z") class TranslationCatalog: - _catalogs: List[Dict[_KeyT, str]] + _catalogs: list[dict[_KeyT, str]] def __init__(self, trans: gettext_module.NullTranslations | None = ...) -> None: ... def __getitem__(self, key: _KeyT) -> str: ... def __setitem__(self, key: _KeyT, value: str) -> None: ... def __contains__(self, key: _KeyT) -> bool: ... - def items(self) -> Iterator[Tuple[_KeyT, str]]: ... + def items(self) -> Iterator[tuple[_KeyT, str]]: ... def keys(self) -> Iterator[_KeyT]: ... def update(self, trans: gettext_module.NullTranslations) -> None: ... def get(self, key: _KeyT, default: _Z = ...) -> str | _Z: ... @@ -33,7 +34,7 @@ class TranslationCatalog: class DjangoTranslation(gettext_module.GNUTranslations): domain: str plural: _PluralCallable - def __init__(self, language: str, domain: str | None = ..., localedirs: List[str] | None = ...) -> None: ... + def __init__(self, language: str, domain: str | None = ..., localedirs: list[str] | None = ...) -> None: ... def merge(self, other: NullTranslations) -> None: ... def language(self) -> str: ... def to_language(self) -> str: ... @@ -52,10 +53,10 @@ def gettext_noop(message: str) -> str: ... def do_ntranslate(singular: str, plural: str, number: float, translation_function: str) -> str: ... def ngettext(singular: str, plural: str, number: float) -> str: ... def npgettext(context: str, singular: str, plural: str, number: int) -> str: ... -def all_locale_paths() -> List[str]: ... +def all_locale_paths() -> list[str]: ... def check_for_language(lang_code: str | None) -> bool: ... -def get_languages() -> Dict[str, str]: ... +def get_languages() -> dict[str, str]: ... def get_supported_language_variant(lang_code: str | None, strict: bool = ...) -> str: ... def get_language_from_path(path: str, strict: bool = ...) -> str | None: ... def get_language_from_request(request: HttpRequest, check_path: bool = ...) -> str: ... -def parse_accept_lang_header(lang_string: str) -> Tuple[Tuple[str, float], ...]: ... +def parse_accept_lang_header(lang_string: str) -> tuple[tuple[str, float], ...]: ... diff --git a/django-stubs/utils/tree.pyi b/django-stubs/utils/tree.pyi index 14df3d5b8..c75bb2cd4 100644 --- a/django-stubs/utils/tree.pyi +++ b/django-stubs/utils/tree.pyi @@ -1,8 +1,9 @@ -from typing import Any, Dict, List, Sequence, Tuple +from collections.abc import Sequence +from typing import Any from django.db.models.sql.where import NothingNode -_NodeChildren = List["Node" | NothingNode | Sequence[Any]] +_NodeChildren = list["Node" | NothingNode | Sequence[Any]] class Node: children: _NodeChildren @@ -12,10 +13,10 @@ class Node: def __init__( self, children: _NodeChildren | None = ..., connector: str | None = ..., negated: bool = ... ) -> None: ... - def __deepcopy__(self, memodict: Dict[Any, Any]) -> Node: ... + def __deepcopy__(self, memodict: dict[Any, Any]) -> Node: ... def __len__(self) -> int: ... def __bool__(self) -> bool: ... - def __contains__(self, other: Tuple[str, int]) -> bool: ... + def __contains__(self, other: tuple[str, int]) -> bool: ... def __hash__(self) -> int: ... def add(self, data: Any, conn_type: str, squash: bool = ...) -> Any: ... def negate(self) -> None: ... diff --git a/django-stubs/utils/version.pyi b/django-stubs/utils/version.pyi index d62a636cd..f9e3c20c3 100644 --- a/django-stubs/utils/version.pyi +++ b/django-stubs/utils/version.pyi @@ -1,5 +1,3 @@ -from typing import Tuple - PY36: bool PY37: bool PY38: bool @@ -7,11 +5,11 @@ PY39: bool PY310: bool PY311: bool -_VT = Tuple[int, int, int, str, int] +_VT = tuple[int, int, int, str, int] def get_version(version: _VT | None = ...) -> str: ... def get_main_version(version: _VT = ...) -> str: ... def get_complete_version(version: _VT | None = ...) -> _VT: ... def get_docs_version(version: _VT | None = ...) -> str: ... def get_git_changeset() -> str | None: ... -def get_version_tuple(version: str) -> Tuple[int, int, int]: ... +def get_version_tuple(version: str) -> tuple[int, int, int]: ... diff --git a/django-stubs/utils/xmlutils.pyi b/django-stubs/utils/xmlutils.pyi index e4ef29279..955b42183 100644 --- a/django-stubs/utils/xmlutils.pyi +++ b/django-stubs/utils/xmlutils.pyi @@ -1,9 +1,8 @@ -from typing import Dict from xml.sax.saxutils import XMLGenerator class UnserializableContentError(ValueError): ... class SimplerXMLGenerator(XMLGenerator): - def addQuickElement(self, name: str, contents: str | None = ..., attrs: Dict[str, str] | None = ...) -> None: ... + def addQuickElement(self, name: str, contents: str | None = ..., attrs: dict[str, str] | None = ...) -> None: ... def characters(self, content: str) -> None: ... - def startElement(self, name: str, attrs: Dict[str, str]) -> None: ... + def startElement(self, name: str, attrs: dict[str, str]) -> None: ... diff --git a/django-stubs/views/debug.pyi b/django-stubs/views/debug.pyi index 5fcc5ab1f..bb14c42e1 100644 --- a/django-stubs/views/debug.pyi +++ b/django-stubs/views/debug.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Iterator from importlib.abc import SourceLoader from pathlib import Path from types import TracebackType -from typing import Any, Callable, Dict, ItemsView, Iterator, List, Type +from typing import Any, ItemsView from django.http.request import HttpRequest, QueryDict from django.http.response import Http404, HttpResponse @@ -11,11 +12,11 @@ CLEANSED_SUBSTITUTE: str CURRENT_DIR: Path class CallableSettingWrapper: - def __init__(self, callable_setting: Callable | Type[Any]) -> None: ... + def __init__(self, callable_setting: Callable | type[Any]) -> None: ... def technical_500_response( request: HttpRequest, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None, status_code: int = ..., @@ -25,17 +26,17 @@ def get_exception_reporter_filter(request: HttpRequest | None) -> SafeExceptionR class SafeExceptionReporterFilter: def cleanse_setting(self, key: int | str, value: Any) -> Any: ... - def get_safe_settings(self) -> Dict[str, Any]: ... + def get_safe_settings(self) -> dict[str, Any]: ... def is_active(self, request: HttpRequest | None) -> bool: ... def get_cleansed_multivaluedict(self, request: HttpRequest, multivaluedict: QueryDict) -> QueryDict: ... - def get_post_parameters(self, request: HttpRequest | None) -> Dict[str, Any]: ... + def get_post_parameters(self, request: HttpRequest | None) -> dict[str, Any]: ... def cleanse_special_types(self, request: HttpRequest | None, value: Any) -> Any: ... def get_traceback_frame_variables(self, request: Any, tb_frame: Any) -> ItemsView[str, Any]: ... class ExceptionReporter: request: HttpRequest | None filter: SafeExceptionReporterFilter - exc_type: Type[BaseException] | None + exc_type: type[BaseException] | None exc_value: BaseException | None tb: TracebackType | None is_email: bool @@ -49,18 +50,18 @@ class ExceptionReporter: def __init__( self, request: HttpRequest | None, - exc_type: Type[BaseException] | None, + exc_type: type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None, is_email: bool = ..., ) -> None: ... - def get_traceback_data(self) -> Dict[str, Any]: ... + def get_traceback_data(self) -> dict[str, Any]: ... def get_traceback_html(self) -> SafeString: ... def get_traceback_text(self) -> SafeString: ... - def get_traceback_frames(self) -> List[Any]: ... + def get_traceback_frames(self) -> list[Any]: ... def get_exception_traceback_frames( self, exc_value: BaseException | None, tb: TracebackType | None - ) -> Iterator[Dict[str, Any]]: ... + ) -> Iterator[dict[str, Any]]: ... def technical_404_response(request: HttpRequest, exception: Http404) -> HttpResponse: ... def default_urlconf(request: HttpResponse | None) -> HttpResponse: ... diff --git a/django-stubs/views/decorators/cache.pyi b/django-stubs/views/decorators/cache.pyi index b61c70aaa..058da9b53 100644 --- a/django-stubs/views/decorators/cache.pyi +++ b/django-stubs/views/decorators/cache.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, TypeVar +from collections.abc import Callable +from typing import Any, TypeVar _F = TypeVar("_F", bound=Callable[..., Any]) diff --git a/django-stubs/views/decorators/clickjacking.pyi b/django-stubs/views/decorators/clickjacking.pyi index 1d0e483dd..f0ba61c7e 100644 --- a/django-stubs/views/decorators/clickjacking.pyi +++ b/django-stubs/views/decorators/clickjacking.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, TypeVar +from collections.abc import Callable +from typing import Any, TypeVar _F = TypeVar("_F", bound=Callable[..., Any]) diff --git a/django-stubs/views/decorators/common.pyi b/django-stubs/views/decorators/common.pyi index cf340c292..a129e01e7 100644 --- a/django-stubs/views/decorators/common.pyi +++ b/django-stubs/views/decorators/common.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, TypeVar +from collections.abc import Callable +from typing import Any, TypeVar _C = TypeVar("_C", bound=Callable[..., Any]) diff --git a/django-stubs/views/decorators/csrf.pyi b/django-stubs/views/decorators/csrf.pyi index c2b73de3c..a9e8b2bca 100644 --- a/django-stubs/views/decorators/csrf.pyi +++ b/django-stubs/views/decorators/csrf.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, TypeVar +from collections.abc import Callable +from typing import Any, TypeVar from django.middleware.csrf import CsrfViewMiddleware diff --git a/django-stubs/views/decorators/debug.pyi b/django-stubs/views/decorators/debug.pyi index e437d4e1f..35d8e37eb 100644 --- a/django-stubs/views/decorators/debug.pyi +++ b/django-stubs/views/decorators/debug.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable +from collections.abc import Callable +from typing import Any def sensitive_variables(*variables: Any) -> Callable: ... def sensitive_post_parameters(*parameters: Any) -> Callable: ... diff --git a/django-stubs/views/decorators/gzip.pyi b/django-stubs/views/decorators/gzip.pyi index c723517d9..9a9de9880 100644 --- a/django-stubs/views/decorators/gzip.pyi +++ b/django-stubs/views/decorators/gzip.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, TypeVar +from collections.abc import Callable +from typing import Any, TypeVar _C = TypeVar("_C", bound=Callable[..., Any]) diff --git a/django-stubs/views/decorators/http.pyi b/django-stubs/views/decorators/http.pyi index cc5f99379..cc0ca96de 100644 --- a/django-stubs/views/decorators/http.pyi +++ b/django-stubs/views/decorators/http.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Container, TypeVar +from collections.abc import Callable +from typing import Any, Container, TypeVar _F = TypeVar("_F", bound=Callable[..., Any]) diff --git a/django-stubs/views/decorators/vary.pyi b/django-stubs/views/decorators/vary.pyi index 0601a4ae6..191a3eaa1 100644 --- a/django-stubs/views/decorators/vary.pyi +++ b/django-stubs/views/decorators/vary.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, TypeVar +from collections.abc import Callable +from typing import Any, TypeVar _F = TypeVar("_F", bound=Callable[..., Any]) diff --git a/django-stubs/views/generic/base.pyi b/django-stubs/views/generic/base.pyi index 751dd2c1b..6f38e27e1 100644 --- a/django-stubs/views/generic/base.pyi +++ b/django-stubs/views/generic/base.pyi @@ -1,14 +1,15 @@ -from typing import Any, Callable, Dict, List, Type +from collections.abc import Callable +from typing import Any from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponseBase class ContextMixin: - extra_context: Dict[str, Any] | None - def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... + extra_context: dict[str, Any] | None + def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ... class View: - http_method_names: List[str] + http_method_names: list[str] request: HttpRequest args: Any kwargs: Any @@ -23,11 +24,11 @@ class View: class TemplateResponseMixin: template_name: str template_engine: str | None - response_class: Type[HttpResponse] + response_class: type[HttpResponse] content_type: str | None request: HttpRequest - def render_to_response(self, context: Dict[str, Any], **response_kwargs: Any) -> HttpResponse: ... - def get_template_names(self) -> List[str]: ... + def render_to_response(self, context: dict[str, Any], **response_kwargs: Any) -> HttpResponse: ... + def get_template_names(self) -> list[str]: ... class TemplateView(TemplateResponseMixin, ContextMixin, View): def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... diff --git a/django-stubs/views/generic/dates.pyi b/django-stubs/views/generic/dates.pyi index 533d6558d..50a9adc85 100644 --- a/django-stubs/views/generic/dates.pyi +++ b/django-stubs/views/generic/dates.pyi @@ -1,5 +1,6 @@ import datetime -from typing import Any, Dict, Sequence, Tuple, TypeVar +from collections.abc import Sequence +from typing import Any, TypeVar from django.db import models from django.db.models.query import QuerySet @@ -51,7 +52,7 @@ class DateMixin: @property def uses_datetime_field(self) -> bool: ... -DatedItems = Tuple[_IndexableCollection[datetime.date] | None, _IndexableCollection[_M], Dict[str, Any]] +DatedItems = tuple[_IndexableCollection[datetime.date] | None, _IndexableCollection[_M], dict[str, Any]] class BaseDateListView(MultipleObjectMixin[_M], DateMixin, View): date_list_period: str diff --git a/django-stubs/views/generic/detail.pyi b/django-stubs/views/generic/detail.pyi index 2d92a8acd..a833c72cc 100644 --- a/django-stubs/views/generic/detail.pyi +++ b/django-stubs/views/generic/detail.pyi @@ -1,4 +1,4 @@ -from typing import Any, Generic, Type, TypeVar +from typing import Any, Generic, TypeVar from django.db import models from django.http import HttpRequest, HttpResponse @@ -7,7 +7,7 @@ from django.views.generic.base import ContextMixin, TemplateResponseMixin, View _M = TypeVar("_M", bound=models.Model) class SingleObjectMixin(Generic[_M], ContextMixin): - model: Type[_M] + model: type[_M] queryset: models.query.QuerySet[_M] | None slug_field: str context_object_name: str | None diff --git a/django-stubs/views/generic/edit.pyi b/django-stubs/views/generic/edit.pyi index 93e0463e9..7c024440a 100644 --- a/django-stubs/views/generic/edit.pyi +++ b/django-stubs/views/generic/edit.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Generic, Type, TypeVar +from typing import Any, Generic, TypeVar from django.db import models from django.forms.forms import BaseForm @@ -14,24 +14,24 @@ _ModelFormT = TypeVar("_ModelFormT", bound=BaseModelForm) _M = TypeVar("_M", bound=models.Model) class FormMixin(Generic[_FormT], ContextMixin): - initial: Dict[str, Any] - form_class: Type[_FormT] | None + initial: dict[str, Any] + form_class: type[_FormT] | None success_url: str | None prefix: str | None - def get_initial(self) -> Dict[str, Any]: ... + def get_initial(self) -> dict[str, Any]: ... def get_prefix(self) -> str | None: ... - def get_form_class(self) -> Type[_FormT]: ... - def get_form(self, form_class: Type[_FormT] | None = ...) -> _FormT: ... - def get_form_kwargs(self) -> Dict[str, Any]: ... + def get_form_class(self) -> type[_FormT]: ... + def get_form(self, form_class: type[_FormT] | None = ...) -> _FormT: ... + def get_form_kwargs(self) -> dict[str, Any]: ... def get_success_url(self) -> str: ... def form_valid(self, form: _FormT) -> HttpResponse: ... def form_invalid(self, form: _FormT) -> HttpResponse: ... - def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... + def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ... class ModelFormMixin(Generic[_M, _ModelFormT], FormMixin[_ModelFormT], SingleObjectMixin[_M]): fields: _ListOrTuple[str] | Literal["__all__"] | None - def get_form_class(self) -> Type[_ModelFormT]: ... - def get_form_kwargs(self) -> Dict[str, Any]: ... + def get_form_class(self) -> type[_ModelFormT]: ... + def get_form_kwargs(self) -> dict[str, Any]: ... def get_success_url(self) -> str: ... def form_valid(self, form: _ModelFormT) -> HttpResponse: ... diff --git a/django-stubs/views/generic/list.pyi b/django-stubs/views/generic/list.pyi index 4a42a153e..89c273ee0 100644 --- a/django-stubs/views/generic/list.pyi +++ b/django-stubs/views/generic/list.pyi @@ -1,4 +1,5 @@ -from typing import Any, Generic, Sequence, Tuple, Type, TypeVar +from collections.abc import Sequence +from typing import Any, Generic, TypeVar from django.core.paginator import Page, Paginator, _SupportsPagination from django.db.models import Model @@ -10,18 +11,18 @@ _M = TypeVar("_M", bound=Model, covariant=True) class MultipleObjectMixin(Generic[_M], ContextMixin): allow_empty: bool queryset: _SupportsPagination[_M] | None - model: Type[_M] | None + model: type[_M] | None paginate_by: int paginate_orphans: int context_object_name: str | None - paginator_class: Type[Paginator] + paginator_class: type[Paginator] page_kwarg: str ordering: str | Sequence[str] | None def get_queryset(self) -> _SupportsPagination[_M]: ... def get_ordering(self) -> str | Sequence[str] | None: ... def paginate_queryset( self, queryset: _SupportsPagination[_M], page_size: int - ) -> Tuple[Paginator, Page, _SupportsPagination[_M], bool]: ... + ) -> tuple[Paginator, Page, _SupportsPagination[_M], bool]: ... def get_paginate_by(self, queryset: _SupportsPagination[_M]) -> int | None: ... def get_paginator( self, diff --git a/django-stubs/views/i18n.pyi b/django-stubs/views/i18n.pyi index b33b53696..4c242f5b3 100644 --- a/django-stubs/views/i18n.pyi +++ b/django-stubs/views/i18n.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, List +from collections.abc import Callable +from typing import Any from django.http.request import HttpRequest from django.http.response import HttpResponse @@ -8,20 +9,20 @@ from django.views.generic import View LANGUAGE_QUERY_PARAMETER: str def set_language(request: HttpRequest) -> HttpResponse: ... -def get_formats() -> Dict[str, List[str] | int | str]: ... +def get_formats() -> dict[str, list[str] | int | str]: ... js_catalog_template: str class JavaScriptCatalog(View): head: Callable domain: str - packages: List[str] + packages: list[str] translation: DjangoTranslation def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... - def get_paths(self, packages: List[str]) -> List[str]: ... - def get_plural(self) -> List[str] | None: ... - def get_catalog(self) -> Dict[str, List[str] | str]: ... - def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... - def render_to_response(self, context: Dict[str, Any], **response_kwargs: Any) -> HttpResponse: ... + def get_paths(self, packages: list[str]) -> list[str]: ... + def get_plural(self) -> list[str] | None: ... + def get_catalog(self) -> dict[str, list[str] | str]: ... + def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ... + def render_to_response(self, context: dict[str, Any], **response_kwargs: Any) -> HttpResponse: ... class JSONCatalog(JavaScriptCatalog): ... From add6b4ce2fc2815c632944255beecee15e1ebd1a Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sun, 13 Nov 2022 15:10:32 +0100 Subject: [PATCH 09/13] allow isort to reorder non-top imports Signed-off-by: Oleg Hoefling --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 5c6ab2679..17b12804f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,7 @@ profile = 'black' line_length = 120 multi_line_output = 3 include_trailing_comma = true +float_to_top = true [build-system] requires = ["setuptools<64", "wheel"] From ba6c37d4fc1a0c9dbca2636b9b2896a501a0feec Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sun, 13 Nov 2022 15:11:36 +0100 Subject: [PATCH 10/13] finish PEP 585 changes, use PEP 613 where possible Signed-off-by: Oleg Hoefling --- django-stubs/conf/global_settings.pyi | 5 ++-- django-stubs/conf/urls/__init__.pyi | 3 ++- django-stubs/contrib/admin/options.pyi | 12 +++++----- django-stubs/contrib/admin/sites.pyi | 5 ++-- django-stubs/contrib/admindocs/views.pyi | 3 ++- django-stubs/contrib/auth/backends.pyi | 3 ++- django-stubs/contrib/auth/models.pyi | 4 ++-- .../contrib/auth/password_validation.pyi | 3 ++- django-stubs/contrib/gis/measure.pyi | 7 ++++-- django-stubs/contrib/postgres/search.pyi | 3 ++- django-stubs/contrib/sessions/serializers.pyi | 3 ++- django-stubs/contrib/staticfiles/handlers.pyi | 4 ++-- django-stubs/contrib/staticfiles/storage.pyi | 3 ++- django-stubs/core/checks/registry.pyi | 5 ++-- django-stubs/core/handlers/asgi.pyi | 10 ++++---- django-stubs/core/handlers/base.pyi | 4 ++-- django-stubs/core/handlers/exception.pyi | 4 ++-- django-stubs/core/handlers/wsgi.pyi | 3 ++- django-stubs/core/mail/message.pyi | 11 +++++---- .../core/management/commands/makemessages.pyi | 3 ++- .../core/management/commands/migrate.pyi | 3 ++- django-stubs/core/paginator.pyi | 3 ++- django-stubs/core/validators.pyi | 12 ++++++---- django-stubs/db/backends/base/base.pyi | 5 +++- .../db/backends/base/introspection.pyi | 1 + django-stubs/db/backends/base/schema.pyi | 5 ++-- django-stubs/db/backends/mysql/base.pyi | 4 ++-- django-stubs/db/backends/utils.pyi | 8 +++---- django-stubs/db/models/expressions.pyi | 4 ++-- django-stubs/db/models/fields/__init__.pyi | 17 +++++++------- django-stubs/db/models/options.pyi | 4 ++-- django-stubs/db/models/query.pyi | 5 ++-- django-stubs/db/models/sql/compiler.pyi | 9 ++++---- django-stubs/db/models/sql/constants.pyi | 2 +- django-stubs/forms/boundfield.pyi | 3 ++- django-stubs/forms/fields.pyi | 6 +++-- django-stubs/forms/models.pyi | 17 +++++++------- django-stubs/forms/utils.pyi | 6 +++-- django-stubs/forms/widgets.pyi | 4 ++-- django-stubs/http/request.pyi | 7 +++--- django-stubs/template/__init__.pyi | 9 ++++---- django-stubs/template/base.pyi | 3 ++- django-stubs/template/context.pyi | 6 +++-- django-stubs/template/engine.pyi | 3 ++- django-stubs/template/response.pyi | 3 ++- django-stubs/template/smartif.pyi | 3 ++- django-stubs/test/client.pyi | 5 ++-- django-stubs/test/html.pyi | 4 +++- django-stubs/test/utils.pyi | 23 ++++++++++--------- django-stubs/urls/__init__.pyi | 4 +++- django-stubs/urls/conf.pyi | 3 ++- django-stubs/urls/resolvers.pyi | 6 +++-- django-stubs/utils/_os.pyi | 4 +++- django-stubs/utils/datastructures.pyi | 8 +++---- django-stubs/utils/dateformat.pyi | 3 ++- django-stubs/utils/dateparse.pyi | 2 +- django-stubs/utils/deprecation.pyi | 3 ++- django-stubs/utils/feedgenerator.pyi | 4 +++- django-stubs/utils/functional.pyi | 4 ++-- django-stubs/utils/html.pyi | 3 ++- django-stubs/utils/http.pyi | 3 ++- django-stubs/utils/regex_helper.pyi | 3 ++- django-stubs/utils/safestring.pyi | 4 +++- django-stubs/utils/text.pyi | 2 +- django-stubs/utils/timezone.pyi | 7 +++--- django-stubs/utils/translation/__init__.pyi | 1 + django-stubs/utils/translation/template.pyi | 2 +- django-stubs/utils/translation/trans_real.pyi | 9 +++++--- django-stubs/utils/tree.pyi | 3 ++- django-stubs/utils/version.pyi | 4 +++- django-stubs/views/debug.pyi | 4 ++-- django-stubs/views/decorators/http.pyi | 4 ++-- django-stubs/views/generic/dates.pyi | 3 ++- 73 files changed, 224 insertions(+), 151 deletions(-) diff --git a/django-stubs/conf/global_settings.pyi b/django-stubs/conf/global_settings.pyi index d90d8c7c8..86fe8ce4b 100644 --- a/django-stubs/conf/global_settings.pyi +++ b/django-stubs/conf/global_settings.pyi @@ -3,12 +3,13 @@ Default Django settings. Override these with settings in the module pointed to by the DJANGO_SETTINGS_MODULE environment variable. """ from collections.abc import Sequence +from re import Pattern # This is defined here as a do-nothing function because we can't import # django.utils.translation -- that module depends on the settings. -from typing import Any, Pattern, Protocol +from typing import Any, Protocol -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias #################### # CORE # diff --git a/django-stubs/conf/urls/__init__.pyi b/django-stubs/conf/urls/__init__.pyi index bc830bd1c..6711367bd 100644 --- a/django-stubs/conf/urls/__init__.pyi +++ b/django-stubs/conf/urls/__init__.pyi @@ -5,13 +5,14 @@ from typing import Any, overload from django.http.response import HttpResponse, HttpResponseBase from django.urls import URLPattern, URLResolver from django.urls import include as include +from typing_extensions import TypeAlias handler400: str | Callable[..., HttpResponse] handler403: str | Callable[..., HttpResponse] handler404: str | Callable[..., HttpResponse] handler500: str | Callable[..., HttpResponse] -IncludedURLConf = tuple[Sequence[URLResolver | URLPattern], str | None, str | None] +IncludedURLConf: TypeAlias = tuple[Sequence[URLResolver | URLPattern], str | None, str | None] # Deprecated @overload diff --git a/django-stubs/contrib/admin/options.pyi b/django-stubs/contrib/admin/options.pyi index 622ffd8ef..5ccbde0e2 100644 --- a/django-stubs/contrib/admin/options.pyi +++ b/django-stubs/contrib/admin/options.pyi @@ -34,14 +34,14 @@ from django.urls.resolvers import URLPattern from django.utils.datastructures import _ListOrTuple from django.utils.functional import _StrOrPromise from django.utils.safestring import SafeString -from typing_extensions import Literal, TypedDict +from typing_extensions import Literal, TypeAlias, TypedDict IS_POPUP_VAR: str TO_FIELD_VAR: str HORIZONTAL: Literal[1] VERTICAL: Literal[2] -_Direction = Union[Literal[1], Literal[2]] +_Direction: TypeAlias = Union[Literal[1], Literal[2]] def get_content_type_for_model(obj: type[Model] | Model) -> ContentType: ... def get_ul_class(radio_style: int) -> str: ... @@ -51,7 +51,7 @@ class IncorrectLookupParameters(Exception): ... FORMFIELD_FOR_DBFIELD_DEFAULTS: Any csrf_protect_m: Any -_FieldGroups = Sequence[Union[str, Sequence[str]]] +_FieldGroups: TypeAlias = Sequence[Union[str, Sequence[str]]] class _OptionalFieldOpts(TypedDict, total=False): classes: Sequence[str] @@ -63,8 +63,8 @@ class _FieldOpts(_OptionalFieldOpts, total=True): # Workaround for mypy issue, a Sequence type should be preferred here. # https://github.com/python/mypy/issues/8921 # _FieldsetSpec = Sequence[Tuple[Optional[str], _FieldOpts]] -_FieldsetSpec = _ListOrTuple[tuple[Optional[_StrOrPromise], _FieldOpts]] -_ListFilterT = Union[ +_FieldsetSpec: TypeAlias = _ListOrTuple[tuple[Optional[_StrOrPromise], _FieldOpts]] +_ListFilterT: TypeAlias = Union[ type[ListFilter], Field, str, @@ -129,7 +129,7 @@ class BaseModelAdmin(Generic[_ModelT]): def has_view_or_change_permission(self, request: HttpRequest, obj: _ModelT | None = ...) -> bool: ... def has_module_permission(self, request: HttpRequest) -> bool: ... -_DisplayT = _ListOrTuple[str | Callable[[_ModelT], str]] +_DisplayT: TypeAlias = _ListOrTuple[str | Callable[[_ModelT], str]] class ModelAdmin(BaseModelAdmin[_ModelT]): list_display: _DisplayT diff --git a/django-stubs/contrib/admin/sites.pyi b/django-stubs/contrib/admin/sites.pyi index ae80b4f76..b76a290f6 100644 --- a/django-stubs/contrib/admin/sites.pyi +++ b/django-stubs/contrib/admin/sites.pyi @@ -13,17 +13,18 @@ from django.http.response import HttpResponse from django.template.response import TemplateResponse from django.urls import URLPattern, URLResolver from django.utils.functional import LazyObject, _StrOrPromise +from typing_extensions import TypeAlias if sys.version_info >= (3, 9): from weakref import WeakSet all_sites: WeakSet[AdminSite] else: - from typing import MutableSet + from collections.abc import MutableSet all_sites: MutableSet[AdminSite] -_ActionCallback = Callable[[ModelAdmin, HttpRequest, QuerySet], TemplateResponse | None] +_ActionCallback: TypeAlias = Callable[[ModelAdmin, HttpRequest, QuerySet], TemplateResponse | None] class AlreadyRegistered(Exception): ... class NotRegistered(Exception): ... diff --git a/django-stubs/contrib/admindocs/views.pyi b/django-stubs/contrib/admindocs/views.pyi index 68051690e..0c19bb5d7 100644 --- a/django-stubs/contrib/admindocs/views.pyi +++ b/django-stubs/contrib/admindocs/views.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Iterable -from typing import Any, Pattern +from re import Pattern +from typing import Any from django.db.models.fields import Field from django.urls import _AnyURL diff --git a/django-stubs/contrib/auth/backends.pyi b/django-stubs/contrib/auth/backends.pyi index 1a4e9ad68..86c68c985 100644 --- a/django-stubs/contrib/auth/backends.pyi +++ b/django-stubs/contrib/auth/backends.pyi @@ -5,8 +5,9 @@ from django.contrib.auth.models import AnonymousUser, Permission from django.db.models import QuerySet from django.db.models.base import Model from django.http.request import HttpRequest +from typing_extensions import TypeAlias -_AnyUser = AbstractBaseUser | AnonymousUser +_AnyUser: TypeAlias = AbstractBaseUser | AnonymousUser UserModel: Any diff --git a/django-stubs/contrib/auth/models.pyi b/django-stubs/contrib/auth/models.pyi index 017982390..54daa18c4 100644 --- a/django-stubs/contrib/auth/models.pyi +++ b/django-stubs/contrib/auth/models.pyi @@ -9,9 +9,9 @@ from django.db import models from django.db.models import QuerySet from django.db.models.base import Model from django.db.models.manager import EmptyManager -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias -_AnyUser = Model | "AnonymousUser" +_AnyUser: TypeAlias = Model | "AnonymousUser" def update_last_login(sender: type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ... diff --git a/django-stubs/contrib/auth/password_validation.pyi b/django-stubs/contrib/auth/password_validation.pyi index b9a124244..806d87871 100644 --- a/django-stubs/contrib/auth/password_validation.pyi +++ b/django-stubs/contrib/auth/password_validation.pyi @@ -3,8 +3,9 @@ from pathlib import Path, PosixPath from typing import Any, Protocol from django.db.models.base import Model +from typing_extensions import TypeAlias -_UserModel = Model +_UserModel: TypeAlias = Model class PasswordValidator(Protocol): def validate(self, __password: str, __user: _UserModel | None = ...) -> None: ... diff --git a/django-stubs/contrib/gis/measure.pyi b/django-stubs/contrib/gis/measure.pyi index 2db984648..4263a6fd5 100644 --- a/django-stubs/contrib/gis/measure.pyi +++ b/django-stubs/contrib/gis/measure.pyi @@ -1,5 +1,7 @@ from typing import Any +from typing_extensions import TypeAlias + class MeasureBase: STANDARD_UNIT: Any ALIAS: Any @@ -38,5 +40,6 @@ class Area(MeasureBase): LALIAS: Any def __truediv__(self, other: Any) -> Any: ... -D = Distance -A = Area +D: TypeAlias = Distance + +A: TypeAlias = Area diff --git a/django-stubs/contrib/postgres/search.pyi b/django-stubs/contrib/postgres/search.pyi index 5896ddb8b..4f86d946b 100644 --- a/django-stubs/contrib/postgres/search.pyi +++ b/django-stubs/contrib/postgres/search.pyi @@ -3,8 +3,9 @@ from typing import Any, TypeVar from django.db.models import Expression, Field from django.db.models.expressions import Combinable, CombinedExpression, Func, Value from django.db.models.lookups import Lookup +from typing_extensions import TypeAlias -_Expression = str | Combinable | "SearchQueryCombinable" +_Expression: TypeAlias = str | Combinable | "SearchQueryCombinable" class SearchVectorExact(Lookup): ... class SearchVectorField(Field): ... diff --git a/django-stubs/contrib/sessions/serializers.pyi b/django-stubs/contrib/sessions/serializers.pyi index ac0b34a66..261819a46 100644 --- a/django-stubs/contrib/sessions/serializers.pyi +++ b/django-stubs/contrib/sessions/serializers.pyi @@ -1,8 +1,9 @@ from django.core.signing import JSONSerializer as BaseJSONSerializer from django.db.models.base import Model +from typing_extensions import TypeAlias class PickleSerializer: def dumps(self, obj: dict[str, Model]) -> bytes: ... def loads(self, data: bytes) -> dict[str, Model]: ... -JSONSerializer = BaseJSONSerializer +JSONSerializer: TypeAlias = BaseJSONSerializer diff --git a/django-stubs/contrib/staticfiles/handlers.pyi b/django-stubs/contrib/staticfiles/handlers.pyi index b907953cc..d20e7f003 100644 --- a/django-stubs/contrib/staticfiles/handlers.pyi +++ b/django-stubs/contrib/staticfiles/handlers.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Mapping, Sequence -from typing import Any, Awaitable +from collections.abc import Awaitable, Callable, Mapping, Sequence +from typing import Any from urllib.parse import ParseResult from django.core.handlers.asgi import ASGIHandler diff --git a/django-stubs/contrib/staticfiles/storage.pyi b/django-stubs/contrib/staticfiles/storage.pyi index 6c5dc892c..0098153f9 100644 --- a/django-stubs/contrib/staticfiles/storage.pyi +++ b/django-stubs/contrib/staticfiles/storage.pyi @@ -5,8 +5,9 @@ from django.core.files.base import File from django.core.files.storage import FileSystemStorage, Storage from django.utils._os import _PathCompatible from django.utils.functional import LazyObject +from typing_extensions import TypeAlias -_PostProcessT = Iterator[tuple[str, str, bool] | tuple[str, None, RuntimeError]] +_PostProcessT: TypeAlias = Iterator[tuple[str, str, bool] | tuple[str, None, RuntimeError]] class StaticFilesStorage(FileSystemStorage): base_location: str diff --git a/django-stubs/core/checks/registry.pyi b/django-stubs/core/checks/registry.pyi index 59f7cc90f..fef7597ca 100644 --- a/django-stubs/core/checks/registry.pyi +++ b/django-stubs/core/checks/registry.pyi @@ -3,7 +3,7 @@ from typing import Any, TypeVar from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage -from typing_extensions import Protocol +from typing_extensions import Protocol, TypeAlias class Tags: admin: str @@ -19,7 +19,8 @@ class Tags: translation: str urls: str -_CheckCallable = Callable[..., Sequence[CheckMessage]] +_CheckCallable: TypeAlias = Callable[..., Sequence[CheckMessage]] + _C = TypeVar("_C", bound=_CheckCallable) class _ProcessedCheckCallable(Protocol[_C]): diff --git a/django-stubs/core/handlers/asgi.pyi b/django-stubs/core/handlers/asgi.pyi index b399f4262..88621620e 100644 --- a/django-stubs/core/handlers/asgi.pyi +++ b/django-stubs/core/handlers/asgi.pyi @@ -1,14 +1,16 @@ -from collections.abc import Callable, Iterator, Mapping, Sequence -from typing import IO, Any, Awaitable, TypeVar +from collections.abc import Awaitable, Callable, Iterator, Mapping, Sequence +from typing import IO, Any, TypeVar from django.core.handlers import base as base from django.http.request import HttpRequest, _ImmutableQueryDict from django.http.response import HttpResponseBase from django.urls.resolvers import ResolverMatch, URLResolver from django.utils.datastructures import MultiValueDict +from typing_extensions import TypeAlias -_ReceiveCallback = Callable[[], Awaitable[Mapping[str, Any]]] -_SendCallback = Callable[[Mapping[str, Any]], Awaitable[None]] +_ReceiveCallback: TypeAlias = Callable[[], Awaitable[Mapping[str, Any]]] + +_SendCallback: TypeAlias = Callable[[Mapping[str, Any]], Awaitable[None]] class ASGIRequest(HttpRequest): body_receive_timeout: int diff --git a/django-stubs/core/handlers/base.pyi b/django-stubs/core/handlers/base.pyi index 15cdcd3ff..fa1c9c350 100644 --- a/django-stubs/core/handlers/base.pyi +++ b/django-stubs/core/handlers/base.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable -from typing import Any, Awaitable +from collections.abc import Awaitable, Callable +from typing import Any from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponseBase diff --git a/django-stubs/core/handlers/exception.pyi b/django-stubs/core/handlers/exception.pyi index 488ee3864..7edff206a 100644 --- a/django-stubs/core/handlers/exception.pyi +++ b/django-stubs/core/handlers/exception.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable -from typing import Any, Awaitable +from collections.abc import Awaitable, Callable +from typing import Any from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponseBase diff --git a/django-stubs/core/handlers/wsgi.pyi b/django-stubs/core/handlers/wsgi.pyi index e529a45bc..0abf98ba9 100644 --- a/django-stubs/core/handlers/wsgi.pyi +++ b/django-stubs/core/handlers/wsgi.pyi @@ -6,8 +6,9 @@ from django.contrib.sessions.backends.base import SessionBase from django.core.handlers import base from django.http import HttpRequest from django.http.response import HttpResponseBase +from typing_extensions import TypeAlias -_WSGIEnviron = dict[str, Any] +_WSGIEnviron: TypeAlias = dict[str, Any] class LimitedStream: stream: BytesIO diff --git a/django-stubs/core/mail/message.pyi b/django-stubs/core/mail/message.pyi index 5f15d3759..3c4dcae8f 100644 --- a/django-stubs/core/mail/message.pyi +++ b/django-stubs/core/mail/message.pyi @@ -6,7 +6,9 @@ from email.mime.base import MIMEBase from email.mime.message import MIMEMessage from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText -from typing import Any, overload +from typing import Any, Tuple, overload + +from typing_extensions import TypeAlias utf8_charset: Any utf8_charset_qp: Any @@ -59,9 +61,10 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): # type: ignore ) -> None: ... def __setitem__(self, name: str, val: str) -> None: ... -_AttachmentContent = bytes | EmailMessage | Message | SafeMIMEText | str -_AttachmentTuple = ( - tuple[str, _AttachmentContent] | tuple[str | None, _AttachmentContent, str] | tuple[str, _AttachmentContent, None] +_AttachmentContent: TypeAlias = bytes | EmailMessage | Message | SafeMIMEText | str +# switch to tuple once https://github.com/python/mypy/issues/11098 is fixed +_AttachmentTuple: TypeAlias = ( + Tuple[str, _AttachmentContent] | Tuple[str | None, _AttachmentContent, str] | Tuple[str, _AttachmentContent, None] ) class EmailMessage: diff --git a/django-stubs/core/management/commands/makemessages.pyi b/django-stubs/core/management/commands/makemessages.pyi index b9461e841..78def0673 100644 --- a/django-stubs/core/management/commands/makemessages.pyi +++ b/django-stubs/core/management/commands/makemessages.pyi @@ -1,4 +1,5 @@ -from typing import Any, Pattern +from re import Pattern +from typing import Any from django.core.management.base import BaseCommand diff --git a/django-stubs/core/management/commands/migrate.pyi b/django-stubs/core/management/commands/migrate.pyi index af3f423a4..786b9c969 100644 --- a/django-stubs/core/management/commands/migrate.pyi +++ b/django-stubs/core/management/commands/migrate.pyi @@ -1,4 +1,5 @@ -from typing import Any, Container +from collections.abc import Container +from typing import Any from django.apps import apps as apps from django.core.management.base import BaseCommand as BaseCommand diff --git a/django-stubs/core/paginator.pyi b/django-stubs/core/paginator.pyi index 9b34b97b4..147a117e3 100644 --- a/django-stubs/core/paginator.pyi +++ b/django-stubs/core/paginator.pyi @@ -3,6 +3,7 @@ from typing import Generic, Protocol, TypeVar, overload from django.db.models.base import Model from django.db.models.query import QuerySet +from typing_extensions import TypeAlias class UnorderedObjectListWarning(RuntimeWarning): ... class InvalidPage(Exception): ... @@ -43,7 +44,7 @@ class Paginator(Generic[_T]): self, number: int | float | str = ..., *, on_each_side: int = ..., on_ends: int = ... ) -> Iterator[str | int]: ... -QuerySetPaginator = Paginator +QuerySetPaginator: TypeAlias = Paginator class Page(Sequence[_T]): object_list: _SupportsPagination[_T] diff --git a/django-stubs/core/validators.pyi b/django-stubs/core/validators.pyi index 22e386220..459d6af07 100644 --- a/django-stubs/core/validators.pyi +++ b/django-stubs/core/validators.pyi @@ -1,15 +1,17 @@ from collections.abc import Callable, Collection, Sequence, Sized from decimal import Decimal -from re import RegexFlag -from typing import Any, Pattern +from re import Pattern, RegexFlag +from typing import Any from django.core.files.base import File from django.utils.functional import _StrPromise +from typing_extensions import TypeAlias EMPTY_VALUES: Any -_Regex = str | Pattern[str] -_ValidatorCallable = Callable[[Any], None] +_Regex: TypeAlias = str | Pattern[str] + +_ValidatorCallable: TypeAlias = Callable[[Any], None] class RegexValidator: regex: _Regex # Pattern[str] on instance, but may be str on class definition @@ -76,7 +78,7 @@ def validate_ipv4_address(value: str) -> None: ... def validate_ipv6_address(value: str) -> None: ... def validate_ipv46_address(value: str) -> None: ... -_IPValidator = tuple[list[Callable[[Any], None]], str] +_IPValidator: TypeAlias = tuple[list[Callable[[Any], None]], str] ip_address_validator_map: dict[str, _IPValidator] def ip_address_validators(protocol: str, unpack_ipv4: bool) -> _IPValidator: ... diff --git a/django-stubs/db/backends/base/base.pyi b/django-stubs/db/backends/base/base.pyi index b14db41e6..30acbd2a3 100644 --- a/django-stubs/db/backends/base/base.pyi +++ b/django-stubs/db/backends/base/base.pyi @@ -11,12 +11,15 @@ from django.db.backends.base.operations import BaseDatabaseOperations from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.backends.base.validation import BaseDatabaseValidation from django.db.backends.utils import CursorDebugWrapper, CursorWrapper +from typing_extensions import TypeAlias NO_DB_ALIAS: str RAN_DB_VERSION_CHECK: set[str] _T = TypeVar("_T", bound="BaseDatabaseWrapper") -_ExecuteWrapper = Callable[[Callable[[str, Any, bool, dict[str, Any]], Any], str, Any, bool, dict[str, Any]], Any] +_ExecuteWrapper: TypeAlias = Callable[ + [Callable[[str, Any, bool, dict[str, Any]], Any], str, Any, bool, dict[str, Any]], Any +] class BaseDatabaseWrapper: data_types: dict[str, str] diff --git a/django-stubs/db/backends/base/introspection.pyi b/django-stubs/db/backends/base/introspection.pyi index 46bfa697c..f1b4be249 100644 --- a/django-stubs/db/backends/base/introspection.pyi +++ b/django-stubs/db/backends/base/introspection.pyi @@ -7,6 +7,7 @@ from django.db.backends.utils import CursorWrapper from django.db.models.base import Model TableInfo = namedtuple("TableInfo", ["name", "type"]) + FieldInfo = namedtuple( "FieldInfo", ["name", "type_code", "display_size", "internal_size", "precision", "scale", "null_ok", "default", "collation"], diff --git a/django-stubs/db/backends/base/schema.pyi b/django-stubs/db/backends/base/schema.pyi index 1f1203a6e..706355f99 100644 --- a/django-stubs/db/backends/base/schema.pyi +++ b/django-stubs/db/backends/base/schema.pyi @@ -1,7 +1,8 @@ from collections.abc import Sequence +from contextlib import AbstractContextManager from logging import Logger from types import TracebackType -from typing import Any, ContextManager +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.ddl_references import Statement @@ -11,7 +12,7 @@ from django.db.models.indexes import Index logger: Logger -class BaseDatabaseSchemaEditor(ContextManager[Any]): +class BaseDatabaseSchemaEditor(AbstractContextManager[Any]): sql_create_table: str sql_rename_table: str sql_retablespace_table: str diff --git a/django-stubs/db/backends/mysql/base.pyi b/django-stubs/db/backends/mysql/base.pyi index af063131e..cfaa370a3 100644 --- a/django-stubs/db/backends/mysql/base.pyi +++ b/django-stubs/db/backends/mysql/base.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator -from typing import Any, Container +from collections.abc import Container, Iterator +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper as BaseDatabaseWrapper from typing_extensions import Literal diff --git a/django-stubs/db/backends/utils.pyi b/django-stubs/db/backends/utils.pyi index c2bbfe08b..b8d10754f 100644 --- a/django-stubs/db/backends/utils.pyi +++ b/django-stubs/db/backends/utils.pyi @@ -7,7 +7,7 @@ from types import TracebackType from typing import Any, Protocol, overload from uuid import UUID -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias logger: Logger @@ -17,10 +17,10 @@ class _Composable(Protocol): def __add__(self, other: _Composable) -> _Composable: ... def __mul__(self, n: int) -> _Composable: ... -_ExecuteQuery = str | _Composable +_ExecuteQuery: TypeAlias = str | _Composable # Python types that can be adapted to SQL. -_SQLType = ( +_SQLType: TypeAlias = ( None | bool | int @@ -34,7 +34,7 @@ _SQLType = ( | tuple[Any, ...] | list[Any] ) -_ExecuteParameters = Sequence[_SQLType] | Mapping[str, _SQLType] | None +_ExecuteParameters: TypeAlias = Sequence[_SQLType] | Mapping[str, _SQLType] | None class CursorWrapper: cursor: Any diff --git a/django-stubs/db/models/expressions.pyi b/django-stubs/db/models/expressions.pyi index ce6eb1615..fda668a2f 100644 --- a/django-stubs/db/models/expressions.pyi +++ b/django-stubs/db/models/expressions.pyi @@ -10,13 +10,13 @@ from django.db.models.lookups import Lookup, Transform from django.db.models.query import QuerySet from django.db.models.sql.compiler import SQLCompiler, _AsSqlType from django.db.models.sql.query import Query -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias class SQLiteNumericMixin: def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... _Self = TypeVar("_Self") -_Numeric = float | Decimal +_Numeric: TypeAlias = float | Decimal class Combinable: ADD: str diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 0635dd5ef..08f87745d 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -18,24 +18,25 @@ from django.forms import Field as FormField from django.forms import Widget from django.utils.datastructures import DictWrapper from django.utils.functional import _Getter, _StrOrPromise -from typing_extensions import Protocol +from typing_extensions import Protocol, TypeAlias class Empty: ... class NOT_PROVIDED: ... BLANK_CHOICE_DASH: list[tuple[str, str]] -_Choice = tuple[Any, Any] -_ChoiceNamedGroup = tuple[str, Iterable[_Choice]] -_FieldChoices = Iterable[_Choice | _ChoiceNamedGroup] -_ChoicesList = Sequence[_Choice] | Sequence[_ChoiceNamedGroup] -_LimitChoicesTo = Q | dict[str, Any] +_Choice: TypeAlias = tuple[Any, Any] + +_ChoiceNamedGroup: TypeAlias = tuple[str, Iterable[_Choice]] +_FieldChoices: TypeAlias = Iterable[_Choice | _ChoiceNamedGroup] +_ChoicesList: TypeAlias = Sequence[_Choice] | Sequence[_ChoiceNamedGroup] +_LimitChoicesTo: TypeAlias = Q | dict[str, Any] class _ChoicesCallable(Protocol): def __call__(self) -> _FieldChoices: ... -_AllLimitChoicesTo = _LimitChoicesTo | _ChoicesCallable -_ErrorMessagesT = dict[str, Any] +_AllLimitChoicesTo: TypeAlias = _LimitChoicesTo | _ChoicesCallable +_ErrorMessagesT: TypeAlias = dict[str, Any] _T = TypeVar("_T", bound="Field") # __set__ value type diff --git a/django-stubs/db/models/options.pyi b/django-stubs/db/models/options.pyi index 2c3d8c3e1..300603285 100644 --- a/django-stubs/db/models/options.pyi +++ b/django-stubs/db/models/options.pyi @@ -14,14 +14,14 @@ from django.db.models.manager import Manager from django.db.models.query_utils import PathInfo from django.utils.datastructures import ImmutableList, _ListOrTuple from django.utils.functional import _StrOrPromise -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias PROXY_PARENTS: object EMPTY_RELATION_TREE: Any IMMUTABLE_WARNING: str DEFAULT_NAMES: tuple[str, ...] -_OptionTogetherT = Union[_ListOrTuple[Union[_ListOrTuple[str], str]], set[tuple[str, ...]]] +_OptionTogetherT: TypeAlias = Union[_ListOrTuple[Union[_ListOrTuple[str], str]], set[tuple[str, ...]]] @overload def normalize_together(option_together: _ListOrTuple[_ListOrTuple[str] | str]) -> tuple[tuple[str, ...], ...]: ... diff --git a/django-stubs/db/models/query.pyi b/django-stubs/db/models/query.pyi index d358d8aac..8871bf446 100644 --- a/django-stubs/db/models/query.pyi +++ b/django-stubs/db/models/query.pyi @@ -8,6 +8,7 @@ from django.db.models.expressions import Combinable as Combinable # noqa: F401 from django.db.models.expressions import F as F from django.db.models.query_utils import Q as Q # noqa: F401 from django.db.models.sql.query import Query, RawQuery +from typing_extensions import TypeAlias _T = TypeVar("_T", bound=Model, covariant=True) _Row = TypeVar("_Row", covariant=True) @@ -213,9 +214,9 @@ class RawQuerySet(Iterable[_T], Sized): def resolve_model_init_order(self) -> tuple[list[str], list[int], list[tuple[str, int]]]: ... def using(self, alias: str | None) -> RawQuerySet[_T]: ... -_QuerySetAny = _QuerySet +_QuerySetAny: TypeAlias = _QuerySet -QuerySet = _QuerySet[_T, _T] +QuerySet: TypeAlias = _QuerySet[_T, _T] class Prefetch: prefetch_through: str diff --git a/django-stubs/db/models/sql/compiler.pyi b/django-stubs/db/models/sql/compiler.pyi index a38344582..c20542a11 100644 --- a/django-stubs/db/models/sql/compiler.pyi +++ b/django-stubs/db/models/sql/compiler.pyi @@ -10,11 +10,12 @@ from django.db.models.base import Model from django.db.models.expressions import BaseExpression, Expression from django.db.models.sql.query import Query from django.db.models.sql.subqueries import AggregateQuery, DeleteQuery, InsertQuery, UpdateQuery -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias -_ParamT = str | int -_ParamsT = list[_ParamT] -_AsSqlType = tuple[str, _ParamsT] +_ParamT: TypeAlias = str | int + +_ParamsT: TypeAlias = list[_ParamT] +_AsSqlType: TypeAlias = tuple[str, _ParamsT] class SQLCompiler: query: Query diff --git a/django-stubs/db/models/sql/constants.pyi b/django-stubs/db/models/sql/constants.pyi index 36c2cda05..a6b068a3c 100644 --- a/django-stubs/db/models/sql/constants.pyi +++ b/django-stubs/db/models/sql/constants.pyi @@ -1,4 +1,4 @@ -from typing import Pattern +from re import Pattern from typing_extensions import Final, Literal diff --git a/django-stubs/forms/boundfield.pyi b/django-stubs/forms/boundfield.pyi index 0864e66d8..25b8c223b 100644 --- a/django-stubs/forms/boundfield.pyi +++ b/django-stubs/forms/boundfield.pyi @@ -8,8 +8,9 @@ from django.forms.utils import ErrorList from django.forms.widgets import Widget from django.utils.functional import _StrOrPromise from django.utils.safestring import SafeString +from typing_extensions import TypeAlias -_AttrsT = dict[str, str | bool] +_AttrsT: TypeAlias = dict[str, str | bool] class BoundField: form: BaseForm diff --git a/django-stubs/forms/fields.pyi b/django-stubs/forms/fields.pyi index 14684a072..aec81189f 100644 --- a/django-stubs/forms/fields.pyi +++ b/django-stubs/forms/fields.pyi @@ -1,7 +1,8 @@ import datetime from collections.abc import Collection, Iterator, Sequence from decimal import Decimal -from typing import Any, Pattern, Protocol +from re import Pattern +from typing import Any, Protocol from uuid import UUID from django.core.files import File @@ -12,6 +13,7 @@ from django.forms.forms import BaseForm from django.forms.widgets import ChoiceWidget, Widget from django.utils.datastructures import _PropertyDescriptor from django.utils.functional import _StrOrPromise +from typing_extensions import TypeAlias # Problem: attribute `widget` is always of type `Widget` after field instantiation. # However, on class level it can be set to `Type[Widget]` too. @@ -20,7 +22,7 @@ from django.utils.functional import _StrOrPromise # If we annotate it as `Widget`, any widget subclasses that do e.g. # `widget = Select` will not typecheck. # `Any` gives too much freedom, but does not create false positives. -_ClassLevelWidgetT = Any +_ClassLevelWidgetT: TypeAlias = Any class Field: initial: Any diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index 12a5420b2..69fcadf37 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Collection, Iterator, Mapping, Sequence -from typing import Any, ClassVar, Container, Generic, TypeAlias, TypeVar, Union, overload +from collections.abc import Callable, Collection, Container, Iterator, Mapping, Sequence +from typing import Any, ClassVar, Generic, TypeAlias, TypeVar, Union, overload from uuid import UUID from django.db import models @@ -17,16 +17,17 @@ from django.forms.utils import ErrorList, _DataT, _FilesT from django.forms.widgets import ChoiceWidget, Input, Widget from django.utils.datastructures import _IndexableCollection, _ListOrTuple, _PropertyDescriptor from django.utils.functional import _StrOrPromise -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias ALL_FIELDS: Literal["__all__"] _Fields: TypeAlias = Union[_ListOrTuple[str], Literal["__all__"]] # https://github.com/python/mypy/issues/12211 -_Widgets = dict[str, Union[type[Widget], Widget]] -_Labels = dict[str, str] -_HelpTexts = dict[str, str] -_ErrorMessages = dict[str, dict[str, str]] -_FormFieldCallback = Callable[[models.Field], Field] +_Widgets: TypeAlias = dict[str, Union[type[Widget], Widget]] + +_Labels: TypeAlias = dict[str, str] +_HelpTexts: TypeAlias = dict[str, str] +_ErrorMessages: TypeAlias = dict[str, dict[str, str]] +_FormFieldCallback: TypeAlias = Callable[[models.Field], Field] _M = TypeVar("_M", bound=Model) _ParentM = TypeVar("_ParentM", bound=Model) diff --git a/django-stubs/forms/utils.pyi b/django-stubs/forms/utils.pyi index e4566eaf0..dd6e8477c 100644 --- a/django-stubs/forms/utils.pyi +++ b/django-stubs/forms/utils.pyi @@ -7,9 +7,11 @@ from django.core.exceptions import ValidationError from django.core.files.uploadedfile import UploadedFile from django.utils.datastructures import MultiValueDict from django.utils.safestring import SafeString +from typing_extensions import TypeAlias -_DataT = Mapping[str, Any] -_FilesT = MultiValueDict[str, UploadedFile] +_DataT: TypeAlias = Mapping[str, Any] + +_FilesT: TypeAlias = MultiValueDict[str, UploadedFile] def pretty_name(name: str) -> str: ... def flatatt(attrs: dict[str, Any]) -> SafeString: ... diff --git a/django-stubs/forms/widgets.pyi b/django-stubs/forms/widgets.pyi index 09b331864..c4422c222 100644 --- a/django-stubs/forms/widgets.pyi +++ b/django-stubs/forms/widgets.pyi @@ -9,9 +9,9 @@ from django.forms.utils import _DataT, _FilesT from django.utils.datastructures import _ListOrTuple from django.utils.functional import _Getter from django.utils.safestring import SafeString -from typing_extensions import Literal, Protocol +from typing_extensions import Literal, Protocol, TypeAlias -_OptAttrs = dict[str, Any] +_OptAttrs: TypeAlias = dict[str, Any] class MediaOrderConflictWarning(RuntimeWarning): ... diff --git a/django-stubs/http/request.pyi b/django-stubs/http/request.pyi index ac849e7dc..e3ed20765 100644 --- a/django-stubs/http/request.pyi +++ b/django-stubs/http/request.pyi @@ -1,6 +1,7 @@ from collections.abc import Iterable, Mapping from io import BytesIO -from typing import Any, BinaryIO, NoReturn, Pattern, TypeVar, overload +from re import Pattern +from typing import Any, BinaryIO, NoReturn, TypeVar, overload from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import AnonymousUser @@ -9,7 +10,7 @@ from django.contrib.sites.models import Site from django.core.files import uploadedfile, uploadhandler from django.urls import ResolverMatch from django.utils.datastructures import CaseInsensitiveMapping, ImmutableList, MultiValueDict -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias RAISE_ERROR: object host_validation_re: Pattern[str] @@ -17,7 +18,7 @@ host_validation_re: Pattern[str] class UnreadablePostError(OSError): ... class RawPostDataException(Exception): ... -UploadHandlerList = list[uploadhandler.FileUploadHandler] | ImmutableList[uploadhandler.FileUploadHandler] +UploadHandlerList: TypeAlias = list[uploadhandler.FileUploadHandler] | ImmutableList[uploadhandler.FileUploadHandler] class HttpHeaders(CaseInsensitiveMapping[str]): HTTP_PREFIX: str diff --git a/django-stubs/template/__init__.pyi b/django-stubs/template/__init__.pyi index 124c69967..128cc1004 100644 --- a/django-stubs/template/__init__.pyi +++ b/django-stubs/template/__init__.pyi @@ -1,8 +1,3 @@ -from .engine import Engine as Engine -from .utils import EngineHandler as EngineHandler - -engines: EngineHandler - from . import defaultfilters as defaultfilters # Template parts @@ -15,6 +10,10 @@ from .base import VariableDoesNotExist as VariableDoesNotExist from .context import Context as Context from .context import ContextPopException as ContextPopException from .context import RequestContext as RequestContext +from .engine import Engine as Engine from .exceptions import TemplateDoesNotExist as TemplateDoesNotExist from .exceptions import TemplateSyntaxError as TemplateSyntaxError from .library import Library as Library +from .utils import EngineHandler as EngineHandler + +engines: EngineHandler diff --git a/django-stubs/template/base.pyi b/django-stubs/template/base.pyi index 937b4de8a..d2f5e4530 100644 --- a/django-stubs/template/base.pyi +++ b/django-stubs/template/base.pyi @@ -1,7 +1,8 @@ from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from enum import Enum from logging import Logger -from typing import Any, Pattern +from re import Pattern +from typing import Any from django.template.context import Context as Context from django.template.engine import Engine diff --git a/django-stubs/template/context.pyi b/django-stubs/template/context.pyi index a89e4b57c..7b85b0a5b 100644 --- a/django-stubs/template/context.pyi +++ b/django-stubs/template/context.pyi @@ -7,9 +7,11 @@ from django.http.request import HttpRequest from django.template.base import Node, Origin, Template from django.template.defaulttags import IfChangedNode from django.template.loader_tags import IncludeNode +from typing_extensions import TypeAlias -_ContextKeys = int | str | Node -_ContextValues = dict[str, Any] | "Context" +_ContextKeys: TypeAlias = int | str | Node + +_ContextValues: TypeAlias = dict[str, Any] | "Context" _ContextCopy = TypeVar("_ContextCopy", bound="BaseContext") class ContextPopException(Exception): ... diff --git a/django-stubs/template/engine.pyi b/django-stubs/template/engine.pyi index 749b69110..2f5d9bcee 100644 --- a/django-stubs/template/engine.pyi +++ b/django-stubs/template/engine.pyi @@ -5,10 +5,11 @@ from django.template.base import Origin from django.template.library import Library from django.template.loaders.base import Loader from django.utils.safestring import SafeString +from typing_extensions import TypeAlias from .base import Template -_Loader = Any +_Loader: TypeAlias = Any class Engine: default_builtins: Any diff --git a/django-stubs/template/response.pyi b/django-stubs/template/response.pyi index 21833fba0..9dd7967d9 100644 --- a/django-stubs/template/response.pyi +++ b/django-stubs/template/response.pyi @@ -10,8 +10,9 @@ from django.template.base import Template from django.template.context import RequestContext from django.test.client import Client from django.utils.datastructures import _ListOrTuple +from typing_extensions import TypeAlias -_TemplateForResponseT = Union[_ListOrTuple[str], Template, str] +_TemplateForResponseT: TypeAlias = Union[_ListOrTuple[str], Template, str] class ContentNotRenderedError(Exception): ... diff --git a/django-stubs/template/smartif.pyi b/django-stubs/template/smartif.pyi index 5a46f7a3f..c3adbaa88 100644 --- a/django-stubs/template/smartif.pyi +++ b/django-stubs/template/smartif.pyi @@ -1,8 +1,9 @@ from typing import Any from django.template.defaulttags import TemplateLiteral +from typing_extensions import TypeAlias -_Token = list[int] | int | str +_Token: TypeAlias = list[int] | int | str class TokenBase: id: Any diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index 8c6392f81..03f0ede2f 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -1,8 +1,9 @@ -from collections.abc import Callable, Iterable, Iterator +from collections.abc import Awaitable, Callable, Iterable, Iterator from io import BytesIO from json import JSONEncoder +from re import Pattern from types import TracebackType -from typing import Any, Awaitable, Generic, NoReturn, Pattern, TypeVar, overload +from typing import Any, Generic, NoReturn, TypeVar, overload from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.sessions.backends.base import SessionBase diff --git a/django-stubs/test/html.pyi b/django-stubs/test/html.pyi index a67d9ea48..ffeec828e 100644 --- a/django-stubs/test/html.pyi +++ b/django-stubs/test/html.pyi @@ -2,13 +2,15 @@ from collections.abc import Sequence from html.parser import HTMLParser from typing import Any, TypeVar +from typing_extensions import TypeAlias + _Self = TypeVar("_Self") WHITESPACE: Any def normalize_whitespace(string: str) -> str: ... -_ElementAttribute = tuple[str, str | None] +_ElementAttribute: TypeAlias = tuple[str, str | None] class Element: name: str | None diff --git a/django-stubs/test/utils.pyi b/django-stubs/test/utils.pyi index e824be661..8c8154ff7 100644 --- a/django-stubs/test/utils.pyi +++ b/django-stubs/test/utils.pyi @@ -1,11 +1,11 @@ import decimal from collections.abc import Callable, Iterable, Iterator, Mapping -from contextlib import contextmanager +from contextlib import AbstractContextManager, contextmanager from decimal import Decimal from io import StringIO from logging import Logger from types import TracebackType -from typing import Any, ContextManager, Protocol, TypeVar +from typing import Any, Protocol, TypeVar from django.apps.registry import Apps from django.conf import LazySettings, Settings @@ -15,10 +15,11 @@ from django.db.models.lookups import Lookup, Transform from django.db.models.query_utils import RegisterLookupMixin from django.test.runner import DiscoverRunner from django.test.testcases import SimpleTestCase -from typing_extensions import SupportsIndex +from typing_extensions import SupportsIndex, TypeAlias -_TestClass = type[SimpleTestCase] -_DecoratedTest = Callable | _TestClass +_TestClass: TypeAlias = type[SimpleTestCase] + +_DecoratedTest: TypeAlias = Callable | _TestClass _C = TypeVar("_C", bound=Callable) # Any callable TZ_SUPPORT: bool @@ -102,7 +103,7 @@ class ignore_warnings(TestContextDecorator): ignore_kwargs: dict[str, Any] filter_func: Callable def __init__(self, **kwargs: Any) -> None: ... - catch_warnings: ContextManager[list | None] + catch_warnings: AbstractContextManager[list | None] requires_tz_support: Any @@ -130,15 +131,15 @@ class isolate_apps(TestContextDecorator): def extend_sys_path(*paths: str) -> Iterator[None]: ... @contextmanager def captured_output(stream_name: str) -> Iterator[StringIO]: ... -def captured_stdin() -> ContextManager: ... -def captured_stdout() -> ContextManager: ... -def captured_stderr() -> ContextManager: ... +def captured_stdin() -> AbstractContextManager: ... +def captured_stdout() -> AbstractContextManager: ... +def captured_stderr() -> AbstractContextManager: ... @contextmanager def freeze_time(t: float) -> Iterator[None]: ... def tag(*tags: str) -> Callable[[_C], _C]: ... -_Signature = str -_TestDatabase = tuple[str, list[str]] +_Signature: TypeAlias = str +_TestDatabase: TypeAlias = tuple[str, list[str]] class TimeKeeperProtocol(Protocol): @contextmanager diff --git a/django-stubs/urls/__init__.pyi b/django-stubs/urls/__init__.pyi index 91104f24e..b3a120d94 100644 --- a/django-stubs/urls/__init__.pyi +++ b/django-stubs/urls/__init__.pyi @@ -1,3 +1,5 @@ +from typing_extensions import TypeAlias + # noinspection PyUnresolvedReferences from .base import clear_script_prefix as clear_script_prefix from .base import clear_url_caches as clear_url_caches @@ -35,4 +37,4 @@ from .resolvers import get_resolver as get_resolver from .utils import get_callable as get_callable from .utils import get_mod_func as get_mod_func -_AnyURL = URLPattern | URLResolver +_AnyURL: TypeAlias = URLPattern | URLResolver diff --git a/django-stubs/urls/conf.pyi b/django-stubs/urls/conf.pyi index 780189e7e..b5a3cb503 100644 --- a/django-stubs/urls/conf.pyi +++ b/django-stubs/urls/conf.pyi @@ -3,11 +3,12 @@ from types import ModuleType from typing import Any, overload from django.urls import URLPattern, URLResolver, _AnyURL +from typing_extensions import TypeAlias from ..conf.urls import IncludedURLConf from ..http.response import HttpResponseBase -_URLConf = str | ModuleType | Sequence[_AnyURL] +_URLConf: TypeAlias = str | ModuleType | Sequence[_AnyURL] def include( arg: _URLConf | tuple[_URLConf, str], namespace: str | None = ... diff --git a/django-stubs/urls/resolvers.pyi b/django-stubs/urls/resolvers.pyi index d894137be..dec8d28d7 100644 --- a/django-stubs/urls/resolvers.pyi +++ b/django-stubs/urls/resolvers.pyi @@ -1,11 +1,13 @@ from collections.abc import Callable, Iterator, Sequence +from re import Pattern from types import ModuleType -from typing import Any, Pattern, overload +from typing import Any, overload from django.core.checks.messages import CheckMessage from django.urls import _AnyURL from django.urls.converters import UUIDConverter from django.utils.datastructures import MultiValueDict +from typing_extensions import TypeAlias class ResolverMatch: func: Callable @@ -38,7 +40,7 @@ class ResolverMatch: def get_resolver(urlconf: str | None = ...) -> URLResolver: ... def get_ns_resolver(ns_pattern: str, resolver: URLResolver, converters: tuple) -> URLResolver: ... -_Pattern = RegexPattern | RoutePattern | LocalePrefixPattern +_Pattern: TypeAlias = RegexPattern | RoutePattern | LocalePrefixPattern class LocaleRegexDescriptor: attr: str diff --git a/django-stubs/utils/_os.pyi b/django-stubs/utils/_os.pyi index 011894a90..808b840ce 100644 --- a/django-stubs/utils/_os.pyi +++ b/django-stubs/utils/_os.pyi @@ -1,7 +1,9 @@ import os from pathlib import Path -_PathCompatible = str | os.PathLike[str] +from typing_extensions import TypeAlias + +_PathCompatible: TypeAlias = str | os.PathLike[str] def safe_join(base: _PathCompatible, *paths: _PathCompatible) -> str: ... def symlinks_supported() -> bool: ... diff --git a/django-stubs/utils/datastructures.pyi b/django-stubs/utils/datastructures.pyi index ad9cdfbba..76477c9ef 100644 --- a/django-stubs/utils/datastructures.pyi +++ b/django-stubs/utils/datastructures.pyi @@ -1,7 +1,7 @@ -from collections.abc import Collection, Iterable, Iterator, Mapping -from typing import Any, Generic, MutableSet, TypeVar, overload +from collections.abc import Collection, Iterable, Iterator, Mapping, MutableSet +from typing import Any, Generic, Tuple, TypeVar, overload -from typing_extensions import Protocol +from typing_extensions import Protocol, TypeAlias _K = TypeVar("_K") _V = TypeVar("_V") @@ -10,7 +10,7 @@ _I = TypeVar("_I", covariant=True) # Unfortunately, there's often check `if isinstance(var, (list, tuple))` in django # codebase. So we need sometimes to declare exactly list or tuple. -_ListOrTuple = list[_K] | tuple[_K, ...] | tuple[()] +_ListOrTuple: TypeAlias = list[_K] | tuple[_K, ...] | Tuple[()] class _PropertyDescriptor(Generic[_K, _V]): """ diff --git a/django-stubs/utils/dateformat.pyi b/django-stubs/utils/dateformat.pyi index 1dc505787..3fe0431af 100644 --- a/django-stubs/utils/dateformat.pyi +++ b/django-stubs/utils/dateformat.pyi @@ -1,7 +1,8 @@ from datetime import date from datetime import datetime as builtin_datetime from datetime import time as builtin_time -from typing import Any, Pattern +from re import Pattern +from typing import Any from django.utils.timezone import _TzInfoT from typing_extensions import Literal diff --git a/django-stubs/utils/dateparse.pyi b/django-stubs/utils/dateparse.pyi index ab3b661fc..33c5f6c5a 100644 --- a/django-stubs/utils/dateparse.pyi +++ b/django-stubs/utils/dateparse.pyi @@ -1,7 +1,7 @@ from datetime import date from datetime import datetime as builtin_datetime from datetime import time, timedelta -from typing import Pattern +from re import Pattern date_re: Pattern[str] time_re: Pattern[str] diff --git a/django-stubs/utils/deprecation.pyi b/django-stubs/utils/deprecation.pyi index 6f6b79364..e15e0ae0a 100644 --- a/django-stubs/utils/deprecation.pyi +++ b/django-stubs/utils/deprecation.pyi @@ -3,11 +3,12 @@ from typing import Any, Protocol from django.http.request import HttpRequest from django.http.response import HttpResponse +from typing_extensions import TypeAlias class RemovedInDjango40Warning(DeprecationWarning): ... class RemovedInDjango41Warning(PendingDeprecationWarning): ... -RemovedInNextVersionWarning = RemovedInDjango40Warning +RemovedInNextVersionWarning: TypeAlias = RemovedInDjango40Warning class warn_about_renamed_method: class_name: str diff --git a/django-stubs/utils/feedgenerator.pyi b/django-stubs/utils/feedgenerator.pyi index 28192bd0c..1001dc835 100644 --- a/django-stubs/utils/feedgenerator.pyi +++ b/django-stubs/utils/feedgenerator.pyi @@ -2,6 +2,8 @@ import datetime from typing import Any from xml.sax import ContentHandler +from typing_extensions import TypeAlias + def rfc2822_date(date: datetime.date) -> str: ... def rfc3339_date(date: datetime.date) -> str: ... def get_tag_uri(url: str, date: datetime.date | None) -> str: ... @@ -73,4 +75,4 @@ class Atom1Feed(SyndicationFeed): ns: str def write_items(self, handler: ContentHandler) -> None: ... -DefaultFeed = Rss201rev2Feed +DefaultFeed: TypeAlias = Rss201rev2Feed diff --git a/django-stubs/utils/functional.pyi b/django-stubs/utils/functional.pyi index b4e8fdcfe..60417aa22 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -3,7 +3,7 @@ from functools import wraps as wraps # noqa: F401 from typing import Any, Generic, TypeVar, overload from django.db.models.base import Model -from typing_extensions import Protocol, SupportsIndex +from typing_extensions import Protocol, SupportsIndex, TypeAlias _T = TypeVar("_T") @@ -44,7 +44,7 @@ class _StrPromise(Promise, Sequence[str]): # Mypy requires this for the attribute hook to take effect def __getattribute__(self, __name: str) -> Any: ... -_StrOrPromise = str | _StrPromise +_StrOrPromise: TypeAlias = str | _StrPromise _C = TypeVar("_C", bound=Callable) def lazy(func: _C, *resultclasses: Any) -> _C: ... diff --git a/django-stubs/utils/html.pyi b/django-stubs/utils/html.pyi index 37ba8878d..3e41d285a 100644 --- a/django-stubs/utils/html.pyi +++ b/django-stubs/utils/html.pyi @@ -1,6 +1,7 @@ from collections.abc import Iterable from html.parser import HTMLParser -from typing import Any, Pattern +from re import Pattern +from typing import Any from django.utils.safestring import SafeString diff --git a/django-stubs/utils/http.pyi b/django-stubs/utils/http.pyi index db25f83df..68a3c878d 100644 --- a/django-stubs/utils/http.pyi +++ b/django-stubs/utils/http.pyi @@ -1,5 +1,6 @@ from collections.abc import Iterable -from typing import Any, Pattern +from re import Pattern +from typing import Any ETAG_MATCH: Pattern[str] MONTHS: list[str] diff --git a/django-stubs/utils/regex_helper.pyi b/django-stubs/utils/regex_helper.pyi index a361359cf..7cd62bbce 100644 --- a/django-stubs/utils/regex_helper.pyi +++ b/django-stubs/utils/regex_helper.pyi @@ -1,5 +1,6 @@ from collections.abc import Iterator, Mapping -from typing import Pattern, TypeVar +from re import Pattern +from typing import TypeVar ESCAPE_MAPPINGS: Mapping[str, str | None] diff --git a/django-stubs/utils/safestring.pyi b/django-stubs/utils/safestring.pyi index ac3ab3311..1569ea103 100644 --- a/django-stubs/utils/safestring.pyi +++ b/django-stubs/utils/safestring.pyi @@ -1,6 +1,8 @@ from collections.abc import Callable from typing import Any, TypeVar, overload +from typing_extensions import TypeAlias + _SD = TypeVar("_SD", bound="SafeData") class SafeData: @@ -13,7 +15,7 @@ class SafeString(str, SafeData): def __add__(self, rhs: str) -> str: ... def __str__(self) -> str: ... -SafeText = SafeString +SafeText: TypeAlias = SafeString _C = TypeVar("_C", bound=Callable) diff --git a/django-stubs/utils/text.pyi b/django-stubs/utils/text.pyi index 424a4c4b9..2c318e5ee 100644 --- a/django-stubs/utils/text.pyi +++ b/django-stubs/utils/text.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Iterable, Iterator from io import BytesIO -from typing import Pattern +from re import Pattern from django.db.models.base import Model from django.utils.functional import SimpleLazyObject diff --git a/django-stubs/utils/timezone.pyi b/django-stubs/utils/timezone.pyi index ab555d238..4da8bda5b 100644 --- a/django-stubs/utils/timezone.pyi +++ b/django-stubs/utils/timezone.pyi @@ -10,10 +10,11 @@ from typing import Any, overload import pytz from pytz import BaseTzInfo -from typing_extensions import Literal, TypeGuard +from typing_extensions import Literal, TypeAlias, TypeGuard -_PytzTzInfoT = pytz.tzinfo.BaseTzInfo | pytz._FixedOffset -_TzInfoT = _PytzTzInfoT | tzinfo +_PytzTzInfoT: TypeAlias = pytz.tzinfo.BaseTzInfo | pytz._FixedOffset + +_TzInfoT: TypeAlias = _PytzTzInfoT | tzinfo utc: Any diff --git a/django-stubs/utils/translation/__init__.pyi b/django-stubs/utils/translation/__init__.pyi index edd9b9e2f..17fd17c5d 100644 --- a/django-stubs/utils/translation/__init__.pyi +++ b/django-stubs/utils/translation/__init__.pyi @@ -46,6 +46,7 @@ def ugettext(message: str) -> str: ... def ungettext(singular: str, plural: str, number: float) -> str: ... ugettext_lazy = gettext_lazy + ungettext_lazy = ngettext_lazy def activate(language: str) -> None: ... diff --git a/django-stubs/utils/translation/template.pyi b/django-stubs/utils/translation/template.pyi index 57a58ccbd..959997b94 100644 --- a/django-stubs/utils/translation/template.pyi +++ b/django-stubs/utils/translation/template.pyi @@ -1,4 +1,4 @@ -from typing import Pattern +from re import Pattern dot_re: Pattern[str] diff --git a/django-stubs/utils/translation/trans_real.pyi b/django-stubs/utils/translation/trans_real.pyi index 085ffdcb9..4a10202b9 100644 --- a/django-stubs/utils/translation/trans_real.pyi +++ b/django-stubs/utils/translation/trans_real.pyi @@ -1,10 +1,11 @@ import gettext as gettext_module from collections.abc import Iterator from gettext import NullTranslations -from typing import Any, Pattern, Protocol, TypeVar +from re import Pattern +from typing import Any, Protocol, Tuple, TypeVar from django.http.request import HttpRequest -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias CONTEXT_SEPARATOR: Literal["\x04"] accept_language_re: Pattern[str] @@ -16,7 +17,9 @@ class _PluralCallable(Protocol): def reset_cache(**kwargs: Any) -> None: ... -_KeyT = str | tuple[str, int] +# switch to tuple once https://github.com/python/mypy/issues/11098 is fixed +_KeyT: TypeAlias = str | Tuple[str, int] + _Z = TypeVar("_Z") class TranslationCatalog: diff --git a/django-stubs/utils/tree.pyi b/django-stubs/utils/tree.pyi index c75bb2cd4..7919f8045 100644 --- a/django-stubs/utils/tree.pyi +++ b/django-stubs/utils/tree.pyi @@ -2,8 +2,9 @@ from collections.abc import Sequence from typing import Any from django.db.models.sql.where import NothingNode +from typing_extensions import TypeAlias -_NodeChildren = list["Node" | NothingNode | Sequence[Any]] +_NodeChildren: TypeAlias = list["Node" | NothingNode | Sequence[Any]] class Node: children: _NodeChildren diff --git a/django-stubs/utils/version.pyi b/django-stubs/utils/version.pyi index f9e3c20c3..a4a31a34c 100644 --- a/django-stubs/utils/version.pyi +++ b/django-stubs/utils/version.pyi @@ -1,3 +1,5 @@ +from typing_extensions import TypeAlias + PY36: bool PY37: bool PY38: bool @@ -5,7 +7,7 @@ PY39: bool PY310: bool PY311: bool -_VT = tuple[int, int, int, str, int] +_VT: TypeAlias = tuple[int, int, int, str, int] def get_version(version: _VT | None = ...) -> str: ... def get_main_version(version: _VT = ...) -> str: ... diff --git a/django-stubs/views/debug.pyi b/django-stubs/views/debug.pyi index bb14c42e1..8d5d4044b 100644 --- a/django-stubs/views/debug.pyi +++ b/django-stubs/views/debug.pyi @@ -1,8 +1,8 @@ -from collections.abc import Callable, Iterator +from collections.abc import Callable, ItemsView, Iterator from importlib.abc import SourceLoader from pathlib import Path from types import TracebackType -from typing import Any, ItemsView +from typing import Any from django.http.request import HttpRequest, QueryDict from django.http.response import Http404, HttpResponse diff --git a/django-stubs/views/decorators/http.pyi b/django-stubs/views/decorators/http.pyi index cc0ca96de..c03160b91 100644 --- a/django-stubs/views/decorators/http.pyi +++ b/django-stubs/views/decorators/http.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable -from typing import Any, Container, TypeVar +from collections.abc import Callable, Container +from typing import Any, TypeVar _F = TypeVar("_F", bound=Callable[..., Any]) diff --git a/django-stubs/views/generic/dates.pyi b/django-stubs/views/generic/dates.pyi index 50a9adc85..c73830bd4 100644 --- a/django-stubs/views/generic/dates.pyi +++ b/django-stubs/views/generic/dates.pyi @@ -9,6 +9,7 @@ from django.utils.datastructures import _IndexableCollection from django.views.generic.base import View from django.views.generic.detail import BaseDetailView, SingleObjectTemplateResponseMixin from django.views.generic.list import MultipleObjectMixin, MultipleObjectTemplateResponseMixin +from typing_extensions import TypeAlias _M = TypeVar("_M", bound=models.Model) @@ -52,7 +53,7 @@ class DateMixin: @property def uses_datetime_field(self) -> bool: ... -DatedItems = tuple[_IndexableCollection[datetime.date] | None, _IndexableCollection[_M], dict[str, Any]] +DatedItems: TypeAlias = tuple[_IndexableCollection[datetime.date] | None, _IndexableCollection[_M], dict[str, Any]] class BaseDateListView(MultipleObjectMixin[_M], DateMixin, View): date_list_period: str From 34bbd9d91c22bfeca58346dced8ff6a285af7115 Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sun, 13 Nov 2022 17:35:06 +0100 Subject: [PATCH 11/13] fix remaining flake8-pyi warnings, silence warnings in question Signed-off-by: Oleg Hoefling --- django-stubs/conf/__init__.pyi | 3 +- django-stubs/conf/global_settings.pyi | 10 ++-- django-stubs/contrib/admin/models.pyi | 3 +- django-stubs/contrib/admin/options.pyi | 16 +++--- .../contrib/admin/templatetags/admin_list.pyi | 3 +- django-stubs/contrib/auth/models.pyi | 6 +-- django-stubs/contrib/contenttypes/models.pyi | 2 +- .../contrib/gis/db/backends/base/adapter.pyi | 2 +- .../gis/db/backends/postgis/adapter.pyi | 2 +- django-stubs/contrib/gis/gdal/envelope.pyi | 2 +- django-stubs/contrib/gis/gdal/feature.pyi | 2 +- django-stubs/contrib/gis/gdal/geometries.pyi | 2 +- django-stubs/contrib/gis/gdal/geomtype.pyi | 2 +- django-stubs/contrib/gis/geos/geometry.pyi | 9 ++-- .../contrib/gis/geos/mutable_list.pyi | 10 ++-- django-stubs/contrib/gis/measure.pyi | 13 ++--- django-stubs/contrib/postgres/search.pyi | 23 ++++----- .../contrib/sessions/base_session.pyi | 2 +- django-stubs/contrib/sessions/models.pyi | 2 +- django-stubs/contrib/sites/models.pyi | 2 +- django-stubs/core/files/base.pyi | 11 ++-- django-stubs/core/files/uploadedfile.pyi | 5 +- django-stubs/core/handlers/base.pyi | 2 +- django-stubs/core/mail/backends/base.pyi | 7 ++- django-stubs/core/mail/message.pyi | 14 +++-- django-stubs/core/paginator.pyi | 6 +-- django-stubs/core/validators.pyi | 8 +-- django-stubs/db/backends/base/base.pyi | 6 +-- django-stubs/db/backends/base/schema.pyi | 3 +- django-stubs/db/backends/utils.pyi | 3 +- django-stubs/db/migrations/graph.pyi | 2 +- django-stubs/db/migrations/migration.pyi | 3 +- .../db/migrations/operations/special.pyi | 16 +++--- django-stubs/db/migrations/state.pyi | 2 +- django-stubs/db/models/base.pyi | 11 ++-- django-stubs/db/models/constraints.pyi | 5 +- django-stubs/db/models/deletion.pyi | 12 ++--- django-stubs/db/models/expressions.pyi | 16 +++--- django-stubs/db/models/fields/__init__.pyi | 12 ++--- django-stubs/db/models/fields/files.pyi | 6 +-- django-stubs/db/models/fields/related.pyi | 11 ++-- django-stubs/db/models/lookups.pyi | 8 +-- django-stubs/db/models/manager.pyi | 4 +- django-stubs/db/models/options.pyi | 7 +-- django-stubs/db/models/query.pyi | 51 ++++++++++--------- django-stubs/db/models/sql/compiler.pyi | 2 +- django-stubs/forms/fields.pyi | 8 +-- django-stubs/forms/models.pyi | 17 +++++-- django-stubs/forms/utils.pyi | 6 +-- django-stubs/http/request.pyi | 6 +-- django-stubs/template/context.pyi | 9 ++-- django-stubs/template/defaultfilters.pyi | 2 +- django-stubs/template/response.pyi | 3 +- django-stubs/test/html.pyi | 4 +- django-stubs/test/runner.pyi | 2 +- django-stubs/test/testcases.pyi | 16 +++--- django-stubs/test/utils.pyi | 5 +- django-stubs/urls/__init__.pyi | 2 +- django-stubs/utils/archive.pyi | 4 +- django-stubs/utils/connection.pyi | 2 +- django-stubs/utils/datastructures.pyi | 19 +++---- django-stubs/utils/functional.pyi | 18 +++---- django-stubs/utils/safestring.pyi | 5 +- django-stubs/utils/translation/trans_real.pyi | 4 +- django-stubs/utils/tree.pyi | 2 +- setup.cfg | 6 +-- tests/typecheck/fields/test_related.yml | 4 +- tests/typecheck/models/test_create.yml | 16 +++--- tests/typecheck/models/test_init.yml | 14 ++--- 69 files changed, 261 insertions(+), 262 deletions(-) diff --git a/django-stubs/conf/__init__.pyi b/django-stubs/conf/__init__.pyi index 4e21cca18..090eaa407 100644 --- a/django-stubs/conf/__init__.pyi +++ b/django-stubs/conf/__init__.pyi @@ -1,5 +1,6 @@ from typing import Any +from _typeshed import Self from django.utils.functional import LazyObject # explicit dependency on standard settings to make it loaded @@ -35,5 +36,5 @@ class UserSettingsHolder: def is_overridden(self, setting: str) -> bool: ... class SettingsReference(str): - def __new__(self, value: Any, setting_name: str) -> SettingsReference: ... + def __new__(self: type[Self], value: Any, setting_name: str) -> Self: ... def __init__(self, value: str, setting_name: str) -> None: ... diff --git a/django-stubs/conf/global_settings.pyi b/django-stubs/conf/global_settings.pyi index 86fe8ce4b..6e1a3cd1e 100644 --- a/django-stubs/conf/global_settings.pyi +++ b/django-stubs/conf/global_settings.pyi @@ -1,7 +1,3 @@ -""" -Default Django settings. Override these with settings in the module pointed to -by the DJANGO_SETTINGS_MODULE environment variable. -""" from collections.abc import Sequence from re import Pattern @@ -11,6 +7,8 @@ from typing import Any, Protocol from typing_extensions import Literal, TypeAlias +_Admins: TypeAlias = list[tuple[str, str]] + #################### # CORE # #################### @@ -23,7 +21,7 @@ DEBUG_PROPAGATE_EXCEPTIONS: bool # People who get code error notifications. # In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')] -ADMINS: list[tuple[str, str]] +ADMINS: _Admins # List of IP addresses, as strings, that: # * See debug comments, when DEBUG is true @@ -72,7 +70,7 @@ USE_L10N: bool # Not-necessarily-technical managers of the site. They get broken link # notifications and other various emails. -MANAGERS = ADMINS +MANAGERS: _Admins # Default charset to use for all HttpResponse objects, if a # MIME type isn't manually specified. These are used to construct the diff --git a/django-stubs/contrib/admin/models.pyi b/django-stubs/contrib/admin/models.pyi index b0c8a774e..3657b5710 100644 --- a/django-stubs/contrib/admin/models.pyi +++ b/django-stubs/contrib/admin/models.pyi @@ -1,7 +1,6 @@ from typing import Any from uuid import UUID -from django.contrib.contenttypes.models import ContentType from django.db import models from django.db.models.base import Model @@ -10,7 +9,7 @@ CHANGE: int DELETION: int ACTION_FLAG_CHOICES: Any -class LogEntryManager(models.Manager["LogEntry"]): +class LogEntryManager(models.Manager[LogEntry]): def log_action( self, user_id: int, diff --git a/django-stubs/contrib/admin/options.pyi b/django-stubs/contrib/admin/options.pyi index 5ccbde0e2..77ccd3231 100644 --- a/django-stubs/contrib/admin/options.pyi +++ b/django-stubs/contrib/admin/options.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence -from typing import Any, Generic, Optional, TypeVar, Union +from typing import Any, Generic, Optional, TypeVar, Union # noqa: Y037 # https://github.com/python/mypy/issues/12211 from django import forms from django.contrib.admin.filters import FieldListFilter, ListFilter @@ -17,7 +17,6 @@ from django.db.models.options import Options from django.db.models.query import QuerySet from django.forms.fields import Field as FormField from django.forms.fields import TypedChoiceField -from django.forms.forms import BaseForm from django.forms.formsets import BaseFormSet from django.forms.models import ( BaseInlineFormSet, @@ -28,7 +27,7 @@ from django.forms.models import ( ) from django.forms.widgets import Media from django.http.request import HttpRequest -from django.http.response import HttpResponse, HttpResponseRedirect, JsonResponse +from django.http.response import HttpResponse, HttpResponseRedirect from django.template.response import _TemplateForResponseT from django.urls.resolvers import URLPattern from django.utils.datastructures import _ListOrTuple @@ -41,7 +40,7 @@ TO_FIELD_VAR: str HORIZONTAL: Literal[1] VERTICAL: Literal[2] -_Direction: TypeAlias = Union[Literal[1], Literal[2]] +_Direction: TypeAlias = Literal[1, 2] def get_content_type_for_model(obj: type[Model] | Model) -> ContentType: ... def get_ul_class(radio_style: int) -> str: ... @@ -51,7 +50,7 @@ class IncorrectLookupParameters(Exception): ... FORMFIELD_FOR_DBFIELD_DEFAULTS: Any csrf_protect_m: Any -_FieldGroups: TypeAlias = Sequence[Union[str, Sequence[str]]] +_FieldGroups: TypeAlias = Sequence[str | Sequence[str]] class _OptionalFieldOpts(TypedDict, total=False): classes: Sequence[str] @@ -63,13 +62,14 @@ class _FieldOpts(_OptionalFieldOpts, total=True): # Workaround for mypy issue, a Sequence type should be preferred here. # https://github.com/python/mypy/issues/8921 # _FieldsetSpec = Sequence[Tuple[Optional[str], _FieldOpts]] -_FieldsetSpec: TypeAlias = _ListOrTuple[tuple[Optional[_StrOrPromise], _FieldOpts]] +_FieldsetSpec: TypeAlias = _ListOrTuple[tuple[_StrOrPromise | None, _FieldOpts]] +# https://github.com/python/mypy/issues/12211 _ListFilterT: TypeAlias = Union[ type[ListFilter], Field, str, - tuple[Union[Field, str], type[FieldListFilter]], - list[Union[Field, str, type[FieldListFilter]]], + tuple[Field | str, type[FieldListFilter]], + list[Field | str | type[FieldListFilter]], ] # Generic type specifically for models, for use in BaseModelAdmin and subclasses diff --git a/django-stubs/contrib/admin/templatetags/admin_list.pyi b/django-stubs/contrib/admin/templatetags/admin_list.pyi index d50e5b3bf..8eb51c31c 100644 --- a/django-stubs/contrib/admin/templatetags/admin_list.pyi +++ b/django-stubs/contrib/admin/templatetags/admin_list.pyi @@ -1,8 +1,7 @@ -from collections.abc import Iterable, Iterator +from collections.abc import Iterator from typing import Any from django.contrib.admin.filters import FieldListFilter -from django.contrib.admin.templatetags.base import InclusionAdminNode from django.contrib.admin.views.main import ChangeList from django.db.models.base import Model from django.forms.boundfield import BoundField diff --git a/django-stubs/contrib/auth/models.pyi b/django-stubs/contrib/auth/models.pyi index 54daa18c4..d537a5d16 100644 --- a/django-stubs/contrib/auth/models.pyi +++ b/django-stubs/contrib/auth/models.pyi @@ -11,11 +11,11 @@ from django.db.models.base import Model from django.db.models.manager import EmptyManager from typing_extensions import Literal, TypeAlias -_AnyUser: TypeAlias = Model | "AnonymousUser" +_AnyUser: TypeAlias = Model | AnonymousUser def update_last_login(sender: type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ... -class PermissionManager(models.Manager["Permission"]): +class PermissionManager(models.Manager[Permission]): def get_by_natural_key(self, codename: str, app_label: str, model: str) -> Permission: ... class Permission(models.Model): @@ -27,7 +27,7 @@ class Permission(models.Model): codename = models.CharField(max_length=100) def natural_key(self) -> tuple[str, str, str]: ... -class GroupManager(models.Manager["Group"]): +class GroupManager(models.Manager[Group]): def get_by_natural_key(self, name: str) -> Group: ... class Group(models.Model): diff --git a/django-stubs/contrib/contenttypes/models.pyi b/django-stubs/contrib/contenttypes/models.pyi index 16f417bb8..d54089ddd 100644 --- a/django-stubs/contrib/contenttypes/models.pyi +++ b/django-stubs/contrib/contenttypes/models.pyi @@ -4,7 +4,7 @@ from django.db import models from django.db.models.base import Model from django.db.models.query import QuerySet -class ContentTypeManager(models.Manager["ContentType"]): +class ContentTypeManager(models.Manager[ContentType]): def get_by_natural_key(self, app_label: str, model: str) -> ContentType: ... def get_for_model(self, model: type[Model] | Model, for_concrete_model: bool = ...) -> ContentType: ... def get_for_models(self, *models: Any, for_concrete_models: bool = ...) -> dict[type[Model], ContentType]: ... diff --git a/django-stubs/contrib/gis/db/backends/base/adapter.pyi b/django-stubs/contrib/gis/db/backends/base/adapter.pyi index c87981245..0f6cffc29 100644 --- a/django-stubs/contrib/gis/db/backends/base/adapter.pyi +++ b/django-stubs/contrib/gis/db/backends/base/adapter.pyi @@ -4,5 +4,5 @@ class WKTAdapter: wkt: Any srid: Any def __init__(self, geom: Any) -> None: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... def __hash__(self) -> int: ... diff --git a/django-stubs/contrib/gis/db/backends/postgis/adapter.pyi b/django-stubs/contrib/gis/db/backends/postgis/adapter.pyi index 999ff5978..32cc806a1 100644 --- a/django-stubs/contrib/gis/db/backends/postgis/adapter.pyi +++ b/django-stubs/contrib/gis/db/backends/postgis/adapter.pyi @@ -7,7 +7,7 @@ class PostGISAdapter: geography: Any def __init__(self, obj: Any, geography: bool = ...) -> None: ... def __conform__(self, proto: Any) -> Any: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... def __hash__(self) -> int: ... def prepare(self, conn: Any) -> None: ... def getquoted(self) -> Any: ... diff --git a/django-stubs/contrib/gis/gdal/envelope.pyi b/django-stubs/contrib/gis/gdal/envelope.pyi index 5f2c1c630..44068f6ce 100644 --- a/django-stubs/contrib/gis/gdal/envelope.pyi +++ b/django-stubs/contrib/gis/gdal/envelope.pyi @@ -5,7 +5,7 @@ class OGREnvelope(Structure): ... class Envelope: def __init__(self, *args: Any) -> None: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... def expand_to_include(self, *args: Any) -> Any: ... @property def min_x(self) -> Any: ... diff --git a/django-stubs/contrib/gis/gdal/feature.pyi b/django-stubs/contrib/gis/gdal/feature.pyi index 9b296e995..9d76734ed 100644 --- a/django-stubs/contrib/gis/gdal/feature.pyi +++ b/django-stubs/contrib/gis/gdal/feature.pyi @@ -8,7 +8,7 @@ class Feature(GDALBase): def __init__(self, feat: Any, layer: Any) -> None: ... def __getitem__(self, index: Any) -> Any: ... def __len__(self) -> int: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... @property def encoding(self) -> Any: ... @property diff --git a/django-stubs/contrib/gis/gdal/geometries.pyi b/django-stubs/contrib/gis/gdal/geometries.pyi index 3eb580352..409ea5e89 100644 --- a/django-stubs/contrib/gis/gdal/geometries.pyi +++ b/django-stubs/contrib/gis/gdal/geometries.pyi @@ -17,7 +17,7 @@ class OGRGeometry(GDALBase): def __and__(self, other: Any) -> Any: ... def __sub__(self, other: Any) -> Any: ... def __xor__(self, other: Any) -> Any: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... @property def dimension(self) -> Any: ... coord_dim: Any diff --git a/django-stubs/contrib/gis/gdal/geomtype.pyi b/django-stubs/contrib/gis/gdal/geomtype.pyi index 3666b594d..177614065 100644 --- a/django-stubs/contrib/gis/gdal/geomtype.pyi +++ b/django-stubs/contrib/gis/gdal/geomtype.pyi @@ -4,7 +4,7 @@ class OGRGeomType: wkb25bit: int num: Any def __init__(self, type_input: Any) -> None: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... @property def name(self) -> Any: ... @property diff --git a/django-stubs/contrib/gis/geos/geometry.pyi b/django-stubs/contrib/gis/geos/geometry.pyi index 4f3742fe1..bd64571cd 100644 --- a/django-stubs/contrib/gis/geos/geometry.pyi +++ b/django-stubs/contrib/gis/geos/geometry.pyi @@ -1,25 +1,24 @@ from typing import Any, TypeVar +from _typeshed import Self from django.contrib.gis.geometry import hex_regex as hex_regex # noqa: F401 from django.contrib.gis.geometry import json_regex as json_regex from django.contrib.gis.geometry import wkt_regex as wkt_regex from django.contrib.gis.geos.base import GEOSBase as GEOSBase from django.contrib.gis.geos.mutable_list import ListMixin as ListMixin -_T = TypeVar("_T") - class GEOSGeometryBase(GEOSBase): ptr_type: Any destructor: Any has_cs: bool def __init__(self, ptr: Any, cls: Any) -> None: ... - def __copy__(self: _T) -> _T: ... - def __deepcopy__(self: _T, memodict: Any) -> _T: ... + def __copy__(self: Self) -> Self: ... + def __deepcopy__(self: Self, memodict: Any) -> Self: ... @staticmethod def from_ewkt(ewkt: Any) -> Any: ... @classmethod def from_gml(cls, gml_string: Any) -> Any: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... def __hash__(self) -> int: ... def __or__(self, other: Any) -> Any: ... def __and__(self, other: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/geos/mutable_list.pyi b/django-stubs/contrib/gis/geos/mutable_list.pyi index 709a24bbf..e17cff6ed 100644 --- a/django-stubs/contrib/gis/geos/mutable_list.pyi +++ b/django-stubs/contrib/gis/geos/mutable_list.pyi @@ -1,5 +1,7 @@ from typing import Any +from _typeshed import Self + class ListMixin: def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __getitem__(self, index: Any) -> Any: ... @@ -7,12 +9,12 @@ class ListMixin: def __setitem__(self, index: Any, val: Any) -> None: ... def __add__(self, other: Any) -> Any: ... def __radd__(self, other: Any) -> Any: ... - def __iadd__(self, other: Any) -> Any: ... + def __iadd__(self: Self, other: Any) -> Self: ... def __mul__(self, n: Any) -> Any: ... def __rmul__(self, n: Any) -> Any: ... - def __imul__(self, n: Any) -> Any: ... - def __eq__(self, other: Any) -> bool: ... - def __lt__(self, other: Any) -> Any: ... + def __imul__(self: Self, n: Any) -> Self: ... + def __eq__(self, other: object) -> bool: ... + def __lt__(self, other: Any) -> bool: ... def count(self, val: Any) -> Any: ... def index(self, val: Any) -> Any: ... def append(self, val: Any) -> None: ... diff --git a/django-stubs/contrib/gis/measure.pyi b/django-stubs/contrib/gis/measure.pyi index 4263a6fd5..cd72527b7 100644 --- a/django-stubs/contrib/gis/measure.pyi +++ b/django-stubs/contrib/gis/measure.pyi @@ -1,5 +1,6 @@ from typing import Any +from _typeshed import Self from typing_extensions import TypeAlias class MeasureBase: @@ -10,17 +11,17 @@ class MeasureBase: def __init__(self, default_unit: Any | None = ..., **kwargs: Any) -> None: ... standard: Any def __getattr__(self, name: Any) -> Any: ... - def __eq__(self, other: Any) -> bool: ... - def __lt__(self, other: Any) -> Any: ... + def __eq__(self, other: object) -> bool: ... + def __lt__(self, other: Any) -> bool: ... def __add__(self, other: Any) -> Any: ... - def __iadd__(self, other: Any) -> Any: ... + def __iadd__(self: Self, other: Any) -> Self: ... def __sub__(self, other: Any) -> Any: ... - def __isub__(self, other: Any) -> Any: ... + def __isub__(self: Self, other: Any) -> Self: ... def __mul__(self, other: Any) -> Any: ... - def __imul__(self, other: Any) -> Any: ... + def __imul__(self: Self, other: Any) -> Self: ... def __rmul__(self, other: Any) -> Any: ... def __truediv__(self, other: Any) -> Any: ... - def __itruediv__(self, other: Any) -> Any: ... + def __itruediv__(self: Self, other: Any) -> Self: ... def __bool__(self) -> bool: ... def default_units(self, kwargs: Any) -> Any: ... @classmethod diff --git a/django-stubs/contrib/postgres/search.pyi b/django-stubs/contrib/postgres/search.pyi index 4f86d946b..e9b7b78f7 100644 --- a/django-stubs/contrib/postgres/search.pyi +++ b/django-stubs/contrib/postgres/search.pyi @@ -1,11 +1,12 @@ -from typing import Any, TypeVar +from typing import Any +from _typeshed import Self from django.db.models import Expression, Field -from django.db.models.expressions import Combinable, CombinedExpression, Func, Value +from django.db.models.expressions import Combinable, CombinedExpression, Func from django.db.models.lookups import Lookup from typing_extensions import TypeAlias -_Expression: TypeAlias = str | Combinable | "SearchQueryCombinable" +_Expression: TypeAlias = str | Combinable | SearchQueryCombinable class SearchVectorExact(Lookup): ... class SearchVectorField(Field): ... @@ -36,18 +37,16 @@ class CombinedSearchVector(SearchVectorCombinable, CombinedExpression): connector: str, rhs: Combinable, config: _Expression | None, - output_field: Field | None = None, + output_field: Field | None = ..., ) -> None: ... -_T = TypeVar("_T", bound="SearchQueryCombinable") - class SearchQueryCombinable: BITAND: str BITOR: str - def __or__(self: _T, other: SearchQueryCombinable) -> _T: ... - def __ror__(self: _T, other: SearchQueryCombinable) -> _T: ... - def __and__(self: _T, other: SearchQueryCombinable) -> _T: ... - def __rand__(self: _T, other: SearchQueryCombinable) -> _T: ... + def __or__(self: Self, other: SearchQueryCombinable) -> Self: ... + def __ror__(self: Self, other: SearchQueryCombinable) -> Self: ... + def __and__(self: Self, other: SearchQueryCombinable) -> Self: ... + def __rand__(self: Self, other: SearchQueryCombinable) -> Self: ... class SearchQuery(SearchQueryCombinable, Func): # type: ignore SEARCH_TYPES: dict[str, str] @@ -60,7 +59,7 @@ class SearchQuery(SearchQueryCombinable, Func): # type: ignore invert: bool = ..., search_type: str = ..., ) -> None: ... - def __invert__(self: _T) -> _T: ... + def __invert__(self: Self) -> Self: ... class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression): # type: ignore def __init__( @@ -69,7 +68,7 @@ class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression): # type: i connector: str, rhs: Combinable, config: _Expression | None, - output_field: Field | None = None, + output_field: Field | None = ..., ) -> None: ... class SearchRank(Func): diff --git a/django-stubs/contrib/sessions/base_session.pyi b/django-stubs/contrib/sessions/base_session.pyi index 9d4e54e0f..6d23fdd81 100644 --- a/django-stubs/contrib/sessions/base_session.pyi +++ b/django-stubs/contrib/sessions/base_session.pyi @@ -4,7 +4,7 @@ from typing import Any, TypeVar from django.contrib.sessions.backends.base import SessionBase from django.db import models -_T = TypeVar("_T", bound="AbstractBaseSession") +_T = TypeVar("_T", bound=AbstractBaseSession) class BaseSessionManager(models.Manager[_T]): def encode(self, session_dict: dict[str, Any]) -> str: ... diff --git a/django-stubs/contrib/sessions/models.pyi b/django-stubs/contrib/sessions/models.pyi index a6afbfe27..492c9c34d 100644 --- a/django-stubs/contrib/sessions/models.pyi +++ b/django-stubs/contrib/sessions/models.pyi @@ -2,7 +2,7 @@ from typing import TypeVar from django.contrib.sessions.base_session import AbstractBaseSession, BaseSessionManager -_T = TypeVar("_T", bound="Session") +_T = TypeVar("_T", bound=Session) class SessionManager(BaseSessionManager[_T]): ... class Session(AbstractBaseSession): ... diff --git a/django-stubs/contrib/sites/models.pyi b/django-stubs/contrib/sites/models.pyi index 05f0a3fbd..15a7d9e08 100644 --- a/django-stubs/contrib/sites/models.pyi +++ b/django-stubs/contrib/sites/models.pyi @@ -5,7 +5,7 @@ from django.http.request import HttpRequest SITE_CACHE: Any -class SiteManager(models.Manager["Site"]): +class SiteManager(models.Manager[Site]): def get_current(self, request: HttpRequest | None = ...) -> Site: ... def clear_cache(self) -> None: ... def get_by_natural_key(self, domain: str) -> Site: ... diff --git a/django-stubs/core/files/base.pyi b/django-stubs/core/files/base.pyi index 6ea00895c..4dbd26133 100644 --- a/django-stubs/core/files/base.pyi +++ b/django-stubs/core/files/base.pyi @@ -1,11 +1,10 @@ from collections.abc import Iterator from types import TracebackType -from typing import IO, AnyStr, TypeVar, type_check_only +from typing import IO, AnyStr, type_check_only +from _typeshed import Self from django.core.files.utils import FileProxyMixin -_T = TypeVar("_T", bound="File") - class File(FileProxyMixin[AnyStr], IO[AnyStr]): DEFAULT_CHUNK_SIZE: int file: IO[AnyStr] | None @@ -21,14 +20,14 @@ class File(FileProxyMixin[AnyStr], IO[AnyStr]): def chunks(self, chunk_size: int | None = ...) -> Iterator[AnyStr]: ... def multiple_chunks(self, chunk_size: int | None = ...) -> bool | None: ... def __iter__(self) -> Iterator[AnyStr]: ... - def __enter__(self: _T) -> _T: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None, ) -> None: ... - def open(self: _T, mode: str | None = ...) -> _T: ... + def open(self: Self, mode: str | None = ...) -> Self: ... def close(self) -> None: ... @type_check_only def __next__(self) -> AnyStr: ... @@ -39,7 +38,7 @@ class ContentFile(File[AnyStr]): def __init__(self, content: AnyStr, name: str | None = ...) -> None: ... def __str__(self) -> str: ... def __bool__(self) -> bool: ... - def open(self: _T, mode: str | None = ...) -> _T: ... + def open(self: Self, mode: str | None = ...) -> Self: ... def close(self) -> None: ... def write(self, data: AnyStr) -> int: ... diff --git a/django-stubs/core/files/uploadedfile.pyi b/django-stubs/core/files/uploadedfile.pyi index 2c63cfa66..437da8d9b 100644 --- a/django-stubs/core/files/uploadedfile.pyi +++ b/django-stubs/core/files/uploadedfile.pyi @@ -1,5 +1,6 @@ from typing import IO, TypeVar +from _typeshed import Self from django.core.files.base import File class UploadedFile(File): @@ -42,9 +43,7 @@ class InMemoryUploadedFile(UploadedFile): content_type_extra: dict[str, str] = ..., ) -> None: ... -_C = TypeVar("_C", bound="SimpleUploadedFile") - class SimpleUploadedFile(InMemoryUploadedFile): def __init__(self, name: str, content: bytes | None, content_type: str = ...) -> None: ... @classmethod - def from_dict(cls: type[_C], file_dict: dict[str, str | bytes]) -> _C: ... + def from_dict(cls: type[Self], file_dict: dict[str, str | bytes]) -> Self: ... diff --git a/django-stubs/core/handlers/base.pyi b/django-stubs/core/handlers/base.pyi index fa1c9c350..011722786 100644 --- a/django-stubs/core/handlers/base.pyi +++ b/django-stubs/core/handlers/base.pyi @@ -12,7 +12,7 @@ class BaseHandler: is_async: bool, method: Callable[[HttpRequest], HttpResponseBase | Awaitable[HttpResponseBase]], method_is_async: bool | None = ..., - debug: bool = False, + debug: bool = ..., name: str | None = ..., ) -> Callable[[HttpRequest], HttpResponseBase | Awaitable[HttpResponseBase]]: ... def get_response(self, request: HttpRequest) -> HttpResponseBase: ... diff --git a/django-stubs/core/mail/backends/base.pyi b/django-stubs/core/mail/backends/base.pyi index 369e41c74..3d46d8b82 100644 --- a/django-stubs/core/mail/backends/base.pyi +++ b/django-stubs/core/mail/backends/base.pyi @@ -1,17 +1,16 @@ from collections.abc import Sequence from types import TracebackType -from typing import Any, TypeVar +from typing import Any +from _typeshed import Self from django.core.mail.message import EmailMessage -_T = TypeVar("_T", bound="BaseEmailBackend") - class BaseEmailBackend: fail_silently: bool def __init__(self, fail_silently: bool = ..., **kwargs: Any) -> None: ... def open(self) -> bool | None: ... def close(self) -> None: ... - def __enter__(self: _T) -> _T: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None, diff --git a/django-stubs/core/mail/message.pyi b/django-stubs/core/mail/message.pyi index 3c4dcae8f..bfa286982 100644 --- a/django-stubs/core/mail/message.pyi +++ b/django-stubs/core/mail/message.pyi @@ -6,7 +6,10 @@ from email.mime.base import MIMEBase from email.mime.message import MIMEMessage from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText -from typing import Any, Tuple, overload + +# switch to tuple once https://github.com/python/mypy/issues/11098 is fixed +# remove Optional once python 3.7 is dropped (Tuple[str | None, ...] works with mypy on py3.10) +from typing import Any, Optional, Tuple, overload # noqa: Y022, Y037 from typing_extensions import TypeAlias @@ -23,8 +26,8 @@ def forbid_multi_line_headers(name: str, val: str, encoding: str) -> tuple[str, def sanitize_address(addr: tuple[str, str] | str, encoding: str) -> str: ... class MIMEMixin: - def as_string(self, unixfrom: bool = ..., linesep: str = "\n") -> str: ... - def as_bytes(self, unixfrom: bool = ..., linesep: str = "\n") -> bytes: ... + def as_string(self, unixfrom: bool = ..., linesep: str = ...) -> str: ... + def as_bytes(self, unixfrom: bool = ..., linesep: str = ...) -> bytes: ... class SafeMIMEMessage(MIMEMixin, MIMEMessage): # type: ignore defects: list[Any] @@ -63,8 +66,11 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): # type: ignore _AttachmentContent: TypeAlias = bytes | EmailMessage | Message | SafeMIMEText | str # switch to tuple once https://github.com/python/mypy/issues/11098 is fixed +# remove Optional once python 3.7 is dropped (Tuple[str | None, ...] works with mypy on py3.10) _AttachmentTuple: TypeAlias = ( - Tuple[str, _AttachmentContent] | Tuple[str | None, _AttachmentContent, str] | Tuple[str, _AttachmentContent, None] + Tuple[str, _AttachmentContent] + | Tuple[Optional[str], _AttachmentContent, str] + | Tuple[str, _AttachmentContent, None] ) class EmailMessage: diff --git a/django-stubs/core/paginator.pyi b/django-stubs/core/paginator.pyi index 147a117e3..b0da16dbf 100644 --- a/django-stubs/core/paginator.pyi +++ b/django-stubs/core/paginator.pyi @@ -31,8 +31,8 @@ class Paginator(Generic[_T]): allow_empty_first_page: bool = ..., ) -> None: ... def __iter__(self) -> Iterator[Page[_T]]: ... - def validate_number(self, number: int | float | str) -> int: ... - def get_page(self, number: int | float | str | None) -> Page[_T]: ... + def validate_number(self, number: float | str) -> int: ... + def get_page(self, number: float | str | None) -> Page[_T]: ... def page(self, number: int | str) -> Page[_T]: ... @property def count(self) -> int: ... @@ -41,7 +41,7 @@ class Paginator(Generic[_T]): @property def page_range(self) -> range: ... def get_elided_page_range( - self, number: int | float | str = ..., *, on_each_side: int = ..., on_ends: int = ... + self, number: float | str = ..., *, on_each_side: int = ..., on_ends: int = ... ) -> Iterator[str | int]: ... QuerySetPaginator: TypeAlias = Paginator diff --git a/django-stubs/core/validators.pyi b/django-stubs/core/validators.pyi index 459d6af07..f7f748761 100644 --- a/django-stubs/core/validators.pyi +++ b/django-stubs/core/validators.pyi @@ -11,7 +11,7 @@ EMPTY_VALUES: Any _Regex: TypeAlias = str | Pattern[str] -_ValidatorCallable: TypeAlias = Callable[[Any], None] +_ValidatorCallable: TypeAlias = Callable[[Any], None] # noqa: Y047 class RegexValidator: regex: _Regex # Pattern[str] on instance, but may be str on class definition @@ -66,7 +66,7 @@ class EmailValidator: def domain_whitelist(self, allowlist: Sequence[str]) -> None: ... def __call__(self, value: str | None) -> None: ... def validate_domain_part(self, domain_part: str) -> bool: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... validate_email: EmailValidator slug_re: Pattern[str] @@ -96,7 +96,7 @@ class BaseValidator: def __call__(self, value: Any) -> None: ... def compare(self, a: Any, b: Any) -> bool: ... def clean(self, x: Any) -> Any: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... class MaxValueValidator(BaseValidator): message: str @@ -126,7 +126,7 @@ class DecimalValidator: decimal_places: int | None def __init__(self, max_digits: int | None, decimal_places: int | None) -> None: ... def __call__(self, value: Decimal) -> None: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... class FileExtensionValidator: message: str diff --git a/django-stubs/db/backends/base/base.pyi b/django-stubs/db/backends/base/base.pyi index 30acbd2a3..b5ac3e0e6 100644 --- a/django-stubs/db/backends/base/base.pyi +++ b/django-stubs/db/backends/base/base.pyi @@ -1,8 +1,9 @@ from collections.abc import Callable, Generator, Iterator, MutableMapping from contextlib import contextmanager from datetime import tzinfo -from typing import Any, TypeVar +from typing import Any +from _typeshed import Self from django.db.backends.base.client import BaseDatabaseClient from django.db.backends.base.creation import BaseDatabaseCreation from django.db.backends.base.features import BaseDatabaseFeatures @@ -16,7 +17,6 @@ from typing_extensions import TypeAlias NO_DB_ALIAS: str RAN_DB_VERSION_CHECK: set[str] -_T = TypeVar("_T", bound="BaseDatabaseWrapper") _ExecuteWrapper: TypeAlias = Callable[ [Callable[[str, Any, bool, dict[str, Any]], Any], str, Any, bool, dict[str, Any]], Any ] @@ -119,4 +119,4 @@ class BaseDatabaseWrapper: def run_and_clear_commit_hooks(self) -> None: ... @contextmanager def execute_wrapper(self, wrapper: _ExecuteWrapper) -> Generator[None, None, None]: ... - def copy(self: _T, alias: str | None = ...) -> _T: ... + def copy(self: Self, alias: str | None = ...) -> Self: ... diff --git a/django-stubs/db/backends/base/schema.pyi b/django-stubs/db/backends/base/schema.pyi index 706355f99..324d1c34d 100644 --- a/django-stubs/db/backends/base/schema.pyi +++ b/django-stubs/db/backends/base/schema.pyi @@ -4,6 +4,7 @@ from logging import Logger from types import TracebackType from typing import Any +from _typeshed import Self from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.ddl_references import Statement from django.db.models.base import Model @@ -49,7 +50,7 @@ class BaseDatabaseSchemaEditor(AbstractContextManager[Any]): def __init__(self, connection: BaseDatabaseWrapper, collect_sql: bool = ..., atomic: bool = ...) -> None: ... deferred_sql: Any atomic: Any - def __enter__(self) -> BaseDatabaseSchemaEditor: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None, diff --git a/django-stubs/db/backends/utils.pyi b/django-stubs/db/backends/utils.pyi index b8d10754f..a91a0061c 100644 --- a/django-stubs/db/backends/utils.pyi +++ b/django-stubs/db/backends/utils.pyi @@ -7,6 +7,7 @@ from types import TracebackType from typing import Any, Protocol, overload from uuid import UUID +from _typeshed import Self from typing_extensions import Literal, TypeAlias logger: Logger @@ -43,7 +44,7 @@ class CursorWrapper: WRAP_ERROR_ATTRS: Any def __getattr__(self, attr: str) -> Any: ... def __iter__(self) -> Iterator[tuple[Any, ...]]: ... - def __enter__(self) -> CursorWrapper: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None, diff --git a/django-stubs/db/migrations/graph.pyi b/django-stubs/db/migrations/graph.pyi index 4f0afe7d7..855038846 100644 --- a/django-stubs/db/migrations/graph.pyi +++ b/django-stubs/db/migrations/graph.pyi @@ -11,7 +11,7 @@ class Node: children: set[Any] parents: set[Any] def __init__(self, key: tuple[str, str]) -> None: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... def __lt__(self, other: tuple[str, str] | Node) -> bool: ... def __getitem__(self, item: int) -> str: ... def __hash__(self) -> int: ... diff --git a/django-stubs/db/migrations/migration.pyi b/django-stubs/db/migrations/migration.pyi index a9292be9f..35d557382 100644 --- a/django-stubs/db/migrations/migration.pyi +++ b/django-stubs/db/migrations/migration.pyi @@ -1,3 +1,4 @@ +from _typeshed import Self from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.migrations.operations.base import Operation from django.db.migrations.state import ProjectState @@ -22,6 +23,6 @@ class Migration: class SwappableTuple(tuple[str, str]): setting: str - def __new__(cls, value: tuple[str, str], setting: str) -> SwappableTuple: ... + def __new__(cls: type[Self], value: tuple[str, str], setting: str) -> Self: ... def swappable_dependency(value: str) -> SwappableTuple: ... diff --git a/django-stubs/db/migrations/operations/special.pyi b/django-stubs/db/migrations/operations/special.pyi index 7fd380fb5..c122d85b1 100644 --- a/django-stubs/db/migrations/operations/special.pyi +++ b/django-stubs/db/migrations/operations/special.pyi @@ -1,5 +1,5 @@ from collections.abc import Mapping, Sequence -from typing import Any, Optional, Union +from typing import Any, Optional # noqa: Y037 # https://github.com/python/mypy/issues/12211 from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.migrations.state import StateApps @@ -17,25 +17,21 @@ class SeparateDatabaseAndState(Operation): class RunSQL(Operation): noop: Literal[""] - sql: Union[str, _ListOrTuple[Union[str, tuple[str, Union[dict[str, Any], Optional[_ListOrTuple[str]]]]]]] - reverse_sql: Optional[ - Union[str, _ListOrTuple[Union[str, tuple[str, Union[dict[str, Any], Optional[_ListOrTuple[str]]]]]]] - ] + sql: str | _ListOrTuple[str | tuple[str, dict[str, Any] | Optional[_ListOrTuple[str]]]] + reverse_sql: str | None | _ListOrTuple[str | tuple[str, dict[str, Any] | Optional[_ListOrTuple[str]]]] state_operations: Sequence[Operation] hints: Mapping[str, Any] def __init__( self, - sql: Union[str, _ListOrTuple[Union[str, tuple[str, Union[dict[str, Any], Optional[_ListOrTuple[str]]]]]]], - reverse_sql: Optional[ - Union[str, _ListOrTuple[Union[str, tuple[str, Union[dict[str, Any], Optional[_ListOrTuple[str]]]]]]] - ] = ..., + sql: str | _ListOrTuple[str | tuple[str, dict[str, Any] | Optional[_ListOrTuple[str]]]], + reverse_sql: str | None | _ListOrTuple[str | tuple[str, dict[str, Any] | Optional[_ListOrTuple[str]]]] = ..., state_operations: Sequence[Operation] = ..., hints: Mapping[str, Any] | None = ..., elidable: bool = ..., ) -> None: ... class _CodeCallable(Protocol): - def __call__(self, __state_apps: StateApps, __shema_editor: BaseDatabaseSchemaEditor) -> None: ... + def __call__(self, __state_apps: StateApps, __schema_editor: BaseDatabaseSchemaEditor) -> None: ... class RunPython(Operation): code: _CodeCallable diff --git a/django-stubs/db/migrations/state.pyi b/django-stubs/db/migrations/state.pyi index 6a211bc89..e09472879 100644 --- a/django-stubs/db/migrations/state.pyi +++ b/django-stubs/db/migrations/state.pyi @@ -37,7 +37,7 @@ class ModelState: def render(self, apps: Apps) -> Any: ... def get_index_by_name(self, name: str) -> Any: ... def get_constraint_by_name(self, name: str) -> Any: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... def get_related_models_tuples(model: type[Model]) -> set[tuple[str, str]]: ... def get_related_models_recursive(model: type[Model]) -> set[tuple[str, str]]: ... diff --git a/django-stubs/db/models/base.pyi b/django-stubs/db/models/base.pyi index 26724afc5..5070352a3 100644 --- a/django-stubs/db/models/base.pyi +++ b/django-stubs/db/models/base.pyi @@ -1,13 +1,14 @@ from collections.abc import Collection, Iterable, Sequence from typing import Any, TypeVar +from _typeshed import Self from django.core.checks.messages import CheckMessage from django.core.exceptions import MultipleObjectsReturned as BaseMultipleObjectsReturned from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.db.models.manager import BaseManager from django.db.models.options import Options -_Self = TypeVar("_Self", bound="Model") +_Self = TypeVar("_Self", bound=Model) class ModelStateFieldsCacheDescriptor: ... @@ -31,17 +32,17 @@ class Model(metaclass=ModelBase): _meta: Options[Any] pk: Any _state: ModelState - def __init__(self: _Self, *args: Any, **kwargs: Any) -> None: ... + def __init__(self: Self, *args: Any, **kwargs: Any) -> None: ... @classmethod def add_to_class(cls, name: str, value: Any) -> Any: ... @classmethod - def from_db(cls: type[_Self], db: str | None, field_names: Collection[str], values: Collection[Any]) -> _Self: ... + def from_db(cls: type[Self], db: str | None, field_names: Collection[str], values: Collection[Any]) -> Self: ... def delete(self, using: Any = ..., keep_parents: bool = ...) -> tuple[int, dict[str, int]]: ... def full_clean(self, exclude: Iterable[str] | None = ..., validate_unique: bool = ...) -> None: ... def clean(self) -> None: ... def clean_fields(self, exclude: Collection[str] | None = ...) -> None: ... def validate_unique(self, exclude: Collection[str] | None = ...) -> None: ... - def unique_error_message(self, model_class: type[_Self], unique_check: Sequence[str]) -> ValidationError: ... + def unique_error_message(self, model_class: type[Self], unique_check: Sequence[str]) -> ValidationError: ... def save( self, force_insert: bool = ..., @@ -57,7 +58,7 @@ class Model(metaclass=ModelBase): using: str | None = ..., update_fields: Iterable[str] | None = ..., ) -> None: ... - def refresh_from_db(self: _Self, using: str | None = ..., fields: Sequence[str] | None = ...) -> None: ... + def refresh_from_db(self: Self, using: str | None = ..., fields: Sequence[str] | None = ...) -> None: ... def get_deferred_fields(self) -> set[str]: ... @classmethod def check(cls, **kwargs: Any) -> list[CheckMessage]: ... diff --git a/django-stubs/db/models/constraints.pyi b/django-stubs/db/models/constraints.pyi index c2a6d9829..ab7d94d3b 100644 --- a/django-stubs/db/models/constraints.pyi +++ b/django-stubs/db/models/constraints.pyi @@ -2,13 +2,12 @@ from collections.abc import Sequence from enum import Enum from typing import Any, TypeVar, overload +from _typeshed import Self from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.models.base import Model from django.db.models.expressions import Combinable from django.db.models.query_utils import Q -_T = TypeVar("_T", bound="BaseConstraint") - class Deferrable(Enum): DEFERRED: str IMMEDIATE: str @@ -20,7 +19,7 @@ class BaseConstraint: def create_sql(self, model: type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ... def remove_sql(self, model: type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ... def deconstruct(self) -> Any: ... - def clone(self: _T) -> _T: ... + def clone(self: Self) -> Self: ... class CheckConstraint(BaseConstraint): check: Q diff --git a/django-stubs/db/models/deletion.pyi b/django-stubs/db/models/deletion.pyi index 23c8b7801..7b688a61c 100644 --- a/django-stubs/db/models/deletion.pyi +++ b/django-stubs/db/models/deletion.pyi @@ -9,37 +9,37 @@ from django.db.models.query import QuerySet from django.utils.datastructures import _IndexableCollection def CASCADE( - collector: "Collector", + collector: Collector, field: Field[Any, Any], sub_objs: QuerySet[Model], using: str, ) -> None: ... def SET_NULL( - collector: "Collector", + collector: Collector, field: Field[Any, Any], sub_objs: QuerySet[Model], using: str, ) -> None: ... def SET_DEFAULT( - collector: "Collector", + collector: Collector, field: Field[Any, Any], sub_objs: QuerySet[Model], using: str, ) -> None: ... def DO_NOTHING( - collector: "Collector", + collector: Collector, field: Field[Any, Any], sub_objs: QuerySet[Model], using: str, ) -> None: ... def PROTECT( - collector: "Collector", + collector: Collector, field: Field[Any, Any], sub_objs: QuerySet[Model], using: str, ) -> None: ... def RESTRICT( - collector: "Collector", + collector: Collector, field: Field[Any, Any], sub_objs: QuerySet[Model], using: str, diff --git a/django-stubs/db/models/expressions.pyi b/django-stubs/db/models/expressions.pyi index fda668a2f..8ccfa062f 100644 --- a/django-stubs/db/models/expressions.pyi +++ b/django-stubs/db/models/expressions.pyi @@ -3,6 +3,7 @@ from collections.abc import Callable, Iterable, Iterator, Sequence from decimal import Decimal from typing import Any, TypeVar +from _typeshed import Self from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models import Q from django.db.models.fields import Field @@ -15,7 +16,6 @@ from typing_extensions import Literal, TypeAlias class SQLiteNumericMixin: def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... -_Self = TypeVar("_Self") _Numeric: TypeAlias = float | Decimal class Combinable: @@ -53,8 +53,6 @@ class Combinable: def __rand__(self, other: Any) -> Combinable: ... def __ror__(self, other: Any) -> Combinable: ... -_SelfB = TypeVar("_SelfB", bound="BaseExpression") - class BaseExpression: is_summary: bool filterable: bool @@ -70,13 +68,13 @@ class BaseExpression: @property def contains_column_references(self) -> bool: ... def resolve_expression( - self: _SelfB, + self: Self, query: Any = ..., allow_joins: bool = ..., reuse: set[str] | None = ..., summarize: bool = ..., for_save: bool = ..., - ) -> _SelfB: ... + ) -> Self: ... @property def conditional(self) -> bool: ... @property @@ -87,9 +85,9 @@ class BaseExpression: def convert_value(self) -> Callable: ... def get_lookup(self, lookup: str) -> type[Lookup] | None: ... def get_transform(self, name: str) -> type[Transform] | None: ... - def relabeled_clone(self: _SelfB, change_map: dict[str | None, str]) -> _SelfB: ... - def copy(self: _SelfB) -> _SelfB: ... - def get_group_by_cols(self: _SelfB, alias: str | None = ...) -> list[_SelfB]: ... + def relabeled_clone(self: Self, change_map: dict[str | None, str]) -> Self: ... + def copy(self: Self) -> Self: ... + def get_group_by_cols(self: Self, alias: str | None = ...) -> list[Self]: ... def get_source_fields(self) -> list[Field | None]: ... def asc( self, @@ -148,7 +146,7 @@ class ResolvedOuterRef(F): ... class OuterRef(F): def __init__(self, name: str | OuterRef) -> None: ... contains_aggregate: bool - def relabeled_clone(self: _Self, relabels: Any) -> _Self: ... + def relabeled_clone(self: Self, relabels: Any) -> Self: ... class Subquery(BaseExpression, Combinable): template: str diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 08f87745d..6068447c7 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -6,6 +6,7 @@ from datetime import datetime as real_datetime from datetime import time, timedelta from typing import Any, Generic, TypeVar, overload +from _typeshed import Self from django.core import validators # due to weird mypy.stubtest error from django.core.checks import CheckMessage from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist @@ -35,10 +36,9 @@ _LimitChoicesTo: TypeAlias = Q | dict[str, Any] class _ChoicesCallable(Protocol): def __call__(self) -> _FieldChoices: ... -_AllLimitChoicesTo: TypeAlias = _LimitChoicesTo | _ChoicesCallable +_AllLimitChoicesTo: TypeAlias = _LimitChoicesTo | _ChoicesCallable # noqa: Y047 _ErrorMessagesT: TypeAlias = dict[str, Any] -_T = TypeVar("_T", bound="Field") # __set__ value type _ST = TypeVar("_ST", contravariant=True) # __get__ return type @@ -172,13 +172,13 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): def __set__(self, instance: Any, value: _ST) -> None: ... # class access @overload - def __get__(self: _T, instance: None, owner: Any) -> _T: ... + def __get__(self: Self, instance: None, owner: Any) -> Self: ... # Model instance access @overload def __get__(self, instance: Model, owner: Any) -> _GT: ... # non-Model instances @overload - def __get__(self: _T, instance: Any, owner: Any) -> _T: ... + def __get__(self: Self, instance: Any, owner: Any) -> Self: ... def deconstruct(self) -> Any: ... def set_attributes_from_name(self, name: str) -> None: ... def db_type_parameters(self, connection: BaseDatabaseWrapper) -> DictWrapper: ... @@ -221,7 +221,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): def value_to_string(self, obj: Model) -> str: ... class IntegerField(Field[_ST, _GT]): - _pyi_private_set_type: float | int | str | Combinable + _pyi_private_set_type: float | str | Combinable _pyi_private_get_type: int _pyi_lookup_exact_type: str | int @@ -235,7 +235,7 @@ class SmallIntegerField(IntegerField[_ST, _GT]): ... class BigIntegerField(IntegerField[_ST, _GT]): ... class FloatField(Field[_ST, _GT]): - _pyi_private_set_type: float | int | str | Combinable + _pyi_private_set_type: float | str | Combinable _pyi_private_get_type: float _pyi_lookup_exact_type: float diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index 7888ac93c..a7c55f54d 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -1,6 +1,7 @@ from collections.abc import Callable, Iterable from typing import Any, TypeVar, overload +from _typeshed import Self from django.core import validators # due to weird mypy.stubtest error from django.core.files.base import File from django.core.files.images import ImageFile @@ -35,7 +36,6 @@ class FileDescriptor(DeferredAttribute): def __set__(self, instance: Model, value: Any | None) -> None: ... def __get__(self, instance: Model | None, cls: type[Model] | None = ...) -> FieldFile | FileDescriptor: ... -_T = TypeVar("_T", bound="Field") _M = TypeVar("_M", bound=Model, contravariant=True) class _UploadToCallable(Protocol[_M]): @@ -78,7 +78,7 @@ class FileField(Field): def __get__(self, instance: Model, owner: Any) -> Any: ... # non-Model instances @overload - def __get__(self: _T, instance: Any, owner: Any) -> _T: ... + def __get__(self: Self, instance: Any, owner: Any) -> Self: ... def generate_filename(self, instance: Model | None, filename: _PathCompatible) -> str: ... class ImageFileDescriptor(FileDescriptor): @@ -106,5 +106,5 @@ class ImageField(FileField): def __get__(self, instance: Model, owner: Any) -> Any: ... # non-Model instances @overload - def __get__(self: _T, instance: Any, owner: Any) -> _T: ... + def __get__(self: Self, instance: Any, owner: Any) -> Self: ... def update_dimension_fields(self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/db/models/fields/related.pyi b/django-stubs/db/models/fields/related.pyi index eb8b05c2f..d4e90e61b 100644 --- a/django-stubs/db/models/fields/related.pyi +++ b/django-stubs/db/models/fields/related.pyi @@ -2,8 +2,8 @@ from collections.abc import Callable, Iterable, Sequence from typing import Any, TypeVar, overload from uuid import UUID +from _typeshed import Self from django.core import validators # due to weird mypy.stubtest error -from django.db import models from django.db.models.base import Model from django.db.models.expressions import Combinable from django.db.models.fields import Field, _AllLimitChoicesTo, _ErrorMessagesT, _FieldChoices, _LimitChoicesTo @@ -24,9 +24,6 @@ from django.db.models.query_utils import FilteredRelation, PathInfo, Q from django.utils.functional import _StrOrPromise from typing_extensions import Literal -_T = TypeVar("_T", bound=models.Model) -_F = TypeVar("_F", bound=models.Field) - RECURSIVE_RELATIONSHIP_CONSTANT: Literal["self"] def resolve_relation(scope_model: type[Model], relation: str | type[Model]) -> str | type[Model]: ... @@ -154,7 +151,7 @@ class ForeignKey(ForeignObject[_ST, _GT]): def __get__(self, instance: Model, owner: Any) -> _GT: ... # non-Model instances @overload - def __get__(self: _F, instance: Any, owner: Any) -> _F: ... + def __get__(self: Self, instance: Any, owner: Any) -> Self: ... class OneToOneField(ForeignKey[_ST, _GT]): _pyi_private_set_type: Any | Combinable @@ -203,7 +200,7 @@ class OneToOneField(ForeignKey[_ST, _GT]): def __get__(self, instance: Model, owner: Any) -> _GT: ... # non-Model instances @overload - def __get__(self: _F, instance: Any, owner: Any) -> _F: ... + def __get__(self: Self, instance: Any, owner: Any) -> Self: ... class ManyToManyField(RelatedField[_ST, _GT]): _pyi_private_set_type: Sequence[Any] @@ -263,7 +260,7 @@ class ManyToManyField(RelatedField[_ST, _GT]): def __get__(self, instance: Model, owner: Any) -> _GT: ... # non-Model instances @overload - def __get__(self: _F, instance: Any, owner: Any) -> _F: ... + def __get__(self: Self, instance: Any, owner: Any) -> Self: ... def get_path_info(self, filtered_relation: FilteredRelation | None = ...) -> list[PathInfo]: ... def get_reverse_path_info(self, filtered_relation: FilteredRelation | None = ...) -> list[PathInfo]: ... def contribute_to_related_class(self, cls: type[Model], related: RelatedField) -> None: ... diff --git a/django-stubs/db/models/lookups.pyi b/django-stubs/db/models/lookups.pyi index 78f6a19bb..e9d3429b5 100644 --- a/django-stubs/db/models/lookups.pyi +++ b/django-stubs/db/models/lookups.pyi @@ -1,6 +1,7 @@ from collections.abc import Iterable, Mapping from typing import Any, Generic, TypeVar +from _typeshed import Self from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.expressions import Expression, Func from django.db.models.query_utils import RegisterLookupMixin @@ -8,7 +9,6 @@ from django.db.models.sql.compiler import SQLCompiler, _AsSqlType, _ParamT from django.utils.datastructures import OrderedSet from typing_extensions import Literal -_L = TypeVar("_L", bound="Lookup") _T = TypeVar("_T") class Lookup(Generic[_T]): @@ -32,7 +32,7 @@ class Lookup(Generic[_T]): ) -> _AsSqlType: ... def process_rhs(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... def rhs_is_direct_value(self) -> bool: ... - def relabeled_clone(self: _L, relabels: Mapping[str, str]) -> _L: ... + def relabeled_clone(self: Self, relabels: Mapping[str, str]) -> Self: ... def get_group_by_cols(self, alias: str | None = ...) -> list[Expression]: ... def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... def as_oracle(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... @@ -83,8 +83,8 @@ class IntegerFieldFloatRounding: rhs: Any def get_prep_lookup(self) -> Any: ... -class IntegerGreaterThanOrEqual(IntegerFieldFloatRounding, GreaterThanOrEqual[int | float]): ... -class IntegerLessThan(IntegerFieldFloatRounding, LessThan[int | float]): ... +class IntegerGreaterThanOrEqual(IntegerFieldFloatRounding, GreaterThanOrEqual[float]): ... +class IntegerLessThan(IntegerFieldFloatRounding, LessThan[float]): ... class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup): def split_parameter_list_as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> Any: ... diff --git a/django-stubs/db/models/manager.pyi b/django-stubs/db/models/manager.pyi index a989f2971..d287e6836 100644 --- a/django-stubs/db/models/manager.pyi +++ b/django-stubs/db/models/manager.pyi @@ -2,6 +2,7 @@ import datetime from collections.abc import Collection, Iterable, Iterator, MutableMapping, Sequence from typing import Any, Generic, NoReturn, TypeVar, overload +from _typeshed import Self from django.db.models import Combinable from django.db.models.base import Model from django.db.models.query import QuerySet, RawQuerySet @@ -9,7 +10,6 @@ from django.db.models.query import QuerySet, RawQuerySet from django_stubs_ext import ValuesQuerySet _T = TypeVar("_T", bound=Model, covariant=True) -_M = TypeVar("_M", bound="BaseManager") class BaseManager(Generic[_T]): creation_counter: int @@ -28,7 +28,7 @@ class BaseManager(Generic[_T]): @classmethod def _get_queryset_methods(cls, queryset_class: type) -> dict[str, Any]: ... def contribute_to_class(self, cls: type[Model], name: str) -> None: ... - def db_manager(self: _M, using: str | None = ..., hints: dict[str, Model] | None = ...) -> _M: ... + def db_manager(self: Self, using: str | None = ..., hints: dict[str, Model] | None = ...) -> Self: ... @property def db(self) -> str: ... def get_queryset(self) -> QuerySet[_T]: ... diff --git a/django-stubs/db/models/options.pyi b/django-stubs/db/models/options.pyi index 300603285..5fa1c47e2 100644 --- a/django-stubs/db/models/options.pyi +++ b/django-stubs/db/models/options.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable, Sequence -from typing import Any, Generic, TypeVar, Union, overload +from typing import Any, Generic, TypeVar, Union, overload # noqa: Y037 # https://github.com/python/mypy/issues/12211 from django.apps.config import AppConfig from django.apps.registry import Apps @@ -21,7 +21,8 @@ EMPTY_RELATION_TREE: Any IMMUTABLE_WARNING: str DEFAULT_NAMES: tuple[str, ...] -_OptionTogetherT: TypeAlias = Union[_ListOrTuple[Union[_ListOrTuple[str], str]], set[tuple[str, ...]]] +# https://github.com/python/mypy/issues/12211 +_OptionTogetherT: TypeAlias = Union[_ListOrTuple[_ListOrTuple[str] | str], set[tuple[str, ...]]] # noqa: Y047 @overload def normalize_together(option_together: _ListOrTuple[_ListOrTuple[str] | str]) -> tuple[tuple[str, ...], ...]: ... @@ -34,7 +35,7 @@ _T = TypeVar("_T") def make_immutable_fields_list(name: str, data: Iterable[_T]) -> ImmutableList[_T]: ... -_M = TypeVar("_M", bound="Model") +_M = TypeVar("_M", bound=Model) class Options(Generic[_M]): constraints: list[BaseConstraint] diff --git a/django-stubs/db/models/query.pyi b/django-stubs/db/models/query.pyi index 8871bf446..279d9e434 100644 --- a/django-stubs/db/models/query.pyi +++ b/django-stubs/db/models/query.pyi @@ -2,6 +2,7 @@ import datetime from collections.abc import AsyncIterator, Collection, Iterable, Iterator, MutableMapping, Reversible, Sequence, Sized from typing import Any, Generic, NamedTuple, TypeVar, overload +from _typeshed import Self from django.db.models import Manager from django.db.models.base import Model from django.db.models.expressions import Combinable as Combinable # noqa: F401 @@ -12,7 +13,7 @@ from typing_extensions import TypeAlias _T = TypeVar("_T", bound=Model, covariant=True) _Row = TypeVar("_Row", covariant=True) -_QS = TypeVar("_QS", bound="_QuerySet") +_QS = TypeVar("_QS", bound=_QuerySet) _TupleT = TypeVar("_TupleT", bound=tuple[Any, ...], covariant=True) MAX_GET_RESULTS: int @@ -60,8 +61,8 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): def __class_getitem__(cls: type[_QS], item: type[_T]) -> type[_QS]: ... def __getstate__(self) -> dict[str, Any]: ... # Technically, the other QuerySet must be of the same type _T, but _T is covariant - def __and__(self: _QS, other: _QuerySet[_T, _Row]) -> _QS: ... - def __or__(self: _QS, other: _QuerySet[_T, _Row]) -> _QS: ... + def __and__(self: Self, other: _QuerySet[_T, _Row]) -> Self: ... + def __or__(self: Self, other: _QuerySet[_T, _Row]) -> Self: ... # IMPORTANT: When updating any of the following methods' signatures, please ALSO modify # the corresponding method in BaseManager. def iterator(self, chunk_size: int = ...) -> Iterator[_Row]: ... @@ -134,25 +135,25 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): def datetimes( self, field_name: str, kind: str, order: str = ..., tzinfo: datetime.tzinfo | None = ... ) -> _QuerySet[_T, datetime.datetime]: ... - def none(self: _QS) -> _QS: ... - def all(self: _QS) -> _QS: ... - def filter(self: _QS, *args: Any, **kwargs: Any) -> _QS: ... - def exclude(self: _QS, *args: Any, **kwargs: Any) -> _QS: ... - def complex_filter(self: _QS, filter_obj: Any) -> _QS: ... + def none(self: Self) -> Self: ... + def all(self: Self) -> Self: ... + def filter(self: Self, *args: Any, **kwargs: Any) -> Self: ... + def exclude(self: Self, *args: Any, **kwargs: Any) -> Self: ... + def complex_filter(self: Self, filter_obj: Any) -> Self: ... def count(self) -> int: ... async def acount(self) -> int: ... - def union(self: _QS, *other_qs: Any, all: bool = ...) -> _QS: ... - def intersection(self: _QS, *other_qs: Any) -> _QS: ... - def difference(self: _QS, *other_qs: Any) -> _QS: ... + def union(self: Self, *other_qs: Any, all: bool = ...) -> Self: ... + def intersection(self: Self, *other_qs: Any) -> Self: ... + def difference(self: Self, *other_qs: Any) -> Self: ... def select_for_update( - self: _QS, nowait: bool = ..., skip_locked: bool = ..., of: Sequence[str] = ..., no_key: bool = ... - ) -> _QS: ... - def select_related(self: _QS, *fields: Any) -> _QS: ... - def prefetch_related(self: _QS, *lookups: Any) -> _QS: ... - def annotate(self: _QS, *args: Any, **kwargs: Any) -> _QS: ... - def alias(self: _QS, *args: Any, **kwargs: Any) -> _QS: ... - def order_by(self: _QS, *field_names: Any) -> _QS: ... - def distinct(self: _QS, *field_names: Any) -> _QS: ... + self: Self, nowait: bool = ..., skip_locked: bool = ..., of: Sequence[str] = ..., no_key: bool = ... + ) -> Self: ... + def select_related(self: Self, *fields: Any) -> Self: ... + def prefetch_related(self: Self, *lookups: Any) -> Self: ... + def annotate(self: Self, *args: Any, **kwargs: Any) -> Self: ... + def alias(self: Self, *args: Any, **kwargs: Any) -> Self: ... + def order_by(self: Self, *field_names: Any) -> Self: ... + def distinct(self: Self, *field_names: Any) -> Self: ... # extra() return type won't be supported any time soon def extra( self, @@ -163,10 +164,10 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): order_by: Sequence[str] | None = ..., select_params: Sequence[Any] | None = ..., ) -> _QuerySet[Any, Any]: ... - def reverse(self: _QS) -> _QS: ... - def defer(self: _QS, *fields: Any) -> _QS: ... - def only(self: _QS, *fields: Any) -> _QS: ... - def using(self: _QS, alias: str | None) -> _QS: ... + def reverse(self: Self) -> Self: ... + def defer(self: Self, *fields: Any) -> Self: ... + def only(self: Self, *fields: Any) -> Self: ... + def using(self: Self, alias: str | None) -> Self: ... @property def ordered(self) -> bool: ... @property @@ -178,7 +179,7 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): @overload def __getitem__(self, i: int) -> _Row: ... @overload - def __getitem__(self: _QS, s: slice) -> _QS: ... + def __getitem__(self: Self, s: slice) -> Self: ... def __reversed__(self) -> Iterator[_Row]: ... class RawQuerySet(Iterable[_T], Sized): @@ -214,7 +215,7 @@ class RawQuerySet(Iterable[_T], Sized): def resolve_model_init_order(self) -> tuple[list[str], list[int], list[tuple[str, int]]]: ... def using(self, alias: str | None) -> RawQuerySet[_T]: ... -_QuerySetAny: TypeAlias = _QuerySet +_QuerySetAny: TypeAlias = _QuerySet # noqa: Y047 QuerySet: TypeAlias = _QuerySet[_T, _T] diff --git a/django-stubs/db/models/sql/compiler.pyi b/django-stubs/db/models/sql/compiler.pyi index c20542a11..a7601c8b2 100644 --- a/django-stubs/db/models/sql/compiler.pyi +++ b/django-stubs/db/models/sql/compiler.pyi @@ -47,7 +47,7 @@ class SQLCompiler: ) -> list[Expression]: ... def get_select( self, - ) -> tuple[list[tuple[Expression, _AsSqlType, str | None]], dict[str, Any] | None, dict[str, int],]: ... + ) -> tuple[list[tuple[Expression, _AsSqlType, str | None]], dict[str, Any] | None, dict[str, int]]: ... def get_order_by(self) -> list[tuple[Expression, tuple[str, _ParamsT, bool]]]: ... def get_extra_select( self, diff --git a/django-stubs/forms/fields.pyi b/django-stubs/forms/fields.pyi index aec81189f..b49e95690 100644 --- a/django-stubs/forms/fields.pyi +++ b/django-stubs/forms/fields.pyi @@ -122,8 +122,8 @@ class FloatField(IntegerField): def __init__( self, *, - max_value: int | float | None = ..., - min_value: int | float | None = ..., + max_value: float | None = ..., + min_value: float | None = ..., required: bool = ..., widget: Widget | type[Widget] | None = ..., label: _StrOrPromise | None = ..., @@ -146,8 +146,8 @@ class DecimalField(IntegerField): def __init__( self, *, - max_value: Decimal | int | float | None = ..., - min_value: Decimal | int | float | None = ..., + max_value: Decimal | float | None = ..., + min_value: Decimal | float | None = ..., max_digits: int | None = ..., decimal_places: int | None = ..., required: bool = ..., diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index 69fcadf37..674089219 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -1,5 +1,12 @@ from collections.abc import Callable, Collection, Container, Iterator, Mapping, Sequence -from typing import Any, ClassVar, Generic, TypeAlias, TypeVar, Union, overload +from typing import ( # noqa: Y037 # https://github.com/python/mypy/issues/12211 + Any, + ClassVar, + Generic, + TypeVar, + Union, + overload, +) from uuid import UUID from django.db import models @@ -8,21 +15,21 @@ from django.db.models.base import Model from django.db.models.fields import _AllLimitChoicesTo, _ChoicesCallable, _FieldChoices, _LimitChoicesTo from django.db.models.manager import Manager from django.db.models.query import QuerySet -from django.db.models.query_utils import Q from django.forms.fields import CallableChoiceIterator, ChoiceField, Field, _ClassLevelWidgetT from django.forms.forms import BaseForm, DeclarativeFieldsMetaclass from django.forms.formsets import BaseFormSet from django.forms.renderers import BaseRenderer from django.forms.utils import ErrorList, _DataT, _FilesT -from django.forms.widgets import ChoiceWidget, Input, Widget +from django.forms.widgets import Widget from django.utils.datastructures import _IndexableCollection, _ListOrTuple, _PropertyDescriptor from django.utils.functional import _StrOrPromise from typing_extensions import Literal, TypeAlias ALL_FIELDS: Literal["__all__"] -_Fields: TypeAlias = Union[_ListOrTuple[str], Literal["__all__"]] # https://github.com/python/mypy/issues/12211 -_Widgets: TypeAlias = dict[str, Union[type[Widget], Widget]] +# https://github.com/python/mypy/issues/12211 +_Fields: TypeAlias = Union[_ListOrTuple[str], Literal["__all__"]] +_Widgets: TypeAlias = dict[str, type[Widget] | Widget] _Labels: TypeAlias = dict[str, str] _HelpTexts: TypeAlias = dict[str, str] diff --git a/django-stubs/forms/utils.pyi b/django-stubs/forms/utils.pyi index dd6e8477c..95529f987 100644 --- a/django-stubs/forms/utils.pyi +++ b/django-stubs/forms/utils.pyi @@ -1,5 +1,5 @@ from collections import UserList -from collections.abc import Iterable, Mapping, Sequence +from collections.abc import Mapping, Sequence from datetime import datetime from typing import Any @@ -9,9 +9,9 @@ from django.utils.datastructures import MultiValueDict from django.utils.safestring import SafeString from typing_extensions import TypeAlias -_DataT: TypeAlias = Mapping[str, Any] +_DataT: TypeAlias = Mapping[str, Any] # noqa: Y047 -_FilesT: TypeAlias = MultiValueDict[str, UploadedFile] +_FilesT: TypeAlias = MultiValueDict[str, UploadedFile] # noqa: Y047 def pretty_name(name: str) -> str: ... def flatatt(attrs: dict[str, Any]) -> SafeString: ... diff --git a/django-stubs/http/request.pyi b/django-stubs/http/request.pyi index e3ed20765..de62079c6 100644 --- a/django-stubs/http/request.pyi +++ b/django-stubs/http/request.pyi @@ -3,6 +3,7 @@ from io import BytesIO from re import Pattern from typing import Any, BinaryIO, NoReturn, TypeVar, overload +from _typeshed import Self from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import AnonymousUser from django.contrib.sessions.backends.base import SessionBase @@ -98,7 +99,6 @@ class _MutableHttpRequest(HttpRequest): GET: QueryDict # type: ignore[assignment] POST: QueryDict # type: ignore[assignment] -_Q = TypeVar("_Q", bound="QueryDict") _Z = TypeVar("_Z") class QueryDict(MultiValueDict[str, str]): @@ -133,12 +133,12 @@ class QueryDict(MultiValueDict[str, str]): ) -> None: ... @classmethod def fromkeys( # type: ignore - cls: type[_Q], + cls: type[Self], iterable: Iterable[bytes | str], value: str | bytes = ..., mutable: bool = ..., encoding: str | None = ..., - ) -> _Q: ... + ) -> Self: ... @property def encoding(self) -> str: ... @encoding.setter diff --git a/django-stubs/template/context.pyi b/django-stubs/template/context.pyi index 7b85b0a5b..5b79664c4 100644 --- a/django-stubs/template/context.pyi +++ b/django-stubs/template/context.pyi @@ -3,23 +3,22 @@ from contextlib import contextmanager from types import TracebackType from typing import Any, TypeVar +from _typeshed import Self from django.http.request import HttpRequest from django.template.base import Node, Origin, Template -from django.template.defaulttags import IfChangedNode from django.template.loader_tags import IncludeNode from typing_extensions import TypeAlias _ContextKeys: TypeAlias = int | str | Node -_ContextValues: TypeAlias = dict[str, Any] | "Context" -_ContextCopy = TypeVar("_ContextCopy", bound="BaseContext") +_ContextValues: TypeAlias = dict[str, Any] | Context class ContextPopException(Exception): ... class ContextDict(dict): context: BaseContext def __init__(self, context: BaseContext, *args: Any, **kwargs: Any) -> None: ... - def __enter__(self) -> ContextDict: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None, @@ -29,7 +28,7 @@ class ContextDict(dict): class BaseContext(Iterable[Any]): def __init__(self, dict_: Any = ...) -> None: ... - def __copy__(self: _ContextCopy) -> _ContextCopy: ... + def __copy__(self: Self) -> Self: ... def __iter__(self) -> Iterator[Any]: ... def push(self, *args: Any, **kwargs: Any) -> ContextDict: ... def pop(self) -> ContextDict: ... diff --git a/django-stubs/template/defaultfilters.pyi b/django-stubs/template/defaultfilters.pyi index d0a29e474..b035a2af0 100644 --- a/django-stubs/template/defaultfilters.pyi +++ b/django-stubs/template/defaultfilters.pyi @@ -63,7 +63,7 @@ def default(value: int | str | None, arg: int | str) -> int | str: ... def default_if_none(value: str | None, arg: int | str) -> int | str: ... def divisibleby(value: int, arg: int) -> bool: ... def yesno(value: int | None, arg: str | None = ...) -> bool | str | None: ... -def filesizeformat(bytes_: complex | int | str) -> str: ... +def filesizeformat(bytes_: complex | str) -> str: ... def pluralize(value: Any, arg: str = ...) -> str: ... def phone2numeric_filter(value: str) -> str: ... def pprint(value: Any) -> str: ... diff --git a/django-stubs/template/response.pyi b/django-stubs/template/response.pyi index 9dd7967d9..4a3982174 100644 --- a/django-stubs/template/response.pyi +++ b/django-stubs/template/response.pyi @@ -1,7 +1,7 @@ import functools from collections.abc import Callable, Iterator, Sequence from http.cookies import SimpleCookie -from typing import Any, Union +from typing import Any, Union # noqa: Y037 # https://github.com/python/mypy/issues/12211 from django.core.handlers.wsgi import WSGIRequest from django.http import HttpResponse @@ -12,6 +12,7 @@ from django.test.client import Client from django.utils.datastructures import _ListOrTuple from typing_extensions import TypeAlias +# https://github.com/python/mypy/issues/12211 _TemplateForResponseT: TypeAlias = Union[_ListOrTuple[str], Template, str] class ContentNotRenderedError(Exception): ... diff --git a/django-stubs/test/html.pyi b/django-stubs/test/html.pyi index ffeec828e..dfe8cb750 100644 --- a/django-stubs/test/html.pyi +++ b/django-stubs/test/html.pyi @@ -1,11 +1,9 @@ from collections.abc import Sequence from html.parser import HTMLParser -from typing import Any, TypeVar +from typing import Any from typing_extensions import TypeAlias -_Self = TypeVar("_Self") - WHITESPACE: Any def normalize_whitespace(string: str) -> str: ... diff --git a/django-stubs/test/runner.pyi b/django-stubs/test/runner.pyi index c3b85acb2..1dc405f75 100644 --- a/django-stubs/test/runner.pyi +++ b/django-stubs/test/runner.pyi @@ -7,7 +7,7 @@ from typing import Any from unittest import TestCase, TestLoader, TestSuite, TextTestResult, TextTestRunner from django.db.backends.base.base import BaseDatabaseWrapper -from django.test.testcases import SimpleTestCase, TestCase +from django.test.testcases import SimpleTestCase from django.test.utils import TimeKeeperProtocol from django.utils.datastructures import OrderedSet from typing_extensions import Literal diff --git a/django-stubs/test/testcases.pyi b/django-stubs/test/testcases.pyi index 478bfc0b2..54642e695 100644 --- a/django-stubs/test/testcases.pyi +++ b/django-stubs/test/testcases.pyi @@ -2,10 +2,10 @@ import threading import unittest from collections.abc import Callable, Collection, Generator, Iterable, Iterator, Mapping, Sequence from contextlib import contextmanager -from datetime import date from types import TracebackType from typing import Any, overload +from _typeshed import Self from django.core.exceptions import ImproperlyConfigured from django.core.handlers.wsgi import WSGIHandler from django.core.servers.basehttp import ThreadedWSGIServer, WSGIRequestHandler @@ -41,7 +41,7 @@ class _AssertTemplateUsedContext: def on_template_render(self, sender: Any, signal: Any, template: Any, context: Any, **kwargs: Any) -> None: ... def test(self) -> None: ... def message(self) -> str: ... - def __enter__(self) -> _AssertTemplateUsedContext: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None, @@ -167,13 +167,13 @@ class SimpleTestCase(unittest.TestCase): def assertJSONEqual( self, raw: str, - expected_data: dict[str, Any] | list[Any] | str | int | float | bool | None, + expected_data: dict[str, Any] | list[Any] | str | float | bool | None, msg: str | None = ..., ) -> None: ... def assertJSONNotEqual( self, raw: str, - expected_data: dict[str, Any] | list[Any] | str | int | float | bool | None, + expected_data: dict[str, Any] | list[Any] | str | float | bool | None, msg: str | None = ..., ) -> None: ... def assertXMLEqual(self, xml1: str, xml2: str, msg: str | None = ...) -> None: ... @@ -260,15 +260,15 @@ class LiveServerTestCase(TransactionTestCase): server_thread: Any static_handler: Any @classproperty - def live_server_url(cls) -> str: ... + def live_server_url(cls: Any) -> str: ... @classproperty - def allowed_host(cls) -> str: ... + def allowed_host(cls: Any) -> str: ... class SerializeMixin: lockfile: Any @classmethod - def setUpClass(cls) -> None: ... + def setUpClass(cls: type[Self]) -> None: ... @classmethod - def tearDownClass(cls) -> None: ... + def tearDownClass(cls: type[Self]) -> None: ... def connections_support_transactions(aliases: Iterable[str] | None = ...) -> bool: ... diff --git a/django-stubs/test/utils.pyi b/django-stubs/test/utils.pyi index 8c8154ff7..252b03ef5 100644 --- a/django-stubs/test/utils.pyi +++ b/django-stubs/test/utils.pyi @@ -7,6 +7,7 @@ from logging import Logger from types import TracebackType from typing import Any, Protocol, TypeVar +from _typeshed import Self from django.apps.registry import Apps from django.conf import LazySettings, Settings from django.core.checks.registry import CheckRegistry @@ -47,7 +48,7 @@ class TestContextDecorator: def __init__(self, attr_name: str | None = ..., kwarg_name: str | None = ...) -> None: ... def enable(self) -> Any: ... def disable(self) -> None: ... - def __enter__(self) -> Apps | None: ... + def __enter__(self) -> Apps | None: ... # noqa: Y034 def __exit__( self, exc_type: type[BaseException] | None, @@ -91,7 +92,7 @@ class CaptureQueriesContext: def __len__(self) -> int: ... @property def captured_queries(self) -> list[dict[str, str]]: ... - def __enter__(self) -> CaptureQueriesContext: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None, diff --git a/django-stubs/urls/__init__.pyi b/django-stubs/urls/__init__.pyi index b3a120d94..3eb258288 100644 --- a/django-stubs/urls/__init__.pyi +++ b/django-stubs/urls/__init__.pyi @@ -37,4 +37,4 @@ from .resolvers import get_resolver as get_resolver from .utils import get_callable as get_callable from .utils import get_mod_func as get_mod_func -_AnyURL: TypeAlias = URLPattern | URLResolver +_AnyURL: TypeAlias = URLPattern | URLResolver # noqa: Y047 diff --git a/django-stubs/utils/archive.pyi b/django-stubs/utils/archive.pyi index 4c82e23d1..26ea469ac 100644 --- a/django-stubs/utils/archive.pyi +++ b/django-stubs/utils/archive.pyi @@ -2,6 +2,8 @@ from collections.abc import Iterable, Sequence from types import TracebackType from typing import Any +from _typeshed import Self + class ArchiveException(Exception): ... class UnrecognizedArchiveFormat(ArchiveException): ... @@ -9,7 +11,7 @@ def extract(path: str, to_path: str) -> None: ... class Archive: def __init__(self, file: str) -> None: ... - def __enter__(self) -> Archive: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None, diff --git a/django-stubs/utils/connection.pyi b/django-stubs/utils/connection.pyi index 0368b72e5..19aa8beb1 100644 --- a/django-stubs/utils/connection.pyi +++ b/django-stubs/utils/connection.pyi @@ -7,7 +7,7 @@ class ConnectionProxy: def __setattr__(self, name: str, value: Any) -> None: ... def __delattr__(self, name: str) -> None: ... def __contains__(self, key: str) -> bool: ... - def __eq__(self, other: Any) -> bool: ... + def __eq__(self, other: object) -> bool: ... class ConnectionDoesNotExist(Exception): ... diff --git a/django-stubs/utils/datastructures.pyi b/django-stubs/utils/datastructures.pyi index 76477c9ef..973f4c551 100644 --- a/django-stubs/utils/datastructures.pyi +++ b/django-stubs/utils/datastructures.pyi @@ -1,6 +1,7 @@ from collections.abc import Collection, Iterable, Iterator, Mapping, MutableSet -from typing import Any, Generic, Tuple, TypeVar, overload +from typing import Any, Generic, Tuple, TypeVar, overload # noqa: Y022 +from _typeshed import Self from typing_extensions import Protocol, TypeAlias _K = TypeVar("_K") @@ -10,7 +11,7 @@ _I = TypeVar("_I", covariant=True) # Unfortunately, there's often check `if isinstance(var, (list, tuple))` in django # codebase. So we need sometimes to declare exactly list or tuple. -_ListOrTuple: TypeAlias = list[_K] | tuple[_K, ...] | Tuple[()] +_ListOrTuple: TypeAlias = list[_K] | tuple[_K, ...] | Tuple[()] # noqa: Y047 class _PropertyDescriptor(Generic[_K, _V]): """ @@ -34,13 +35,11 @@ class _PropertyDescriptor(Generic[_K, _V]): def __get__(self, instance: Any, owner: Any | None) -> _V: ... def __set__(self, instance: Any, value: _K) -> None: ... -_IC = TypeVar("_IC", bound="_IndexableCollection") - class _IndexableCollection(Protocol[_I], Collection[_I]): @overload def __getitem__(self, index: int) -> _I: ... @overload - def __getitem__(self: _IC, index: slice) -> _IC: ... + def __getitem__(self: Self, index: slice) -> Self: ... class OrderedSet(MutableSet[_K]): dict: dict[_K, None] @@ -55,8 +54,6 @@ class OrderedSet(MutableSet[_K]): class MultiValueDictKeyError(KeyError): ... -_D = TypeVar("_D", bound="MultiValueDict") - class MultiValueDict(dict[_K, _V]): @overload def __init__(self, key_to_list_mapping: Mapping[_K, list[_V] | None] = ...) -> None: ... @@ -74,7 +71,7 @@ class MultiValueDict(dict[_K, _V]): def items(self) -> Iterator[tuple[_K, _V | list[object]]]: ... # type: ignore def lists(self) -> Iterable[tuple[_K, list[_V]]]: ... def dict(self) -> dict[_K, _V | list[object]]: ... - def copy(self: _D) -> _D: ... + def copy(self: Self) -> Self: ... def __getitem__(self, key: _K) -> _V | list[object]: ... # type: ignore def __setitem__(self, key: _K, value: _V) -> None: ... # These overrides are needed to convince mypy that this isn't an abstract class @@ -86,7 +83,7 @@ class MultiValueDict(dict[_K, _V]): class ImmutableList(tuple[_V, ...]): warning: str - def __new__(cls, *args: Any, warning: str = ..., **kwargs: Any) -> ImmutableList: ... + def __new__(cls: type[Self], *args: Any, warning: str = ..., **kwargs: Any) -> Self: ... def complain(self, *args: Any, **kwargs: Any) -> None: ... class _ItemCallable(Protocol[_V]): @@ -103,12 +100,10 @@ class DictWrapper(dict[str, _V]): def __init__(self, data: Iterable[tuple[str, _V]], func: _ItemCallable[_V], prefix: str) -> None: ... def __getitem__(self, key: str) -> _V: ... -_T = TypeVar("_T", bound="CaseInsensitiveMapping") - class CaseInsensitiveMapping(Mapping[str, _V]): _store: dict[str, tuple[str, _V]] def __init__(self, data: Mapping[str, _V] | Iterable[tuple[str, _V]]) -> None: ... def __getitem__(self, key: str) -> _V: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[str]: ... - def copy(self: _T) -> _T: ... + def copy(self: Self) -> Self: ... diff --git a/django-stubs/utils/functional.pyi b/django-stubs/utils/functional.pyi index 60417aa22..18284e041 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -2,6 +2,7 @@ from collections.abc import Callable, Sequence from functools import wraps as wraps # noqa: F401 from typing import Any, Generic, TypeVar, overload +from _typeshed import Self from django.db.models.base import Model from typing_extensions import Protocol, SupportsIndex, TypeAlias @@ -12,7 +13,7 @@ class cached_property(Generic[_T]): name: str def __init__(self, func: Callable[..., _T], name: str = ...) -> None: ... @overload - def __get__(self, instance: None, cls: type[Any] = ...) -> "cached_property[_T]": ... + def __get__(self: Self, instance: None, cls: type[Any] = ...) -> Self: ... @overload def __get__(self, instance: object, cls: type[Any] = ...) -> _T: ... @@ -25,7 +26,7 @@ class Promise: def __mod__(self, rhs: Any) -> Any: ... def __add__(self, other: Any) -> Any: ... def __radd__(self, other: Any) -> Any: ... - def __deepcopy__(self: _T, memo: Any) -> _T: ... + def __deepcopy__(self: Self, memo: Any) -> Self: ... class _StrPromise(Promise, Sequence[str]): def __add__(self, __s: str) -> str: ... @@ -44,7 +45,7 @@ class _StrPromise(Promise, Sequence[str]): # Mypy requires this for the attribute hook to take effect def __getattribute__(self, __name: str) -> Any: ... -_StrOrPromise: TypeAlias = str | _StrPromise +_StrOrPromise: TypeAlias = str | _StrPromise # noqa: Y047 _C = TypeVar("_C", bound=Callable) def lazy(func: _C, *resultclasses: Any) -> _C: ... @@ -88,13 +89,12 @@ def partition( ) -> tuple[list[_PartitionMember], list[_PartitionMember]]: ... _Get = TypeVar("_Get", covariant=True) -_Self = TypeVar("_Self") class classproperty(Generic[_Get]): - fget: Callable[[_Self], _Get] | None - def __init__(self, method: Callable[[_Self], _Get] | None = ...) -> None: ... - def __get__(self, instance: _Self | None, cls: type[_Self] = ...) -> _Get: ... - def getter(self, method: Callable[[_Self], _Get]) -> classproperty[_Get]: ... + fget: Callable[[Self], _Get] | None + def __init__(self: Self, method: Callable[[Self], _Get] | None = ...) -> None: ... + def __get__(self: Self, instance: Self | None, cls: type[Self] = ...) -> _Get: ... + def getter(self: Self, method: Callable[[Self], _Get]) -> classproperty[_Get]: ... class _Getter(Protocol[_Get]): """Type fake to declare some read-only properties (until `property` builtin is generic) @@ -104,6 +104,6 @@ class _Getter(Protocol[_Get]): """ @overload - def __get__(self: _Self, __instance: None, __typeobj: type[Any] | None) -> _Self: ... + def __get__(self: Self, __instance: None, __typeobj: type[Any] | None) -> Self: ... @overload def __get__(self, __instance: Any, __typeobj: type[Any] | None) -> _Get: ... diff --git a/django-stubs/utils/safestring.pyi b/django-stubs/utils/safestring.pyi index 1569ea103..9708c039a 100644 --- a/django-stubs/utils/safestring.pyi +++ b/django-stubs/utils/safestring.pyi @@ -1,12 +1,13 @@ from collections.abc import Callable from typing import Any, TypeVar, overload +from _typeshed import Self from typing_extensions import TypeAlias -_SD = TypeVar("_SD", bound="SafeData") +_SD = TypeVar("_SD", bound=SafeData) class SafeData: - def __html__(self: _SD) -> _SD: ... + def __html__(self: Self) -> Self: ... class SafeString(str, SafeData): @overload diff --git a/django-stubs/utils/translation/trans_real.pyi b/django-stubs/utils/translation/trans_real.pyi index 4a10202b9..157d427bf 100644 --- a/django-stubs/utils/translation/trans_real.pyi +++ b/django-stubs/utils/translation/trans_real.pyi @@ -2,7 +2,9 @@ import gettext as gettext_module from collections.abc import Iterator from gettext import NullTranslations from re import Pattern -from typing import Any, Protocol, Tuple, TypeVar + +# switch to tuple once https://github.com/python/mypy/issues/11098 is fixed +from typing import Any, Protocol, Tuple, TypeVar # noqa: Y022 from django.http.request import HttpRequest from typing_extensions import Literal, TypeAlias diff --git a/django-stubs/utils/tree.pyi b/django-stubs/utils/tree.pyi index 7919f8045..d45a94ddd 100644 --- a/django-stubs/utils/tree.pyi +++ b/django-stubs/utils/tree.pyi @@ -4,7 +4,7 @@ from typing import Any from django.db.models.sql.where import NothingNode from typing_extensions import TypeAlias -_NodeChildren: TypeAlias = list["Node" | NothingNode | Sequence[Any]] +_NodeChildren: TypeAlias = list[Node | NothingNode | Sequence[Any]] class Node: children: _NodeChildren diff --git a/setup.cfg b/setup.cfg index dc551d268..1c6cee57f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,13 +1,9 @@ [flake8] exclude = .*/ extend-ignore = E203 -extend-select = F401, Y max_line_length = 120 per-file-ignores = - *.pyi: B, E301, E302, E305, E501, E701, E704, W503 - *__init__.pyi: F401 - base_user.pyi: Y003 - models.pyi: Y003 + *.pyi: B, E301, E302, E305, E501, E701, E741, E743, NQA102, F401, F403, F405, F822, Y021, Y023, Y024, Y029, Y043 [metadata] license_file = LICENSE.txt diff --git a/tests/typecheck/fields/test_related.yml b/tests/typecheck/fields/test_related.yml index 18921e2f8..e66f35ff0 100644 --- a/tests/typecheck/fields/test_related.yml +++ b/tests/typecheck/fields/test_related.yml @@ -387,9 +387,9 @@ reveal_type(Book2().publisher_id) # N: Revealed type is "builtins.int" Book2(publisher_id=1) - Book2(publisher_id=[]) # E: Incompatible type for "publisher_id" of "Book2" (got "List[Any]", expected "Union[float, int, str, Combinable]") + Book2(publisher_id=[]) # E: Incompatible type for "publisher_id" of "Book2" (got "List[Any]", expected "Union[float, str, Combinable]") Book2.objects.create(publisher_id=1) - Book2.objects.create(publisher_id=[]) # E: Incompatible type for "publisher_id" of "Book2" (got "List[Any]", expected "Union[float, int, str, Combinable]") + Book2.objects.create(publisher_id=[]) # E: Incompatible type for "publisher_id" of "Book2" (got "List[Any]", expected "Union[float, str, Combinable]") installed_apps: - myapp files: diff --git a/tests/typecheck/models/test_create.yml b/tests/typecheck/models/test_create.yml index e82ff7be4..aaea40a4c 100644 --- a/tests/typecheck/models/test_create.yml +++ b/tests/typecheck/models/test_create.yml @@ -2,7 +2,7 @@ main: | from myapp.models import User User.objects.create(pk=1, name='Max', age=10) - User.objects.create(age=[]) # E: Incompatible type for "age" of "User" (got "List[Any]", expected "Union[float, int, str, Combinable]") + User.objects.create(age=[]) # E: Incompatible type for "age" of "User" (got "List[Any]", expected "Union[float, str, Combinable]") installed_apps: - myapp files: @@ -62,7 +62,7 @@ main: | from myapp.models import Publisher, Book - Book.objects.create(id=None) # E: Incompatible type for "id" of "Book" (got "None", expected "Union[float, int, str, Combinable]") + Book.objects.create(id=None) # E: Incompatible type for "id" of "Book" (got "None", expected "Union[float, str, Combinable]") Book.objects.create(publisher=None) # E: Incompatible type for "publisher" of "Book" (got "None", expected "Union[Publisher, Combinable]") Book.objects.create(publisher_id=None) # E: Incompatible type for "publisher_id" of "Book" (got "None", expected "Union[Combinable, int, str]") installed_apps: @@ -104,18 +104,18 @@ reveal_type(first.id) # N: Revealed type is "builtins.int" from myapp.models import MyModel2 - MyModel2(id=None) # E: Incompatible type for "id" of "MyModel2" (got "None", expected "Union[float, int, str, Combinable]") - MyModel2.objects.create(id=None) # E: Incompatible type for "id" of "MyModel2" (got "None", expected "Union[float, int, str, Combinable]") + MyModel2(id=None) # E: Incompatible type for "id" of "MyModel2" (got "None", expected "Union[float, str, Combinable]") + MyModel2.objects.create(id=None) # E: Incompatible type for "id" of "MyModel2" (got "None", expected "Union[float, str, Combinable]") second = MyModel2() - second.id = None # E: Incompatible types in assignment (expression has type "None", variable has type "Union[float, int, str, Combinable]") + second.id = None # E: Incompatible types in assignment (expression has type "None", variable has type "Union[float, str, Combinable]") reveal_type(second.id) # N: Revealed type is "builtins.int" # default set but no primary key doesn't allow None from myapp.models import MyModel3 - MyModel3(default=None) # E: Incompatible type for "default" of "MyModel3" (got "None", expected "Union[float, int, str, Combinable]") - MyModel3.objects.create(default=None) # E: Incompatible type for "default" of "MyModel3" (got "None", expected "Union[float, int, str, Combinable]") + MyModel3(default=None) # E: Incompatible type for "default" of "MyModel3" (got "None", expected "Union[float, str, Combinable]") + MyModel3.objects.create(default=None) # E: Incompatible type for "default" of "MyModel3" (got "None", expected "Union[float, str, Combinable]") third = MyModel3() - third.default = None # E: Incompatible types in assignment (expression has type "None", variable has type "Union[float, int, str, Combinable]") + third.default = None # E: Incompatible types in assignment (expression has type "None", variable has type "Union[float, str, Combinable]") reveal_type(third.default) # N: Revealed type is "builtins.int" installed_apps: - myapp diff --git a/tests/typecheck/models/test_init.yml b/tests/typecheck/models/test_init.yml index ebc100671..107f8c061 100644 --- a/tests/typecheck/models/test_init.yml +++ b/tests/typecheck/models/test_init.yml @@ -37,7 +37,7 @@ from myapp.models import MyUser user = MyUser(name='hello', age=[]) out: | - main:2: error: Incompatible type for "age" of "MyUser" (got "List[Any]", expected "Union[float, int, str, Combinable]") + main:2: error: Incompatible type for "age" of "MyUser" (got "List[Any]", expected "Union[float, str, Combinable]") installed_apps: - myapp files: @@ -107,7 +107,7 @@ - case: typechecking_of_pk main: | from myapp.models import MyUser1 - user = MyUser1(pk=[]) # E: Incompatible type for "pk" of "MyUser1" (got "List[Any]", expected "Union[float, int, str, Combinable, None]") + user = MyUser1(pk=[]) # E: Incompatible type for "pk" of "MyUser1" (got "List[Any]", expected "Union[float, str, Combinable, None]") installed_apps: - myapp files: @@ -155,11 +155,11 @@ class NotAValid: pass array_val3: List[NotAValid] = [NotAValid()] - MyModel(array=array_val3) # E: Incompatible type for "array" of "MyModel" (got "List[NotAValid]", expected "Union[Sequence[Union[float, int, str]], Combinable]") + MyModel(array=array_val3) # E: Incompatible type for "array" of "MyModel" (got "List[NotAValid]", expected "Union[Sequence[Union[float, str]], Combinable]") non_init = MyModel() non_init.array = array_val non_init.array = array_val2 - non_init.array = array_val3 # E: Incompatible types in assignment (expression has type "List[NotAValid]", variable has type "Union[Sequence[Union[float, int, str]], Combinable]") + non_init.array = array_val3 # E: Incompatible types in assignment (expression has type "List[NotAValid]", variable has type "Union[Sequence[Union[float, str]], Combinable]") installed_apps: - myapp files: @@ -191,7 +191,7 @@ from myapp.models import MyModel, MyModel2 MyModel(1) MyModel2(1, 12) - MyModel2(1, []) # E: Incompatible type for "name" of "MyModel2" (got "List[Any]", expected "Union[float, int, str, Combinable]") + MyModel2(1, []) # E: Incompatible type for "name" of "MyModel2" (got "List[Any]", expected "Union[float, str, Combinable]") installed_apps: - myapp files: @@ -291,11 +291,11 @@ main:9: error: Incompatible types in assignment (expression has type "str", variable has type "int") main:10: error: Incompatible types in assignment (expression has type "str", variable has type "Union[int, float]") main:12: error: Incompatible types in assignment (expression has type "List[str]", variable has type "Sequence[Union[int, float]]") - main:13: error: Incompatible types in assignment (expression has type "List[]", variable has type "Union[float, int, str, Combinable]") + main:13: error: Incompatible types in assignment (expression has type "List[]", variable has type "Union[float, str, Combinable]") main:15: error: Incompatible type for "redefined_set_type" of "MyModel" (got "str", expected "int") main:15: error: Incompatible type for "redefined_union_set_type" of "MyModel" (got "str", expected "Union[int, float]") main:15: error: Incompatible type for "redefined_array_set_type" of "MyModel" (got "int", expected "Sequence[Union[int, float]]") - main:15: error: Incompatible type for "default_set_type" of "MyModel" (got "List[Any]", expected "Union[float, int, str, Combinable]") + main:15: error: Incompatible type for "default_set_type" of "MyModel" (got "List[Any]", expected "Union[float, str, Combinable]") installed_apps: - myapp files: From 4ae7cf9bc7f02aaf43fa74155a3838662c3365b3 Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sun, 13 Nov 2022 17:46:35 +0100 Subject: [PATCH 12/13] fix Y023 Signed-off-by: Oleg Hoefling --- django-stubs/core/checks/registry.pyi | 4 ++-- django-stubs/db/backends/ddl_references.pyi | 4 +--- django-stubs/db/migrations/executor.pyi | 2 +- django-stubs/db/migrations/operations/special.pyi | 4 ++-- django-stubs/db/models/fields/__init__.pyi | 4 ++-- django-stubs/db/models/fields/files.pyi | 3 +-- django-stubs/forms/widgets.pyi | 4 ++-- django-stubs/utils/datastructures.pyi | 4 ++-- django-stubs/utils/functional.pyi | 4 ++-- setup.cfg | 2 +- 10 files changed, 16 insertions(+), 19 deletions(-) diff --git a/django-stubs/core/checks/registry.pyi b/django-stubs/core/checks/registry.pyi index fef7597ca..ea9402fc7 100644 --- a/django-stubs/core/checks/registry.pyi +++ b/django-stubs/core/checks/registry.pyi @@ -1,9 +1,9 @@ from collections.abc import Callable, Sequence -from typing import Any, TypeVar +from typing import Any, Protocol, TypeVar from django.apps.config import AppConfig from django.core.checks.messages import CheckMessage -from typing_extensions import Protocol, TypeAlias +from typing_extensions import TypeAlias class Tags: admin: str diff --git a/django-stubs/db/backends/ddl_references.pyi b/django-stubs/db/backends/ddl_references.pyi index 923e1183c..36ddbd840 100644 --- a/django-stubs/db/backends/ddl_references.pyi +++ b/django-stubs/db/backends/ddl_references.pyi @@ -1,7 +1,5 @@ from collections.abc import Sequence -from typing import Any - -from typing_extensions import Protocol +from typing import Any, Protocol class _QuoteCallable(Protocol): """Get rid of `cannot assign to method`""" diff --git a/django-stubs/db/migrations/executor.pyi b/django-stubs/db/migrations/executor.pyi index 13635726d..058598b68 100644 --- a/django-stubs/db/migrations/executor.pyi +++ b/django-stubs/db/migrations/executor.pyi @@ -1,8 +1,8 @@ from collections.abc import Sequence +from typing import Protocol from django.db.backends.base.base import BaseDatabaseWrapper from django.db.migrations.migration import Migration -from typing_extensions import Protocol from .loader import MigrationLoader from .recorder import MigrationRecorder diff --git a/django-stubs/db/migrations/operations/special.pyi b/django-stubs/db/migrations/operations/special.pyi index c122d85b1..7698068d4 100644 --- a/django-stubs/db/migrations/operations/special.pyi +++ b/django-stubs/db/migrations/operations/special.pyi @@ -1,10 +1,10 @@ from collections.abc import Mapping, Sequence -from typing import Any, Optional # noqa: Y037 # https://github.com/python/mypy/issues/12211 +from typing import Any, Optional, Protocol # noqa: Y037 # https://github.com/python/mypy/issues/12211 from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.migrations.state import StateApps from django.utils.datastructures import _ListOrTuple -from typing_extensions import Literal, Protocol +from typing_extensions import Literal from .base import Operation diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 6068447c7..9cebd0e38 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -4,7 +4,7 @@ from collections.abc import Callable, Iterable, Sequence from datetime import date from datetime import datetime as real_datetime from datetime import time, timedelta -from typing import Any, Generic, TypeVar, overload +from typing import Any, Generic, Protocol, TypeVar, overload from _typeshed import Self from django.core import validators # due to weird mypy.stubtest error @@ -19,7 +19,7 @@ from django.forms import Field as FormField from django.forms import Widget from django.utils.datastructures import DictWrapper from django.utils.functional import _Getter, _StrOrPromise -from typing_extensions import Protocol, TypeAlias +from typing_extensions import TypeAlias class Empty: ... class NOT_PROVIDED: ... diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index a7c55f54d..e5f098389 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Iterable -from typing import Any, TypeVar, overload +from typing import Any, Protocol, TypeVar, overload from _typeshed import Self from django.core import validators # due to weird mypy.stubtest error @@ -11,7 +11,6 @@ from django.db.models.fields import Field, _ErrorMessagesT, _FieldChoices from django.db.models.query_utils import DeferredAttribute from django.utils._os import _PathCompatible from django.utils.functional import _StrOrPromise -from typing_extensions import Protocol class FieldFile(File): instance: Model diff --git a/django-stubs/forms/widgets.pyi b/django-stubs/forms/widgets.pyi index c4422c222..868bf463c 100644 --- a/django-stubs/forms/widgets.pyi +++ b/django-stubs/forms/widgets.pyi @@ -1,6 +1,6 @@ import datetime from collections.abc import Iterable, Iterator, Mapping, Sequence -from typing import Any +from typing import Any, Protocol from django.core.files.base import File from django.db.models.fields import _FieldChoices @@ -9,7 +9,7 @@ from django.forms.utils import _DataT, _FilesT from django.utils.datastructures import _ListOrTuple from django.utils.functional import _Getter from django.utils.safestring import SafeString -from typing_extensions import Literal, Protocol, TypeAlias +from typing_extensions import Literal, TypeAlias _OptAttrs: TypeAlias = dict[str, Any] diff --git a/django-stubs/utils/datastructures.pyi b/django-stubs/utils/datastructures.pyi index 973f4c551..4c7fd669e 100644 --- a/django-stubs/utils/datastructures.pyi +++ b/django-stubs/utils/datastructures.pyi @@ -1,8 +1,8 @@ from collections.abc import Collection, Iterable, Iterator, Mapping, MutableSet -from typing import Any, Generic, Tuple, TypeVar, overload # noqa: Y022 +from typing import Any, Generic, Protocol, Tuple, TypeVar, overload # noqa: Y022 from _typeshed import Self -from typing_extensions import Protocol, TypeAlias +from typing_extensions import TypeAlias _K = TypeVar("_K") _V = TypeVar("_V") diff --git a/django-stubs/utils/functional.pyi b/django-stubs/utils/functional.pyi index 18284e041..085b16a95 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -1,10 +1,10 @@ from collections.abc import Callable, Sequence from functools import wraps as wraps # noqa: F401 -from typing import Any, Generic, TypeVar, overload +from typing import Any, Generic, Protocol, TypeVar, overload from _typeshed import Self from django.db.models.base import Model -from typing_extensions import Protocol, SupportsIndex, TypeAlias +from typing_extensions import SupportsIndex, TypeAlias _T = TypeVar("_T") diff --git a/setup.cfg b/setup.cfg index 1c6cee57f..c70913fd4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ exclude = .*/ extend-ignore = E203 max_line_length = 120 per-file-ignores = - *.pyi: B, E301, E302, E305, E501, E701, E741, E743, NQA102, F401, F403, F405, F822, Y021, Y023, Y024, Y029, Y043 + *.pyi: B, E301, E302, E305, E501, E701, E741, E743, NQA102, F401, F403, F405, F822, Y021, Y024, Y029, Y043 [metadata] license_file = LICENSE.txt From 6483d4acff19ae9afab9d816971b5ea7f4a2ce35 Mon Sep 17 00:00:00 2001 From: Oleg Hoefling Date: Sun, 13 Nov 2022 18:05:16 +0100 Subject: [PATCH 13/13] fix Y029 Signed-off-by: Oleg Hoefling --- django-stubs/core/files/base.pyi | 3 --- django-stubs/core/files/uploadhandler.pyi | 1 - django-stubs/db/models/enums.pyi | 1 - django-stubs/forms/models.pyi | 1 - django-stubs/http/request.pyi | 1 - django-stubs/utils/safestring.pyi | 1 - setup.cfg | 2 +- 7 files changed, 1 insertion(+), 9 deletions(-) diff --git a/django-stubs/core/files/base.pyi b/django-stubs/core/files/base.pyi index 4dbd26133..b3a13e8d6 100644 --- a/django-stubs/core/files/base.pyi +++ b/django-stubs/core/files/base.pyi @@ -11,8 +11,6 @@ class File(FileProxyMixin[AnyStr], IO[AnyStr]): name: str | None # type: ignore[assignment] mode: str def __init__(self, file: IO[AnyStr] | None, name: str | None = ...) -> None: ... - def __str__(self) -> str: ... - def __repr__(self) -> str: ... def __bool__(self) -> bool: ... def __len__(self) -> int: ... @property @@ -36,7 +34,6 @@ class ContentFile(File[AnyStr]): file: IO[AnyStr] size: int def __init__(self, content: AnyStr, name: str | None = ...) -> None: ... - def __str__(self) -> str: ... def __bool__(self) -> bool: ... def open(self: Self, mode: str | None = ...) -> Self: ... def close(self) -> None: ... diff --git a/django-stubs/core/files/uploadhandler.pyi b/django-stubs/core/files/uploadhandler.pyi index f1c936eae..1135d0215 100644 --- a/django-stubs/core/files/uploadhandler.pyi +++ b/django-stubs/core/files/uploadhandler.pyi @@ -11,7 +11,6 @@ class UploadFileException(Exception): ... class StopUpload(UploadFileException): connection_reset: bool def __init__(self, connection_reset: bool = ...) -> None: ... - def __str__(self) -> str: ... class SkipFile(UploadFileException): ... class StopFutureHandlers(UploadFileException): ... diff --git a/django-stubs/db/models/enums.pyi b/django-stubs/db/models/enums.pyi index 0e4c43d01..9d7f33896 100644 --- a/django-stubs/db/models/enums.pyi +++ b/django-stubs/db/models/enums.pyi @@ -15,7 +15,6 @@ class ChoicesMeta(enum.EnumMeta): def __contains__(self, member: Any) -> bool: ... class Choices(enum.Enum, metaclass=ChoicesMeta): - def __str__(self) -> str: ... @property def label(self) -> str: ... @enum_property diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index 674089219..db8025fbf 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -244,7 +244,6 @@ class InlineForeignKeyField(Field): class ModelChoiceIteratorValue: def __init__(self, value: Any, instance: Model) -> None: ... - def __str__(self) -> str: ... class ModelChoiceIterator: field: ModelChoiceField diff --git a/django-stubs/http/request.pyi b/django-stubs/http/request.pyi index de62079c6..690615a20 100644 --- a/django-stubs/http/request.pyi +++ b/django-stubs/http/request.pyi @@ -84,7 +84,6 @@ class HttpRequest(BytesIO): def upload_handlers(self, upload_handlers: UploadHandlerList) -> None: ... @property def accepted_types(self) -> list[MediaType]: ... - def __repr__(self) -> str: ... def parse_file_upload( self, META: Mapping[str, Any], post_data: BinaryIO ) -> tuple[QueryDict, MultiValueDict[str, uploadedfile.UploadedFile]]: ... diff --git a/django-stubs/utils/safestring.pyi b/django-stubs/utils/safestring.pyi index 9708c039a..6dbb5870e 100644 --- a/django-stubs/utils/safestring.pyi +++ b/django-stubs/utils/safestring.pyi @@ -14,7 +14,6 @@ class SafeString(str, SafeData): def __add__(self, rhs: SafeString) -> SafeString: ... @overload def __add__(self, rhs: str) -> str: ... - def __str__(self) -> str: ... SafeText: TypeAlias = SafeString diff --git a/setup.cfg b/setup.cfg index c70913fd4..1441ce65e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ exclude = .*/ extend-ignore = E203 max_line_length = 120 per-file-ignores = - *.pyi: B, E301, E302, E305, E501, E701, E741, E743, NQA102, F401, F403, F405, F822, Y021, Y024, Y029, Y043 + *.pyi: B, E301, E302, E305, E501, E701, E741, E743, NQA102, F401, F403, F405, F822, Y021, Y024, Y043 [metadata] license_file = LICENSE.txt