Title: set.__and__ false-positive involving generic inference · Issue #15462 · python/mypy · GitHub
Open Graph Title: set.__and__ false-positive involving generic inference · Issue #15462 · python/mypy
X Title: set.__and__ false-positive involving generic inference · Issue #15462 · python/mypy
Description: Bug Report The way mypy does type inference breaks calling a generic function on the right side of set.__and__, because it takes an argument of type AbstractSet[object]. It seems like it is propagating 'object' instead of the more specif...
Open Graph Description: Bug Report The way mypy does type inference breaks calling a generic function on the right side of set.__and__, because it takes an argument of type AbstractSet[object]. It seems like it is propaga...
X Description: Bug Report The way mypy does type inference breaks calling a generic function on the right side of set.__and__, because it takes an argument of type AbstractSet[object]. It seems like it is propaga...
Opengraph URL: https://github.com/python/mypy/issues/15462
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"set.__and__ false-positive involving generic inference","articleBody":"**Bug Report**\r\n\r\nThe way mypy does type inference breaks calling a generic function on the right side of `set.__and__`, because it takes an argument of type `AbstractSet[object]`. It seems like it is propagating 'object' instead of the more specific type and then complaining when that does not work.\r\n\r\nI reported this as a comment on #5738, but this is apparently a different issue because this problem was not fixed when that issue was closed.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom typing import TypeVar\r\n\r\nT = TypeVar('T')\r\n\r\ndef identity(x: set[T]) -> set[T]:\r\n return x\r\n\r\nx = {0, 1}\r\n\r\nprint({0} & identity(x))\r\n```\r\n\r\n**Actual Behavior**\r\n\r\n```\r\n$ mypy repr.py\r\nrepr.py:10: error: Argument 1 to \"identity\" has incompatible type \"set[int]\"; expected \"set[object]\" [arg-type]\r\nFound 1 error in 1 file (checked 1 source file)\r\n\r\n$ mypy --new-type-inference repr.py\r\nrepr.py:10: error: Argument 1 to \"identity\" has incompatible type \"set[int]\"; expected \"set[object]\" [arg-type]\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: mypy 1.5.0+dev.0873230ee60461110bd7bfde7ca3886878aae389 (compiled: no)\r\n- Python version used: Python 3.11.3","author":{"url":"https://github.com/cebtenzzre","@type":"Person","name":"cebtenzzre"},"datePublished":"2023-06-18T23:51:49Z","url":"https://github.com/python/mypy/issues/15462"}
| 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:8603f0d0-6828-08f2-2afa-05b423aea9fb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A598:308D9D:226356C:2EDCD6C:6B002A75 |
| html-safe-nonce | 004d66e202e9316acad3a5cc21f26b4b886991049af3ea4d9fb54b7e6a6efb93 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTk4OjMwOEQ5RDoyMjYzNTZDOjJFRENENkM6NkIwMDJBNzUiLCJ2aXNpdG9yX2lkIjoiMjQ3NTI5NjE5NTQzODcxNzU1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ead93bb04b79f98652f3002103af7874e5dcf3c0e541fc781d466a869818c852 |
| hovercard-subject-tag | issue:1762514046 |
| 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/15462/issue_layout |
| twitter:image | https://opengraph.githubassets.com/51e764501e834f1d5a10bdd52c56a1bc20bef30bbf34a53fdda271ebb5331053/python/mypy/issues/15462 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/51e764501e834f1d5a10bdd52c56a1bc20bef30bbf34a53fdda271ebb5331053/python/mypy/issues/15462 |
| og:image:alt | Bug Report The way mypy does type inference breaks calling a generic function on the right side of set.__and__, because it takes an argument of type AbstractSet[object]. It seems like it is propaga... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cebtenzzre |
| 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 | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width