René's URL Explorer Experiment


Title: False Positives in Protocol Assignability Check Where `Self` Is a Parameter of a Decorated Method (1.17.0) · Issue #19482 · python/mypy · GitHub

Open Graph Title: False Positives in Protocol Assignability Check Where `Self` Is a Parameter of a Decorated Method (1.17.0) · Issue #19482 · python/mypy

X Title: False Positives in Protocol Assignability Check Where `Self` Is a Parameter of a Decorated Method (1.17.0) · Issue #19482 · python/mypy

Description: Bug Report This bug appears to be a regression in mypy 1.17.0, version 1.16.1 works as expected. To Reproduce Consider the following code snippet: from typing import Protocol, Self class Proto(Protocol): def foo(self, x: Self) -> None: ....

Open Graph Description: Bug Report This bug appears to be a regression in mypy 1.17.0, version 1.16.1 works as expected. To Reproduce Consider the following code snippet: from typing import Protocol, Self class Proto(Prot...

X Description: Bug Report This bug appears to be a regression in mypy 1.17.0, version 1.16.1 works as expected. To Reproduce Consider the following code snippet: from typing import Protocol, Self class Proto(Prot...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False Positives in Protocol Assignability Check Where `Self` Is a Parameter of a Decorated Method (1.17.0)","articleBody":"**Bug Report**\n\nThis bug appears to be a regression in `mypy` 1.17.0, version 1.16.1 works as expected.\n\n**To Reproduce**\n\nConsider the following code snippet:\n\n```python\nfrom typing import Protocol, Self\n\n\nclass Proto(Protocol):\n    def foo(self, x: Self) -> None: ...\n\n\nclass Impl:\n    def foo(self, x: Self) -> None:\n        pass\n\n\nx: Proto = Impl()\n```\n\nThis is fine on both mypy 1.17.0 and 1.16.1. When we decorate `foo` in `Proto`  (e.g., with `@abstractmethod`, `@deprecated`, or `@classmethod`), then the assignability check fails in `mypy` 1.17.0 only. Here are some snippets revealing the bug (the links use the `master` branch version because 1.17.0 is not available on mypy-play.net yet):\n\n- Using `@abstractmethod`: https://mypy-play.net/?mypy=master&python=3.13&gist=6ca38235427121b221eb1f2971c4205b\n- Using `@deprecated`: https://mypy-play.net/?mypy=master&python=3.13&gist=59bcf4be17a8924e7b1ba8df158daad6\n- Using `@classmethod`: https://mypy-play.net/?mypy=master&python=3.13&gist=18ab582214b1c2a87b9e99606f7fd15e\n- Using `@classmethod`, but with `Sequence[Self]`: https://mypy-play.net/?mypy=master&python=3.13&gist=9c335818a610c248a6546c090b0ac617\n\nI played around with some other variants:\n\n- The bug only shows if `Self` is used as the type of an argument. Using `Self` as a return type only is fine in 1.17.0.\n- When `Impl` declares compatibility with `Proto` explicitly (i.e., `class Impl(Proto)`), the bug does not show.\n- Whether `foo` in `Impl` is decorated or not does not appear to matter (only tested with `@deprecated`).\n- Whether `foo` in `Impl` has `x: Self` or `x: Impl` does not matter\n\n**Expected Behavior**\n\nThere should not be an error for all playground links above, as with `mypy` 1.16.1 or `pyright`.\n\n**Actual Behavior**\n\n`mypy` 1.17.0 shows errors like these (here for the example with `@abstractmethod`):\n\n    main.py:18: error: Incompatible types in assignment (expression has type \"Impl\", variable has type \"Proto\")  [assignment]\n    main.py:18: note: Following member(s) of \"Impl\" have conflicts:\n    main.py:18: note:     Expected:\n    main.py:18: note:         def [Self: Proto] foo(self, x: Proto) -> None\n    main.py:18: note:     Got:\n    main.py:18: note:         def foo(self, x: Impl) -> None\n    Found 1 error in 1 file (checked 1 source file)\n\n`mypy` 1.16.1 and `pyright` do not print any diagnostics.\n\n**Your Environment**\n\n- Mypy version used: 1.17.0 (bug) / 1.16.1 (expected behavior)\n- Mypy command-line flags: none\n- Mypy configuration options from `mypy.ini` (and other config files): none\n- Python version used: 3.13.5","author":{"url":"https://github.com/nhusung","@type":"Person","name":"nhusung"},"datePublished":"2025-07-20T10:23:54Z","url":"https://github.com/python/mypy/issues/19482"}

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:8560f2a2-06e7-6180-1316-b9655aa23822
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB552:392E27:DBBFBF:11EDC59:6AFFFA1D
html-safe-noncea89a1f9f4fbce6a34eb0218516ec57ad6e5bf5ef0b3152f2eb252de4974a44c4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTUyOjM5MkUyNzpEQkJGQkY6MTFFREM1OTo2QUZGRkExRCIsInZpc2l0b3JfaWQiOiIzNzYyMDU0NDM4Njc2NTkzMTgxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf78980e39a510e52fc468e72408655e1b0258c81cd7c972b74647767eb648488
hovercard-subject-tagissue:3246239853
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/19482/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f5c90d92d22a1a373f1e2cb748f998e90b65185c576afa40bd0758bf3ac95053/python/mypy/issues/19482
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f5c90d92d22a1a373f1e2cb748f998e90b65185c576afa40bd0758bf3ac95053/python/mypy/issues/19482
og:image:altBug Report This bug appears to be a regression in mypy 1.17.0, version 1.16.1 works as expected. To Reproduce Consider the following code snippet: from typing import Protocol, Self class Proto(Prot...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamenhusung
hostnamegithub.com
expected-hostnamegithub.com
None0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729
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
release16a11879678aaf97e2a42c33ee70830aa084fa37
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/19482#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F19482
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%2F19482
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/19482
Reloadhttps://github.com/python/mypy/issues/19482
Reloadhttps://github.com/python/mypy/issues/19482
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 requests547 (547)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/19482
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/19482
#19484https://github.com/python/mypy/pull/19484
False Positives in Protocol Assignability Check Where Self Is a Parameter of a Decorated Method (1.17.0)https://github.com/python/mypy/issues/19482#top
#19484https://github.com/python/mypy/pull/19484
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
topic-protocolshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-protocols%22
topic-self-typesTypes for selfhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-self-types%22
https://github.com/nhusung
nhusunghttps://github.com/nhusung
on Jul 20, 2025https://github.com/python/mypy/issues/19482#issue-3246239853
https://mypy-play.net/?mypy=master&python=3.13&gist=6ca38235427121b221eb1f2971c4205bhttps://mypy-play.net/?mypy=master&python=3.13&gist=6ca38235427121b221eb1f2971c4205b
https://mypy-play.net/?mypy=master&python=3.13&gist=59bcf4be17a8924e7b1ba8df158daad6https://mypy-play.net/?mypy=master&python=3.13&gist=59bcf4be17a8924e7b1ba8df158daad6
https://mypy-play.net/?mypy=master&python=3.13&gist=18ab582214b1c2a87b9e99606f7fd15ehttps://mypy-play.net/?mypy=master&python=3.13&gist=18ab582214b1c2a87b9e99606f7fd15e
https://mypy-play.net/?mypy=master&python=3.13&gist=9c335818a610c248a6546c090b0ac617https://mypy-play.net/?mypy=master&python=3.13&gist=9c335818a610c248a6546c090b0ac617
nhusunghttps://github.com/nhusung
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
on Jul 20, 2025https://github.com/python/mypy/issues/19482#event-18715870503
nhusunghttps://github.com/nhusung
on Jul 20, 2025https://github.com/python/mypy/issues/19482#event-18716038779
Pin mypy to 1.16.1https://github.com/OxiDD/oxidd/commit/a3c63422c811eeb5ec78aadf4d3e9543c1a56784
a3c6342https://github.com/OxiDD/oxidd/commit/a3c63422c811eeb5ec78aadf4d3e9543c1a56784
Pin mypy to 1.16.1https://github.com/OxiDD/oxidd/commit/064bc5295bcd35b6b89ace7dbca2964f2f799a3a
064bc52https://github.com/OxiDD/oxidd/commit/064bc5295bcd35b6b89ace7dbca2964f2f799a3a
brianschuberthttps://github.com/brianschubert
topic-protocolshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-protocols%22
on Jul 20, 2025https://github.com/python/mypy/issues/19482#event-18716336720
https://github.com/brianschubert
brianschuberthttps://github.com/brianschubert
on Jul 20, 2025https://github.com/python/mypy/issues/19482#issuecomment-3094493639
#18943https://github.com/python/mypy/pull/18943
@ilevkivskyihttps://github.com/ilevkivskyi
sterliakovhttps://github.com/sterliakov
topic-self-typesTypes for selfhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-self-types%22
on Jul 20, 2025https://github.com/python/mypy/issues/19482#event-18716477696
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Jul 20, 2025https://github.com/python/mypy/issues/19482#issuecomment-3094525121
ilevkivskyihttps://github.com/ilevkivskyi
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#19484https://github.com/python/mypy/pull/19484
on Jul 21, 2025https://github.com/python/mypy/issues/19482#event-18734735056
pullhttps://github.com/apps/pull
on Jul 21, 2025https://github.com/python/mypy/issues/19482#event-18735690614
Fix decorated methods with self-types in protocols (python#19484)https://github.com/Mu-L/mypy/commit/d5287070fc60c9a30b305372bd12ce3c1985bf28
python#19484https://github.com/python/mypy/pull/19484
d528707https://github.com/Mu-L/mypy/commit/d5287070fc60c9a30b305372bd12ce3c1985bf28
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/19482
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/19482
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
topic-protocolshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-protocols%22
topic-self-typesTypes for selfhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-self-types%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.