-
Notifications
You must be signed in to change notification settings - Fork 177
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
Type Hints for Supabase-py #50
Comments
Hey @J0 can I work on this ? |
@SwarajBaral Sure 😄 |
Thank you @dreinon ,I will give it a go. Just a question before I begin. Should I add type hinting to a single file and create a PR first ? Just to check if I am going on the right path or not ? |
@dreinon beat me to it and yes, go for it! If you'd like, you can add hints to a single file and then request a review before moving on to the rest of the files. |
Thank you for the reply @J0. I am on it. |
I can help with this as well; @SwarajBaral wanna split work? 😄 |
This is just a recommendation, but Pydantic supports autogenerating Python models from OpenAPI specs: https://pydantic-docs.helpmanual.io/datamodel_code_generator/ Might help with this. |
On second thought, I think I'm misinterpreting this issue :) The pydantic code generation is useful if you want to add type hints for the user's tables in Supabase, not to add typehints to the Supabase codebase itself. |
Right @aantn. Nevertheless, it's a good point what you are saying, since it would help in the job of keeping updated the code if there is any change in the database. For instance, we could have the models generated from the OpenAPI of the db and use them when we do an insert, first instancing the Pydantic model to validate the format is okay, and then passing to the Do we have OpenAPI specs ready from postgrest? Maybe we can open a discussion for this 😊 |
@dreinon exactly. Yes, there are already OpenAPI specs from Postgrest. You can use them to generate types for the typescript bindings in a similar manner: https://supabase.io/docs/reference/javascript/generating-types |
Ping @SwarajBaral. How are you doing with this issue? Maybe you can split the work with @anand2312 or even let him go forth with the issue in case you didn't have time to do much. Thanks! 😊 |
@dreinon I can write a blog post for that if you like and publish it on my personal blog. |
@leynier @anand2312 feel free to take this issue and split the work if you want since we got no response from @SwarajBaral yet. |
Many modules and functions in this code base look to already be using type hints (typed). Here are the functions I see that are not typed or are missing some type hints (so far):
... |
I've been manually looking at files for missing type hints. Trying to use
This is using
|
@joeriddles Thanks for compiling this list! Helps a lot 😄 |
It would be nice if we could get type hints on the library so that we can allow users to sanity check their code.
Thank you @dreinon for proposing this!
The text was updated successfully, but these errors were encountered: