-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Labels
unconfirmed bugSomething might not be workingSomething might not be working
Description
Summary
deprecated decorator is too opinionated and forces itself on
Reproduction Steps
Looping through channel history interacting with the deprecated message.Interaction.
No matter how I set the warnings filters, the deprecation warning kept coming through, and because it was over a channel history and nearly every single message had an interaction, it caused mega console clutter.
Minimal Reproducible Code
The issue is explained in the comments below of the code snippet of warn_deprecated which is called in the `deprecated` decorator.
python
def warn_deprecated(
*args: Any, stacklevel: int = 1, skip_internal_frames: bool = False, **kwargs: Any
) -> None:
# NOTE: skip_file_prefixes was added in 3.12; in older versions,
# we'll just have to live with the warning location possibly being wrong
if sys.version_info >= (3, 12) and skip_internal_frames:
kwargs["skip_file_prefixes"] = (_root_module_path,)
stacklevel = 1 # reset stacklevel, assume we just want the first frame outside library code
old_filters = warnings.filters[:]
try:
warnings.simplefilter("always", DeprecationWarning) # this forces the warning to always show, not respecting the user's runtime settings
warnings.warn(*args, stacklevel=stacklevel + 1, category=DeprecationWarning, **kwargs) # then shows it irregardless
finally:
assert isinstance(warnings.filters, list)
warnings.filters[:] = old_filters # then resets the filters to preserve the user's settingsExpected Results
To respect the user's warnings settings and not force it on if not wanted.
Actual Results
import warnings
warnings.simplefilter("ignore", DeprecationWarning)When this is used, the deprecation warnings still come through, which was particularly problematic when message.Interaction has a deprecation warning and I am looping through channel history getting information from it whilst I can.
Intents
All
System Information
- Python v3.12.3-final
- disnake v2.11.0-final
- disnake importlib.metadata: v2.11.0
- aiohttp v3.13.2
- system info: Windows 10 10.0.19045 AMD64Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
- I have removed my token from display, if visible.
Additional Context
Not strictly a bug, it was intended.

Metadata
Metadata
Assignees
Labels
unconfirmed bugSomething might not be workingSomething might not be working