FIX: updating Worksheet properties after calling methods that can change them #548
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Digging into issue #545 I found out, that there were multiple problems caused by this.
Essentially, when any method that modifies the properties of a sheet online is called, the Worksheet instance properties didn't get updated accordingly.
For example, when you called
gspread.models.Worksheet.add_cols(x)
twice in a row, it only added this number of columns to the initial number of columns (ie. the number of columns from when the Worksheet() class was instantiated)I tried fixing this by adding a decorator, which causes the function to read the actual metadata from the API and update the instance properties accordingly - testing this, it seems to fix all the issues.