New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"static type has not been initialized" when type lives in another module #5210
Comments
static types are initializable in Rust side code. So python code doesn't provide that much information. Technically it means One of the possible reason can be separated but not initialized python modules. If you created modules named A and B, referencing A::SomeType in B, running code including B but didn't run |
Do you have any advice to make this less confusing? |
FWIW I ran into this same problem trying to add I think the only real way to improve this discovery process is documentation. Either an example which covers this use case (with useful comments), or some documentation on all the magical |
Summary
Let's say we have two separate native modules,
things_types
which defines aThing
class, andthings
which has aget_all() -> List[Thing]
function. Then I write the following code.Expected
I would expect this to work just fine, for
Thing
instances to be returned fromthings.get_all()
and for the pymethoddo_stuff
to be called on each instance.Actual
An error occurs when calling
things.get_all()
, which isstatic type is not initialized
.Workaround
A workaround here is to import
things_types
as well, but I don't think that's very ergonomic.Context
I'm creating a set of native modules to be provided to a rustpython interpreter as a sandbox for users. Asking users to import everything, even if they don't need it, is a little awkward. If there was a way I could, in my pymodule itself, intialize the static type easily, I would be happy to do that; I just couldn't find a way in the docs or examples or my journey through the source code (admittedly, my journey through the source code was to figure out the
static type is not initialized
meaning.)The text was updated successfully, but these errors were encountered: