mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:25:17 +00:00
![]() ## Summary This PR adds handling for comments on open parentheses in parenthesized context managers. For example, given: ```python with ( # comment CtxManager1() as example1, CtxManager2() as example2, CtxManager3() as example3, ): ... ``` We want to preserve that formatting. (Black does the same.) On `main`, we format as: ```python with ( # comment CtxManager1() as example1, CtxManager2() as example2, CtxManager3() as example3, ): ... ``` It's very similar to how `StmtImportFrom` is handled. Note that this case _isn't_ covered by the "parenthesized comment" proposal, since this is a common on the statement that would typically be attached to the first `WithItem`, and the `WithItem` _itself_ can have parenthesized comments, like: ```python with ( # comment ( CtxManager1() # comment ) as example1, CtxManager2() as example2, CtxManager3() as example3, ): ... ``` ## Test Plan `cargo test` Confirmed no change in similarity score. |
||
---|---|---|
.. | ||
snapshots | ||
fixtures.rs |