Title: Add typing.Property · Issue #594 · python/typing · GitHub
Open Graph Title: Add typing.Property · Issue #594 · python/typing
X Title: Add typing.Property · Issue #594 · python/typing
Description: Currently there is no type for the values @Property returns. a) the returned value of property has no typing equivalent def create_property() -> ???: some_really_bad_code = True def setter(value): some_really_bad_code = value def getter(...
Open Graph Description: Currently there is no type for the values @Property returns. a) the returned value of property has no typing equivalent def create_property() -> ???: some_really_bad_code = True def setter(value): ...
X Description: Currently there is no type for the values @Property returns. a) the returned value of property has no typing equivalent def create_property() -> ???: some_really_bad_code = True def setter(value...
Opengraph URL: https://github.com/python/typing/issues/594
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add typing.Property","articleBody":"Currently there is no type for the values @property returns.\r\n\r\na) the returned value of `property` has no `typing` equivalent\r\n```py\r\ndef create_property() -> ???:\r\n some_really_bad_code = True\r\n def setter(value):\r\n some_really_bad_code = value\r\n def getter():\r\n return some_really_bad_code\r\n def deller():\r\n some_really_bad_code = None\r\n return property(getter, setter, deller)\r\n```\r\n\r\nb) There is no consistency in how properties in classes work in comparison to normal variables or functions:\r\n```py\r\nclass Example:\r\n foo: str\r\n \r\n def bar(self, value: str) -> str:\r\n return value\r\n # end def\r\n\r\n @property\r\n def batz(self) -> str:\r\n return 'test2'\r\n # end def\r\n\r\n @batz.setter\r\n def batz(self, value: str):\r\n pass\r\n # end def\r\n# end class\r\n\r\n\r\n# variable\r\n\r\n>>> typing.get_type_hints(Example)\r\n{'foo': \u003cclass 'str'>}\r\n\r\n>>> Example.__annotations__\r\n{'foo': \u003cclass 'str'>}\r\n\r\n\r\n# function\r\n\r\n>>> typing.get_type_hints(Example.bar)\r\n{'value': \u003cclass 'str'>, 'return': \u003cclass 'str'>}\r\n\r\n>>> Example.bar.__annotations__\r\n{'value': \u003cclass 'str'>, 'return': \u003cclass 'str'>}\r\n\r\n\r\n# property\r\n# not in the class's hints\r\n>>> 'batz' in typing.get_type_hints(Example)\r\nFalse\r\n\r\n>>> typing.get_type_hints(Example.batz)\r\nTraceback (most recent call last):\r\n File \"\u003cinput>\", line 1, in \u003cmodule>\r\n File \"/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/typing.py\", line 1527, in get_type_hints\r\n 'or function.'.format(obj))\r\nTypeError: \u003cproperty object at 0x10e81b868> is not a module, class, method, or function.\r\n\r\n>>> Example.batz.__annotations__\r\nTraceback (most recent call last):\r\n File \"\u003cinput>\", line 1, in \u003cmodule>\r\nAttributeError: 'property' object has no attribute '__annotations__'\r\n\r\n```\r\n","author":{"url":"https://github.com/luckydonald","@type":"Person","name":"luckydonald"},"datePublished":"2018-11-20T13:37:44Z","url":"https://github.com/python/typing/issues/594"}
| 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:4d45f144-3961-9717-dac3-a4eda3afdaf4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E174:34D604:1993D1B:21CD4EF:6B002B77 |
| html-safe-nonce | 413b7a8ec78c4aeb03be50678d13081939a2d8b49a5cd56811e167e44c943b11 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTc0OjM0RDYwNDoxOTkzRDFCOjIxQ0Q0RUY6NkIwMDJCNzciLCJ2aXNpdG9yX2lkIjoiMjM0MzM3NTE2MjU0NTU0ODE1MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | da0dcae4c4b9a42f467c5448a31db61b773bd91520158dd99381b1ee880a50ba |
| hovercard-subject-tag | issue:382666966 |
| 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/594/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f4a0d554406d7a05485a2bee737309544b2015f02c846235a33d161d2dca4484/python/typing/issues/594 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f4a0d554406d7a05485a2bee737309544b2015f02c846235a33d161d2dca4484/python/typing/issues/594 |
| og:image:alt | Currently there is no type for the values @Property returns. a) the returned value of property has no typing equivalent def create_property() -> ???: some_really_bad_code = True def setter(value): ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | luckydonald |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width