Title: Type of first argument of class methods should not be 'type' · Issue #123 · python/typing · GitHub
Open Graph Title: Type of first argument of class methods should not be 'type' · Issue #123 · python/typing
X Title: Type of first argument of class methods should not be 'type' · Issue #123 · python/typing
Description: This is an extract from the PEP draft: An exception is that the first argument of instance and class methods does not need to be annotated; it is assumed to have the type of the containing class for instance methods, and type for class m...
Open Graph Description: This is an extract from the PEP draft: An exception is that the first argument of instance and class methods does not need to be annotated; it is assumed to have the type of the containing class fo...
X Description: This is an extract from the PEP draft: An exception is that the first argument of instance and class methods does not need to be annotated; it is assumed to have the type of the containing class fo...
Mail addresses
notifications@github.com
Opengraph URL: https://github.com/python/typing/issues/123
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type of first argument of class methods should not be 'type'","articleBody":"This is an extract from the PEP draft:\n\n> An exception is that the first argument of instance and\n> class methods does not need to be annotated; it is assumed to have the\n> type of the containing class for instance methods, and `type` for\n> class methods.\n\nIf the type of first argument of a class method is `type`, it wouldn't be possible to access other class attributes or methods via the argument. Consider this code:\n\n```\nclass A:\n n = 0\n\n @classmethod\n def f(cls) -> None:\n cls.n = 1 # Error?\n```\n\nThis should probably be okay, but `type` does not have attribute `n`, so a type checker would have to reject the code if type of `cls` is `type`. A better type would be something like `Type[A]` mentioned in #107. Note that we don't necessarily need to support `Type[A]` for user code -- this type can be internal to the type checker, similar to callable types with `*args` etc. that can't be represented using the type syntax.\n\n(Mypy currently uses `Any` for the first argument of class methods, but that's an implementation limitation that should be fixed.)\n","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2015-05-21T05:13:35Z","url":"https://github.com/python/typing/issues/123"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fec567a5-c987-3609-fb1c-167608de5093 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 824E:5875E:2A4ECA6:39B7CBA:6B0050B8 |
| html-safe-nonce | e101d528b021c124cfb05ef552fe70c25c182b8fa89a27b094160dc1cf3eabfd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjRFOjU4NzVFOjJBNEVDQTY6MzlCN0NCQTo2QjAwNTBCOCIsInZpc2l0b3JfaWQiOiIzMzE4ODQ1NzgxMTcwOTk5NDgwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 60f871fc27ac1cd612e7d4632d11519e79413cf75fac55f1dae498d510087b9b |
| hovercard-subject-tag | issue:78834803 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typing/123/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2bfc9cbcef2fc58266086e5331ffaf1a13f059f32e22db2f1f0136962abe2b4e/python/typing/issues/123 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2bfc9cbcef2fc58266086e5331ffaf1a13f059f32e22db2f1f0136962abe2b4e/python/typing/issues/123 |
| og:image:alt | This is an extract from the PEP draft: An exception is that the first argument of instance and class methods does not need to be annotated; it is assumed to have the type of the containing class fo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JukkaL |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typing git https://github.com/python/typing.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 24604008 |
| octolytics-dimension-repository_nwo | python/typing |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24604008 |
| octolytics-dimension-repository_network_root_nwo | python/typing |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width