Title: Multiple Inheritance Makes Mypy think an if branch is unreachable. · Issue #3603 · python/mypy · GitHub
Open Graph Title: Multiple Inheritance Makes Mypy think an if branch is unreachable. · Issue #3603 · python/mypy
X Title: Multiple Inheritance Makes Mypy think an if branch is unreachable. · Issue #3603 · python/mypy
Description: In the following example, the branch of an if-statement is not being typechecked. class Parent1: pass class Parent2: pass class Child(Parent1, Parent2): pass def goo(p: Parent1) -> None: if isinstance(p, Parent2): # this branch is not ty...
Open Graph Description: In the following example, the branch of an if-statement is not being typechecked. class Parent1: pass class Parent2: pass class Child(Parent1, Parent2): pass def goo(p: Parent1) -> None: if isinsta...
X Description: In the following example, the branch of an if-statement is not being typechecked. class Parent1: pass class Parent2: pass class Child(Parent1, Parent2): pass def goo(p: Parent1) -> None: if isin...
Opengraph URL: https://github.com/python/mypy/issues/3603
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Multiple Inheritance Makes Mypy think an if branch is unreachable.","articleBody":"In the following example, the branch of an if-statement is not being typechecked.\r\n\r\n```py\r\nclass Parent1: pass\r\n\r\nclass Parent2: pass\r\n\r\nclass Child(Parent1, Parent2): pass\r\n\r\ndef goo(p: Parent1) -\u003e None:\r\n if isinstance(p, Parent2):\r\n # this branch is not typechecked\r\n 1 + 'boom' # no error from mypy here.\r\n\r\n\r\ngoo(Child())\r\n```\r\n\r\nHere is the output from `mypy` and `python`.\r\n```\r\n$ mypy i.py \r\n$ python3 i.py \r\nTraceback (most recent call last):\r\n File \"i.py\", line 13, in \u003cmodule\u003e\r\n goo(Child())\r\n File \"i.py\", line 10, in goo\r\n 1 + 'boom' # no error from mypy but there's an error at runtime\r\nTypeError: unsupported operand type(s) for +: 'int' and 'str'\r\n```","author":{"url":"https://github.com/ilinum","@type":"Person","name":"ilinum"},"datePublished":"2017-06-23T21:56:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":18},"url":"https://github.com/3603/mypy/issues/3603"}
| 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:3963e44d-ac50-a16e-079e-36105d75a2ef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A26A:1346D1:2EAA1D:3F933C:6A5A6038 |
| html-safe-nonce | 3642f79f04139e977b051dc35fce42fee3524570e1bb17a3437417e91a007f3c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjZBOjEzNDZEMToyRUFBMUQ6M0Y5MzNDOjZBNUE2MDM4IiwidmlzaXRvcl9pZCI6IjMzMDAyMjA0MzY0Mzc2ODgzNzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | db9d7fd7fde738d88a636feb1357846243833ccd4dfd3607509e6cd9915f0450 |
| hovercard-subject-tag | issue:238262801 |
| 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/3603/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8d8f679a36fe92b580b1b5d25e2e769c1ada95b59298856677e9b1062af62e09/python/mypy/issues/3603 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8d8f679a36fe92b580b1b5d25e2e769c1ada95b59298856677e9b1062af62e09/python/mypy/issues/3603 |
| og:image:alt | In the following example, the branch of an if-statement is not being typechecked. class Parent1: pass class Parent2: pass class Child(Parent1, Parent2): pass def goo(p: Parent1) -> None: if isinsta... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ilinum |
| hostname | github.com |
| expected-hostname | github.com |
| None | 05b9ddf6a47d2dbe13944873a99f5fb4b83ba4871f9cb8a8e256793a63ca9687 |
| 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 | f8d29d1bd03dda2dd14b3f80b8bc27e1111f43bd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width