Title: Add a `import type` feature (like typescript) · Issue #928 · python/typing · GitHub
Open Graph Title: Add a `import type` feature (like typescript) · Issue #928 · python/typing
X Title: Add a `import type` feature (like typescript) · Issue #928 · python/typing
Description: Importing types can lead to circular imports, longer start up times and unwanted side effects. I want something like: from foo.bar import type Baz def foo(baz: Baz): print(baz.bat) Such that foo, foo.bar and foo.bar.Baz are not actually ...
Open Graph Description: Importing types can lead to circular imports, longer start up times and unwanted side effects. I want something like: from foo.bar import type Baz def foo(baz: Baz): print(baz.bat) Such that foo, f...
X Description: Importing types can lead to circular imports, longer start up times and unwanted side effects. I want something like: from foo.bar import type Baz def foo(baz: Baz): print(baz.bat) Such that foo, f...
Opengraph URL: https://github.com/python/typing/issues/928
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add a `import type` feature (like typescript)","articleBody":"Importing types can lead to circular imports, longer start up times and unwanted side effects.\r\n\r\nI want something like:\r\n```py\r\nfrom foo.bar import type Baz\r\n\r\ndef foo(baz: Baz):\r\n print(baz.bat)\r\n```\r\nSuch that `foo`, `foo.bar` and `foo.bar.Baz` are not actually loaded at all.\r\nIt could 'import' the symbol as a forward-ref or some type machinery thing. (maybe just the string \"Baz\")\r\n\r\n### Alternatives:\r\n```py\r\nfrom __future__ import annotations\r\n\r\nfrom typing import TYPE_CHECKING\r\nif TYPE_CHECKING:\r\n from foo.bar import Baz\r\n\r\ndef foo(baz: Baz):\r\n print(baz.bat)\r\n```\r\nThis is mega boilerplate, gross, and leads to messy wacky 'type-time' side effects (https://github.com/python/mypy/issues/11503).","author":{"url":"https://github.com/KotlinIsland","@type":"Person","name":"KotlinIsland"},"datePublished":"2021-11-09T06:39:06Z","url":"https://github.com/python/typing/issues/928"}
| 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:dd039513-2a95-40c6-16d1-2fa6e79fa079 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A978:1756E4:19025A1:20FE7D1:6B002BAE |
| html-safe-nonce | c160db8d4a65d35403a0deecd6f38389499d720ea8253053c3f94dbd9643793c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTc4OjE3NTZFNDoxOTAyNUExOjIwRkU3RDE6NkIwMDJCQUUiLCJ2aXNpdG9yX2lkIjoiMzAyOTg0MjQ5OTg4NDU1OTI3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8b898d7793d33093aed8c76da7a37d3da07965dd8de35b5b2ea2f078962bcf6f |
| hovercard-subject-tag | issue:1048243496 |
| 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/928/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8ce8999d3649f2ce114a9152ab825804bc83e2d2abdd738503ccb812e5d44d6a/python/typing/issues/928 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8ce8999d3649f2ce114a9152ab825804bc83e2d2abdd738503ccb812e5d44d6a/python/typing/issues/928 |
| og:image:alt | Importing types can lead to circular imports, longer start up times and unwanted side effects. I want something like: from foo.bar import type Baz def foo(baz: Baz): print(baz.bat) Such that foo, f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | KotlinIsland |
| 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