hiku
hiku copied to clipboard
super wip mypy plugin implementation
Problem:
Standard mypy capabilities is not sufficient to cover specific hiku's typing requirements.
For example, consider Optional[TypeRef["User"]]
declaration.
Because of the way hiku.types
implemented, mypy thinks that Optional
is generic as well as TypeRef
.
And even if we can declare class Optional[Generic[T], OptionalMeta]): ...
, making TypeRef
gereric is still complicated.
Mypy think that in TypeRef['User']
TypeRef is generic over User
type, but can not find it declared (because User
is a ref for hiku node).
Solution:
We can create a mypy plugin for hiku in which we can implement any typechecking logic.
For example. here is a dummy implementation, that checks that TypeRef
ref is a string (even better will be to check that there is Node for that ref)