Title: `warnings.simplefilter` and `warnings.catch_warnings` take `tuple[type[Warning], ...]` as well as `type[Warning]` for `category` parameter · Issue #15829 · python/typeshed · GitHub
Open Graph Title: `warnings.simplefilter` and `warnings.catch_warnings` take `tuple[type[Warning], ...]` as well as `type[Warning]` for `category` parameter · Issue #15829 · python/typeshed
X Title: `warnings.simplefilter` and `warnings.catch_warnings` take `tuple[type[Warning], ...]` as well as `type[Warning]` for `category` parameter · Issue #15829 · python/typeshed
Description: When a warning is encountered by the mechanisms of the warnings module, it uses issubclass checks on its type against the warning filters previously inserted. This makes tuples of warning classes as the category argument to warnings.simp...
Open Graph Description: When a warning is encountered by the mechanisms of the warnings module, it uses issubclass checks on its type against the warning filters previously inserted. This makes tuples of warning classes a...
X Description: When a warning is encountered by the mechanisms of the warnings module, it uses issubclass checks on its type against the warning filters previously inserted. This makes tuples of warning classes a...
Opengraph URL: https://github.com/python/typeshed/issues/15829
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`warnings.simplefilter` and `warnings.catch_warnings` take `tuple[type[Warning], ...]` as well as `type[Warning]` for `category` parameter","articleBody":"When a warning is encountered by the mechanisms of the `warnings` module, it uses `issubclass` checks on its type against the warning filters previously inserted. This makes tuples of warning classes as the `category` argument to `warnings.simplefilter` acceptable as well, but the current annotations .\n\n[Standard library example of this usage](https://github.com/python/cpython/blob/a38804bb981ba93a1efbb95a1e35a1c0b05740c7/Lib/codeop.py#L61) on the main branch, in `Lib/codeop.py`, under the `_maybe_compile` helper function:\n\n```python\n # Disable compiler warnings when checking for incomplete input.\n with warnings.catch_warnings():\n warnings.simplefilter(\"ignore\", (SyntaxWarning, DeprecationWarning))\n try:\n compiler(source, filename, symbol, flags=flags)\n except SyntaxError: # Let other compile() errors propagate.\n try:\n compiler(source + \"\\n\", filename, symbol, flags=flags)\n return None\n except _IncompleteInputError:\n return None\n except SyntaxError:\n pass\n # fallthrough\n```\n\nThe analogous parameter in the `warnings.catch_warnings` constructor, introduced in Python 3.11 and added to typeshed by #7685, is passed straight through to `warnings.simplefilter`. Its type should be updated accordingly.","author":{"url":"https://github.com/jonathandung","@type":"Person","name":"jonathandung"},"datePublished":"2026-05-24T10:39:38Z","url":"https://github.com/python/typeshed/issues/15829"}
| 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:b3a89441-55fe-7c28-5c51-f7d0c9bb36c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D6DE:9E1B2:358A17C:47246B4:6B0044A2 |
| html-safe-nonce | 327c37cc280beff7a6d58ddfbb84dc4beaafe6d1604fccad65c25e13ca8402a3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkRFOjlFMUIyOjM1OEExN0M6NDcyNDZCNDo2QjAwNDRBMiIsInZpc2l0b3JfaWQiOiI3MzgzMDIzNzc4MzE5NTgyMzcwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b7db64984654c5c3797fb5a7fcb257d2dd611ca26930ba2e7446a801bd8f9c28 |
| hovercard-subject-tag | issue:4511261309 |
| 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/typeshed/15829/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c6579c9f1641b9b37820b5d317b0d2799873d0e65a7e6c6b0dfaed500e91d032/python/typeshed/issues/15829 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c6579c9f1641b9b37820b5d317b0d2799873d0e65a7e6c6b0dfaed500e91d032/python/typeshed/issues/15829 |
| og:image:alt | When a warning is encountered by the mechanisms of the warnings module, it uses issubclass checks on its type against the warning filters previously inserted. This makes tuples of warning classes a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jonathandung |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width