Title: Subscripted generic classes should not have independent class variables · Issue #392 · python/typing · GitHub
Open Graph Title: Subscripted generic classes should not have independent class variables · Issue #392 · python/typing
X Title: Subscripted generic classes should not have independent class variables · Issue #392 · python/typing
Description: Currently we have class A(Generic[T]): x = None A[int].x = 1 A[str].x = 'a' print(A[int].x) # prints 1 print(A[int]().x) # prints None, since type is erased on instantiation @JukkaL argues and I agree with him, that this looks wrong. Con...
Open Graph Description: Currently we have class A(Generic[T]): x = None A[int].x = 1 A[str].x = 'a' print(A[int].x) # prints 1 print(A[int]().x) # prints None, since type is erased on instantiation @JukkaL argues and I ag...
X Description: Currently we have class A(Generic[T]): x = None A[int].x = 1 A[str].x = 'a' print(A[int].x) # prints 1 print(A[int]().x) # prints None, since type is erased on instantiation @JukkaL argues ...
Opengraph URL: https://github.com/python/typing/issues/392
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Subscripted generic classes should not have independent class variables","articleBody":"Currently we have\r\n```python\r\nclass A(Generic[T]):\r\n x = None\r\n\r\nA[int].x = 1\r\nA[str].x = 'a'\r\n\r\nprint(A[int].x) # prints 1\r\nprint(A[int]().x) # prints None, since type is erased on instantiation\r\n```\r\n\r\n@JukkaL argues and I agree with him, that this looks wrong. Conceptually, there should be only one runtime class. I think we can implement this without loosing the current runtime generic information by tweaking descriptor ``__dict__`` of ``GenericMeta``, so that all assignments and look-ups on subscripted class objects like ``A[int]`` will be transferred to the original class object ``A``.\r\n\r\n@gvanrossum What do you think?","author":{"url":"https://github.com/ilevkivskyi","@type":"Person","name":"ilevkivskyi"},"datePublished":"2017-02-22T14:05:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/392/typing/issues/392"}
| 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:103adbc1-e3c2-8448-573c-af79ac55698b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 89A4:AFA59:53F718:72783C:6A4DCB7B |
| html-safe-nonce | fe703f892d03441f04d247cd12968665ff9058dea0f0f4f777d6f11fd8433191 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OUE0OkFGQTU5OjUzRjcxODo3Mjc4M0M6NkE0RENCN0IiLCJ2aXNpdG9yX2lkIjoiNTg3MTMxMTI4ODU5MjYxNjMxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 211860c8900a7470cda501f7764f0f98fdf8abe13b0cb4d6adb0a5d6c5ad2e9e |
| hovercard-subject-tag | issue:209463410 |
| 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/392/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e8b2c355e581654de60624147b98c15beb06ec7e953252b6074693c13c624173/python/typing/issues/392 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e8b2c355e581654de60624147b98c15beb06ec7e953252b6074693c13c624173/python/typing/issues/392 |
| og:image:alt | Currently we have class A(Generic[T]): x = None A[int].x = 1 A[str].x = 'a' print(A[int].x) # prints 1 print(A[int]().x) # prints None, since type is erased on instantiation @JukkaL argues and I ag... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ilevkivskyi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| 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 | 1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width