You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need more metadata for our deprecation decorator, but the spec doesn’t say howdeprecated marks an API. So the only way to mark something as deprecated it is by creating an API with the same exact signature and replace it with warnings.deprecated at the type level:
How do I keep the property of seeing the deprecation (strike-through function call) and its message, but can also add e.g. a mandatory version parameter and extra behavior to the decorator?
The following hack is very unpythonic and easy to get wrong:
Activity
flying-sheep commentedon Apr 15, 2026
Another issue: there seems to be no reason why it takes
LiteralStringonly, so that should be changed tostrin the stubs.srittau commentedon Apr 15, 2026
LiteralStringis used intentionally, see python/typeshed#11699.flying-sheep commentedon Apr 15, 2026
This goes back to the original issue then:
How do I keep the property of seeing the deprecation (strike-through function call) and its message, but can also add e.g. a mandatory
versionparameter and extra behavior to the decorator?The following hack is very unpythonic and easy to get wrong:
flying-sheep commentedon May 19, 2026
So
deprecatedis a class: python/cpython#150076I want to add keyword arguments. So how about we say this?
cc @JelleZijlstra
JelleZijlstra commentedon May 19, 2026
Subclasses of deprecated have no special meaning in the type system.
flying-sheep commentedon May 19, 2026
let’s change that then
flying-sheep commentedon Jun 17, 2026
@JelleZijlstra what’s necessary to change that? A whole PEP?
JelleZijlstra commentedon Jun 18, 2026
At a minimum we should have a discussion on discuss.python.org. A small extension like the ones you suggested above shouldn't need a PEP.
flying-sheep commentedon Jun 18, 2026
Done: https://discuss.python.org/t/proposal-allow-extending-warnings-deprecated/107794