Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Python's Type Checking Renaissance. Parent comment
You don't actually need this workaround—the problem is typechecker support, not syntax. You can use strings for forward definitions, like this:
JSON = Union[str, int, None, bool, List["JSON"], Dict[str, "JSON"]]
error: Cannot resolve name "JSON" (possible cyclic definition)
Recursive type annotations not supported yet
There are no comments on this comment yet.
You don't actually need this workaround—the problem is typechecker support, not syntax. You can use strings for forward definitions, like this:
What happens next depends on your typechecker. Mypy says this: Pytype says this: But Pyre accepts it and correctly uses it for typechecking.