Title: Always use `warnings.warn` for deprecation messages. · Issue #4109 · getsentry/sentry-python · GitHub
Open Graph Title: Always use `warnings.warn` for deprecation messages. · Issue #4109 · getsentry/sentry-python
X Title: Always use `warnings.warn` for deprecation messages. · Issue #4109 · getsentry/sentry-python
Description: Make all deprecation messages use the warnings.warn function. Right now we use two different ways, some deprecation messages use logging.warning and some are using warnings.warn. There was some discussion about using logging or warnings ...
Open Graph Description: Make all deprecation messages use the warnings.warn function. Right now we use two different ways, some deprecation messages use logging.warning and some are using warnings.warn. There was some dis...
X Description: Make all deprecation messages use the warnings.warn function. Right now we use two different ways, some deprecation messages use logging.warning and some are using warnings.warn. There was some dis...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/4109
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Always use `warnings.warn` for deprecation messages.","articleBody":"Make all deprecation messages use the `warnings.warn` function. \n\nRight now we use two different ways, some deprecation messages use `logging.warning` and some are using `warnings.warn`.\n\nThere was some discussion about using `logging` or `warnings` module for deprecation. In the Python world, `warnings` module is the most use way to do deprecation. Here are some arguments that where taken into account when deciding to use `warnings` module over `logging`:\n\n- When running normal (`python manage.py runserver 0.0.0.0:8000`)\n - Logging deprecations ARE printed (every time they appear)\n - Warnings deprecations are NOT printed.\n\n- When deprecation warnings enabled (`python -Wd manage.py runserver 0.0.0.0:8000`)\n - Logging deprecations ARE printed. (every time they appear)\n - Warnings deprecations ARE printed. (only printed ONCE, the first time it is emmited.)\n\n- When running tests (`pytest ...`)\n - Logging deprecations ARE printed (when the test fails) \n - Warnings deprecations ARE printed.\n - Tests DO NOT FAIL!\n\n- When running tests and treating errors as warnings (`pytest -W error`) This is what we are doing in `sentry` repo.\n - Logging deprecations ARE printed (when the test fails)\n - Logging deprecations are NOT breaking the test run.\n - Warnings deprecations ARE printed.\n - Warnings deprecations ARE breaking the test run. \n - Deprecation warnings from certain packages can be ignored by adding this to pytest.ini:\n```ini\n filterwarnings =\n error ; turn warnings into errors\n ; ignore::DeprecationWarning:polls.* ; if users call deprecated sentry function from their code they also need to ignore depreactions from their module\n ignore::DeprecationWarning:sentry_sdk.* ; ignore deprecations from sentry_sdk\n```\n\nAll in all:\n- `warnings` are not shown in the default case (which is good, we do not want to annoy users)\n- `warnings` are only emitted once (compared to logging, where every call will be logged, so warnings do not spam the users logs that much\n- `warnings` are printed by default when running tests. This is OK.\n- There is fine grained settings for showing/hiding `warnings` and also a lot of tooling supports `warnings`. ","author":{"url":"https://github.com/antonpirker","@type":"Person","name":"antonpirker"},"datePublished":"2025-02-28T12:46:27Z","url":"https://github.com/getsentry/sentry-python/issues/4109"}
| 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:f2f18a8e-7bdb-f06f-490b-e5168492437c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 828C:19F84C:204050:2ABDE7:6B00BEA6 |
| html-safe-nonce | bd845592dba1ceb2998e000db2fd6153817d351dd88cd45b66430022d4bd7914 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjhDOjE5Rjg0QzoyMDQwNTA6MkFCREU3OjZCMDBCRUE2IiwidmlzaXRvcl9pZCI6IjUyNDQyMjc3OTI1OTc0NjY3OTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3869683cf81de11d2efbafaa36820d444f893dea96d362c09fe43f6186eb23e3 |
| hovercard-subject-tag | issue:2887066990 |
| 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/getsentry/sentry-python/4109/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c40652c5e722827f0c0de0cd4da61f103db993253917e7dc613f9700d60c5853/getsentry/sentry-python/issues/4109 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c40652c5e722827f0c0de0cd4da61f103db993253917e7dc613f9700d60c5853/getsentry/sentry-python/issues/4109 |
| og:image:alt | Make all deprecation messages use the warnings.warn function. Right now we use two different ways, some deprecation messages use logging.warning and some are using warnings.warn. There was some dis... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | antonpirker |
| hostname | github.com |
| expected-hostname | github.com |
| None | 93edd3bebc4afb7ce711ee74cb5d2a95927850b082a4d43e212222389cb1c415 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| 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 | 1fee81a280ea86312b69448e261b418189bfd5b5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width