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: different than black when wrapping parentheses for assert #8331

Open
njzjz opened this issue Oct 30, 2023 · 1 comment
Open

Formatter: different than black when wrapping parentheses for assert #8331

njzjz opened this issue Oct 30, 2023 · 1 comment
Labels
formatter Related to the formatter

Comments

@njzjz
Copy link

njzjz commented Oct 30, 2023

The ruff version is v0.1.3.

Original code:

class SomeClass:
    def some_method(necessary_key, kwargs):
        assert set(necessary_key).issubset(set(kwargs)), "Must give neccessary key: %s" % ", ".join(necessary_key)

Black:

class SomeClass:
    def some_method(necessary_key, kwargs):
        assert set(necessary_key).issubset(
            set(kwargs)
        ), "Must give neccessary key: %s" % ", ".join(necessary_key)

ruff:

class SomeClass:
    def some_method(necessary_key, kwargs):
        assert set(necessary_key).issubset(set(kwargs)), (
            "Must give neccessary key: %s" % ", ".join(necessary_key)
        )

See https://play.ruff.rs/f16cda56-ec7f-4b88-9dc9-1ba2dd18b39b

@MichaReiser MichaReiser added the formatter Related to the formatter label Oct 30, 2023
@MichaReiser MichaReiser added this to the Formatter: Stable milestone Oct 30, 2023
@spaceone
Copy link
Contributor

spaceone commented Nov 8, 2023

The ruff style is better and much more readable! E.g. above examples and this here:

-            assert (
-                not should_fail
-            ), "Creating a school(%s) cli with dc_name=%s was unexpectedly successful" % (
-                school,
-                dc_name,
+            assert not should_fail, (
+                "Creating a school(%s) cli with dc_name=%s was unexpectedly successful"
+                % (
+                    school,
+                    dc_name,
+                )
             )

please keep as is.

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

3 participants