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

Add missing method import_csv() #1426

Merged
merged 1 commit into from
Mar 14, 2024
Merged

Conversation

lavigne958
Copy link
Collaborator

Prior to v6.x.y the method could be used as follow:

file = client.open('x')
file.client.import_csv()

Now file.client is of type HTTPClient
so we need to add the method back for backward compatibility

closes #1423

Prior to v6.x.y the method could be used as follow:

file = client.open('x')
file.client.import_csv()

Now file.client is of type HTTPClient
so we need to add the method back for backward compatibility

closes #1423

Signed-off-by: Alexandre Lavigne <lavigne958@gmail.com>
@lavigne958 lavigne958 self-assigned this Feb 27, 2024
gspread/utils.py Show resolved Hide resolved
gspread/utils.py Show resolved Hide resolved
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 looks good. I only note:

I don't think import_csv makes sense within HTTP_Client? This method provides spreadsheet functionality, so it should be in gspread.Client?

I am not fully up to date with the idea of the HTTP_Client, but my understanding is that it was made so that people could make their own custom HTTP_Clients easier. Then, they would have to make their own import_csv method? Should this not belong to Client?

I see that it might have to be in HTTP_Client, because of hierarchical reasons. If this is the case, then I guess we must leave it.

@lavigne958
Copy link
Collaborator Author

This looks good. I only note:

I don't think import_csv makes sense within HTTP_Client? This method provides spreadsheet functionality, so it should be in gspread.Client?

I am not fully up to date with the idea of the HTTP_Client, but my understanding is that it was made so that people could make their own custom HTTP_Clients easier. Then, they would have to make their own import_csv method? Should this not belong to Client?

I see that it might have to be in HTTP_Client, because of hierarchical reasons. If this is the case, then I guess we must leave it.

I know 😞 I faced the same thought, I wish it could only be located in the client itself and only be used like: gs_client.import_csv() which returns the new spreadsheet instance.

I agree, the HTTPClient allows users to make their own if necessary, and mostly it is here to handle only pure HTTP calls, on the least amount of logic.

The way the project was designed before, allowed users to reach the argument client in a spreadsheet and call methods on it, like this one. now that client argument is the HTTPClient so some logic has been removed.

what we can do is:

  • leave the function only in the gspread client, like it is now
  • do not put it back in the HTTPClient

which is in the end: make no changes, as currently the documentation of the function shows that you should use that function using the gspread client directly, it never shows that you can reach it from elsewhere.

or add it back to the HTTPClient so users can do: spreadsheet.client.import_csv() but we put back the deprecation warnings, in order to be very clean. and we live with it until next major release 🤔

@alifeee
Copy link
Collaborator

alifeee commented Feb 28, 2024

or add it back to the HTTPClient so users can do: spreadsheet.client.import_csv() but we put back the deprecation warnings, in order to be very clean. and we live with it until next major release 🤔

This is a good question. I er towards adding it to the HTTPClient. As, in the end, if someone wanted to make their own, they would probably create a sub-class of the HTTPClient, and override the request methods. So the import_csv etc methods would remain.

Maximum backwards compatibility :)

@lavigne958
Copy link
Collaborator Author

or add it back to the HTTPClient so users can do: spreadsheet.client.import_csv() but we put back the deprecation warnings, in order to be very clean. and we live with it until next major release 🤔

This is a good question. I er towards adding it to the HTTPClient. As, in the end, if someone wanted to make their own, they would probably create a sub-class of the HTTPClient, and override the request methods. So the import_csv etc methods would remain.

Maximum backwards compatibility :)

agreed, we can later depreciate it, like before for the v6.0.0, but this time we should have way less methods to depreciate ! so it should be much easier.

@lavigne958
Copy link
Collaborator Author

thinking about it, I have no changes to make currently right ? unless I forgot something.

@alifeee
Copy link
Collaborator

alifeee commented Mar 13, 2024

something must be changed to fix #1423, no?

@lavigne958
Copy link
Collaborator Author

the current pull request will fix it.
The original issue mentions: AttributeError: 'HTTPClient' object has no attribute 'import_csv'

and the pull request adds a new method import_csv to the HTTPClient.

I am waiting for your review/approval mostly now that we agree on leaving the new method. 🙃

Unless: I did not understand and we still need to find a solution, which is fine.

@lavigne958 lavigne958 merged commit f34cb6a into master Mar 14, 2024
10 checks passed
@lavigne958 lavigne958 deleted the regression/add_missing_import_csv branch March 14, 2024 18:45
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.

AttributeError: 'HTTPClient' object has no attribute 'import_csv'
2 participants