René's URL Explorer Experiment


Title: polymorphic overloads on `list.__add__` and `dict.__or__` lead to divergences in type checkers. · Issue #14283 · python/typeshed · GitHub

Open Graph Title: polymorphic overloads on `list.__add__` and `dict.__or__` lead to divergences in type checkers. · Issue #14283 · python/typeshed

X Title: polymorphic overloads on `list.__add__` and `dict.__or__` lead to divergences in type checkers. · Issue #14283 · python/typeshed

Description: The overloads on list.__add__ lead to divergent behavior between mypy and pyright when doing something as simple as a list concatenation # Overloading looks unnecessary, but is needed to work around complex mypy problems @overload def __...

Open Graph Description: The overloads on list.__add__ lead to divergent behavior between mypy and pyright when doing something as simple as a list concatenation # Overloading looks unnecessary, but is needed to work aroun...

X Description: The overloads on list.__add__ lead to divergent behavior between mypy and pyright when doing something as simple as a list concatenation # Overloading looks unnecessary, but is needed to work aroun...

Opengraph URL: https://github.com/python/typeshed/issues/14283

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"polymorphic overloads on `list.__add__` and `dict.__or__` lead to divergences in type checkers.","articleBody":"The overloads on `list.__add__` lead to divergent behavior between `mypy` and `pyright` when doing something as simple as a list concatenation\n\n```python\n    # Overloading looks unnecessary, but is needed to work around complex mypy problems\n    @overload\n    def __add__(self, value: list[_T], /) -\u003e list[_T]: ...\n    @overload\n    def __add__(self, value: list[_S], /) -\u003e list[_S | _T]: ...\n```\n\nCode sample in [pyright playground](https://pyright-play.net/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoCCKcANFGAG4CmIANmAIYAmAUCwMa0MDO3UAMkm4wCAbQAqAXQBcUKAGIoVCAFcuMKnwBGKpLRio%2BtITBZy5AAUo16zM%2BaZVgUAPovmTNwApuVWsDIwGAALGlkAIkFhMSlwsgB6AEooAFoAPihIkxjJcNkQKhgVEBQBbK9E%2B0trOkZWcyhHZzcPN1EAZUkfPwDyELDMqJEO3ITk9MHsiSgAHyhOvKgCopKy6IqqqE2OLl41mAAhCRk5RQB3JBCwFXwa2yZuTabXdyZPFxHu-0D%2BkAiho4LMapDJZYRHcSzea5fKFYqlAEbTYNFGotHojEKKAQRBwTENOYIOAgJBoYL4fGUlEsArUBi0FzwBBULxQYzCUTCEBdZIAajZJk5MG5FSgyXMinZMCF3IxcylMskmMAoOQ0qh0hlMlkCjlcnlQfkK1AwfXi0466VcqHGpVyeWCq1zG0NVW0qj0xmIbUKvWiw2CohwU0NSUB4i2tH23XCiNowAy5Gw3R6tayhmJfXz9umY6LxYo04r0XMC3qMa71e7NV7U1MMwas6IbbnzSXhdaUCa7Q3HZgOxHyxrPcya9FFX6G4Hg1iC5Oi92YxiE2rByn9kc6-yAWPknm14XI3vS%2BiB5Wh9qtxu902dy2TOu206%2B12Lw-e525Cfk9XDznM1vJ82053jKUKzlCL4gKB4bmKqQA), https://mypy-play.net/?mypy=latest\u0026python=3.12\u0026gist=abf6a8834020af17a16bd8cfb44b2f10\n\n```python\nfrom typing import Any, overload\n\nclass ListA[T]:  # emulates builtins list\n    @overload\n    def __add__(self, other: \"ListA[T]\", /) -\u003e \"ListA[T]\": return ListA()\n    @overload\n    def __add__[S](self, other: \"ListA[S]\", /) -\u003e \"ListA[T | S]\": return ListA()\n    \n    \nclass ListB[T]:  # without overloads\n    def __add__[S](self, other: \"ListB[S]\", /) -\u003e \"ListB[T | S]\": return ListB()\n\n                                            # mypy              | pyright                             \nreveal_type( list[str]() + list[str]() )    # list[str]         | list[str]          ✅️\nreveal_type( list[str]() + list[int]() )    # list[str | int]   | list[str | int]    ✅️\nreveal_type( list[str]() + list[Any]() )    # list[Any]         | list[str]          ❌️\n\nreveal_type( ListA[str]() + ListA[str]() )  # ListA[str]        | ListA[str]         ✅️\nreveal_type( ListA[str]() + ListA[int]() )  # ListA[str | int]  | ListA[str | int]   ✅️\nreveal_type( ListA[str]() + ListA[Any]() )  # ListA[Any]        | ListA[str]         ❌️\n\nreveal_type( ListB[str]() + ListB[str]() )  # ListB[str]        | ListB[str]         ✅️\nreveal_type( ListB[str]() + ListB[int]() )  # ListB[str | int]  | ListB[str | int]   ✅️\nreveal_type( ListB[str]() + ListB[Any]() )  # ListB[str | Any]  | ListB[str | Any]   ✅️\n\n```\n\nThis ultimately causes some very annoying type errors when checking wrapper functions in `pyright`.\n\n\u003cdetails\u003e\n\nCode sample in [pyright playground](https://pyright-play.net/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoCyAhgsugDRQCCKcAUHQMRTACuKAxjEmClAO5IYACygAmKGATdeRADZQiINKwgBTFDADOdACZrgLMGAAUStAC5JAIwBWarpQD0lAFSUpMAIxWtMEFAAvFAAdGEe0mJWqPjBYSEAlFAAtAB8UAByvGpW8QzM-CAkCGoBIkT4wLj8Srpaisr1AG5IRFC6SFx6BkZgAPqFxaVmylZgdg4wlFX9ANY1jVbEpKhoANp%2BIJQ0cAC6SWmZ2RZ0UGdQzMVycFAoavztBkSsctqn5zN98%2Bb1wQDeACJPF4AVYAXd%2BH19MBnq8AQBfKAAH3anRgJk%2B30aCXeZxmIzQblcmIWaC0SQuUABmwBUA4RBQKDA%2BGsakUWi0SDQd10sDAUAQSiI6hgpSpnjEALoQA)\n\n```python\nfrom typing import Mapping, Any\n\n# function with 2 optional arguments\ndef foo(arg: object, /, *, opt1: str = ..., opt2: int = ...) -\u003e None: ...\n\n# wrapper that forwards args via dict\ndef foo_wrapper(arg: object, foo_kwargs: Mapping[str, Any]) -\u003e None:\n    # apply new defaults\n    foo_kwargs = {\"opt1\": \"new_default\"} | dict(foo_kwargs)\n    foo(arg, **foo_kwargs)  # \"str\" cannot be assigned to parameter \"opt2\"\n\n```\n\n\u003c/details\u003e\n\nPR #14282 and #14284 show mypy-primer results of simplifying the overloads away from `list.__add__` and `dict.__or__`.\n\n\n\n\n","author":{"url":"https://github.com/randolf-scholz","@type":"Person","name":"randolf-scholz"},"datePublished":"2025-06-16T11:32:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/14283/typeshed/issues/14283"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f290a508-ea39-9482-0426-d75ed061e546
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD692:8A973:DDDEBF:12EB1C6:6A61A1F3
html-safe-nonce251bd05f481efaa179cb7ee38e2fcbd1049d2960f9ba10e5ef88457c61fce150
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjkyOjhBOTczOkREREVCRjoxMkVCMUM2OjZBNjFBMUYzIiwidmlzaXRvcl9pZCI6Ijg5NjE3MjE0MjgzNzYzOTYyNzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac65b0082e2295033eb89db4273c635b7a8b596527e66ba851a63e62f5d1224f98
hovercard-subject-tagissue:3149651348
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/typeshed/14283/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3ead5be2d520a155567a8713a840a8e87d71e19144af33d214a570311fd3cd76/python/typeshed/issues/14283
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3ead5be2d520a155567a8713a840a8e87d71e19144af33d214a570311fd3cd76/python/typeshed/issues/14283
og:image:altThe overloads on list.__add__ lead to divergent behavior between mypy and pyright when doing something as simple as a list concatenation # Overloading looks unnecessary, but is needed to work aroun...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerandolf-scholz
hostnamegithub.com
expected-hostnamegithub.com
None6f4633bcf01c1ad14b73fd07dd39ac31d61f3d3c2578ee08ec1792b7b351eeb9
turbo-cache-controlno-preview
go-importgithub.com/python/typeshed git https://github.com/python/typeshed.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id31696383
octolytics-dimension-repository_nwopython/typeshed
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id31696383
octolytics-dimension-repository_network_root_nwopython/typeshed
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
releaseac296ae7f21856f1f92adbad22f870b6fbb4b907
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/typeshed/issues/14283#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F14283
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F14283
Sign up https://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%2Ftypeshed
Reloadhttps://github.com/python/typeshed/issues/14283
Reloadhttps://github.com/python/typeshed/issues/14283
Reloadhttps://github.com/python/typeshed/issues/14283
Please reload this pagehttps://github.com/python/typeshed/issues/14283
python https://github.com/python
typeshedhttps://github.com/python/typeshed
Please reload this pagehttps://github.com/python/typeshed/issues/14283
Notifications https://github.com/login?return_to=%2Fpython%2Ftypeshed
Fork 2.1k https://github.com/login?return_to=%2Fpython%2Ftypeshed
Star 5.1k https://github.com/login?return_to=%2Fpython%2Ftypeshed
Code https://github.com/python/typeshed
Issues 219 https://github.com/python/typeshed/issues
Pull requests 146 https://github.com/python/typeshed/pulls
Actions https://github.com/python/typeshed/actions
Security and quality 0 https://github.com/python/typeshed/security
Insights https://github.com/python/typeshed/pulse
Code https://github.com/python/typeshed
Issues https://github.com/python/typeshed/issues
Pull requests https://github.com/python/typeshed/pulls
Actions https://github.com/python/typeshed/actions
Security and quality https://github.com/python/typeshed/security
Insights https://github.com/python/typeshed/pulse
polymorphic overloads on list.__add__ and dict.__or__ lead to divergences in type checkers.https://github.com/python/typeshed/issues/14283#top
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
on Jun 16, 2025https://github.com/python/typeshed/issues/14283#issue-3149651348
pyright playgroundhttps://pyright-play.net/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoCCKcANFGAG4CmIANmAIYAmAUCwMa0MDO3UAMkm4wCAbQAqAXQBcUKAGIoVCAFcuMKnwBGKpLRio%2BtITBZy5AAUo16zM%2BaZVgUAPovmTNwApuVWsDIwGAALGlkAIkFhMSlwsgB6AEooAFoAPihIkxjJcNkQKhgVEBQBbK9E%2B0trOkZWcyhHZzcPN1EAZUkfPwDyELDMqJEO3ITk9MHsiSgAHyhOvKgCopKy6IqqqE2OLl41mAAhCRk5RQB3JBCwFXwa2yZuTabXdyZPFxHu-0D%2BkAiho4LMapDJZYRHcSzea5fKFYqlAEbTYNFGotHojEKKAQRBwTENOYIOAgJBoYL4fGUlEsArUBi0FzwBBULxQYzCUTCEBdZIAajZJk5MG5FSgyXMinZMCF3IxcylMskmMAoOQ0qh0hlMlkCjlcnlQfkK1AwfXi0466VcqHGpVyeWCq1zG0NVW0qj0xmIbUKvWiw2CohwU0NSUB4i2tH23XCiNowAy5Gw3R6tayhmJfXz9umY6LxYo04r0XMC3qMa71e7NV7U1MMwas6IbbnzSXhdaUCa7Q3HZgOxHyxrPcya9FFX6G4Hg1iC5Oi92YxiE2rByn9kc6-yAWPknm14XI3vS%2BiB5Wh9qtxu902dy2TOu206%2B12Lw-e525Cfk9XDznM1vJ82053jKUKzlCL4gKB4bmKqQA
https://mypy-play.net/?mypy=latest&python=3.12&gist=abf6a8834020af17a16bd8cfb44b2f10https://mypy-play.net/?mypy=latest&python=3.12&gist=abf6a8834020af17a16bd8cfb44b2f10
pyright playgroundhttps://pyright-play.net/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoCyAhgsugDRQCCKcAUHQMRTACuKAxjEmClAO5IYACygAmKGATdeRADZQiINKwgBTFDADOdACZrgLMGAAUStAC5JAIwBWarpQD0lAFSUpMAIxWtMEFAAvFAAdGEe0mJWqPjBYSEAlFAAtAB8UAByvGpW8QzM-CAkCGoBIkT4wLj8Srpaisr1AG5IRFC6SFx6BkZgAPqFxaVmylZgdg4wlFX9ANY1jVbEpKhoANp%2BIJQ0cAC6SWmZ2RZ0UGdQzMVycFAoavztBkSsctqn5zN98%2Bb1wQDeACJPF4AVYAXd%2BH19MBnq8AQBfKAAH3anRgJk%2B30aCXeZxmIzQblcmIWaC0SQuUABmwBUA4RBQKDA%2BGsakUWi0SDQd10sDAUAQSiI6hgpSpnjEALoQA
#14282https://github.com/python/typeshed/pull/14282
#14284https://github.com/python/typeshed/pull/14284
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.