Title: repr(subclass of typing.Any) shows typing.Any not <__main__.subclass of typing.Any> · Issue #95987 · python/cpython · GitHub
Open Graph Title: repr(subclass of typing.Any) shows typing.Any not <__main__.subclass of typing.Any> · Issue #95987 · python/cpython
X Title: repr(subclass of typing.Any) shows typing.Any not <__main__.subclass of typing.Any> · Issue #95987 · python/cpython
Description: Bug report from typing import Any class Foo(Any): ... print(repr(Foo)) # => typing.Any not
Open Graph Description: Bug report from typing import Any class Foo(Any): ... print(repr(Foo)) # => typing.Any not
X Description: Bug report from typing import Any class Foo(Any): ... print(repr(Foo)) # => typing.Any not <class '__main__.Foo'> as I would expect I believe cpython/Lib/typing.py Lines 495 to 496...
Opengraph URL: https://github.com/python/cpython/issues/95987
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"repr(subclass of typing.Any) shows typing.Any not \u003c__main__.subclass of typing.Any\u003e","articleBody":"# Bug report\r\n\r\n```py\r\nfrom typing import Any\r\n\r\nclass Foo(Any): ...\r\n\r\nprint(repr(Foo)) # =\u003e typing.Any not \u003cclass '__main__.Foo'\u003e as I would expect\r\n```\r\nI believe https://github.com/python/cpython/blob/e8259e047c42976427b08f100b9d8ba52db7ee69/Lib/typing.py#L495-L496 needs to be changed to\r\n```py\r\n def __repr__(self):\r\n if self is Any:\r\n return \"typing.Any\"\r\n return super().__repr__()\r\n```\r\n\r\n# Your environment\r\n\r\n- CPython versions tested on: 3.11 and 3.12\r\n- Operating system and architecture: macOS","author":{"url":"https://github.com/Gobot1234","@type":"Person","name":"Gobot1234"},"datePublished":"2022-08-14T22:36:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/95987/cpython/issues/95987"}
| 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:9b0ec196-038a-7704-330e-7138112ae20c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8DA2:9124A:24D5909:2FFF6D0:696B5543 |
| html-safe-nonce | ac5fbeebc27297dfc7e5745552290c8860aea787d2302db9333bf3f408ca772f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4REEyOjkxMjRBOjI0RDU5MDk6MkZGRjZEMDo2OTZCNTU0MyIsInZpc2l0b3JfaWQiOiI2NDQ0NjY0MTAzNzYxNTY0OTk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ade359915414d046aaa9d09206861e27c4d5b006278cdc2efac7aa75dba475bb |
| hovercard-subject-tag | issue:1338367140 |
| 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/cpython/95987/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ac97a1b1c19105b7a5913914c76d8b298441f21c8535a9413d3df56aba7915e9/python/cpython/issues/95987 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ac97a1b1c19105b7a5913914c76d8b298441f21c8535a9413d3df56aba7915e9/python/cpython/issues/95987 |
| og:image:alt | Bug report from typing import Any class Foo(Any): ... print(repr(Foo)) # => typing.Any not |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Gobot1234 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width