Title: `LoggerAdapter` is typed as a generic but using it as such raises an error at runtime · Issue #7855 · python/typeshed · GitHub
Open Graph Title: `LoggerAdapter` is typed as a generic but using it as such raises an error at runtime · Issue #7855 · python/typeshed
X Title: `LoggerAdapter` is typed as a generic but using it as such raises an error at runtime · Issue #7855 · python/typeshed
Description: With the following code: class ContextLoggingAdapter(logging.LoggerAdapter): def process(self, msg: str, kwargs: Any) -> Tuple[str, Any]: ... mypy raises the following type-arg error : error: Missing type parameters for generic type "Log...
Open Graph Description: With the following code: class ContextLoggingAdapter(logging.LoggerAdapter): def process(self, msg: str, kwargs: Any) -> Tuple[str, Any]: ... mypy raises the following type-arg error : error: Missi...
X Description: With the following code: class ContextLoggingAdapter(logging.LoggerAdapter): def process(self, msg: str, kwargs: Any) -> Tuple[str, Any]: ... mypy raises the following type-arg error : error: Mi...
Opengraph URL: https://github.com/python/typeshed/issues/7855
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`LoggerAdapter` is typed as a generic but using it as such raises an error at runtime","articleBody":"With the following code:\r\n\r\n```python\r\nclass ContextLoggingAdapter(logging.LoggerAdapter):\r\n def process(self, msg: str, kwargs: Any) -\u003e Tuple[str, Any]:\r\n ...\r\n```\r\n\r\nmypy raises the following `type-arg` error : `error: Missing type parameters for generic type \"LoggerAdapter\"`\r\n\r\nAccording to [this type stub](https://github.com/python/typeshed/blob/81be86af6e27ac0135b11c7f6697d8ae9623a034/stdlib/logging/__init__.pyi#L413-L414) it's typed as a generic and should be passed the type of the logger it's an adapter for. However, changing the code into this:\r\n\r\n```python\r\nclass ContextLoggingAdapter(logging.LoggerAdapter[logging.Logger]):\r\n def process(self, msg: str, kwargs: Any) -\u003e Tuple[str, Any]:\r\n ...\r\n```\r\n\r\nmakes mypy happy but raises an error at runtime: `TypeError: 'type' object is not subscriptable`\r\n\r\nI'm not sure if this is an issue with the stubs or with mypy (and I'm not fully sure how they interact), so apologies if this issue should have been created on https://github.com/python/mypy instead (feel free to transfer it there if that's the case).","author":{"url":"https://github.com/babolivier","@type":"Person","name":"babolivier"},"datePublished":"2022-05-17T12:59:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/7855/typeshed/issues/7855"}
| 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:4ef02043-7da2-79b7-66cd-f04f01278d80 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8128:161A62:E90EE1:14D1AA2:6A633247 |
| html-safe-nonce | 6c21d774978dccf0d89537d097df822d236967de98bfa8d52f8ab63d381e156f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTI4OjE2MUE2MjpFOTBFRTE6MTREMUFBMjo2QTYzMzI0NyIsInZpc2l0b3JfaWQiOiIyNjQzMjgwNjM4NDgyMDAyNTAzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7d231d15ab6235e27b36d602fd4244d06db4b804117ddd7dcfe77daa56c1b3c3 |
| hovercard-subject-tag | issue:1238604857 |
| 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/7855/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a4d0b924d0d2f298d73ed423f150b2c54d5123641d3cf995d9426253aa43151c/python/typeshed/issues/7855 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a4d0b924d0d2f298d73ed423f150b2c54d5123641d3cf995d9426253aa43151c/python/typeshed/issues/7855 |
| og:image:alt | With the following code: class ContextLoggingAdapter(logging.LoggerAdapter): def process(self, msg: str, kwargs: Any) -> Tuple[str, Any]: ... mypy raises the following type-arg error : error: Missi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | babolivier |
| hostname | github.com |
| expected-hostname | github.com |
| None | df6e1c2adcceb061ec8c4106a1b34f38280f08e13f2b195c661c202834cbc3b1 |
| 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 | 822a0ff2a479845adcdd40a1a7b1734a56e05818 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width