René's URL Explorer Experiment


Title: Incorrect types are used to describe google.protobuf enums · Issue #2521 · python/typeshed · GitHub

Open Graph Title: Incorrect types are used to describe google.protobuf enums · Issue #2521 · python/typeshed

X Title: Incorrect types are used to describe google.protobuf enums · Issue #2521 · python/typeshed

Description: Let's take google.protobuf.descriptor_pb2.FieldDescriptorProto as an example. In Python FieldDescriptorProto.TYPE_DOUBLE is instance of int In mypy FieldDescriptorProto.TYPE_DOUBLE is instance of FieldDescriptorProto.Type In Python Field...

Open Graph Description: Let's take google.protobuf.descriptor_pb2.FieldDescriptorProto as an example. In Python FieldDescriptorProto.TYPE_DOUBLE is instance of int In mypy FieldDescriptorProto.TYPE_DOUBLE is instance of F...

X Description: Let's take google.protobuf.descriptor_pb2.FieldDescriptorProto as an example. In Python FieldDescriptorProto.TYPE_DOUBLE is instance of int In mypy FieldDescriptorProto.TYPE_DOUBLE is instance ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect types are used to describe google.protobuf enums","articleBody":"Let's take `google.protobuf.descriptor_pb2.FieldDescriptorProto` as an example.\r\n\r\nIn Python `FieldDescriptorProto.TYPE_DOUBLE` is instance of `int`\r\nIn mypy `FieldDescriptorProto.TYPE_DOUBLE` is instance of `FieldDescriptorProto.Type`\r\n\r\nIn Python `FieldDescriptorProto.Type` is instance of `EnumTypeWrapper`\r\nIn mypy `FieldDescriptorProto.Type` is subclass of `int` with additional methods\r\n\r\nIn Python `FieldDescriptorProto.Type.keys()` is of type `List[str]`\r\nIn mypy `FieldDescriptorProto.Type.keys()` is of type `List[bytes]`\r\n\r\nIn Python `EnumTypeWrapper.items` is an `instancemethod`\r\nIn mypy `EnumTypeWrapper.items` is a `classmethod`\r\n\r\nIn mypy this code works:\r\n```python\r\nfrom google.protobuf.descriptor_pb2 import FieldDescriptorProto\r\nprint(FieldDescriptorProto.TYPE_DOUBLE.values())\r\n```\r\nIn Python it fails:\r\n```python\r\nTraceback (most recent call last):\r\n  File \"sandbox.py\", line 5, in \u003cmodule>\r\n    print(FieldDescriptorProto.TYPE_DOUBLE.values())\r\nAttributeError: 'int' object has no attribute 'values'\r\n```\r\nCurrently this stub looks like this:\r\n```python\r\nclass FieldDescriptorProto(Message):\r\n    class Type(int):\r\n        @classmethod\r\n        def Name(cls, number: int) -> bytes: ...\r\n\r\n        @classmethod\r\n        def Value(cls, name: bytes) -> FieldDescriptorProto.Type: ...\r\n\r\n        @classmethod\r\n        def keys(cls) -> List[bytes]: ...\r\n\r\n        @classmethod\r\n        def values(cls) -> List[FieldDescriptorProto.Type]: ...\r\n\r\n        @classmethod\r\n        def items(cls) -> List[Tuple[bytes, FieldDescriptorProto.Type]]: ...\r\n    TYPE_DOUBLE: Type\r\n    ...\r\n```\r\nI think it is possible to change it into this:\r\n```python\r\nclass FieldDescriptorProto(Message):\r\n    FieldDescriptorProto_Type = typing.NewType('FieldDescriptorProto_Type', int)\r\n    Type: EnumTypeWrapper[FieldDescriptorProto_Type]\r\n    TYPE_DOUBLE: FieldDescriptorProto_Type\r\n    ...\r\n```\r\nwhere `google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper` looks like this:\r\n```python\r\nclass EnumTypeWrapper(Generic[T]):\r\n    def Name(self, number: T) -> str: ...\r\n    def Value(self, name: str) -> T: ...\r\n    def keys(self) -> List[str]: ...\r\n    def values(self) -> List[T]: ...\r\n    def items(self) -> List[Tuple[str, T]]: ...\r\n```\r\nThe only problem I see is how to generate unique type name for enum values, in the example above I'm using concatenation of message name and enum name: `FieldDescriptorProto_Type`.\r\n\r\nIs it ok to create PR with this fix?","author":{"url":"https://github.com/vmagamedov","@type":"Person","name":"vmagamedov"},"datePublished":"2018-10-16T11:09:46Z","url":"https://github.com/python/typeshed/issues/2521"}

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:98db1efb-8a9b-198b-0187-eeaf99c11353
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD27C:59847:CB229B:110ADBA:6B00532B
html-safe-nonce3d4a74ed4ef7ad91730306413169d5a56e2f185806921beb0dc20e56b6ed2c3b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjdDOjU5ODQ3OkNCMjI5QjoxMTBBREJBOjZCMDA1MzJCIiwidmlzaXRvcl9pZCI6IjEzMjkyMjYxNjQzOTYzODA5NzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacba06816fa2dd6c3eb9713a22095e4f908e8cee57b212e2e376cf9aea3f875ef2
hovercard-subject-tagissue:370559239
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/2521/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e383359561cef935067851eb212ee6acc817271b65015b4a3979d149123aef64/python/typeshed/issues/2521
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e383359561cef935067851eb212ee6acc817271b65015b4a3979d149123aef64/python/typeshed/issues/2521
og:image:altLet's take google.protobuf.descriptor_pb2.FieldDescriptorProto as an example. In Python FieldDescriptorProto.TYPE_DOUBLE is instance of int In mypy FieldDescriptorProto.TYPE_DOUBLE is instance of F...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamevmagamedov
hostnamegithub.com
expected-hostnamegithub.com
Nonef420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb
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
release26e00df917aba0f128135dc073ea0c5e33a70d40
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typeshed/issues/2521#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F2521
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%2Ftypeshed%2Fissues%2F2521
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%2Ftypeshed
Reloadhttps://github.com/python/typeshed/issues/2521
Reloadhttps://github.com/python/typeshed/issues/2521
Reloadhttps://github.com/python/typeshed/issues/2521
pythonhttps://github.com/python
typeshedhttps://github.com/python/typeshed
Codehttps://github.com/python/typeshed
Issues196 (196)https://github.com/python/typeshed/issues
Pull requests252 (252)https://github.com/python/typeshed/pulls
Actionshttps://github.com/python/typeshed/actions
Security and qualityhttps://github.com/python/typeshed/security
Insightshttps://github.com/python/typeshed/insights
https://github.com/python/typeshed
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/2521
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/2521
#4785https://github.com/python/typeshed/pull/4785
Incorrect types are used to describe google.protobuf enumshttps://github.com/python/typeshed/issues/2521#top
#4785https://github.com/python/typeshed/pull/4785
stubs: false positiveType checkers report false errorshttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20positive%22
https://github.com/vmagamedov
vmagamedovhttps://github.com/vmagamedov
on Oct 16, 2018https://github.com/python/typeshed/issues/2521#issue-370559239
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Oct 19, 2018https://github.com/python/typeshed/issues/2521#issuecomment-431254898
https://github.com/vmagamedov
vmagamedovhttps://github.com/vmagamedov
on Oct 19, 2018https://github.com/python/typeshed/issues/2521#issuecomment-431311943
https://github.com/vmagamedov
vmagamedovhttps://github.com/vmagamedov
on Oct 27, 2018https://github.com/python/typeshed/issues/2521#issuecomment-433615750
@JelleZijlstrahttps://github.com/JelleZijlstra
vmagamedov@fe85fcdhttps://github.com/vmagamedov/typeshed/commit/fe85fcd051cf8f9974d6ac72d94c9b900ab6dc87
srittauhttps://github.com/srittau
stubs: false positiveType checkers report false errorshttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20positive%22
size-largehttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22size-large%22
on Nov 29, 2018https://github.com/python/typeshed/issues/2521#event-1995159117
https://github.com/nipunn1313
nipunn1313https://github.com/nipunn1313
on Jul 20, 2020https://github.com/python/typeshed/issues/2521#issuecomment-660780718
nipunn1313https://github.com/nipunn1313
on Jul 20, 2020https://github.com/python/typeshed/issues/2521#event-3563914442
Regenerate google.protobuf stubs using mypy-protobufhttps://github.com/nipunn1313/typeshed/commit/44f18a232d407a59b3da2eff4c073691869a34d6
https://docs.github.com/articles/closing-issues-via-commit-messages
44f18a2https://github.com/nipunn1313/typeshed/commit/44f18a232d407a59b3da2eff4c073691869a34d6
JelleZijlstrahttps://github.com/JelleZijlstra
completedhttps://github.com/python/typeshed/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#4785https://github.com/python/typeshed/pull/4785
on Nov 25, 2020https://github.com/python/typeshed/issues/2521#event-4039448085
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typeshed/issues/2521
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typeshed/issues/2521
stubs: false positiveType checkers report false errorshttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20positive%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.