Skip to content
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

Fix wrapper cast_to_a1_notation #1427

Merged
merged 3 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions gspread/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,17 +527,23 @@ def cast_to_a1_notation(method: Callable[..., Any]) -> Callable[..., Any]:
method calls.
"""

def contains_row_cols(args: Tuple[Any, ...]) -> bool:
return (
isinstance(args[0], int)
and isinstance(args[1], int)
and isinstance(args[2], int)
and isinstance(args[3], int)
)

@wraps(method)
def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
try:
if len(args):
int(args[0])

if len(args) >= 4 and contains_row_cols(args):
# Convert to A1 notation
# Assuming rowcol_to_a1 has appropriate typing
range_start = rowcol_to_a1(*args[:2])
# Assuming rowcol_to_a1 has appropriate typing
range_end = rowcol_to_a1(*args[-2:])
range_end = rowcol_to_a1(*args[2:4])
range_name = ":".join((range_start, range_end))

args = (range_name,) + args[4:]
Expand Down
Loading