Skip to content

Comments

Make GSheetsHook return an empty list when there are no values#27261

Merged
potiuk merged 4 commits intoapache:mainfrom
alexandermalyga:fix-gsheets-get-values-empty
Oct 26, 2022
Merged

Make GSheetsHook return an empty list when there are no values#27261
potiuk merged 4 commits intoapache:mainfrom
alexandermalyga:fix-gsheets-get-values-empty

Conversation

@alexandermalyga
Copy link
Contributor

GSheetsHook.get_values() now returns an empty list when there are no values in the spreadsheet range.
Previously a KeyError was raised, which is not very ergonomic.

@boring-cyborg boring-cyborg bot added area:providers provider:google Google (including GCP) related issues labels Oct 25, 2022
)

return response["values"]
return response.get('values', [])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why empty list rather than None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used an empty list to respect the function's signature, but None could also be valid if we're willing to change the return type to Optional[list].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it makes more sense to return what the API returns. If the API returns nothing so should we.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants