Skip to content

Commit

Permalink
Update to gspread 6.0.x, remove deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dgilman committed Feb 10, 2024
1 parent 2f53d97 commit 1684eba
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
needs: lint
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
name: Python ${{ matrix.python-version }} test run
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

An [asyncio wrapper](https://docs.python.org/3/library/asyncio.html) for [burnash's excellent Google Spreadsheet API library](https://github.com/burnash/gspread). `gspread_asyncio` isn't just a plain asyncio wrapper around the `gspread` API, it implements several useful and helpful features on top of those APIs. It's useful for long-running processes and one-off scripts.

Requires Python >= 3.7.
Requires Python >= 3.8.

[![Documentation Status](https://readthedocs.org/projects/gspread-asyncio/badge/?version=latest)](https://gspread-asyncio.readthedocs.io/en/latest/?badge=latest) ![CI status](https://github.com/dgilman/gspread_asyncio/actions/workflows/ci.yml/badge.svg)

Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sphinx==7.2.*
m2r2==0.3.3.post2
sphinxcontrib-trio==1.1.2
gspread==5.10.*
gspread==6.0.*
4 changes: 3 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ google-auth==2.27.0
# gspread
google-auth-oauthlib==1.2.0
# via gspread
gspread==5.10.0
gspread==6.0.1
# via -r docs/requirements.in
idna==3.6
# via requests
Expand Down Expand Up @@ -78,5 +78,7 @@ sphinxcontrib-serializinghtml==1.1.10
# via sphinx
sphinxcontrib-trio==1.1.2
# via -r docs/requirements.in
strenum==0.4.15
# via gspread
urllib3==2.2.0
# via requests
101 changes: 5 additions & 96 deletions gspread_asyncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import functools
import logging
from typing import TYPE_CHECKING, Callable, Dict, Iterable, List, Optional, Tuple, Union
import warnings

import gspread
from gspread.utils import a1_to_rowcol, extract_id_from_url
Expand Down Expand Up @@ -880,24 +879,6 @@ async def reorder_worksheets(
self.ss.reorder_worksheets, (aws.ws for aws in worksheets_in_desired_order)
)

@property
async def sheet1(self) -> "AsyncioGspreadWorksheet":
""":returns: Shortcut property for getting the first worksheet.
:rtype: :class:`AsyncioGspreadWorksheet`
.. warning::
This is an asynchronous property! It must be awaited.
.. deprecated:: 1.6
use `AsyncioGspreadSpreadsheet.get_sheet1()` instead
"""
warnings.warn(
"get_title will be removed in a future version of gspread_asyncio, use .get_sheet1()",
DeprecationWarning,
)
return await self.get_sheet1()

async def get_sheet1(self) -> "AsyncioGspreadWorksheet":
""":returns: Shortcut for getting the first worksheet.
:rtype: :class:`AsyncioGspreadWorksheet`
Expand All @@ -920,19 +901,6 @@ def title(self) -> str:
"""
return self.ss.title

async def get_title(self) -> str:
""":returns: Title of the spreadsheet.
:rtype: str
.. deprecated:: 1.6
Use the `.title` property instead.
"""
warnings.warn(
"get_title will be removed in gspread_asyncio 2.x, use the .title property",
DeprecationWarning,
)
return await self.agcm._call(getattr, self.ss, "title")

@_nowait
async def update_locale(self, locale: str):
"""Update the locale of the spreadsheet.
Expand Down Expand Up @@ -1768,24 +1736,6 @@ async def delete_protected_range(self, id: str) -> dict:
"""
return await self.agcm._call(self.ws.delete_protected_range, id)

@_nowait
async def delete_row(self, index: int):
"""Deletes the row from the worksheet at the specified index. Wraps
:meth:`gspread.Worksheet.delete_row`.
:param int index: Index of a row for deletion.
:param bool nowait: (optional) If true, return a scheduled future instead of
waiting for the API call to complete.
.. deprecated:: 1.6
Use `AsyncioGspreadWorksheet.delete_rows()` instead.
"""
warnings.warn(
"delete_row will be removed in a future version of gspread, use .delete_rows()",
DeprecationWarning,
)
return await self.agcm._call(self.ws.delete_rows, index)

@_nowait
async def delete_rows(self, index: int, end_index: Optional[int] = None):
"""Deletes multiple rows from the worksheet starting at the specified
Expand All @@ -1802,47 +1752,6 @@ async def delete_rows(self, index: int, end_index: Optional[int] = None):
"""
return await self.agcm._call(self.ws.delete_rows, index, end_index=end_index)

async def duplicate(
self,
insert_sheet_index: int = None,
new_sheet_id: int = None,
new_sheet_name: str = None,
) -> "AsyncioGspreadWorksheet":
"""Duplicate the sheet.
:param int insert_sheet_index: (optional) The zero-based index
where the new sheet should be inserted. The index of all sheets
after this are incremented.
:param int new_sheet_id: (optional) The ID of the new sheet.
If not set, an ID is chosen. If set, the ID must not conflict with
any existing sheet ID. If set, it must be non-negative.
:param str new_sheet_name: (optional) The name of the new sheet.
If empty, a new name is chosen for you.
:returns: a newly created :class:`AsyncioGspreadWorksheet`.
.. warning::
This breaks caching assumptions in AsyncioGspreadSpreadsheet.
Its use is not recommended and it will be removed in a future version.
.. versionadded:: 1.6
.. deprecated:: 1.9
Use `AsyncioGspreadSpreadsheet.duplicate_sheet` instead.
"""
warnings.warn(
"duplicate() will be removed in a future version of gspread_asyncio, use duplicate_sheet()",
DeprecationWarning,
)
dup_ws = await self.agcm._call(
self.ws.duplicate,
insert_sheet_index=insert_sheet_index,
new_sheet_id=new_sheet_id,
new_sheet_name=new_sheet_name,
)
return AsyncioGspreadWorksheet(self.agcm, dup_ws)

async def find(
self,
query: "Union[str, re.Pattern]",
Expand Down Expand Up @@ -2196,9 +2105,9 @@ def id(self) -> int:
return self.ws.id

@property
def index(self) -> str:
def index(self) -> int:
""":returns: Worksheet index.
:rtype: str
:rtype: int
.. versionadded:: 1.6
"""
Expand Down Expand Up @@ -2610,8 +2519,8 @@ async def unmerge_cells(self, name: str):
@_nowait
async def update(
self,
range_name: str,
values: List[List],
range_name: Optional[str] = None,
raw=True,
major_dimension: str = None,
value_input_option: gspread.utils.ValueInputOption = None,
Expand All @@ -2622,9 +2531,9 @@ async def update(
"""Sets values in a cell range of the sheet. Wraps
:meth:`gspread.Worksheet.update`.
:param list values: The data to be written.
:param str range_name: The A1 notation of the values
to update.
:param list values: The data to be written.
:param bool raw: The values will not be parsed by Sheets API and will
be stored as-is. For example, formulas will be rendered as plain
strings. Defaults to ``True``. This is a shortcut for
Expand All @@ -2650,8 +2559,8 @@ async def update(
"""
return await self.agcm._call(
self.ws.update,
range_name,
values,
range_name=range_name,
raw=raw,
major_dimension=major_dimension,
value_input_option=value_input_option,
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests==2.*
gspread==5.10.*
gspread==6.0.*
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ google-auth==2.27.0
# gspread
google-auth-oauthlib==1.2.0
# via gspread
gspread==5.10.0
gspread==6.0.1
# via -r requirements.in
idna==3.6
# via requests
Expand All @@ -36,5 +36,7 @@ requests-oauthlib==1.3.1
# via google-auth-oauthlib
rsa==4.9
# via google-auth
strenum==0.4.15
# via gspread
urllib3==2.2.0
# via requests
4 changes: 3 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ google-auth==2.27.0
# gspread
google-auth-oauthlib==1.2.0
# via gspread
gspread==5.10.0
gspread==6.0.1
# via
# -r docs/requirements.in
# -r requirements.in
Expand Down Expand Up @@ -117,6 +117,8 @@ sphinxcontrib-serializinghtml==1.1.10
# via sphinx
sphinxcontrib-trio==1.1.2
# via -r docs/requirements.in
strenum==0.4.15
# via gspread
urllib3==2.2.0
# via requests
wheel==0.42.0
Expand Down
4 changes: 3 additions & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ google-auth==2.27.0
# gspread
google-auth-oauthlib==1.2.0
# via gspread
gspread==5.10.0
gspread==6.0.1
# via -r requirements.in
httplib2==0.22.0
# via oauth2client
Expand Down Expand Up @@ -49,5 +49,7 @@ rsa==4.9
# oauth2client
six==1.16.0
# via oauth2client
strenum==0.4.15
# via gspread
urllib3==2.2.0
# via requests
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def read(filename):
"Source": "https://github.com/dgilman/gspread_asyncio",
"Tracker": "https://github.com/dgilman/gspread_asyncio/issues",
},
python_requires=">=3.7",
python_requires=">=3.8",
packages=setuptools.find_packages(),
install_requires=install_reqs,
)

0 comments on commit 1684eba

Please sign in to comment.