You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this is actually a bug but it may not be one that idiomatic wit files would trigger so it may not be an important issue but I'll post it anyway just in case.
When records are defined in a world along side functions which use the record type, the functions are generated first in the binding's init.py file so that type checking fails due to the undefined type.
For example, this wit file will not produce usable bindings:
My naive fix was to stick from __future__ import annotations at the top of the __init__.py file and that does work. But then I realized that the idiomatic thing to do seems to be to put type definitions in a separate types interface and import from there. Doing that produces valid bindings without having to change componentize_py at all.
The text was updated successfully, but these errors were encountered:
Good catch. Glad you found a workaround, but we should also fix componentize-py so it generates valid bindings for any valid WIT world, and ideally without having to use __future__ if possible. I'll play around with it when I get a chance.
I think this is actually a bug but it may not be one that idiomatic wit files would trigger so it may not be an important issue but I'll post it anyway just in case.
When records are defined in a world along side functions which use the record type, the functions are generated first in the binding's init.py file so that type checking fails due to the undefined type.
For example, this wit file will not produce usable bindings:
My naive fix was to stick
from __future__ import annotations
at the top of the__init__.py
file and that does work. But then I realized that the idiomatic thing to do seems to be to put type definitions in a separate types interface and import from there. Doing that produces valid bindings without having to change componentize_py at all.The text was updated successfully, but these errors were encountered: