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 return type annotations when returning classes (i.e. Worksheet) #544

Open
WBETHERI opened this issue Jun 29, 2022 · 3 comments
Open

Comments

@WBETHERI
Copy link

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
Copy link
Owner

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

Sure please go ahead :)

@talpid
Copy link

talpid commented Apr 4, 2023

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

@WBETHERI
Copy link
Author

WBETHERI commented Apr 8, 2023

@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!

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

3 participants