Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Enums instead of NamedTuple #1222

Closed
lavigne958 opened this issue Jun 15, 2023 · 2 comments
Closed

Use Enums instead of NamedTuple #1222

lavigne958 opened this issue Jun 15, 2023 · 2 comments
Assignees
Milestone

Comments

@lavigne958
Copy link
Collaborator

Overview

Currently we use NamedTuple for the static parameters to send to the API.
Replace with Enum instances, much better to deal with.

Details

The named tuples are more complexe to type and to work with.

With the enums it's much easier and faster.

Mention

Add warnings again in the latest release for the coming breaking change 😬

@lavigne958 lavigne958 added this to the 6.0.0 milestone Jun 15, 2023
@lavigne958
Copy link
Collaborator Author

Currently working on the typing for the coming release 6.0.0

This change will allow me to reduce the noise in the output of mypy.

After merging this PR in feature/release_6_0_0 I can rebase the typing of gspread/worksheet.py and either merge it or solve what is left to solve.

lavigne958 added a commit that referenced this issue Jun 19, 2023
Most of the parameters for the API are `ENUM`s

Replace the named tuples that are not fitted for that
with enums.

Each enum hold one of the choices.
The actual string value must be extracted in order
to pass strings only to the API using the function `extract_enum_value`
using the `enum.value` field if the enum is not `None`.

this forces us to filter all arguments that are passed when they
can possibly be `None`.

thouhgt about setting the default value for each instead
but this changes the API call made to the API and that could lead
to unwanted behavior for the users.

closes #1222
lavigne958 added a commit that referenced this issue Jul 5, 2023
Most of the parameters for the API are `ENUM`s

Replace the named tuples that are not fitted for that
with enums.

Each enum hold one of the choices.
The actual string value must be extracted in order
to pass strings only to the API using the function `extract_enum_value`
using the `enum.value` field if the enum is not `None`.

this forces us to filter all arguments that are passed when they
can possibly be `None`.

thouhgt about setting the default value for each instead
but this changes the API call made to the API and that could lead
to unwanted behavior for the users.

closes #1222
@lavigne958
Copy link
Collaborator Author

Merged in #1250 closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant