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

fix(python): improved namespace/accessor behaviour (resolves VSCode autocomplete issue) #5469

Merged
merged 1 commit into from
Nov 11, 2022
Merged

fix(python): improved namespace/accessor behaviour (resolves VSCode autocomplete issue) #5469

merged 1 commit into from
Nov 11, 2022

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Nov 10, 2022

Closes #5460.


Building the docs properly requires access to the Expr & Series namespaces from the class-level, so the @accessor decorator (which is capable of also behaving as a classproperty) was introduced. PyCharm autocomplete is fine with this, but apparently VSCode is not.

Given that this access pattern is only required for sphinx docs to build, I've reworked it so that the docs build exports a temporary environment variable, allowing the @accessor to function as such only when building docs, and to map to a vanilla @property in all other cases (eg: developing/editing, runtime, etc).

With this new approach I have confirmed that the docs still correctly generate namespaced methods (without exposing the internal/private paths) and that proper autocomplete is preserved for both VSCode & PyCharm (screenshots below). Best of both worlds...

Screenshot 2022-11-11 at 00 21 07 Screenshot 2022-11-11 at 00 21 39

(Also fixes several accessor-related linting issues).

@github-actions github-actions bot added fix Bug fix python Related to Python Polars labels Nov 10, 2022
@alexander-beedie
Copy link
Collaborator Author

alexander-beedie commented Nov 11, 2022

(Squashed, and added some explanatory inline comments).

@ritchie46 ritchie46 merged commit 174ecc5 into pola-rs:master Nov 11, 2022
@alexander-beedie alexander-beedie deleted the reworked-namespace-accessor branch November 11, 2022 09:23
zundertj pushed a commit to zundertj/polars that referenced this pull request Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Methods of pl.col().dt and .str are no longer recognised by autocomplete
2 participants