Skip to content

Commit

Permalink
Merge pull request #1427 from burnash/bugfix/fix_cast_to_a1
Browse files Browse the repository at this point in the history
Fix wrapper `cast_to_a1_notation`
  • Loading branch information
lavigne958 authored Mar 2, 2024
2 parents c5fd13e + ab70b48 commit 3c4fd5f
Show file tree
Hide file tree
Showing 3 changed files with 295 additions and 1,309 deletions.
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

0 comments on commit 3c4fd5f

Please sign in to comment.