René's URL Explorer Experiment


Title: Protocols with property descriptors require all compliant symbols to use the same implementation. · Issue #9202 · python/mypy · GitHub

Open Graph Title: Protocols with property descriptors require all compliant symbols to use the same implementation. · Issue #9202 · python/mypy

X Title: Protocols with property descriptors require all compliant symbols to use the same implementation. · Issue #9202 · python/mypy

Description: Are you reporting a bug, or opening a feature request? Bug. Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to simplify your case to a minimal repro. Co...

Open Graph Description: Are you reporting a bug, or opening a feature request? Bug. Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to s...

X Description: Are you reporting a bug, or opening a feature request? Bug. Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to s...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Protocols with property descriptors require all compliant symbols to use the same implementation.","articleBody":"\r\n* Are you reporting a bug, or opening a feature request?\r\n\r\nBug.\r\n\r\n* Please insert below the code you are checking with mypy,\r\n  or a mock-up repro if the source is private. We would appreciate\r\n  if you try to simplify your case to a minimal repro.\r\n\r\nCode snippet attached at end of report.\r\nIt appears to be not possible to define a Protocol describing an object that has an attribute named \"prop1\" with type \"int\".\r\nAny attempt to do so binds the resulting protocol to the implementation chosen in defining the protocol (i.e. must use the same property/descriptor type).\r\n\r\n* What is the actual behavior/output?\r\n\r\n```\r\n % mypy /tmp/test.py\r\n/tmp/test.py:72: error: Incompatible types in assignment (expression has type \"Foo3\", variable has type \"Proto1\")\r\n/tmp/test.py:72: note: Following member(s) of \"Foo3\" have conflicts:\r\n/tmp/test.py:72: note:     prop1: expected \"int\", got \"cached_property[int]\"\r\n/tmp/test.py:73: error: Incompatible types in assignment (expression has type \"Foo4\", variable has type \"Proto1\")\r\n/tmp/test.py:73: note: Following member(s) of \"Foo4\" have conflicts:\r\n/tmp/test.py:73: note:     prop1: expected \"int\", got \"Property[Foo4, int]\"\r\n/tmp/test.py:75: note: Revealed type is 'def (self: test.Foo1) -> builtins.int'\r\n/tmp/test.py:76: note: Revealed type is 'builtins.int'\r\n/tmp/test.py:77: note: Revealed type is 'functools.cached_property[builtins.int*]'\r\n/tmp/test.py:78: note: Revealed type is 'test.Property[test.Foo4*, builtins.int*]'\r\nFound 2 errors in 1 file (checked 1 source file)\r\n```\r\n\r\n* What is the behavior/output you expect?\r\n\r\nNo errors should be reported.\r\n\r\n* What are the versions of mypy and Python you are using?\r\n\r\nmypy == 0.770 ,  Python=3.8.4.\r\n\r\n* What are the mypy flags you are using? (For example --strict-optional)\r\n\r\nNone.\r\n\r\n```\r\nimport functools\r\nfrom typing import Callable, cast, Generic, overload, Protocol, Type, TypeVar, Optional, TYPE_CHECKING, Union\r\n\r\nT = TypeVar('T')\r\nV = TypeVar('V')\r\n\r\n\r\n# Arbitrary descriptor implementation.\r\nclass Property(Generic[T, V]):\r\n    def __init__(self, fn: Callable[[T], V]):\r\n        self.fn = fn\r\n\r\n    @overload\r\n    def __get__(self, obj: T, owner: Type[T]) -> V: ...\r\n\r\n    @overload\r\n    def __get__(self, obj: None, owner: Type[T]) -> Property[T, V]: ...    \r\n     \r\n         \r\n    def __get__(self, obj: Optional[T], owner: Type[T]) -> Union[Property[T, V], V]:\r\n        if obj is None:\r\n            return self\r\n        return self.fn(obj)\r\n\r\n\r\n\r\n# Protocols that define pretty much the same thing.\r\nclass Proto1(Protocol):\r\n    @property\r\n    def prop1(self) -> int:\r\n        ...\r\n\r\nclass Proto2(Protocol):\r\n    prop1: int\r\n\r\nclass Proto3(Protocol):\r\n    @functools.cached_property\r\n    def prop1(self) -> int:\r\n        ...\r\n\r\nclass Proto4(Protocol):\r\n    @Property\r\n    def prop1(self) -> int:\r\n        ...        \r\n\r\n# Implementation of each protocol above\r\nclass Foo1:\r\n    @property\r\n    def prop1(self) -> int:\r\n        return 1\r\n\r\nclass Foo2:\r\n    def __init__(self, x: int):\r\n        self.prop1 = x\r\n    \r\nclass Foo3:\r\n    @functools.cached_property\r\n    def prop1(self) -> int:\r\n        return 3\r\n\r\nclass Foo4:\r\n    @Property\r\n    def prop1(self) -> int:\r\n        return 4    \r\n\r\n\r\n# All 4 statements below have RHS values that conform to the behavior\r\n# defined by 'Proto1': objects that have a 'prop1' attribute that is an 'int',\r\n# and that is not settable.\r\n# No errors should be reported.\r\n# It does not appear possible to define a common protocol that all 4 classes\r\n# conform to, even though in code they all have valid common behavior:\r\n# \"intVal: int = x.prop1\"\r\n\r\nx : Proto1 = Foo1()\r\ny : Proto1 = Foo2(2)\r\nz : Proto1 = Foo3()\r\na : Proto1 = Foo4()\r\n\r\nif TYPE_CHECKING:\r\n    reveal_type(Foo1.prop1)\r\n    reveal_type(Foo2.prop1)\r\n    reveal_type(Foo3.prop1)\r\n    reveal_type(Foo4.prop1)    \r\n\r\n```\r\n","author":{"url":"https://github.com/mostrows2","@type":"Person","name":"mostrows2"},"datePublished":"2020-07-24T22:07:52Z","url":"https://github.com/python/mypy/issues/9202"}

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:c5cbc2b4-5979-fb89-c9dd-bc62986dc32e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA750:1334EF:C91681:106C73A:6AFFF669
html-safe-nonce1295a6c57fee690a7753fcc3591c4e85705330f4470b54d5b4e8b0955176147a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzUwOjEzMzRFRjpDOTE2ODE6MTA2QzczQTo2QUZGRjY2OSIsInZpc2l0b3JfaWQiOiI0MzIzMzgyNDQ0OTQzMjEwMDkwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac90961e44011ebc8cad5496fd6bd4f8d8e2f3aa6fa6566fe9479ad9f057e434b4
hovercard-subject-tagissue:665442981
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/9202/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b8dc898f949d4c7547da3a5ab3f8328f81aabdfcd75dfc795b9667b6d54da7aa/python/mypy/issues/9202
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b8dc898f949d4c7547da3a5ab3f8328f81aabdfcd75dfc795b9667b6d54da7aa/python/mypy/issues/9202
og:image:altAre you reporting a bug, or opening a feature request? Bug. Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to s...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemostrows2
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/9202#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F9202
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%2F9202
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/9202
Reloadhttps://github.com/python/mypy/issues/9202
Reloadhttps://github.com/python/mypy/issues/9202
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/9202
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/9202
#18943https://github.com/python/mypy/pull/18943
Protocols with property descriptors require all compliant symbols to use the same implementation.https://github.com/python/mypy/issues/9202#top
#18943https://github.com/python/mypy/pull/18943
topic-descriptorsProperties, class vs. instance attributeshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-descriptors%22
https://github.com/mostrows2
mostrows2https://github.com/mostrows2
on Jul 24, 2020https://github.com/python/mypy/issues/9202#issue-665442981
https://github.com/mostrows2
mostrows2https://github.com/mostrows2
on Jul 24, 2020https://github.com/python/mypy/issues/9202#issuecomment-663753807
#7153https://github.com/python/mypy/issues/7153
JelleZijlstrahttps://github.com/JelleZijlstra
topic-descriptorsProperties, class vs. instance attributeshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-descriptors%22
on Mar 19, 2022https://github.com/python/mypy/issues/9202#event-6270152262
https://github.com/nejcskofic
nejcskofichttps://github.com/nejcskofic
on Feb 23, 2023https://github.com/python/mypy/issues/9202#issuecomment-1441515274
#6002https://github.com/python/mypy/issues/6002
ilevkivskyihttps://github.com/ilevkivskyi
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#18943https://github.com/python/mypy/pull/18943
on May 30, 2025https://github.com/python/mypy/issues/9202#event-17892000147
ilevkivskyihttps://github.com/ilevkivskyi
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
3957025https://github.com/python/mypy/commit/39570250e35151e387e6e1daf08b4f4e4262726e
on May 30, 2025https://github.com/python/mypy/issues/9202#event-17892000212
pullhttps://github.com/apps/pull
on May 30, 2025https://github.com/python/mypy/issues/9202#event-17892394491
Use checkmember.py to check protocol subtyping (python#18943)https://github.com/Dareh123/mypy/commit/39570250e35151e387e6e1daf08b4f4e4262726e
python#18943https://github.com/python/mypy/pull/18943
3957025https://github.com/Dareh123/mypy/commit/39570250e35151e387e6e1daf08b4f4e4262726e
cdce8phttps://github.com/cdce8p
on May 31, 2025https://github.com/python/mypy/issues/9202#event-17902197749
Use checkmember.py to check protocol subtyping (python#18943)https://github.com/cdce8p/mypy/commit/2b175b2cd6fa183fbd0c8320fbb4f96866857ebe
python#18943https://github.com/python/mypy/pull/18943
2b175b2https://github.com/cdce8p/mypy/commit/2b175b2cd6fa183fbd0c8320fbb4f96866857ebe
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/9202
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/9202
topic-descriptorsProperties, class vs. instance attributeshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-descriptors%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.