Title: Overriding final method only raises error if overriding method is annotated · Issue #7015 · python/mypy · GitHub
Open Graph Title: Overriding final method only raises error if overriding method is annotated · Issue #7015 · python/mypy
X Title: Overriding final method only raises error if overriding method is annotated · Issue #7015 · python/mypy
Description: In the code below I expected both subclasses to raise errors due to overriding method marked with @final, but only the B class raises an error, it seems like adding the return type annotation triggers the check. The same behavior is not ...
Open Graph Description: In the code below I expected both subclasses to raise errors due to overriding method marked with @final, but only the B class raises an error, it seems like adding the return type annotation trigg...
X Description: In the code below I expected both subclasses to raise errors due to overriding method marked with @final, but only the B class raises an error, it seems like adding the return type annotation trigg...
Opengraph URL: https://github.com/python/mypy/issues/7015
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Overriding final method only raises error if overriding method is annotated ","articleBody":"In the code below I expected both subclasses to raise errors due to overriding method marked with `@final`, but only the `B` class raises an error, it seems like adding the return type annotation triggers the check. The same behavior is not specific to `__init__` but happens with any method name.\r\n\r\n\r\n```python\r\nfrom typing_extensions import final\r\n\r\n\r\nclass Base:\r\n @final\r\n def __init__(self):\r\n pass\r\n\r\n\r\nclass A(Base):\r\n def __init__(self): # no error raised\r\n pass\r\n\r\n\r\nclass B(Base):\r\n def __init__(self) -> None: # raises an error\r\n pass\r\n```\r\n\r\nsetup.cfg:\r\n\r\n```\r\n[mypy]\r\nignore_missing_imports = True\r\nstrict_optional = True\r\nno_implicit_optional = True\r\ncheck_untyped_defs = True\r\ndisallow_incomplete_defs = True\r\ndisallow_any_unimported = True\r\ndisallow_untyped_decorators = True\r\n```\r\n\r\nSame result with both master `mypy 0.710+dev.44172caa122b01af5a63ec5787931b910f272eb6` and latest stable `mypy 0.701` using Python 3.7.0.\r\n","author":{"url":"https://github.com/antonagestam","@type":"Person","name":"antonagestam"},"datePublished":"2019-06-18T07:17:47Z","url":"https://github.com/python/mypy/issues/7015"}
| 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:1a70b9f1-c29a-80b2-6db0-f49d8d87d50d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D4C:1BAA33:19E2BB3:22588A1:6B0026FE |
| html-safe-nonce | 7390531df406d5271e7ee8f5c588cdf6a13c1b027c39796ad16417ac70aded01 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDRDOjFCQUEzMzoxOUUyQkIzOjIyNTg4QTE6NkIwMDI2RkUiLCJ2aXNpdG9yX2lkIjoiNDY0MDc2NjcxMTIwNzgzMTI5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 48d2f81d00124ec50866f7e016bd5f516eed13bd9522b28010d2d58fb411c55f |
| hovercard-subject-tag | issue:457302055 |
| 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/7015/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fe740bea4c3bde8c05a858f6d289cd6a4b0dd46fd1de2121c942f77f1fa28adf/python/mypy/issues/7015 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fe740bea4c3bde8c05a858f6d289cd6a4b0dd46fd1de2121c942f77f1fa28adf/python/mypy/issues/7015 |
| og:image:alt | In the code below I expected both subclasses to raise errors due to overriding method marked with @final, but only the B class raises an error, it seems like adding the return type annotation trigg... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | antonagestam |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width