-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix some type defs #5
Conversation
Add a type guard to make parsing values / containers from the maps easier. It still feels a little verbose but better than having to do:
now you can just do:
|
The enum values work at runtime but fail against a linter (pylance) for me. Looking into it: https://docs.python.org/3/howto/enum.html enums are supposed to map to unique static values. This is the error I see in my project:
I think instead of these, it'd be better to use something like TypedDict, we could then do something like:
If we wanted to still enable the factory method, we could do something like:
|
After looking into this, I think the root of the issue was the stub using pyo3 just generates these as classes so we should just define them as such in the stubs. That fixed the errors for me! The one thing that is a little weird about this to me now is Ideally we'd return the same thing here. For now at least you get typed dicts back when you invoke |
Thanks for your contribution! These are issues I overlooked. Regarding You're right about keeping the types consistent between |
Yea, this would be great -- |
From working with the swift code, it would be nice to export Ideally we could just |
Yes |
I should have done this as a couple commits but the changes are pretty minimal:
ruff
as a dev requirement to format the file