Title: Output type of warnings.catch_warnings with record=True · Issue #3463 · python/typeshed · GitHub
Open Graph Title: Output type of warnings.catch_warnings with record=True · Issue #3463 · python/typeshed
X Title: Output type of warnings.catch_warnings with record=True · Issue #3463 · python/typeshed
Description: Although warnings.catch_warnings with record=True returns a list, mypy is not aware of that: File foo.py: import warnings with warnings.catch_warnings(record=True) as w: print(len(w)) Command mypy foo.py gives: $ mypy foo.py foo.py:4: er...
Open Graph Description: Although warnings.catch_warnings with record=True returns a list, mypy is not aware of that: File foo.py: import warnings with warnings.catch_warnings(record=True) as w: print(len(w)) Command mypy ...
X Description: Although warnings.catch_warnings with record=True returns a list, mypy is not aware of that: File foo.py: import warnings with warnings.catch_warnings(record=True) as w: print(len(w)) Command mypy ...
Opengraph URL: https://github.com/python/typeshed/issues/3463
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Output type of warnings.catch_warnings with record=True","articleBody":"Although [warnings.catch_warnings](https://docs.python.org/3/library/warnings.html#warnings.catch_warnings) with `record=True` returns\r\na list, mypy is not aware of that:\r\n\r\nFile `foo.py`:\r\n\r\n```python\r\nimport warnings\r\n\r\nwith warnings.catch_warnings(record=True) as w:\r\n print(len(w))\r\n```\r\n\r\nCommand `mypy foo.py` gives:\r\n\r\n```\r\n$ mypy foo.py\r\nfoo.py:4: error: Argument 1 to \"len\" has incompatible type \"Optional[List[_Record]]\"; expected \"Sized\"\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\nUsing recent mypy from master (`0.750+dev.e97377c454a1d5c019e9c56871d5f229db6b47b2`).\r\n\r\n---\r\n\r\nI've attached PR fixing this #3464.","author":{"url":"https://github.com/mslapek","@type":"Person","name":"mslapek"},"datePublished":"2019-11-14T07:11:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/3463/typeshed/issues/3463"}
| 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:a493a82a-b85f-71bf-b78a-c77461164f8a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C0B0:425E5:2DBEF59:3F9DDF4:6A60C8E7 |
| html-safe-nonce | 39d68a29db9dfdf2398d122b798fa9c0b99145c0e7bea284b74310b40d59692d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEIwOjQyNUU1OjJEQkVGNTk6M0Y5RERGNDo2QTYwQzhFNyIsInZpc2l0b3JfaWQiOiI4NjYzOTE5MDI2MTE1NzU4MzExIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b5c886253712f53d4fd484858d5506d5527ce7489f3bdc17410518e686cf7224 |
| hovercard-subject-tag | issue:522669655 |
| 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/3463/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ed6d0f71a7177ffe229cb0023567c63cdd2c9d441089cce48a4c8dbac5064956/python/typeshed/issues/3463 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ed6d0f71a7177ffe229cb0023567c63cdd2c9d441089cce48a4c8dbac5064956/python/typeshed/issues/3463 |
| og:image:alt | Although warnings.catch_warnings with record=True returns a list, mypy is not aware of that: File foo.py: import warnings with warnings.catch_warnings(record=True) as w: print(len(w)) Command mypy ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mslapek |
| hostname | github.com |
| expected-hostname | github.com |
| None | e30aeaafb59b2438b8b0aaa24f4c6777e8e86dae0737625adfc928cac5443cd5 |
| 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 | 34b43e23ce2dc970fbfce25d0e96500f2af8266d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width