gspread
gspread copied to clipboard
Remove StrEnum dependency
gspread dependencies are:
https://github.com/burnash/gspread/blob/c740b88e072962ffe772ec3bd90907a579524692/pyproject.toml#L30-L34
StrEnum amounts to
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?
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 :)