diff --git a/django-stubs/utils/deprecation.pyi b/django-stubs/utils/deprecation.pyi index 4021bf8fb..f97d6268d 100644 --- a/django-stubs/utils/deprecation.pyi +++ b/django-stubs/utils/deprecation.pyi @@ -5,10 +5,9 @@ from django.http.request import HttpRequest from django.http.response import HttpResponseBase from typing_extensions import TypeAlias -class RemovedInDjango51Warning(DeprecationWarning): ... +class RemovedInNextVersionWarning(DeprecationWarning): ... class RemovedInDjango60Warning(PendingDeprecationWarning): ... -RemovedInNextVersionWarning: TypeAlias = RemovedInDjango51Warning RemovedAfterNextVersionWarning: TypeAlias = RemovedInDjango60Warning class warn_about_renamed_method: diff --git a/django-stubs/utils/html.pyi b/django-stubs/utils/html.pyi index 522074b48..b72f961f0 100644 --- a/django-stubs/utils/html.pyi +++ b/django-stubs/utils/html.pyi @@ -9,7 +9,7 @@ from _typeshed import Incomplete from django.utils.functional import SimpleLazyObject, _StrOrPromise from django.utils.safestring import SafeData, SafeString -VOID_ELEMENTS: set[str] +VOID_ELEMENTS: frozenset[str] MAX_URL_LENGTH: int def escape(text: Any) -> SafeString: ... diff --git a/django-stubs/utils/inspect.pyi b/django-stubs/utils/inspect.pyi index 1a2baa509..a1ebae5f3 100644 --- a/django-stubs/utils/inspect.pyi +++ b/django-stubs/utils/inspect.pyi @@ -1,6 +1,9 @@ from collections.abc import Callable +from inspect import _ParameterKind from typing import Any +ARG_KINDS: frozenset[_ParameterKind] + 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: ... diff --git a/django-stubs/utils/text.pyi b/django-stubs/utils/text.pyi index aa54b1cd9..c7187358f 100644 --- a/django-stubs/utils/text.pyi +++ b/django-stubs/utils/text.pyi @@ -1,36 +1,35 @@ from collections.abc import Callable, Iterable, Iterator +from html.parser import HTMLParser from io import BytesIO -from re import Match, Pattern +from re import Pattern from typing import ClassVar, TypeVar, overload from django.db.models.base import Model -from django.utils.functional import SimpleLazyObject, _StrOrPromise +from django.utils.functional import SimpleLazyObject, _StrOrPromise, cached_property _StrOrPromiseT = TypeVar("_StrOrPromiseT", bound=_StrOrPromise) _StrOrPromiseOrNoneT = TypeVar("_StrOrPromiseOrNoneT", bound=_StrOrPromise | None) def capfirst(x: _StrOrPromiseOrNoneT) -> _StrOrPromiseOrNoneT: ... -re_notag: Pattern[str] -re_prt: Pattern[str] - -class WordsRegex: - @staticmethod - def search(text: str, pos: int) -> Match | FakeMatch: ... - -class FakeMatch: - def __init__(self, text: str, end: int) -> None: ... - def __getitem__(self, group: int) -> str | None: ... - def end(self, group: int = 0) -> int: ... - -re_words: type[WordsRegex] -re_chars: Pattern[str] -re_tag: Pattern[str] 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 = None) -> str: ... +def calculate_truncate_chars_length(length: int, replacement: str | None) -> int: ... + +class TruncateHTMLParser(HTMLParser): + TruncationCompleted: ClassVar[type[Exception]] + def __init__(self, *, length: int, replacement: str | None, convert_charrefs: bool = True) -> None: ... + @cached_property + def void_elements(self) -> frozenset[str]: ... + +class TruncateCharsHTMLParser(TruncateHTMLParser): + def process(self, data: str) -> tuple[str, str]: ... + +class TruncateWordsHTMLParser(TruncateHTMLParser): + def process(self, data: str) -> tuple[str, str]: ... class Truncator(SimpleLazyObject): MAX_LENGTH_HTML: ClassVar[int] diff --git a/django-stubs/utils/version.pyi b/django-stubs/utils/version.pyi index 7bc0e2da3..10004882e 100644 --- a/django-stubs/utils/version.pyi +++ b/django-stubs/utils/version.pyi @@ -1,12 +1,13 @@ from typing_extensions import TypeAlias -PY36: bool -PY37: bool +PYPY: bool + PY38: bool PY39: bool PY310: bool PY311: bool PY312: bool +PY313: bool _VT: TypeAlias = tuple[int, int, int, str, int] diff --git a/scripts/stubtest/allowlist.txt b/scripts/stubtest/allowlist.txt index 2ac951136..16dd56311 100644 --- a/scripts/stubtest/allowlist.txt +++ b/scripts/stubtest/allowlist.txt @@ -95,10 +95,6 @@ django.utils.http.ASCTIME_DATE django.utils.http.ETAG_MATCH django.utils.http.RFC1123_DATE django.utils.http.RFC850_DATE -django.utils.text.re_notag -django.utils.text.re_prt -django.utils.text.re_chars -django.utils.text.re_tag django.utils.text.re_newlines django.utils.text.re_camel_case django.utils.text.smart_split_re @@ -404,6 +400,7 @@ django.utils.connection.BaseConnectionHandler.settings django.utils.html.Urlizer.trailing_punctuation_chars_has_semicolon django.utils.html.Urlizer.trailing_punctuation_chars_no_semicolon django.utils.html.Urlizer.wrapping_punctuation_openings +django.utils.text.TruncateHTMLParser.void_elements django.db.models.Q.referenced_base_fields django.db.models.query_utils.Q.referenced_base_fields django.contrib.gis.db.models.Q.referenced_base_fields diff --git a/scripts/stubtest/allowlist_todo_django51.txt b/scripts/stubtest/allowlist_todo_django51.txt index b64905951..b288c2119 100644 --- a/scripts/stubtest/allowlist_todo_django51.txt +++ b/scripts/stubtest/allowlist_todo_django51.txt @@ -389,20 +389,6 @@ django.test.utils.garbage_collect django.urls.converters.get_converter django.urls.resolvers.LocaleRegexRouteDescriptor django.urls.resolvers.whitespace_set -django.utils.deprecation.RemovedInDjango51Warning -django.utils.html.VOID_ELEMENTS -django.utils.inspect.ARG_KINDS -django.utils.text.FakeMatch -django.utils.text.TruncateCharsHTMLParser -django.utils.text.TruncateHTMLParser -django.utils.text.TruncateWordsHTMLParser -django.utils.text.WordsRegex -django.utils.text.calculate_truncate_chars_length -django.utils.text.re_words -django.utils.version.PY313 -django.utils.version.PY36 -django.utils.version.PY37 -django.utils.version.PYPY # Only discrepancies that appeared after Django 4.2 -> 5.0 update. # Unsorted: there are real problems and things we can really ignore: