From 32d5b983f6e624c8dda85a89cd21446b38d2b146 Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Wed, 13 Mar 2024 19:05:53 +0000 Subject: [PATCH] 5.0: Update `django.utils` Excludes `django.utils.choices` as handling all issues related to choices together makes more sense than trying to combine it here. --- django-stubs/utils/deprecation.pyi | 8 ++++---- django-stubs/utils/html.pyi | 2 ++ django-stubs/utils/text.pyi | 2 +- django-stubs/utils/timezone.pyi | 6 ++---- django-stubs/utils/topological_sort.pyi | 7 ------- scripts/stubtest/allowlist_todo_django50.txt | 8 -------- 6 files changed, 9 insertions(+), 24 deletions(-) delete mode 100644 django-stubs/utils/topological_sort.pyi diff --git a/django-stubs/utils/deprecation.pyi b/django-stubs/utils/deprecation.pyi index 0f61174d52..4021bf8fbb 100644 --- a/django-stubs/utils/deprecation.pyi +++ b/django-stubs/utils/deprecation.pyi @@ -5,11 +5,11 @@ from django.http.request import HttpRequest from django.http.response import HttpResponseBase from typing_extensions import TypeAlias -class RemovedInDjango50Warning(DeprecationWarning): ... -class RemovedInDjango51Warning(PendingDeprecationWarning): ... +class RemovedInDjango51Warning(DeprecationWarning): ... +class RemovedInDjango60Warning(PendingDeprecationWarning): ... -RemovedInNextVersionWarning: TypeAlias = RemovedInDjango50Warning -RemovedAfterNextVersionWarning: TypeAlias = RemovedInDjango51Warning +RemovedInNextVersionWarning: TypeAlias = RemovedInDjango51Warning +RemovedAfterNextVersionWarning: TypeAlias = RemovedInDjango60Warning class warn_about_renamed_method: class_name: str diff --git a/django-stubs/utils/html.pyi b/django-stubs/utils/html.pyi index 44e01a4cd9..3b66160c4d 100644 --- a/django-stubs/utils/html.pyi +++ b/django-stubs/utils/html.pyi @@ -8,6 +8,8 @@ from _typeshed import Incomplete from django.utils.functional import SimpleLazyObject, _StrOrPromise from django.utils.safestring import SafeData, SafeString +VOID_ELEMENTS: set[str] + def escape(text: Any) -> SafeString: ... def escapejs(value: Any) -> SafeString: ... def json_script(value: Any, element_id: str | None = ..., encoder: type[JSONEncoder] | None = ...) -> SafeString: ... diff --git a/django-stubs/utils/text.pyi b/django-stubs/utils/text.pyi index 3dcc43b793..ecf3e90089 100644 --- a/django-stubs/utils/text.pyi +++ b/django-stubs/utils/text.pyi @@ -30,11 +30,11 @@ re_newlines: Pattern[str] re_camel_case: Pattern[str] def wrap(text: _StrOrPromiseT, width: int) -> _StrOrPromiseT: ... +def add_truncation_text(text: str, truncate: str | None = ...) -> str: ... class Truncator(SimpleLazyObject): MAX_LENGTH_HTML: ClassVar[int] 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: ... diff --git a/django-stubs/utils/timezone.pyi b/django-stubs/utils/timezone.pyi index 4b86a38bbd..6efb4be88f 100644 --- a/django-stubs/utils/timezone.pyi +++ b/django-stubs/utils/timezone.pyi @@ -1,12 +1,10 @@ from contextlib import ContextDecorator from datetime import date, datetime, time, timedelta, timezone, tzinfo from types import TracebackType -from typing import Any, Literal, overload +from typing import Literal, overload import zoneinfo -utc: Any - def get_fixed_timezone(offset: timedelta | int) -> timezone: ... def get_default_timezone() -> zoneinfo.ZoneInfo: ... def get_default_timezone_name() -> str: ... @@ -38,5 +36,5 @@ 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: tzinfo | None = ..., is_dst: bool | None = ...) -> datetime: ... +def make_aware(value: datetime, timezone: tzinfo | None = ...) -> datetime: ... def make_naive(value: datetime, timezone: tzinfo | None = ...) -> datetime: ... diff --git a/django-stubs/utils/topological_sort.pyi b/django-stubs/utils/topological_sort.pyi deleted file mode 100644 index 057ffe49e8..0000000000 --- a/django-stubs/utils/topological_sort.pyi +++ /dev/null @@ -1,7 +0,0 @@ -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]: ... diff --git a/scripts/stubtest/allowlist_todo_django50.txt b/scripts/stubtest/allowlist_todo_django50.txt index 25c1b4930b..37e9ea0bba 100644 --- a/scripts/stubtest/allowlist_todo_django50.txt +++ b/scripts/stubtest/allowlist_todo_django50.txt @@ -246,14 +246,6 @@ django.test.client.AsyncClient.trace django.test.runner.DiscoverRunner.__init__ django.test.runner.RemoteTestResult.addDuration django.utils.choices -django.utils.deprecation.RemovedInDjango50Warning -django.utils.deprecation.RemovedInDjango60Warning -django.utils.html.VOID_ELEMENTS -django.utils.text.Truncator.add_truncation_text -django.utils.text.add_truncation_text -django.utils.timezone.make_aware -django.utils.timezone.utc -django.utils.topological_sort django.views.csrf.CSRF_FAILURE_TEMPLATE django.views.csrf.builtin_template_path django.views.decorators.debug.coroutine_functions_to_sensitive_variables