nithinmurali / pygsheets

Google Sheets Python API v4
https://pygsheets.readthedocs.io/en/latest
Other
1.51k stars 220 forks source link

Add return type annotations when returning classes (i.e. Worksheet) #544

Open WBETHERI opened 2 years ago

WBETHERI commented 2 years ago

Issue: When calling functions such as Spreadsheet.worksheet_by_title(), which return a custom class (such as Worksheet, Spreadsheet), intellisense cannot provide autocomplete intelligently unless you utilize function chaining.

Consider the below:

worksheet = Spreadsheet.worksheet_by_title('Sheet1')

When utilizing the worksheet variable, intellisense doesn't know what to do, seeing it as type 'any'.

Solution:

Add appropriate type annotations to functions that return custom classes.

Example: def worksheet_by_title(self, title): -> Worksheet rather than def worksheet_by_title(self, title):

I'd be happy to work on a PR for this myself if the author is amenable :)

nithinmurali commented 2 years ago

I'd be happy to work on a PR for this myself if the author is amenable :)

Sure please go ahead :)

talpid commented 1 year ago

@WBETHERI did you ever get around to this? I could probably do it if you haven't started yet.

WBETHERI commented 1 year ago

@MoleyCode Unfortunately I only got a little ways into working on it before I fell in to some crunch at work and haven't come up for air -- feel free to take it!