Skip to content

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

@njzjz

Description

@njzjz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterRelated to the formatter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions