Title: Generics is not supported with some operators · Issue #6157 · python/mypy · GitHub
Open Graph Title: Generics is not supported with some operators · Issue #6157 · python/mypy
X Title: Generics is not supported with some operators · Issue #6157 · python/mypy
Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to simplify your case to a minimal repro. Sup...
Open Graph Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to si...
X Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to si...
Opengraph URL: https://github.com/python/mypy/issues/6157
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generics is not supported with some operators","articleBody":"\r\n* Are you reporting a bug, or opening a feature request?\r\n Bug\r\n* Please insert below the code you are checking with mypy,\r\n or a mock-up repro if the source is private. We would appreciate\r\n if you try to simplify your case to a minimal repro.\r\n\r\n[Supporting operators with union](https://github.com/python/mypy/pull/5545) does not work with generics. \r\n\r\n```\r\nS = TypeVar('S', bound=Union[int, float])\r\nT = TypeVar('T', bound=Union[int, float])\r\n\r\ndef some_function(a:S, b:T) -> S:\r\n // do some operation and returns the type based on first parameter.\r\n c = a + b\r\n // if there is an addition involved in the computation, then we would get the below error. \r\n // some_computed_variable would be finally computed and has the value based on first parameter type.\r\n return some_computed_variable\r\n\r\n```\r\n\r\n* What is the actual behavior/output?\r\n`error: Unsupported operand types for + (\"S\" and \"T\")`\r\n\r\n We can use alias (Union[int, float] as type) instead of generics (`S`) as a workaround but it loses generic support.\r\n\r\n* What is the behavior/output you expect?\r\n Should not report error\r\n\r\n* What are the versions of mypy and Python you are using?\r\n Python: 3.6 mypy: 0.650\r\n\r\n* What are the mypy flags you are using? (For example --strict-optional)\r\n`--ignore-missing-imports`\r\n\r\n","author":{"url":"https://github.com/appraveen","@type":"Person","name":"appraveen"},"datePublished":"2019-01-07T16:46:07Z","url":"https://github.com/python/mypy/issues/6157"}
| 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:40a6becb-c27a-8034-8990-75a5a2082cae |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 80AC:142FA7:AE15B:EA3D5:6B001C49 |
| html-safe-nonce | e37500d9087ebc303a8b0fe02ca52683074dc2902477267842b86a5a056d73b2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEFDOjE0MkZBNzpBRTE1QjpFQTNENTo2QjAwMUM0OSIsInZpc2l0b3JfaWQiOiIzODU4MTg4NjQwMTIzMzYyMzc3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 23d10b6feccc263f376aee0f2b1453e3344301b12be452921f6b1e24ff7462bf |
| hovercard-subject-tag | issue:396563148 |
| 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/6157/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3e12eddb0f81aad4976e87debe207ccee2a8c0f2b20aef38d2cf9ad11134441d/python/mypy/issues/6157 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3e12eddb0f81aad4976e87debe207ccee2a8c0f2b20aef38d2cf9ad11134441d/python/mypy/issues/6157 |
| og:image:alt | Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to si... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | appraveen |
| 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