-
Notifications
You must be signed in to change notification settings - Fork 948
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
gspread 6.0.0 no longer compatible with gspread-formatting #1395
Comments
hi! thanks for this issue! :) I can see that For now, I recommend using the previous version of pip install gspread==5.12.4 Then, we will try and fix this issue. The problem was introduced by commit e212e5c at worksheet.py class Worksheet
- def __init__(self, spreadsheet, properties):
- self.spreadsheet = spreadsheet
- self.client = spreadsheet.client
+ def __init__(self, spreadsheet_id, client, properties):
+ self.spreadsheet_id = spreadsheet_id
+ self.client = client So the It could be possible to reintroduce class Worksheet
+ @property
+ def spreadsheet(self)
+ ... but I am not sure. A question for @lavigne958 and why the change was motivated in the first place. |
Thanks @alifeee! Just to clarify- any way this issue will be resolved right? Either |
Hello everyone, I wanted to let you know that I am also experiencing this issue with I hope this information helps others who might come across the same issue. I am looking forward to a permanent fix. Thank you! |
Hi everyone thank you for raising the issue. I apologize for breaking the use of third-party libraries relying on gspread 😑 I don't use them and they are not part of our test suite (this is something to consider in the long time). I removed the spreadsheet attribute from the worksheet in order to better architecture the project. A worksheet instance only needs to know the ID of its owner spreadsheet and the HTTP Client in order to make its requests. I am not in favor of adding back the spreadsheet attribute in the worksheet, instead I would recommend the other projects to adapt to the new architecture of gspread 6.x.y please. I'll be happy to help too with PRs after we fix/clean gspread. Note: having the spreadsheet attribute was introducing circular decency which triggered me to remove it. Hope you'll understand and hope it makes sense too. |
These are the two options. Personally I am a fan of the former (reintroduce spreadsheet as a computed property of worksheet). However, I know @lavigne958 likely has a good reason that it was removed, and that it cannot be reintroduced(?)
While not in the documentation, the
What was the problem with this? |
That's true I did not take into account the visibility of the attribute which makes it publicly accessible 🤔 I still think that other libraries using gspread should adapt if we change things. If you have access to a worksheet object, it means you have access to it's parent spreadsheet object as this is the only way to obtain a worksheet. For now I suggest we add back the spreadsheet attribute in order to prevent breaking changes and mark it as deprecated for the next major release. We take special care to only keep the attribute and prevent any use of it. This should allow everyone to keep working and give everyone a heads up on the coming changes. Would this be suitable?
This is strongly discouraged in software design as it prevents you from changing things easily when you need to and it added extra complications for the typing too. |
The `Worksheet` object was missing the `spreadsheet` attribute. Add it back to be backward compatible. closes #1395 Signed-off-by: Alexandre Lavigne <lavigne958@gmail.com>
@lavigne958 thanks for adding back, just as a note- in my experience changes should be backwards compatible or at least be on deprecation notice for a long time, especially when it's a public attribute that other packages are using. Just to make sure- so you will mark as deprecated and if other packages will not adapt I should expect again to have issues in the future? Because in that case I will still prefer sadly to fixate my gspread version and to ignore next versions |
you're welcome ! I agree this is our fault to remove it without notice. 😞 So far I wish to remove that attribute yes. We need to discuss it with @alifeee in order to decide the faith of this attribute. if we remove it, then we'll add some deprecation warning for it long before it is removed. We are open to help everyone benefit from gspread, we can make changes if they are useful to others too and if they help you without breaking or requiring changing gspread too much out of scope. In that regard, I have a question: You need the attribute |
Thanks for the response! From your question I see there is a bit of confusion, I am not myself using the |
I have not used or created code for The problem is: a user wants the conditional formatting rules for a worksheet. So, It would be unreasonable for So, |
I followed the link and checked the example method. I found that the method Now the method that pulls sheet metadata is located in our new So first thing first, make it work and backward compatible with gspread-6.0.1 then use the new features. Though we need to check if the whole project can be adjusted not juste that specific function |
I like the enthusiasm! But, if the typing is fine with the circular import, what is the problem with just leaving the Why do we want to remove I think it seems like a useful pattern. |
The problem is the circular import. I checked the gspread formating package and the only reason it uses the spreadsheet attribute is to call HTTP methods. That was the only option back then, it's not anymore today. So the package can be updated.
To have a better software architecture that removes some issues and work from us, no more circular dependency, that simplifies typing, allows to change, edit, upgrade any part without being blocked by other components, easier to introduce new features etc. |
Describe the bug
gspread 6.0.0 no longer compatible with gspread-formatting. Specifically,
get_conditional_format_rules(worksheet)
raises anAttributeError: 'Worksheet' object has no attribute 'spreadsheet'. Did you mean: 'spreadsheet_id'?
. I checked and this is because indeed, theWorksheet
object no longer has the attributespreadsheet
, but onlyspreadsheet_id
(as one might see when printingworksheet.__dict__
).To Reproduce
Steps to reproduce the behavior:
Expected behavior
I would have expected worksheet to have the attribute
spreadsheet
and that will sort out the incompatibility with gspread-formatting.Code example*
Environment info:
The text was updated successfully, but these errors were encountered: