Title: Regression with covariant type through built-in function · Issue #16476 · python/mypy · GitHub
Open Graph Title: Regression with covariant type through built-in function · Issue #16476 · python/mypy
X Title: Regression with covariant type through built-in function · Issue #16476 · python/mypy
Description: Bug Report Regression from 1.6.1 to 1.7: when passing a simple covariant type through a builtin (like sorted) the return type becomes a wider generic based type. To Reproduce def foo(a: list[int] | list[str]) -> list[int] | list[str]: re...
Open Graph Description: Bug Report Regression from 1.6.1 to 1.7: when passing a simple covariant type through a builtin (like sorted) the return type becomes a wider generic based type. To Reproduce def foo(a: list[int] |...
X Description: Bug Report Regression from 1.6.1 to 1.7: when passing a simple covariant type through a builtin (like sorted) the return type becomes a wider generic based type. To Reproduce def foo(a: list[int] |...
Opengraph URL: https://github.com/python/mypy/issues/16476
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression with covariant type through built-in function","articleBody":"**Bug Report**\r\n\r\nRegression from 1.6.1 to 1.7: when passing a simple covariant type through a builtin (like sorted) the return type becomes a wider generic based type.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\ndef foo(a: list[int] | list[str]) -> list[int] | list[str]:\r\n return sorted(a)\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nrunning mypy on the simple code above produces no error in 1.6.1.\r\n\r\n**Actual Behavior**\r\n\r\n```python\r\nerror: Incompatible return value type (got \"list[SupportsDunderLT[Any] | SupportsDunderGT[Any]]\", expected \"list[int] | list[str]\") [return-value]\r\n```\r\n\r\n**Your Environment**\r\n\r\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\r\n\r\nRegression from 1.6.1 to 1.7.0. Seen on multiple python versions (3.10, 3.11)\r\n\r\n\u003c!-- You can freely edit this text, please remove all the lines you believe are unnecessary. -->\r\n","author":{"url":"https://github.com/daveah","@type":"Person","name":"daveah"},"datePublished":"2023-11-13T14:39:30Z","url":"https://github.com/python/mypy/issues/16476"}
| 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:63d134d8-b9be-455c-ad20-d619902812ad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BC34:2E6021:28CEF39:3599A3B:6B000AE4 |
| html-safe-nonce | 4633371e964195b303b2d2422e417052283d4ed00047c79181cc5fba6148b426 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzM0OjJFNjAyMToyOENFRjM5OjM1OTlBM0I6NkIwMDBBRTQiLCJ2aXNpdG9yX2lkIjoiMzAyODk0MTYzMDQ5NDIxNDg4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | eba8b3df898335189feafd1883486148ff78d547cbf45a7c5f0a0dcc666e115e |
| hovercard-subject-tag | issue:1990796014 |
| 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/16476/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9134889e741a576647dc01e08663cc564e41d89b6b2ab1ea8a5877c7d5b32812/python/mypy/issues/16476 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9134889e741a576647dc01e08663cc564e41d89b6b2ab1ea8a5877c7d5b32812/python/mypy/issues/16476 |
| og:image:alt | Bug Report Regression from 1.6.1 to 1.7: when passing a simple covariant type through a builtin (like sorted) the return type becomes a wider generic based type. To Reproduce def foo(a: list[int] |... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | daveah |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width