From 266642c1029cfe46053e72546faa9c08a3e39c93 Mon Sep 17 00:00:00 2001 From: Alberto Karakoutev Date: Thu, 11 Dec 2025 17:02:37 +0200 Subject: [PATCH 1/2] Specify list results in SDK methods --- CHANGELOG.md | 4 ++++ smartsheet/favorites.py | 6 +++--- smartsheet/groups.py | 6 +++--- smartsheet/sheets.py | 14 +++++++------- smartsheet/users.py | 6 +++--- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e5b703..76ce9de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [x.x.x] - Unreleased +### Fixed + +- Update correct method types, which may return either list or a singleton object + ## [3.7.0] - 2025-12-11 ### Added diff --git a/smartsheet/favorites.py b/smartsheet/favorites.py index 234bf63..918c4d4 100644 --- a/smartsheet/favorites.py +++ b/smartsheet/favorites.py @@ -17,7 +17,7 @@ from __future__ import absolute_import -from typing import Union +from typing import Union, List import logging @@ -34,7 +34,7 @@ def __init__(self, smartsheet_obj): self._base = smartsheet_obj self._log = logging.getLogger(__name__) - def add_favorites(self, favorite_obj) -> Union[Result[Favorite], Error]: + def add_favorites(self, favorite_obj) -> Union[Result[Union[Favorite, List[Favorite]]], Error]: """Add one or more items to the user's list of Favorite items. Adds one or more items to the user's list of Favorite @@ -50,7 +50,7 @@ def add_favorites(self, favorite_obj) -> Union[Result[Favorite], Error]: more Favorite objects Returns: - Union[Result[Favorite], Error]: The result of the operation, or an Error object if the request fails. + Union[Result[Union[Favorite, List[Favorite]]], Error]: The result of the operation - either a list or a single object, or an Error object if the request fails. """ _op = fresh_operation("add_favorites") _op["method"] = "POST" diff --git a/smartsheet/groups.py b/smartsheet/groups.py index e6636c2..e3b96bd 100644 --- a/smartsheet/groups.py +++ b/smartsheet/groups.py @@ -17,7 +17,7 @@ from __future__ import absolute_import -from typing import Union +from typing import Union, List import logging @@ -34,7 +34,7 @@ def __init__(self, smartsheet_obj): self._base = smartsheet_obj self._log = logging.getLogger(__name__) - def add_members(self, group_id, group_member_obj) -> Union[Result[GroupMember], Error]: + def add_members(self, group_id, group_member_obj) -> Union[Result[Union[GroupMember, List[GroupMember]]], Error]: """Add one or more members to a Group. Args: @@ -43,7 +43,7 @@ def add_members(self, group_id, group_member_obj) -> Union[Result[GroupMember], object(s). Returns: - Union[Result[GroupMember], Error]: The result of the operation, or an Error object if the request fails. + Union[Result[Union[GroupMember, List[GroupMember]]], Error]: The result of the operation - either a list or a single object, or an Error object if the request fails. """ _op = fresh_operation("add_members") _op["method"] = "POST" diff --git a/smartsheet/sheets.py b/smartsheet/sheets.py index 717508e..aa473db 100644 --- a/smartsheet/sheets.py +++ b/smartsheet/sheets.py @@ -20,7 +20,7 @@ import logging import os.path from datetime import datetime -from typing import Union +from typing import Union, List import six @@ -40,7 +40,7 @@ def __init__(self, smartsheet_obj): self._base = smartsheet_obj self._log = logging.getLogger(__name__) - def add_columns(self, sheet_id, list_of_columns) -> Union[Result[Column], Error]: + def add_columns(self, sheet_id, list_of_columns) -> Union[Result[Union[Column, List[Column]]], Error]: """Insert one or more Columns into the specified Sheet Args: @@ -49,7 +49,7 @@ def add_columns(self, sheet_id, list_of_columns) -> Union[Result[Column], Error] Column objects Returns: - Union[Result[Column], Error]: The result of the operation, or an Error object if the request fails. + Union[Result[Union[Column, List[Column]]], Error]: The result of the operation - either a list or a single object, or an Error object if the request fails. """ if isinstance(list_of_columns, (dict, Column)): @@ -69,7 +69,7 @@ def add_columns(self, sheet_id, list_of_columns) -> Union[Result[Column], Error] return response - def add_rows(self, sheet_id, list_of_rows) -> Union[Result[Row], Error]: + def add_rows(self, sheet_id, list_of_rows) -> Union[Result[Union[Row, List[Row]]], Error]: """Insert one or more Rows into the specified Sheet. If multiple rows are specified in the request, all rows @@ -109,7 +109,7 @@ def add_rows(self, sheet_id, list_of_rows) -> Union[Result[Row], Error]: hyperlink (optional) Returns: - Union[Result[Row], Error]: The result of the operation, or an Error object if the request fails. + Union[Result[Union[Row, List[Row]]], Error]: The result of the operation - either a list or a single object, or an Error object if the request fails. """ if isinstance(list_of_rows, (dict, Row)): arg_value = list_of_rows @@ -281,7 +281,7 @@ def delete_column(self, sheet_id, column_id) -> Union[Result[None], Error]: return response - def delete_rows(self, sheet_id, ids, ignore_rows_not_found=False) -> Union[Result[NumberObjectValue], Error]: + def delete_rows(self, sheet_id, ids, ignore_rows_not_found=False) -> Union[Result[List[NumberObjectValue]], Error]: """Deletes one or more Row(s) from the specified Sheeet. Args: @@ -296,7 +296,7 @@ def delete_rows(self, sheet_id, ids, ignore_rows_not_found=False) -> Union[Resul will be altered). Returns: - Union[Result[NumberObjectValue], Error]: The result of the operation, or an Error object if the request fails. + Union[Result[List[NumberObjectValue]], Error]: The result of the operation - a list of deleted object IDs, or an Error object if the request fails. """ _op = fresh_operation("delete_rows") _op["method"] = "DELETE" diff --git a/smartsheet/users.py b/smartsheet/users.py index 9f91681..3761f2d 100644 --- a/smartsheet/users.py +++ b/smartsheet/users.py @@ -17,7 +17,7 @@ from __future__ import absolute_import -from typing import Union +from typing import Union, List import logging from datetime import datetime @@ -36,7 +36,7 @@ def __init__(self, smartsheet_obj): self._base = smartsheet_obj self._log = logging.getLogger(__name__) - def add_alternate_email(self, user_id, list_of_alternate_emails) -> Union[Result[AlternateEmail], Error]: + def add_alternate_email(self, user_id, list_of_alternate_emails) -> Union[Result[Union[AlternateEmail, List[AlternateEmail]]], Error]: """Add one or more alternate email addresses for the specified User Args: @@ -45,7 +45,7 @@ def add_alternate_email(self, user_id, list_of_alternate_emails) -> Union[Result An array of one or more AlternateEmail objects. Returns: - Union[Result[AlternateEmail], Error]: The result of the operation, or an Error object if the request fails. + Union[Result[List[AlternateEmail]], Error]: The result of the operation - either a list or a single object, or an Error object if the request fails. """ _op = fresh_operation("add_alternate_email") _op["method"] = "POST" From b9a5dac7b63c3db142d6f12883027fefb483944f Mon Sep 17 00:00:00 2001 From: Alberto Karakoutev Date: Thu, 11 Dec 2025 17:07:01 +0200 Subject: [PATCH 2/2] Formatting updates --- smartsheet/favorites.py | 3 ++- smartsheet/groups.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/smartsheet/favorites.py b/smartsheet/favorites.py index 918c4d4..1002f32 100644 --- a/smartsheet/favorites.py +++ b/smartsheet/favorites.py @@ -50,7 +50,8 @@ def add_favorites(self, favorite_obj) -> Union[Result[Union[Favorite, List[Favor more Favorite objects Returns: - Union[Result[Union[Favorite, List[Favorite]]], Error]: The result of the operation - either a list or a single object, or an Error object if the request fails. + Union[Result[Union[Favorite, List[Favorite]]], Error]: The result of the operation - either a list or a + single object, or an Error object if the request fails. """ _op = fresh_operation("add_favorites") _op["method"] = "POST" diff --git a/smartsheet/groups.py b/smartsheet/groups.py index e3b96bd..186f7e5 100644 --- a/smartsheet/groups.py +++ b/smartsheet/groups.py @@ -43,7 +43,8 @@ def add_members(self, group_id, group_member_obj) -> Union[Result[Union[GroupMem object(s). Returns: - Union[Result[Union[GroupMember, List[GroupMember]]], Error]: The result of the operation - either a list or a single object, or an Error object if the request fails. + Union[Result[Union[GroupMember, List[GroupMember]]], Error]: The result of the operation - either a list or + a single object, or an Error object if the request fails. """ _op = fresh_operation("add_members") _op["method"] = "POST"