Title: Mypy reports error for different argument, than the one which is actually wrong · Issue #19289 · python/mypy · GitHub
Open Graph Title: Mypy reports error for different argument, than the one which is actually wrong · Issue #19289 · python/mypy
X Title: Mypy reports error for different argument, than the one which is actually wrong · Issue #19289 · python/mypy
Description: Bug Report When using generic Callables as parameters, the error is correctly reported, but it's reported for different argument than the one which is in fact wrong. To Reproduce from typing import Callable, TypeVar, List T1 = TypeVar('T...
Open Graph Description: Bug Report When using generic Callables as parameters, the error is correctly reported, but it's reported for different argument than the one which is in fact wrong. To Reproduce from typing import...
X Description: Bug Report When using generic Callables as parameters, the error is correctly reported, but it's reported for different argument than the one which is in fact wrong. To Reproduce from typing im...
Opengraph URL: https://github.com/python/mypy/issues/19289
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Mypy reports error for different argument, than the one which is actually wrong","articleBody":"\u003c!--\nIf you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form instead.\nPlease consider:\n\n- checking our common issues page: https://mypy.readthedocs.io/en/stable/common_issues.html\n- searching our issue tracker: https://github.com/python/mypy/issues to see if it's already been reported\n- asking on gitter chat: https://gitter.im/python/typing\n-->\n\n**Bug Report**\n\n\u003c!--\nIf you're reporting a problem with a specific library function, the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues\n\nIf the project you encountered the issue in is open source, please provide a link to the project.\n-->\n\nWhen using generic Callables as parameters, the error is correctly reported, but it's reported for different argument than the one which is in fact wrong.\n\n**To Reproduce**\n\n```python\nfrom typing import Callable, TypeVar, List\n\nT1 = TypeVar('T1')\nT2 = TypeVar('T2')\n\ndef bigfunc(\n a: int,\n b: T1,\n c: Callable[[T1], T2],\n d: Callable[[T2], str],\n) -> None:\n res = d(c(b))\n print(f'{a=}, {b=}, {res=}')\n\n\n# should be:\n# c_func(x: float) -> List[float]:\ndef c_func(x: float) -> None:\n pass\n\ndef d_func(y: List[float]) -> str:\n return str(y)\n\nbigfunc(1, 0.1, c_func, d_func)\n```\n\n**Expected Behavior**\n\n\u003c!--\nHow did you expect mypy to behave? It’s fine if you’re not sure your understanding is correct.\nWrite down what you thought would happen. If you expected no errors, delete this section.\n-->\nI would expect mypy to complain about 3rd argument (`c - c_func`).\n\n**Actual Behavior**\n\n\u003c!-- What went wrong? Paste mypy's output. -->\n\nMypy complains about 1st argument, which is 100% correct (`a: int`)\n```\na.py:24: error: Cannot infer type argument 1 of \"bigfunc\" [misc]\nFound 1 error in 1 file (checked 1 source file)\n```\n\n**Your Environment**\n\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\n\n- Mypy version used: 1.16.0\n- Mypy command-line flags: None\n- Mypy configuration options from `mypy.ini` (and other config files): None\n- Python version used: 3.11.2\n\n\u003c!-- You can freely edit this text, please remove all the lines you believe are unnecessary. -->\n","author":{"url":"https://github.com/jan-spurny","@type":"Person","name":"jan-spurny"},"datePublished":"2025-06-13T09:08:15Z","url":"https://github.com/python/mypy/issues/19289"}
| 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:facc9dbd-d12e-c7e2-a74a-c050192de1c7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 845A:18FDF5:3F7460:552D5C:6B002A18 |
| html-safe-nonce | c8c7e31636f29e00f1d81dbb8c2f23a35e7921c467efc4c303790b0898d70284 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDVBOjE4RkRGNTozRjc0NjA6NTUyRDVDOjZCMDAyQTE4IiwidmlzaXRvcl9pZCI6Ijc5NTM1OTMxNDExNjI5NDUwNDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9860ccc76be5fdc66e067da54aa41e8d44cfadfdc8abd01a28e1dd9ad76b23a1 |
| hovercard-subject-tag | issue:3142834999 |
| 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/19289/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fafed42478ee93988491be05e1e60167b2c1c627b80d199108751431531f6f83/python/mypy/issues/19289 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fafed42478ee93988491be05e1e60167b2c1c627b80d199108751431531f6f83/python/mypy/issues/19289 |
| og:image:alt | Bug Report When using generic Callables as parameters, the error is correctly reported, but it's reported for different argument than the one which is in fact wrong. To Reproduce from typing import... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jan-spurny |
| 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