I'm trying to add good #Python type annotations to #Lisien
Everything stored in it needs to be serializable in messagepack, so I've annotated all its function signatures with one of the type aliases
Key: TypeAlias = (
str | int | float | None | tuple["Key", ...] | frozenset["Key"]
)
Value: TypeAlias = (
Key
| dict[Key, "Value"]
| tuple["Value", ...]
| list["Value"]
| set["Value"]
| frozenset["Value"]
)
Works ok so far.
But now I'm trying to use NewType to distinguish generic keys from those that name a Lisien entity, such as a node, edge, or graph.
You can't use NewType on type annotations, so I have to make a class for it. I did it like this: