Title: Inheriting overloaded signatures · Issue #5146 · python/mypy · GitHub
Open Graph Title: Inheriting overloaded signatures · Issue #5146 · python/mypy
X Title: Inheriting overloaded signatures · Issue #5146 · python/mypy
Description: Say we have a class Foo: class Foo: @overload def fun(self, s:str) -> str: pass @overload def fun(self, i:int) -> int: pass def fun(self, x): pass If we now add a subclass Bar like this: class Bar(Foo): @overload def fun(self, s:str) -> ...
Open Graph Description: Say we have a class Foo: class Foo: @overload def fun(self, s:str) -> str: pass @overload def fun(self, i:int) -> int: pass def fun(self, x): pass If we now add a subclass Bar like this: class Bar(...
X Description: Say we have a class Foo: class Foo: @overload def fun(self, s:str) -> str: pass @overload def fun(self, i:int) -> int: pass def fun(self, x): pass If we now add a subclass Bar like this: clas...
Opengraph URL: https://github.com/python/mypy/issues/5146
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inheriting overloaded signatures","articleBody":"Say we have a class `Foo`:\r\n```python\r\nclass Foo:\r\n @overload\r\n def fun(self, s:str) -> str:\r\n pass\r\n\r\n @overload\r\n def fun(self, i:int) -> int:\r\n pass\r\n\r\n def fun(self, x):\r\n pass\r\n```\r\nIf we now add a subclass `Bar` like this:\r\n```python\r\nclass Bar(Foo):\r\n @overload\r\n def fun(self, s:str) -> str:\r\n pass\r\n\r\n @overload\r\n def fun(self, i:int) -> int:\r\n pass\r\n\r\n def fun(self, x):\r\n pass\r\nBar().fun([])\r\n```\r\nand run mypy on it without any flags, we get the expected\r\n`error: No overload variant of \"fun\" of \"Bar\" matches argument type \"List[\u003cnothing>]\"`.\r\nIf however we don't copy the overloaded signatures,\r\n```python\r\nclass Bar(Foo):\r\n def fun(self, x):\r\n pass\r\nBar().fun([])\r\n```\r\nthen mypy does not find any errors. Is this inteded behaviour? Is it not possible to find the overloaded signatures of the base classes statically? Am I not supposed to do this sort of thing in the first place?\r\n```\r\n> python -V\r\nPython 3.6.2\r\n> mypy -V\r\nmypy 0.610+dev-eb1bb064d707ce05735ff6795df82126e75ea6ea\r\n```","author":{"url":"https://github.com/Geggles","@type":"Person","name":"Geggles"},"datePublished":"2018-06-05T11:09:21Z","url":"https://github.com/python/mypy/issues/5146"}
| 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:b4829ecd-e962-c4a7-30b6-9100682d5011 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F6C:30E5B0:36D503D:48CDC17:6B004835 |
| html-safe-nonce | e681fbdaa10583fc3eab0b1cbf1c14dc0ae20ca0a21715f79f09934ad278373e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjZDOjMwRTVCMDozNkQ1MDNEOjQ4Q0RDMTc6NkIwMDQ4MzUiLCJ2aXNpdG9yX2lkIjoiNDgxODE1MTI4MTg3MDk1MDk0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6122dff083f9deaa1c812d538fc15fd6c239c0f71edea32a742aed4c3f49cdac |
| hovercard-subject-tag | issue:329408129 |
| 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/5146/issue_layout |
| twitter:image | https://opengraph.githubassets.com/56cb50e86a5fdf79b1a5dac8a5f82c902219e75df4aeec15010746e6db3547d1/python/mypy/issues/5146 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/56cb50e86a5fdf79b1a5dac8a5f82c902219e75df4aeec15010746e6db3547d1/python/mypy/issues/5146 |
| og:image:alt | Say we have a class Foo: class Foo: @overload def fun(self, s:str) -> str: pass @overload def fun(self, i:int) -> int: pass def fun(self, x): pass If we now add a subclass Bar like this: class Bar(... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Geggles |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width