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

Formatter: % formatting on right side of assignment #6976

Closed
MichaReiser opened this issue Aug 29, 2023 · 0 comments
Closed

Formatter: % formatting on right side of assignment #6976

MichaReiser opened this issue Aug 29, 2023 · 0 comments
Labels
formatter Related to the formatter

Comments

@MichaReiser
Copy link
Member

Black prefers to keep the % on the same line as the string and parenthesize the format arguments:

def test():
    if True:
        if False:
            if True:
                if False:
                    if True:
                        if False:
                            self.renamed_models_rel[
                                renamed_models_rel_key
                            ] = "%s.%s" % (
                                model_state.app_label,
                                model_state.name_lower
                            )
                            

Ruff parenthesized the whole assignment value and breaks before the % operator

def test():
    if True:
        if False:
            if True:
                if False:
                    if True:
                        if False:
                            self.renamed_models_rel[renamed_models_rel_key] = (
                                "%s.%s"
                                % (model_state.app_label, model_state.name_lower)
                            )

IMO, Ruff's layout is more readable because it avoids unnecessary newlines.

@MichaReiser MichaReiser added the formatter Related to the formatter label Aug 29, 2023
@MichaReiser MichaReiser added this to the Formatter: Alpha milestone Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter
Projects
None yet
Development

No branches or pull requests

1 participant