-
Notifications
You must be signed in to change notification settings - Fork 0
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
Enhance DX & Type Safety with Typed Loading Methods #109
Comments
As you closed it, did you found another solution? |
Oh i think i closed it by accident, but no, at the moment we just assume that the user is not tampering with their serialized YAML files. |
Yes, I think it would be very nice to have correct typing, but it is not a nice solution if the user has to provide the expected class as argument. |
I agree, maybe there is a better solution. I will reopen the issue. |
Currently the loading methods (e.g.
audobject.from_yaml_s
) return an instance ofaudobject.Object
, causing the loss of specific type information for LSPs and tools like mypy.It might be a good idea to add an optional type parameter (e.g.
instance_of
) to improve static analysis and type verification.In addition, this could ensure that the loaded object is actually an instance of the expected type, providing an additional layer of safety and reducing potential runtime errors.
This could default to
instance_of=audobject.Object
such that full backwards compatibility should be provided (assuming no parameter with the same name was passed).Example with the loss of typing information:
Example with added typing information:
The text was updated successfully, but these errors were encountered: