Re:Python’s “type hints” are a bit of a disappointment to me
by nine_zeros on Saturday April 23, 2022 @02:37PM
(#31137038)
In a language with a sensible typing system, I would create
class Route:
_route = [] # can be GoogleyRoute or MetaRoute
And import Route everywhere. That import would help in creating instance objects AND be used as a type.But we can't do this with the spaghetti that python type annotations are.
Like that unwieldy nested union already exists in your code, adding the type just documents it and the type checker makes you handle all the cases.
Is there something specific about imports that don’t work with type alises?