Skip to content

Allow client to use external Session object - #1384

Merged
lavigne958 merged 1 commit into
masterfrom
bugfix/allow_external_session
Jan 29, 2024
Merged

lavigne958 merged 1 commit into
masterfrom
bugfix/allow_external_session

Conversation

@lavigne958

Copy link
Copy Markdown
Collaborator

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

closes #1383

@lavigne958
lavigne958 requested a review from alifeee January 28, 2024 22:44
@lavigne958 lavigne958 self-assigned this Jan 28, 2024
@alifeee

alifeee commented Jan 28, 2024

Copy link
Copy Markdown
Collaborator

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.

@alifeee alifeee left a comment

Copy link
Copy Markdown
Collaborator

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

lavigne958 commented Jan 29, 2024 •

Copy link
Copy Markdown
Collaborator Author

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
Copy Markdown
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

alifeee commented Jan 29, 2024

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
lavigne958 force-pushed the bugfix/allow_external_session branch from ca644f1 to 963097e Compare January 29, 2024 19:07
@lavigne958

Copy link
Copy Markdown
Collaborator Author

rebased on master branch before merge

@lavigne958
lavigne958 merged commit a14470e into master Jan 29, 2024
@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