Repository: burnash/gspread (language: python)

Issue:
Remove StrEnum dependency
gspread dependencies are:

https://github.com/burnash/gspread/blob/c740b88e072962ffe772ec3bd90907a579524692/pyproject.toml#L30-L34

StrEnum [amounts to](https://github.com/irgeek/StrEnum/blob/ab34b770aacac80431cd77f28770a60144679d38/strenum/__init__.py#L21-L49)

```python
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
```

We ought not need to rely on a dependency, and can think of a way of including this code in the project, so that the dependencies are just google auth libraries.

@lavigne958 thoughts?


Discussion / hints:
Hi that's true, it's simple enough to be vendored (meaning we copy/paste the current code in our repository)

the pros & cons:

pros:
- less dependencies
- users don't need to rely on this dependency too

cons:
- in case of any changes in python we need to fix it ourselves
- if some improvements are added we need to add them ourselves.

I have no strong preference :roll_eyes: 

do we have a major/manior reason to do this move ? is this blocking some users or something ? 
I think this is something that will not change very often. We basically just use it to polyfill old Python versions, and do not use any advanced features of StrEnum

gspread is usable before without installing StrEnum and I think this is nicer.
`StrEnum` is part of 3.11+.

Wouldn't this need to be conditional then?
Context:

https://github.com/burnash/gspread/pull/1250#issuecomment-1623815446

https://github.com/burnash/gspread/pull/1340

I think there are many "solutions" to this issue, and they all depend on what "problem" we are trying to solve.

Personally, I think the dependency is not needed, especially as we have so few dependencies to begin with (apart from the required Google Auth, we have none (or, only StrEnum, which I argue is unneeded))
Yeah I just checked the `StrEnum` implementation in cpyton, it's not more efficient to begin with.

I can add it, if y'all would like.
> I can add it, if y'all would like.

That would be grand 😊

I think there are many ways to add this. One would be to provide this StrEnum class/subclass in the `utils.py` file. Of course, the tests would be nice to port over too.

Would you like any guidance? I trust you can make a good change :)


Fix patch:
diff --git a/gspread/utils.py b/gspread/utils.py
index 799f61123..11e848371 100644
--- a/gspread/utils.py
+++ b/gspread/utils.py
@@ -6,6 +6,7 @@
 
 """
 
+import enum
 import re
 from collections import defaultdict
 from collections.abc import Sequence
@@ -30,7 +31,6 @@
 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
 
@@ -47,6 +47,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"
diff --git a/pyproject.toml b/pyproject.toml
index ee306cf98..deb3670a4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -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"]
 


Test patch:
diff --git a/test-requirements.txt b/test-requirements.txt
index f9ccfd0d5..aee52f88d 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -4,4 +4,3 @@ vcrpy
 pytest
 pytest-vcr
 urllib3==1.26.15
-StrEnum==0.4.15