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

Ruff format - polars chaining #9577

Closed
mlarcane opened this issue Jan 19, 2024 · 5 comments
Closed

Ruff format - polars chaining #9577

mlarcane opened this issue Jan 19, 2024 · 5 comments
Labels
formatter Related to the formatter style How should formatted code look

Comments

@mlarcane
Copy link

First of all; thx for providing this neat framework! In our team, we write alot of polars code and we like to chain such that each new polars method "has it's own line" so to speak. We can't seem to find any configurations that allow for this. This is quite a big deal in data science in general, that people like to chain pandas and polars in this way.

Is there anything you can do on this end so it can be configured?

ruff_format_polars

@MichaReiser
Copy link
Member

Hy @mlarcane

No, there's currently no way to configure method chaining but I know that method chaining has come up before (I also find Ruff's/Black's formatting hard to read).

The main challenge with method chaining is that Black/Ruff try very hard to avoid (introducing) parentheses. But method chaining would require parentheses because of Python (a problem other languages don't have).

I don't expect us to work on this anytime soon but I'll leave it open and track it as a style discussion.

@MichaReiser MichaReiser added formatter Related to the formatter style How should formatted code look labels Jan 19, 2024
@tmke8
Copy link
Contributor

tmke8 commented Jan 19, 2024

There could be magic parentheses (analogous to magic commas) which, if present, would tell the formatter to apply the "call chain style".

@mlarcane
Copy link
Author

@tmke8 That would be awesome! Really dig the magic commas (for consistency).

@MartinBernstorff
Copy link
Contributor

Related to #8598

@MichaReiser
Copy link
Member

Thanks, @MartinBernstorff, for linking the issue. I did search for it before replying on the issue but failed to find it.

I'll close this issue in favour of #8598

@MichaReiser MichaReiser closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter style How should formatted code look
Projects
None yet
Development

No branches or pull requests

4 participants