René's URL Explorer Experiment


Title: mypy rejects subclassing Any typed **kwargs entries within a function · Issue #22309 · python/mypy · GitHub

Open Graph Title: mypy rejects subclassing Any typed **kwargs entries within a function · Issue #22309 · python/mypy

X Title: mypy rejects subclassing Any typed **kwargs entries within a function · Issue #22309 · python/mypy

Description: (No AI or LLMs were used in finding or writing up this issue.) This bug is analogous to #21998 but for **kwargs instead of *args . Summary In Python and passing other type checkers (e.g. pyright 1.1.414 commandline and the pyright playgr...

Open Graph Description: (No AI or LLMs were used in finding or writing up this issue.) This bug is analogous to #21998 but for **kwargs instead of *args . Summary In Python and passing other type checkers (e.g. pyright 1....

X Description: (No AI or LLMs were used in finding or writing up this issue.) This bug is analogous to #21998 but for **kwargs instead of *args . Summary In Python and passing other type checkers (e.g. pyright 1....

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypy rejects subclassing Any typed **kwargs entries within a function","articleBody":"**(No AI or LLMs were used in finding or writing up this issue.)**\n\nThis bug is analogous to https://github.com/python/mypy/issues/21998 but for `**kwargs` instead of `*args` .\n\n**Summary**\n\nIn Python and passing other type checkers (e.g. pyright 1.1.414 commandline and the pyright playground ) it is ok to subclass an entry passed within the **kwargs which is typed as Any, but mypy 2.4.0 and recent master seem to reject this, inconsistent with the apparent intention of https://github.com/python/mypy/issues/5865 and https://github.com/python/mypy/pull/14135 .\n\n**To Reproduce**\n\nFor example, consider the following MyPy playground example modified off of https://github.com/python/mypy/blob/93b5e5101575551be20bda9f018498c62c2a30a6/test-data/unit/check-varargs.test#L763 to add an `Any` typed field to the `**kwargs` and try to subclass it: \n https://mypy-play.net/?gist=58c6c0424361c088e769d22bc04383f6&mypy=2.4.0&python=3.12\n```\nfrom typing import Unpack, TypedDict, Any\n\nclass Person(TypedDict):\n    name: str\n    age: int\n    some_any_field: Any\n\ndef foo(arg: bool, **kwargs: Unpack[Person]) -> None:\n    reveal_type(kwargs)\n    reveal_type(kwargs['name'])\n    reveal_type(kwargs['some_any_field'])\n    # mypy says cannot subclass an explicit `Any` type here, inconsistent with https://github.com/python/mypy/issues/5865 and https://github.com/python/mypy/pull/14135\n    # pyright allows it (it is a valid thing to do), see https://pyright-play.net/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoCqKCAhgMYDWANFACqICmAJgCJJkw0CCKcAUHzIAbEgGdRUAAoMQosCgAU9BMzYcAlAC4%2BUXVBQkIDTVFEwQOvSTTHMKGJd1yjAfRK8XwJAyFMTPfj4mBmAoYDAwBRIQNBMAIwihGgAqZIoAd2i0URMiUkoAbWlZeQBddSgAWgA%2BKAA5eWNHKBAGADcGEiEXeBUFDKzRdWbWjq6exn7MmNECgHIDIznykfbO7t6GKcH55wY3Dy8fJmXhvShhMQkAZQBXOO2Z3ch99zhPb19Tk1JxKABiKBtLpIJiwMCme6XP4MAAeCCE7CQ%2BACNAgiDgphIcAkKDADj4o3WEz64TA6iAA\n    class Sub(kwargs['some_any_field']): pass\n\nreveal_type(foo)\n```\n\n\u003cimg width=\"1920\" height=\"1017\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/22a8aba2-a5a8-479c-a99e-54a7191a2cab\" />\n\n**Note that the same is recognized as valid in Pyright, e.g.** https://pyright-play.net/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoCqKCAhgMYDWANFACqICmAJgCJJkw0CCKcAUHzIAbEgGdRUAAoMQosCgAU9BMzYcAlAC4%2BUXVBQkIDTVFEwQOvSTTHMKGJd1yjAfRK8XwJAyFMTPfj4mBmAoYDAwBRIQNBMAIwihGgAqZIoAd2i0URMiUkoAbWlZeQBddSgAWgA%2BKAA5eWNHKBAGADcGEiEXeBUFDKzRdWbWjq6exn7MmNECgHIDIznykfbO7t6GKcH55wY3Dy8fJmXhvShhMQkAZQBXOO2Z3ch99zhPb19Tk1JxKABiKBtLpIJiwMCme6XP4MAAeCCE7CQ%2BACNAgiDgphIcAkKDADj4o3WEz64TA6iAA \n\n\u003cimg width=\"1920\" height=\"1017\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/a980a992-2813-4e1b-b625-ddbc325348ba\" />\n\n**Expected Behavior**\n\nMyPy, like Pyright (see link above), should recognize it is valid for explicitly `Any` typed kwargs entries to be subclassed, like MyPy already recognizes for explicitly `Any` typed parameters that are not `*args`, `**kwargs` or accessed by index.\n\n**Actual Behavior**\n\nMyPy treats explicit `Any` typed function arguments as valid bases if they are not in `**kwargs` (or `*args`) or accessed by index, but treats them as invalid inheritance bases if they are from `**kwargs` (or `*args`) .\n\n**Your Environment**\n\n- Mypy version used: 2.4.0 and recent master\n- Mypy command-line flags: see sandbox/playground link (  https://mypy-play.net/?gist=58c6c0424361c088e769d22bc04383f6&mypy=2.4.0&python=3.12 )\n- Mypy configuration options from `mypy.ini` (and other config files):  https://mypy-play.net/?gist=58c6c0424361c088e769d22bc04383f6&mypy=2.4.0&python=3.12\n- Python version used: 3.12\n","author":{"url":"https://github.com/willy-b","@type":"Person","name":"willy-b"},"datePublished":"2026-10-27T21:58:48Z","url":"https://github.com/python/mypy/issues/22309"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:901adf5b-e507-bd97-d1a3-5212a8e50ed5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8A9C:3F7946:1EF7726:2A1255B:6B00197C
html-safe-nonce099e6a479cfdb3a72f1dd19f90899075509223d23668f86731050565efbd172c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTlDOjNGNzk0NjoxRUY3NzI2OjJBMTI1NUI6NkIwMDE5N0MiLCJ2aXNpdG9yX2lkIjoiOTE2MTgyODM2MTM0Mzg2NzI2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4a492494afc00445d5c7c379a6f9c616061d06a816fda64ec70325ab488caac8
hovercard-subject-tagissue:6068450234
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/22309/issue_layout
twitter:imagehttps://opengraph.githubassets.com/8452464b41804bdbc2861f8970a5c8e67a747085aecd7d7687086d273ea8d246/python/mypy/issues/22309
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8452464b41804bdbc2861f8970a5c8e67a747085aecd7d7687086d273ea8d246/python/mypy/issues/22309
og:image:alt(No AI or LLMs were used in finding or writing up this issue.) This bug is analogous to #21998 but for **kwargs instead of *args . Summary In Python and passing other type checkers (e.g. pyright 1....
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamewilly-b
hostnamegithub.com
expected-hostnamegithub.com
Nonea2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4
turbo-cache-controlno-preview
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
release70121d4e855ee0bb7b75cf15d061d91f8863c0f8
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/22309#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F22309
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%2F22309
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fmypy
Reloadhttps://github.com/python/mypy/issues/22309
Reloadhttps://github.com/python/mypy/issues/22309
Reloadhttps://github.com/python/mypy/issues/22309
pythonhttps://github.com/python
mypyhttps://github.com/python/mypy
Codehttps://github.com/python/mypy
Issues2.7k (2.7k)https://github.com/python/mypy/issues
Pull requests546 (546)https://github.com/python/mypy/pulls
Actionshttps://github.com/python/mypy/actions
Projectshttps://github.com/python/mypy/projects
Wikihttps://github.com/python/mypy/wiki
Security and qualityhttps://github.com/python/mypy/security
Insightshttps://github.com/python/mypy/insights
https://github.com/python/mypy
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/22309
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/22309
mypy rejects subclassing Any typed **kwargs entries within a functionhttps://github.com/python/mypy/issues/22309#top
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/willy-b
willy-bhttps://github.com/willy-b
on Oct 27, 2026https://github.com/python/mypy/issues/22309#issue-6068450234
#21998https://github.com/python/mypy/issues/21998
#5865https://github.com/python/mypy/issues/5865
#14135https://github.com/python/mypy/pull/14135
mypy/test-data/unit/check-varargs.testhttps://github.com/python/mypy/blob/93b5e5101575551be20bda9f018498c62c2a30a6/test-data/unit/check-varargs.test#L763
93b5e51https://github.com/python/mypy/commit/93b5e5101575551be20bda9f018498c62c2a30a6
https://mypy-play.net/?gist=58c6c0424361c088e769d22bc04383f6&mypy=2.4.0&python=3.12https://mypy-play.net/?gist=58c6c0424361c088e769d22bc04383f6&mypy=2.4.0&python=3.12
https://private-user-images.githubusercontent.com/6969859/686819559-22a8aba2-a5a8-479c-a99e-54a7191a2cab.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTUxNjg5MzYsIm5iZiI6MTc5NTE2ODYzNiwicGF0aCI6Ii82OTY5ODU5LzY4NjgxOTU1OS0yMmE4YWJhMi1hNWE4LTQ3OWMtYTk5ZS01NGE3MTkxYTJjYWIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MTEyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjExMjBUMDk1NzE2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTExMzJmYjIwMDRlMmQ5YzQ0Y2E3YjBmMjI2ZmE5NjliZDk5NWVmMmFlYjQ1MjJlYWQxYjBlZjMzMWY5ZDgwNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.YkyKpt2H5DFpG8WJY7qqAFPDYCb_shHuSsZoXAejt_0
https://pyright-play.net/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoCqKCAhgMYDWANFACqICmAJgCJJkw0CCKcAUHzIAbEgGdRUAAoMQosCgAU9BMzYcAlAC4%2BUXVBQkIDTVFEwQOvSTTHMKGJd1yjAfRK8XwJAyFMTPfj4mBmAoYDAwBRIQNBMAIwihGgAqZIoAd2i0URMiUkoAbWlZeQBddSgAWgA%2BKAA5eWNHKBAGADcGEiEXeBUFDKzRdWbWjq6exn7MmNECgHIDIznykfbO7t6GKcH55wY3Dy8fJmXhvShhMQkAZQBXOO2Z3ch99zhPb19Tk1JxKABiKBtLpIJiwMCme6XP4MAAeCCE7CQ%2BACNAgiDgphIcAkKDADj4o3WEz64TA6iAAhttps://pyright-play.net/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoCqKCAhgMYDWANFACqICmAJgCJJkw0CCKcAUHzIAbEgGdRUAAoMQosCgAU9BMzYcAlAC4%2BUXVBQkIDTVFEwQOvSTTHMKGJd1yjAfRK8XwJAyFMTPfj4mBmAoYDAwBRIQNBMAIwihGgAqZIoAd2i0URMiUkoAbWlZeQBddSgAWgA%2BKAA5eWNHKBAGADcGEiEXeBUFDKzRdWbWjq6exn7MmNECgHIDIznykfbO7t6GKcH55wY3Dy8fJmXhvShhMQkAZQBXOO2Z3ch99zhPb19Tk1JxKABiKBtLpIJiwMCme6XP4MAAeCCE7CQ%2BACNAgiDgphIcAkKDADj4o3WEz64TA6iAA
https://private-user-images.githubusercontent.com/6969859/686814464-a980a992-2813-4e1b-b625-ddbc325348ba.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTUxNjg5MzYsIm5iZiI6MTc5NTE2ODYzNiwicGF0aCI6Ii82OTY5ODU5LzY4NjgxNDQ2NC1hOTgwYTk5Mi0yODEzLTRlMWItYjYyNS1kZGJjMzI1MzQ4YmEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MTEyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjExMjBUMDk1NzE2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTE2NTY4NjE0ZmY4MDNkNWMwOGEwNzQwYjg0MTQ3NjRkNmUyN2IzZTNkYTA5MWFlNmM4MWI5OGE4NDJjYTY4NSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.47D24UQ6lZKGrIpOMrXUffoJOqKD4kYqKQ85huyxwq8
https://mypy-play.net/?gist=58c6c0424361c088e769d22bc04383f6&mypy=2.4.0&python=3.12https://mypy-play.net/?gist=58c6c0424361c088e769d22bc04383f6&mypy=2.4.0&python=3.12
https://mypy-play.net/?gist=58c6c0424361c088e769d22bc04383f6&mypy=2.4.0&python=3.12https://mypy-play.net/?gist=58c6c0424361c088e769d22bc04383f6&mypy=2.4.0&python=3.12
willy-bhttps://github.com/willy-b
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
on Oct 27, 2026https://github.com/python/mypy/issues/22309#event-34416833363
benjaminkincseshttps://github.com/benjaminkincses
on Oct 29, 2026https://github.com/python/mypy/issues/22309#event-34543840345
Support string subscripts on deferred base classeshttps://github.com/benjaminkincses/mypy/commit/e0576e0ef05333c9c65f834b7056cfa677e4c896
e0576e0https://github.com/benjaminkincses/mypy/commit/e0576e0ef05333c9c65f834b7056cfa677e4c896
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/22309
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/22309
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%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.