hiku icon indicating copy to clipboard operation
hiku copied to clipboard

super wip mypy plugin implementation

Open kindermax opened this issue 1 year ago • 0 comments

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)

image

kindermax avatar Aug 11 '22 14:08 kindermax