robin900 / gspread-formatting

Complete cell formatting support for Google spreadsheets via gspread package.

Repository from Github https://github.comrobin900/gspread-formattingRepository from Github https://github.comrobin900/gspread-formatting

AttributeError: 'list' object has no attribute 'to_props'

heskarioth opened this issue · comments

commented

Describe the bug
A clear and concise description of what the bug is.

I am unable to save new rules to my worksheet.

Version and Environment
Version of package: 1.0.5
Jupyter Notebooks - Anaconda
Python 3.8.3

To Reproduce
Steps to reproduce the behavior:

#intiate client
client = gspread.authorize(creds)
worksheet=client.open_by_key(GOOGLE_SHEET_ID)
sheet =worksheet.worksheet('V')
#get all conditional formatting rules
rules = get_conditional_format_rules(sheet)
#save them
rule1 = rules[0]
rule2 = rules[1]
#clear existing ones
rules.clear()
#add new rule
rules.append(rule2)
#save
rules.save()

Expected behavior
A clear and concise description of what you expected to happen.
Expected behaviour is to save the new conditional formatting ( I haven't made any changes to the rule1 object but intend to do so)
Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):
Windows

  • Browser Chrome

Additional context
Add any other context about the problem here.
image

@heskarioth What is the actual behavior? Does save() complete without an exception, and there is no change to the rules in the sheet? Or is an exception raised?

@heskarioth I can only reproduce your error if I .append() or set an item to be an actual list, e.g.

rules.append([])
# or
rules.insert(0, [])

Using the sample code you provided above, I cannot reproduce the error. My guess is that the code you are actually running differs from what is pasted above. Would you double-check your code and let me know?

I've added type checking for the ConditionalFormatRules object, so that only items of type ConditionalFormatRule can be added to it. That is now in release 1.0.6 in PyPI. Closing this issue.