Title: warnings.deprecated should support instances as input · Issue #138165 · python/cpython · GitHub
Open Graph Title: warnings.deprecated should support instances as input · Issue #138165 · python/cpython
X Title: warnings.deprecated should support instances as input · Issue #138165 · python/cpython
Description: Feature or enhancement Proposal: i'm working on a library that allows to manage the life-cycle of deprecations its using different warning types based on different contexts and is heavily relying on warnings.warn... supporting passing in...
Open Graph Description: Feature or enhancement Proposal: i'm working on a library that allows to manage the life-cycle of deprecations its using different warning types based on different contexts and is heavily relying o...
X Description: Feature or enhancement Proposal: i'm working on a library that allows to manage the life-cycle of deprecations its using different warning types based on different contexts and is heavily relyi...
Opengraph URL: https://github.com/python/cpython/issues/138165
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"warnings.deprecated should support instances as input","articleBody":"# Feature or enhancement\n\n### Proposal:\n\ni'm working on a library that allows to manage the life-cycle of deprecations \n\nits using different warning types based on different contexts and is heavily relying on warnings.warn... supporting passing instances or strings \n\n```python\nfrom deprecator import Deprecator\n\ndeprecator = Deprecator.for_package(\"my_package\")\n\n# depending on the version of package and gone_in/warn_in this will be a PendingDeprecation, a Deprecation or a PassedDeprecation as defined in deprecator (Passed deprecations will auto register for triggering errors)\n\n\nOLD_FEATURE = deprecator.define(\"Myfeature\", warn_in=\"25.02.0\", gone_in=\"26.05.0\", repacement=\"new feature)\n\n\ndef my_code(...):\n warnings.warn(OLD_FEATURE)\n\n\n```\ni'd like to be able to do\n\n\n```\n\n@warnings.deprecated(OLD_FEATURE)\ndef my_code(...):\n ...\n```\nhowever currently warnings.deprecated is defined in terms that only allow a string\n\ni'm aware of https://github.com/python/cpython/blob/fd8f42d3d1038a812340c3ec3cbfc995a80c4e13/Lib/_py_warnings.py#L817-L833 and intentional choose a new warning subclass to be registered for errors, as i want to ensure test suites can keep running with records of the issue instead of failures plus enable a work-flow where dead code removal happens after dysfunction sets in so that users have the possibility of a informed workaround while mitigating\n\n\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n### Links to previous discussion of this feature:\n\n_No response_","author":{"url":"https://github.com/RonnyPfannschmidt","@type":"Person","name":"RonnyPfannschmidt"},"datePublished":"2025-08-26T15:41:53Z","url":"https://github.com/python/cpython/issues/138165"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7a7b8363-1a1d-f5f1-2b8b-b9060328a12d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D80A:2A0045:FC1C66:13BD0A4:6AFF873C |
| html-safe-nonce | 588bce9cd7ba76bf8a2c22f9fadf922036cc928c98014ad25cd33c14433cb12f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODBBOjJBMDA0NTpGQzFDNjY6MTNCRDBBNDo2QUZGODczQyIsInZpc2l0b3JfaWQiOiI2NjgxOTI4NzYxNjIyODkwMzAwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a10b9eaeaca8bfdabe574dfe6c501cd305fa5e390060c6c9e50e9e4d2a2b6e28 |
| hovercard-subject-tag | issue:3356188532 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/138165/issue_layout |
| twitter:image | https://opengraph.githubassets.com/afd2767204cec0db44c8ba54d08ba169394d3dbce3b99797613b0407ec45cbde/python/cpython/issues/138165 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/afd2767204cec0db44c8ba54d08ba169394d3dbce3b99797613b0407ec45cbde/python/cpython/issues/138165 |
| og:image:alt | Feature or enhancement Proposal: i'm working on a library that allows to manage the life-cycle of deprecations its using different warning types based on different contexts and is heavily relying o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RonnyPfannschmidt |
| hostname | github.com |
| expected-hostname | github.com |
| None | 587ad99a3e443b2e1cb0d3df059ec49ab54389861f13310766dfdeb615fed90d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5bb0fb68d64881d1344f5863d809515d496801e5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width