-
-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add deprecated decorators for multiple classes and methods #2458
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ from typing import Any, TypeVar, overload, type_check_only | |
|
||
from _typeshed import ConvertibleToInt | ||
from django.utils.functional import _StrOrPromise | ||
from typing_extensions import TypeAlias | ||
from typing_extensions import TypeAlias, deprecated | ||
|
||
_Self = TypeVar("_Self") | ||
|
||
|
@@ -21,6 +21,7 @@ else: | |
class IntEnum(int, ReprEnum): ... | ||
class StrEnum(str, ReprEnum): ... | ||
|
||
@deprecated("ChoicesMeta is deprecated in favor of ChoicesType and will be removed in Django 6.0.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that this works either as As an aside, we should probably also invert the alias so that we have |
||
class ChoicesMeta(EnumType): | ||
# There's a contradiction between mypy and PYI019 regarding metaclasses. Where mypy | ||
# disallows 'typing_extensions.Self' on metaclasses, while PYI019 try to enforce | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ from typing import Any | |
from _typeshed import Incomplete | ||
from django.utils.functional import SimpleLazyObject, _StrOrPromise | ||
from django.utils.safestring import SafeData, SafeString | ||
from typing_extensions import deprecated | ||
|
||
VOID_ELEMENTS: frozenset[str] | ||
MAX_URL_LENGTH: int | ||
|
@@ -19,6 +20,7 @@ def json_script(value: Any, element_id: str | None = None, encoder: type[JSONEnc | |
|
||
# conditional_escape could use a protocol to be more precise, see https://github.com/typeddjango/django-stubs/issues/1474 | ||
def conditional_escape(text: _StrOrPromise | SafeData) -> SafeString: ... | ||
@deprecated("Calling format_html() without passing args or kwargs is deprecated.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, it's not possible to use |
||
def format_html(format_string: str, *args: Any, **kwargs: Any) -> SafeString: ... | ||
def format_html_join(sep: str, format_string: str, args_generator: Iterable[Iterable[Any]]) -> SafeString: ... | ||
def linebreaks(value: Any, autoescape: bool = False) -> str: ... | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,3 +1,8 @@ | ||||||
from typing import Any | ||||||
|
||||||
from typing_extensions import deprecated | ||||||
|
||||||
@deprecated( | ||||||
"The django.utils.itercompat.is_iterable() is deprecated and will be removed in Django 6.0. Use isinstance(..., collections.abc.Iterable) instead." | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a lot of
Suggested change
Please review all the other introductions of this. |
||||||
) | ||||||
def is_iterable(x: Any) -> bool: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should be removed.
@deprecated
can only be used if the whole function is deprecated, not changes to types for individual parameters. This will cause the deprecation to be shown even ifrequest
is notNone
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, deprecated overloads can be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, yes!