-
Notifications
You must be signed in to change notification settings - Fork 950
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
Feature/add type hints worksheets #1254
Feature/add type hints worksheets #1254
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big change! You've done great work with it ❤
I have added a few comments.
I also wonder: JSONAnyType
is returned by a lot of the functions like update_title
. This seems a bit vague. I am not sure where else it is used, but when we return response
(which we do a lot), perhaps we could change the name to HTTPResponseType
, or the default import requests
response type? In my opinion this would make it more obvious when a method is returning the (raw) HTTP response, rather than a "useful" JSON object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the review that's a good catch. I added the missing types and updated the wrong types.
We could but when you look at the file
so that's the JSON reponse. We can rename it 'JSONResponse', that is more helpful and type it: The responses can vary, when it's a value from a get it should be this: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values#ValueRange I thought may be we want to be exaustif and create a new type with all possible values inside from the API but that means we need to maintain it ! and we don't look at the response very often we simply return it to the user so no point to me but it's open for discussion 😆 |
This sounds like a lot to me, and probably not worth it...! Just having the JSON Any type makes sense, but perhaps with a different name like JSONResponse :) |
agreed we can rename it |
Alright this is a go for merge ! 🥳 |
Add type hints for
Worksheet
object.It's complete, but the majority's of it is done. It could be improved with time and when all files have been typed.
It passez the test suite, it passes mypy (some errors are still showing due to missing type annotations on some files).
Later on some of the types here will be improved when I type
Spreadsheet
object and once merged I will be able to better type the functions inutils.py
etc.