Skip to content

refactor(utils): stop force-enabling DeprecationWarnings in warn_deprecated - #1639

Open
shiftinv wants to merge 5 commits into
masterfrom
refactor/no-force-deprecationwarnings
Open

shiftinv wants to merge 5 commits into
masterfrom
refactor/no-force-deprecationwarnings

Conversation

@shiftinv

Copy link
Copy Markdown
Member

Summary

closes #1475, supersedes #1476

Given the precedent in #1527 to stop bypassing the current warning filters for @deprecated, this PR now expands this to warn_deprecated() as well.

This, just like #1527, has the unfortunate consequence of DeprecationWarnings no longer showing up for most people, unless they use -W default/-X dev/etc.
see also https://sethmlarson.dev/deprecations-via-warnings-dont-work-for-python-libraries

There are a few possible solutions to this:

  • Use FutureWarning (linky)
    • this would be really easy. This warning is not suppressed by default, and semantically very similar, though perhaps not exactly the same (probably depends on who you ask?)
  • Add a class DisnakeDeprecationWarning(DeprecationWarning) and a default::DisnakeDeprecationWarning filter
    • this has the possible side effect of overriding warning filters set by users before importing the library. We could potentially avoid this by only inserting this filter after checking the existence of other relevant filters in warnings.filters?
    • worth mentioning that simply adding a default::DeprecationWarning:disnake filter instead (without a custom subclass) would not work, as the module filtering is based on where the warning surfaces (i.e. whichever frame the stacklevel points to), not the module the original .warn() call location is in
  • Add a class DisnakeDeprecationWarning(UserWarning)
    • this feels slightly wrong, not sure. For instance, numpy does this in a few places, though they also use DeprecationWarning and FutureWarning all over.
  • Petition the Python Steering Council to retroactively remove the default ignore::DeprecationWarning filter in 3.10+, I guess?? /j

Changing that would be a followup PR, and I'd very much love to find a solution before the next release, but I'm still sorta undecided on which way to go with this, so I would appreciate any ideas/feedback c:

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running uv run nox -s lint
    • I have type-checked the code by running uv run nox -s pyright
  • This PR fixes an issue
  • This PR adds something new (e.g. new method or parameters)
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@shiftinv shiftinv added this to the v2.13 milestone Nov 18, 2026
@shiftinv shiftinv added the t: refactor/typing/lint Refactors, typing changes and/or linting changes label Nov 18, 2026
@shiftinv shiftinv added this to disnake Nov 18, 2026
@github-project-automation github-project-automation Bot moved this to Todo in disnake Nov 18, 2026
@read-the-docs-community

read-the-docs-community Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 disnake | 🛠️ Build #36046081 | 📁 Comparing c6d0a71 against latest (f5fad28)

  🔍 Preview build  

1 file changed
± whats_new.html

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t: refactor/typing/lint Refactors, typing changes and/or linting changes

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Deprecation warning overriding user settings by forcing it on.

1 participant