Title: Subclassing a contextmanager fails · Issue #2469 · python/mypy · GitHub
Open Graph Title: Subclassing a contextmanager fails · Issue #2469 · python/mypy
X Title: Subclassing a contextmanager fails · Issue #2469 · python/mypy
Description: from contextlib import contextmanager from typing import Iterator class Foo(object): @contextmanager def bar(self): # type: () -> Iterator[int] yield 4 class Bar(Foo): @contextmanager def bar(self): # type: () -> Iterator[int] yield 3 re...
Open Graph Description: from contextlib import contextmanager from typing import Iterator class Foo(object): @contextmanager def bar(self): # type: () -> Iterator[int] yield 4 class Bar(Foo): @contextmanager def bar(self)...
X Description: from contextlib import contextmanager from typing import Iterator class Foo(object): @contextmanager def bar(self): # type: () -> Iterator[int] yield 4 class Bar(Foo): @contextmanager def bar(se...
Opengraph URL: https://github.com/python/mypy/issues/2469
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Subclassing a contextmanager fails","articleBody":"```\r\nfrom contextlib import contextmanager\r\nfrom typing import Iterator\r\n\r\nclass Foo(object):\r\n @contextmanager\r\n def bar(self):\r\n # type: () -> Iterator[int]\r\n yield 4\r\n\r\nclass Bar(Foo):\r\n @contextmanager\r\n def bar(self):\r\n # type: () -> Iterator[int]\r\n yield 3\r\n\r\nreveal_type(Foo.bar)\r\nreveal_type(Bar.bar)\r\n```\r\nFails thus:\r\n```\r\nt5.py: note: In class \"Bar\":\r\nt5.py:12: error: Signature of \"bar\" incompatible with supertype \"Foo\"\r\nt5.py: note: At top level:\r\nt5.py:17: error: Revealed type is 'def (*Any, **Any) -> contextlib.ContextManager[builtins.int*]'\r\nt5.py:18: error: Revealed type is 'def (*Any, **Any) -> contextlib.ContextManager[builtins.int*]'\r\n```\r\n","author":{"url":"https://github.com/euresti","@type":"Person","name":"euresti"},"datePublished":"2016-11-18T23:00:14Z","url":"https://github.com/python/mypy/issues/2469"}
| 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:2e226820-290d-2387-210a-116940128964 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E008:37308E:27B0809:3420467:6B0007F8 |
| html-safe-nonce | f2a38f981543bc4960b339ac3734546aceb61c2b5b6ce67a992e1e9303b6adb4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDA4OjM3MzA4RToyN0IwODA5OjM0MjA0Njc6NkIwMDA3RjgiLCJ2aXNpdG9yX2lkIjoiODI0NzY3MTIwNTQ4MjQ2NTI3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 195e9dd1c23747e9dc8626ea63716dc044567b2bf615de3dc6d89b48b7211b66 |
| hovercard-subject-tag | issue:190442389 |
| 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/mypy/2469/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b5bdc474fb35eda598c681c3f67644e0f81bb6dca3856f7b565360ca513f4e3e/python/mypy/issues/2469 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b5bdc474fb35eda598c681c3f67644e0f81bb6dca3856f7b565360ca513f4e3e/python/mypy/issues/2469 |
| og:image:alt | from contextlib import contextmanager from typing import Iterator class Foo(object): @contextmanager def bar(self): # type: () -> Iterator[int] yield 4 class Bar(Foo): @contextmanager def bar(self)... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | euresti |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width