Title: Protocol incorrectly matches when positional or keyword parameter matches *args · Issue #21014 · python/mypy · GitHub
Open Graph Title: Protocol incorrectly matches when positional or keyword parameter matches *args · Issue #21014 · python/mypy
X Title: Protocol incorrectly matches when positional or keyword parameter matches *args · Issue #21014 · python/mypy
Description: Bug Report When a protocol defines a function with a keyword or positional parameter (a: int) -> None, a concrete function where said parameter is missing, but matches the *args parameter (*args: int) -> None will be seen as implementing...
Open Graph Description: Bug Report When a protocol defines a function with a keyword or positional parameter (a: int) -> None, a concrete function where said parameter is missing, but matches the *args parameter (*args: i...
X Description: Bug Report When a protocol defines a function with a keyword or positional parameter (a: int) -> None, a concrete function where said parameter is missing, but matches the *args parameter (*args...
Opengraph URL: https://github.com/python/mypy/issues/21014
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Protocol incorrectly matches when positional or keyword parameter matches *args","articleBody":"**Bug Report**\n\nWhen a protocol defines a function with a keyword or positional parameter `(a: int) -> None`, a concrete function where said parameter is missing, but matches the `*args` parameter `(*args: int) -> None` will be seen as implementing the protocol.\n\nI would expect `(a: int) -> None` to also need matching `**kwargs` such as `(*args: int, **kwargs: int) -> None` and for it to only match `*args` alone when specified as a positional only argument (e.g. `(a: int, /) -> None`)\n\nOtherwise it cannot be called safely, `pyright` and `ty` both successfully raise errors for this case.\n\n**To Reproduce**\n\nhttps://mypy-play.net/?mypy=master&python=3.14&flags=strict&gist=a5f86e32e70cbc84c45a53db5426f78f\n\n**Expected Behavior**\n\n```\nmain.py:13: error: Argument 1 to \"f\" has incompatible type \"C\"; expected \"P\" [arg-type]\n```\n\nbecause calling the method as `foo(a=1)` would fail.\n\n**Actual Behavior**\n\nmypy:\n```\nSuccess: no issues found in 1 source file\n```\n\npyright:\n```\nArgument of type \"C\" cannot be assigned to parameter \"o\" of type \"P\" in function \"f\"\n \"C\" is incompatible with protocol \"P\"\n \"foo\" is an incompatible type\n Type \"(*args: int) -> None\" is not assignable to type \"(a: int) -> None\"\n Missing keyword parameter \"a\" (reportArgumentType)\n```\n\nty:\n```\nArgument to function `f` is incorrect: Expected `P`, found `C` (invalid-argument-type) [Ln 17, Col 3]\n```\n\npython:\n```\nTraceback (most recent call last):\n File \"xxx.py\", line 17, in \u003cmodule>\n f(C())\n ~^^^^^\n File \"xxx.py\", line 14, in f\n o.foo(a=1)\n ~~~~~^^^^^\nTypeError: C.foo() got an unexpected keyword argument 'a'\n```\n\n**Your Environment**\n\n- Mypy version used: 1.19.1 and master\n- Mypy command-line flags: `--strict`\n- Mypy configuration options from `mypy.ini` (and other config files):\n- Python version used: `1.14`\n\n","author":{"url":"https://github.com/danielknell","@type":"Person","name":"danielknell"},"datePublished":"2026-03-12T16:51:12Z","url":"https://github.com/python/mypy/issues/21014"}
| 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:8ae6c5e6-9b64-90f2-a9f7-c071fd6a2e23 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C6C:DB416:1363B6A:195018E:6B000655 |
| html-safe-nonce | dc4b5a3a25fa9c8533cab90d1e86e00693adc664589d057bee78fd7ec071d56b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzZDOkRCNDE2OjEzNjNCNkE6MTk1MDE4RTo2QjAwMDY1NSIsInZpc2l0b3JfaWQiOiI0MDc5NDgwMDc0MDY2MjAwMTQ5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 66f08b1da3ab24fcf2918e8462c860362a57e3af8ccc34a9608697ec536738ef |
| hovercard-subject-tag | issue:4065967107 |
| 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/21014/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d0074983b86587dc8de11f2f6ba1d979d8262071d4c7962556c422ada2155872/python/mypy/issues/21014 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d0074983b86587dc8de11f2f6ba1d979d8262071d4c7962556c422ada2155872/python/mypy/issues/21014 |
| og:image:alt | Bug Report When a protocol defines a function with a keyword or positional parameter (a: int) -> None, a concrete function where said parameter is missing, but matches the *args parameter (*args: i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danielknell |
| 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