-
Notifications
You must be signed in to change notification settings - Fork 268
Open
Labels
topic: featureDiscussions about new features for Python's type annotationsDiscussions about new features for Python's type annotations
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 loaded at all.
It could 'import' the symbol as a forward-ref or some type machinery thing. (maybe just the string "Baz")
Alternatives:
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from foo.bar import Baz
def foo(baz: Baz):
print(baz.bat)
This is mega boilerplate, gross, and leads to messy wacky 'type-time' side effects (python/mypy#11503).
DetachHead, tuchandra, vrslev, TheAfroOfDoom, relsunkaev and 32 more
Metadata
Metadata
Assignees
Labels
topic: featureDiscussions about new features for Python's type annotationsDiscussions about new features for Python's type annotations