Skip to content

Commit

Permalink
Remove StrEnum dependency and added custom class[issue burnash#1462]
Browse files Browse the repository at this point in the history
  • Loading branch information
muddi900 committed May 15, 2024
1 parent 618fb49 commit d6d2d87
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
18 changes: 17 additions & 1 deletion gspread/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
Union,
)
from urllib.parse import quote as uquote
import enum

from google.auth.credentials import Credentials as Credentials
from google.oauth2.credentials import Credentials as UserCredentials
from google.oauth2.service_account import Credentials as ServiceAccountCredentials
from strenum import StrEnum


from .exceptions import IncorrectCellLabel, InvalidInputValue, NoValidUrlKeyFound

Expand All @@ -47,6 +48,21 @@
URL_KEY_V2_RE = re.compile(r"/spreadsheets/d/([a-zA-Z0-9-_]+)")


class StrEnum(str, enum.Enum):
def __new__(cls, value, *args, **kwargs):
if not isinstance(value, (str, enum.auto)):
raise TypeError(
f"Values of StrEnums must be strings: {value!r} is a {type(value)}"
)
return super().__new__(cls, value, *args, **kwargs)

def __str__(self):
return str(self.value)

def _generate_next_value_(name, *_):
return name


class Dimension(StrEnum):
rows = "ROWS"
cols = "COLUMNS"
Expand Down
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ classifiers = [
"Topic :: Office/Business :: Financial :: Spreadsheet",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"google-auth>=1.12.0",
"google-auth-oauthlib>=0.4.1",
"StrEnum==0.4.15",
]
dependencies = ["google-auth>=1.12.0", "google-auth-oauthlib>=0.4.1"]
requires-python = ">=3.8"
dynamic = ["version", "description"]

Expand Down
1 change: 0 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ vcrpy
pytest
pytest-vcr
urllib3==1.26.15
StrEnum==0.4.15

0 comments on commit d6d2d87

Please sign in to comment.