Skip to content

Formatter undocumented deviation in with with multiple context managers #8580

@DeD1rk

Description

@DeD1rk

Hi, I noticed a small difference between Black and ruff's formatting, that is not listed in https://docs.astral.sh/ruff/formatter/#intentional-deviations. I've added a sample below.

# Input:

with some_context_manager(
    "aaaaaaaaaaaaaaaaaaaaaaaa", another_long_function("test1")
), some_context_manager(
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", another_long_function("test1")
), some_context_manager(
    "aaaaaaaaaaaaaaaaaaaaaaa", another_long_function("test1")
):
    print("hi")


# Black:

with some_context_manager(
    "aaaaaaaaaaaaaaaaaaaaaaaa", another_long_function("test1")
), some_context_manager(
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", another_long_function("test1")
), some_context_manager(
    "aaaaaaaaaaaaaaaaaaaaaaa", another_long_function("test1")
):
    print("hi")


# Ruff:

with some_context_manager(
    "aaaaaaaaaaaaaaaaaaaaaaaa", another_long_function("test1")
), some_context_manager(
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", another_long_function("test1")
), some_context_manager("aaaaaaaaaaaaaaaaaaaaaaa", another_long_function("test1")):
    print("hi")

This is on ruff v0.1.4 and black 23.11.0, both with line-length 100.

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationformatterRelated to the formatter

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions