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

Is it possible to disable formatting for chains with line-breaking? #12312

Closed
VladimirPodolian opened this issue Jul 13, 2024 · 1 comment
Closed
Labels
question Asking for support or clarification

Comments

@VladimirPodolian
Copy link

Ruff command:

ruff format

Default ruff.toml + these updates

line-length = 120
quote-style = "single"

Ruff version:

ruff 0.5.1

Hi there! I would like to use ruff on my work project and on myself project for selenium. But i'm facing an issue, that it formats lines like this

        self._action_chains\
            .move_to_element(self.element)\
            .move_by_offset(1, 1)\
            .move_to_element(self.element)\
            .perform()

To this

self._action_chains.move_to_element(self.element).move_by_offset(1, 1).move_to_element(self.element).perform()

Is it possible to disable formatting for chains with line-breaking on whole project ?

@MichaReiser MichaReiser added the question Asking for support or clarification label Jul 15, 2024
@MichaReiser
Copy link
Member

Hi @VladimirPodolian

I'm sorry. There's currently no option to disable chain formatting other than using suppression comments.

self._action_chains
    .move_to_element(self.element)
    .move_by_offset(1, 1)
    .move_to_element(self.element)
    .perform() # fmt: skip

But that turns off all formatting and is rather verbose.

There's a tracking issue for improving call chain formatting overall. Unfortunately, chain formatting is especially hard in Python because line breaks are only allowed in parenthesized context (line-continuation tokens are an option but not something that the majority of the community prefers).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

2 participants