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

feat(python): Add typing to hvplot plot namespace #13813

Merged
merged 3 commits into from
Jan 18, 2024

Conversation

thomasaarholt
Copy link
Contributor

Tagging @MarcoGorelli who added the super nice plotting functionality.

I noticed that I didn't get type hinting on the df.plot namespace, so decided to add it here. Were there any particular reasons you didn't do so?

Note that since we from __future__ import annotations, the return type won't raise a runtime this (without strings) despite hvplot possibly not being installed.

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Jan 18, 2024
@MarcoGorelli
Copy link
Collaborator

hey - hvplot doesn't have a py.typed file, so this type annotation wouldn't really have any effect

@thomasaarholt
Copy link
Contributor Author

thomasaarholt commented Jan 18, 2024

hvplot might not have a py.typed file, but the annotation still gives me autocomplete using pyright 😊 :

Here in VSCode:
image

Same in helix, also using pyright:
image

@MarcoGorelli
Copy link
Collaborator

ah, nice! should be fine then, do you want to add it for Series.plot too then?

@thomasaarholt
Copy link
Contributor Author

Done! Thanks, I wasn't aware it existed there too!

Thank you so much for the plotting functionality! It really adds that extra bit of elegance to the whole package!

Copy link
Collaborator

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

thanks @thomasaarholt !

@hoxbro sorry for the ping, just wanted to check if hvplot.plotting.core.hvPlotTabularPolars can be considered public, and if not, if there's anything else which should be used?

@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Jan 18, 2024

Joining in the fun 😅 Moved the hvimport import into the TYPE_CHECKING block so it can import directly but can't affect runtime; there's at least some chance that'll result in more success across a wider range of type-checkers as they won't have to indirect the lazy import. Tested locally on PyCharm Professional and can confirm that I see autocomplete in the editor, not just the console 👍

@hoxbro
Copy link

hoxbro commented Jan 18, 2024

@hoxbro sorry for the ping, just wanted to check if hvplot.plotting.core.hvPlotTabularPolars can be considered public, and if not, if there's anything else which should be used?

It can be considered public.

And you are always welcome to ping me 👍

Copy link
Collaborator

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

thanks all!

@stinodego stinodego merged commit 36d0e94 into pola-rs:main Jan 18, 2024
11 checks passed
r-brink pushed a commit to r-brink/polars that referenced this pull request Jan 24, 2024
Co-authored-by: alexander-beedie <alexander.m.beedie@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants