Title: False exception error in raise statement with a ternary conditional operator · Issue #5128 · python/mypy · GitHub
Open Graph Title: False exception error in raise statement with a ternary conditional operator · Issue #5128 · python/mypy
X Title: False exception error in raise statement with a ternary conditional operator · Issue #5128 · python/mypy
Description: I faced with a strange mypy error, with such a code below: def foo() -> None: message = 'test' raise Exception(message) if message else Exception # -> mypy error def bar() -> None: raise Exception # ok def baz() -> None: message = 'test'...
Open Graph Description: I faced with a strange mypy error, with such a code below: def foo() -> None: message = 'test' raise Exception(message) if message else Exception # -> mypy error def bar() -> None: raise Exception ...
X Description: I faced with a strange mypy error, with such a code below: def foo() -> None: message = 'test' raise Exception(message) if message else Exception # -> mypy error def bar() -> None:...
Opengraph URL: https://github.com/python/mypy/issues/5128
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False exception error in raise statement with a ternary conditional operator","articleBody":"I faced with a strange mypy error, with such a code below:\r\n```Python\r\ndef foo() -> None:\r\n message = 'test'\r\n raise Exception(message) if message else Exception # -> mypy error\r\n\r\n\r\ndef bar() -> None:\r\n raise Exception # ok\r\n\r\n\r\ndef baz() -> None:\r\n message = 'test'\r\n raise Exception(message) # ok\r\n\r\n\r\ndef qux() -> None:\r\n message = 'test'\r\n raise Exception if not message else Exception(message) # -> mypy error\r\n\r\n\r\nif __name__ == '__main__':\r\n foo()\r\n```\r\n\r\nIt seems legal code, but mypy produces two error messages there. \r\n```\r\n$ mypy test.py\r\ntest.py:3: error: Exception must be derived from BaseException\r\ntest.py:17: error: Exception must be derived from BaseException\r\n```\r\nActually, this error seems to happen not only with `Exception` but with any other built-in exceptions.\r\nThe version of mypy is 0.600, and that of Python is 3.6.3.\r\n\r\nThanks in advance.","author":{"url":"https://github.com/bonotake","@type":"Person","name":"bonotake"},"datePublished":"2018-05-31T14:27:31Z","url":"https://github.com/python/mypy/issues/5128"}
| 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:f694b2d7-88a8-5fd4-69e7-af7e769f26be |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B5A:2FD3CB:4AF5B8:64CDBE:6B002F67 |
| html-safe-nonce | a75b0e8ad3a57bb8dbee8bb5a8d5ed7805b668184966931513c7c4b8fd453fae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjVBOjJGRDNDQjo0QUY1Qjg6NjRDREJFOjZCMDAyRjY3IiwidmlzaXRvcl9pZCI6IjYwMDU0MzE1MTEyMzM0NTI1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9c40ae5dce7dc6112eb28ea32ef45bbfa4318117f66cf4cfaaa80b0f2a4e8a95 |
| hovercard-subject-tag | issue:328161767 |
| 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/5128/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30bdba6dbb420cea6f6a5d1c37ac55189a2aa6f24590015e264aedbb96bb781c/python/mypy/issues/5128 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30bdba6dbb420cea6f6a5d1c37ac55189a2aa6f24590015e264aedbb96bb781c/python/mypy/issues/5128 |
| og:image:alt | I faced with a strange mypy error, with such a code below: def foo() -> None: message = 'test' raise Exception(message) if message else Exception # -> mypy error def bar() -> None: raise Exception ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bonotake |
| 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