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

Allow client to use external Session object #1384

Merged
merged 1 commit into from Jan 29, 2024

Conversation

lavigne958
Copy link
Collaborator

Allow new gspread.client.Client to be initialized using an external requests.Session object.

closes #1383

@lavigne958 lavigne958 self-assigned this Jan 28, 2024
@alifeee
Copy link
Collaborator

alifeee commented Jan 28, 2024

I am not really clear on how the client works.

Is this something that was possible in v5 but was made impossible in v6?

Either way, nice fix.

Copy link
Collaborator

@alifeee alifeee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good.

Is this something we would've caught if we'd tried to use gspread for some common actions?

@lavigne958
Copy link
Collaborator Author

lavigne958 commented Jan 29, 2024

I am not really clear on how the client works.

The client is the gspread entry point, it required some credentials and the Type of http client you want to use (standard/BackOff).

Is this something that was possible in v5 but was made impossible in v6?

Yes it is 😑😞 that's a regression out of the box right here.

In v5 it used to take the following arguments to instantiate a new client:

  • credentials
  • session object.

Now with the rework and new client it takes:

  • credentials
  • the Type of http client to use

So no more ways to pass you own session object 😬

Either way, nice fix.

Thanks ! 🙃

@lavigne958
Copy link
Collaborator Author

This is good.

Is this something we would've caught if we'd tried to use gspread for some common actions?

I don't think so, this can be caught only by having a test with a custom session object. Otherwise you don't see that you miss something in your interface.

@alifeee
Copy link
Collaborator

alifeee commented Jan 29, 2024

The client is the gspread entry point, it required some credentials and the Type of http client you want to use (standard/BackOff).

ok I think I'm getting confused between "client" (gspread client) and "client" (http client)

I don't think so, this can be caught only by having a test with a custom session object. Otherwise you don't see that you miss something in your interface.

Then we should also add a regression test...

@lavigne958
Copy link
Collaborator Author

The client is the gspread entry point, it required some credentials and the Type of http client you want to use (standard/BackOff).

ok I think I'm getting confused between "client" (gspread client) and "client" (http client)

yes sorry ! that's a very good point ! we should use client for the gspread client and http_client for the actual class that handles all HTTP request (the HTTPClient or BackOffHTTPClient)

I don't think so, this can be caught only by having a test with a custom session object. Otherwise you don't see that you miss something in your interface.

Then we should also add a regression test...

yes, I propose we add it later exceptionally if that's ok for you ? that would allow us to release first for the users

Allow new `gspread.client.Client` to be initialized
using an external `requests.Session` object.

closes #1383

Signed-off-by: Alexandre Lavigne <lavigne958@gmail.com>
@lavigne958
Copy link
Collaborator Author

rebased on master branch before merge

@lavigne958 lavigne958 merged commit a14470e into master Jan 29, 2024
10 checks passed
@lavigne958 lavigne958 deleted the bugfix/allow_external_session branch January 29, 2024 19:13
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

Successfully merging this pull request may close these issues.

Cannot use session with Client() in v6.0.0
2 participants