|
|
|
|
|
by lawrencejgd
932 days ago
|
|
In Python you can use this: from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import mymodule
def myfunc(arg: mymodule.MyType) -> bool:
return bool(arg)
This will make type annotations to be converted internally to strings. TYPE_CHECKING is a constant that's always false except when you use a type checker, so mymodule will never be imported on runtime, but the type checker will think that it was imported. |
|