-
Notifications
You must be signed in to change notification settings - Fork 951
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
Remove API calls from creationTime
/lastUpdateTime
#1255
Conversation
tests currently broken because of new API request in |
@lavigne958 Before I continue with this I'd like your thoughts on the above, no rush :) |
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.
that's a nice catch, a single API call at init is ok as it is for a good reason.
will be able to remove the property later too nicely.
Moving this to here instead of in a review comment...?
|
Two questions for @lavigne958: should I add a fetch of the Drive metadata to gspread/gspread/spreadsheet.py Lines 239 to 247 in ba16232
should I turn this warning into a deprecation warning? gspread/gspread/spreadsheet.py Lines 62 to 73 in ba16232
|
I would go for: keep it next to it, it's ok to have both method next ot each others. we only call them in the init method.
I would say YES, but I feel like we are removing so much code 🙈 |
I do not understand this. The options are:
I do the first. I will stick with that for now, because to do otherwise would mean refreshing the cassettes again...
This is fair. Perhaps we just leave in a warning |
Agreed, to me it looks good like this. the first option you suggest is fine.
yep that's fine like that, it does not break a thing, people can use the new function, sounds nice for everyone. |
it fills tests with warnings if it is deprecated it is not needed
okay, super Changes are:
|
12k lines of diff, nothing to see here, please keep going 😂 Great job l'été get this merge. So it start adding content for next release. 😁 |
closes #1253
creationTime
andlastUpdateTime
were@property
s. But, the first time they were used they called the APIgspread/gspread/spreadsheet.py
Lines 52 to 60 in d0f1380
This is because they are both Drive metadata, and not Sheets metadata. Thus, the drive metadata was fetched the first time the
@property
s were accessed.This PR changes the behaviour of this. In my opinion, there are several options to fix the problem of "Avoid doing i/o in properties" (issue #1253):
@property
, i.e., change them to methodsI don't particularly like this since the API call is only made one time, the first time. After that, they act as properties
None
if they do not exist, and expect the user to userefresh_lastUpdateTime
orget_lastUpdateTime
This is not very user-friendly, imo.
Exception
if they do not exist, and tell the user to userefresh_lastUpdateTime
orget_lastUpdateTime
Again, not very user friendly
Spreadsheet.__init__
This means they can be
@property
s just like the other ones (id
,title
, etc.). However, it means another API call when opening a spreadsheetI went with option 4 for this PR. Please convince me otherwise if you think another idea is better, or have a different idea.
This solution introduces another API call, but otherwise does not change the public API, as we do not have to deprecate anything*.
If using the properties anyway, it would be 2 as soon as you try to access the properties, or 3 if using both.
*: however, I do suggest deprecating
lastUpdateTime
in favour ofget_lastUpdateTime()
(which calls the API), since this is something that a user probably always wants the latest version oftodo: