René's URL Explorer Experiment


Title: Spurious error with `partial` and `ParamSpec` · Issue #15215 · python/mypy · GitHub

Open Graph Title: Spurious error with `partial` and `ParamSpec` · Issue #15215 · python/mypy

X Title: Spurious error with `partial` and `ParamSpec` · Issue #15215 · python/mypy

Description: Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.

Open Graph Description: Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.

X Description: Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.

Opengraph URL: https://github.com/python/mypy

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Spurious error with `partial` and `ParamSpec`","articleBody":"**Bug Report**\r\n\r\nWhen type checking the code below `mypy` produces a bunch of weird errors, most interesting one being\r\n\r\n```\r\nArgument 1 to \"partial\" has incompatible type \"Callable[[Callable[_P, _T], NamedArg(str, 'name')], Task[_P, _T]]\"; expected \"Callable[..., Task[_P, _T]]\"  [arg-type]\r\n```\r\n\r\nI'm not sure, but isn't `Callable[[Something], Task[_P, _T]]` *always* compatible with `Callable[..., Task[_P, _T]]`?\r\n\r\n**To Reproduce**\r\n\r\nYou can also see this [in playground](https://mypy-play.net/?mypy=master&python=3.10&flags=strict&gist=414c88ef9fe3f0804d59dc59a43b7009).\r\n\r\n```python\r\nfrom __future__ import annotations\r\n\r\nfrom dataclasses import dataclass\r\nfrom functools import partial\r\nfrom typing import Any, TypeVar, ParamSpec, Generic, Protocol, Callable\r\n\r\n\r\n_T = TypeVar(\"_T\")\r\n_P = ParamSpec(\"_P\")\r\n\r\n\r\n@dataclass(kw_only=True, repr=True)\r\nclass Task(Generic[_P, _T]):\r\n    name: str\r\n    function: Callable[_P, _T]\r\n\r\n\r\nclass _TaskRegistrator(Protocol):\r\n    def __call__(self, func: Callable[_P, _T], /, *, name: str = ...) -> Task[_P, _T]:\r\n        ...\r\n\r\n\r\nclass TaskQueue:\r\n    def _register_task(self, func: Callable[_P, _T], *, name: str) -> Task[_P, _T]:\r\n        # Actual implementation omitted\r\n        return Task(name=name, function=func)\r\n\r\n    def task(self, name: str) -> _TaskRegistrator:\r\n        return partial(self._register_task, name=name)  # E: see below (L29)\r\n        \r\n    def task2(self, name: str) -> Callable[[Callable[_P, _T]], Task[_P, _T]]:\r\n        return partial(self._register_task, name=name)  # E: see below (L32)\r\n\r\n\r\n# And now we see that the problem is even unrelated to `self`:\r\n\r\ndef _register_task(func: Callable[_P, _T], *, name: str) -> Task[_P, _T]:\r\n    # Actual implementation omitted\r\n    return Task(name=name, function=func)\r\n\r\ndef task(name: str) -> _TaskRegistrator:\r\n    return partial(_register_task, name=name)  # E: see below (L42)\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nFrom my understanding, no `mypy` errors should be pointed out. `pyright` agrees with me (just to test on another typechecker) - all green - but I'm not ready to switch from convenient `mypy` to `pyright` (I personally dislike that project for being non-python in python ecosystem, plus my current project relies heavily on Django plugin).\r\n\r\n**Actual Behavior**\r\n\r\nSeveral errors, all located on lines with `partial(...)` calls.\r\n\r\n```\r\nmain.py:29: error: Argument 1 to \"partial\" has incompatible type \"Callable[[Callable[_P, _T], NamedArg(str, 'name')], Task[_P, _T]]\"; expected \"Callable[..., Task[_P, _T]]\"  [arg-type]\r\nmain.py:32: error: Incompatible return value type (got \"partial[Task[_P, _T]]\", expected \"Callable[[Callable[_P, _T]], Task[_P, _T]]\")  [return-value]\r\nmain.py:32: note: \"partial[Task[_P, _T]].__call__\" has type \"Callable[[VarArg(Any), KwArg(Any)], Task[_P, _T]]\"\r\nmain.py:32: error: Argument 1 to \"partial\" has incompatible type \"Callable[[Callable[_P, _T], NamedArg(str, 'name')], Task[_P, _T]]\"; expected \"Callable[..., Task[_P, _T]]\"  [arg-type]\r\nmain.py:42: error: Argument 1 to \"partial\" has incompatible type \"Callable[[Callable[_P, _T], NamedArg(str, 'name')], Task[_P, _T]]\"; expected \"Callable[..., Task[_P, _T]]\"  [arg-type]\r\nFound 4 errors in 1 file (checked 1 source file)\r\n```\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 1.2.0, then master and all versions since 0.990.\r\n- Mypy command-line flags: none (with and without `--strict` result is the same)\r\n- Mypy configuration options from `mypy.ini` (and other config files): none\r\n- Python version used: 3.10\r\n","author":{"url":"https://github.com/sterliakov","@type":"Person","name":"sterliakov"},"datePublished":"2023-05-10T11:45:57Z","url":"https://github.com/python/mypy/issues/15215"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/issues/:id(.:format)
route-controllerissues
route-actionshow
fetch-noncev2:9559afb0-756a-f812-b1d5-e4df6cbf3572
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9196:102136:105234F:15E0053:6B005DFC
html-safe-nonce3107ed8bc4b5f6a5a7e70f1cf23228e1375e34dc3ba35afacd6e14bebe0af20e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MTk2OjEwMjEzNjoxMDUyMzRGOjE1RTAwNTM6NkIwMDVERkMiLCJ2aXNpdG9yX2lkIjoiNDM0ODQwMjc2ODMzNjE1MDAxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacb62501173c2e0317e4896eb9b8115e90347196dae9c76fdf70bb2ab77c607081
hovercard-subject-tagrepository:7053637
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///issues/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/mypy/issues/15215
twitter:imagehttps://opengraph.githubassets.com/f79ae5636353a0db17350af0a02700f2e9c3bbcf096f9450bf0c369c77cd1022/python/mypy
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f79ae5636353a0db17350af0a02700f2e9c3bbcf096f9450bf0c369c77cd1022/python/mypy
og:image:altOptional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73
turbo-cache-controlno-cache
go-importgithub.com/python/mypy git https://github.com/python/mypy.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id7053637
octolytics-dimension-repository_nwopython/mypy
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7053637
octolytics-dimension-repository_network_root_nwopython/mypy
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseeacd927ba6112e3b01ba99c762bd699a4a4f5df7
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/15215#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F15215
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F15215
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fissues%2Fshow&source=header-repo&source_repo=python%2Fmypy
Reloadhttps://github.com/python/mypy/issues/15215
Reloadhttps://github.com/python/mypy/issues/15215
Reloadhttps://github.com/python/mypy/issues/15215
https://github.com/python/mypy
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/15215
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/15215
#18954https://github.com/python/mypy/pull/18954
Spurious error with partial and ParamSpechttps://github.com/python/mypy/issues/15215#top
#18954https://github.com/python/mypy/pull/18954
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
topic-paramspecPEP 612, ParamSpec, Concatenatehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-paramspec%22
https://github.com/sterliakov
sterliakovhttps://github.com/sterliakov
on May 10, 2023https://github.com/python/mypy/issues/15215#issue-1703741100
in playgroundhttps://mypy-play.net/?mypy=master&python=3.10&flags=strict&gist=414c88ef9fe3f0804d59dc59a43b7009
sterliakovhttps://github.com/sterliakov
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
on May 10, 2023https://github.com/python/mypy/issues/15215#event-9210722482
JelleZijlstrahttps://github.com/JelleZijlstra
topic-paramspecPEP 612, ParamSpec, Concatenatehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-paramspec%22
on May 10, 2023https://github.com/python/mypy/issues/15215#event-9212152498
JukkaLhttps://github.com/JukkaL
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
f902275https://github.com/python/mypy/commit/f90227519d62c4507d7e33db2f018ca6da3a6170
on Jun 5, 2025https://github.com/python/mypy/issues/15215#event-18003054056
JukkaLhttps://github.com/JukkaL
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#18954https://github.com/python/mypy/pull/18954
on Jun 5, 2025https://github.com/python/mypy/issues/15215#event-18003054092
cdce8phttps://github.com/cdce8p
on Jun 5, 2025https://github.com/python/mypy/issues/15215#event-18004432171
Erase stray typevars in functools.partial generic (python#18954)https://github.com/cdce8p/mypy/commit/f90227519d62c4507d7e33db2f018ca6da3a6170
python#18954https://github.com/python/mypy/pull/18954
https://docs.github.com/articles/closing-issues-via-commit-messages
f902275https://github.com/cdce8p/mypy/commit/f90227519d62c4507d7e33db2f018ca6da3a6170
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/15215
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/15215
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
topic-paramspecPEP 612, ParamSpec, Concatenatehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-paramspec%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.