Title: Regression on validation of manual type annotations to functools.partial between stable version and git · Issue #17301 · python/mypy · GitHub
Open Graph Title: Regression on validation of manual type annotations to functools.partial between stable version and git · Issue #17301 · python/mypy
X Title: Regression on validation of manual type annotations to functools.partial between stable version and git · Issue #17301 · python/mypy
Description: Bug Report When validating manual type hints to the return of a call to functools.partial, there has occurred a regression between the latest stable release (1.10.0) and the master branch, in that the git version asserts that the correct...
Open Graph Description: Bug Report When validating manual type hints to the return of a call to functools.partial, there has occurred a regression between the latest stable release (1.10.0) and the master branch, in that ...
X Description: Bug Report When validating manual type hints to the return of a call to functools.partial, there has occurred a regression between the latest stable release (1.10.0) and the master branch, in that ...
Opengraph URL: https://github.com/python/mypy/issues/17301
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression on validation of manual type annotations to functools.partial between stable version and git","articleBody":"**Bug Report**\r\n\r\nWhen validating manual type hints to the return of a call to `functools.partial`, there has occurred a regression between the latest stable release (1.10.0) and the master branch, in that the git version asserts that the correct annotation should be `partial[partial[T]]`, where `T` is the type manually annotated for the `functools.partial` call.\r\n\r\n**To Reproduce**\r\n**TL;DR:**\r\nmaster branch: https://mypy-play.net/?mypy=master&python=3.12&gist=e45e31f06514aabe6a039dfc759e9a3b\r\n1.10.0: https://mypy-play.net/?mypy=latest&python=3.12&gist=e45e31f06514aabe6a039dfc759e9a3b\r\n\r\nConsider:\r\n```python\r\nfrom functools import partial\r\nfrom typing import Type, TypeVar\r\n\r\nT = TypeVar(\"T\")\r\n\r\n\r\ndef generic(string: str, integer: int, resulting_type: Type[T]) -> T:\r\n if isinstance(string, resulting_type):\r\n return string\r\n elif isinstance(integer, resulting_type):\r\n return integer\r\n raise RuntimeError\r\n```\r\n\r\n**Expected Behavior**\r\nFor the below definition:\r\n```python\r\np: partial[str] = partial(generic, resulting_type=str)\r\n```\r\nThe stable release does not generate any errors, as expected.\r\n\r\n**Actual Behavior**\r\nHowever, on the current git build, the following error message is displayed:\r\n```\r\nerror: Incompatible types in assignment (expression has type \"partial[partial[str]]\", variable has type \"partial[str]\") [assignment]\r\nerror: Argument 1 to \"generic\" has incompatible type \"type[str]\"; expected \"type[partial[str]]\" [arg-type]\r\n```\r\n\r\nIf the type annotation is changed to something nonsensical:\r\n```python\r\np: partial[bool] = partial(generic, resulting_type=str)\r\n```\r\n\r\nmypy now generates an error asserting the type of the expression is of type `partial[partial[TYPE GIVEN]]`:\r\n```\r\nmain.py:13: error: Incompatible types in assignment (expression has type \"partial[partial[bool]]\", variable has type \"partial[bool]\") [assignment]\r\nmain.py:13: error: Argument 1 to \"generic\" has incompatible type \"type[str]\"; expected \"type[partial[bool]]\" [arg-type]\r\n```\r\nPlayground for this: https://mypy-play.net/?mypy=master&python=3.12&gist=8b38f943d002dc6ce084e8771251e78a\r\n\r\n**Your Environment**\r\nN/A, reproducible in mypy Playground environment.\r\n\r\n**_Thank you for your hard work maintaining mypy!_**\r\n","author":{"url":"https://github.com/surrealoatmeal","@type":"Person","name":"surrealoatmeal"},"datePublished":"2024-05-31T01:40:41Z","url":"https://github.com/python/mypy/issues/17301"}
| 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:070d7139-9e3e-8b4c-27a0-d65b3b558358 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B266:3A7693:23F7F34:30D1798:6B002CD4 |
| html-safe-nonce | b64f4ba9a7976dd7694140bcf64d7e05aec95dd3820dcc9f43ab9804bb52d9c6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjY2OjNBNzY5MzoyM0Y3RjM0OjMwRDE3OTg6NkIwMDJDRDQiLCJ2aXNpdG9yX2lkIjoiMzM5NTUyNTEwMzYxNjc5NzkwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6b5686125d9903fb269f788433e666525c6fe8555849cca1ce4712fcd46007e0 |
| hovercard-subject-tag | issue:2326810762 |
| 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/17301/issue_layout |
| twitter:image | https://opengraph.githubassets.com/780777b3876d8d428963fab07b85ac82ba9460703abe912d51939cc6996cb735/python/mypy/issues/17301 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/780777b3876d8d428963fab07b85ac82ba9460703abe912d51939cc6996cb735/python/mypy/issues/17301 |
| og:image:alt | Bug Report When validating manual type hints to the return of a call to functools.partial, there has occurred a regression between the latest stable release (1.10.0) and the master branch, in that ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | surrealoatmeal |
| 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