Format ExprTuple (#4963)

This implements formatting ExprTuple, including magic trailing comma. I
intentionally didn't change the settings mechanism but just added a
dummy global const flag.

Besides the snapshots, I added custom breaking/joining tests and a
deeply nested test case. The diffs look better than previously, proper
black compatibility depends on parentheses handling.

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
konstin 2023-06-12 14:55:47 +02:00 committed by GitHub
parent 8161757229
commit e586c27590
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 735 additions and 219 deletions

View file

@ -30,6 +30,10 @@ mod trivia;
include!("../../ruff_formatter/shared_traits.rs");
/// TODO(konstin): hook this up to the settings by replacing `SimpleFormatOptions` with a python
/// specific struct.
pub(crate) const USE_MAGIC_TRAILING_COMMA: bool = true;
/// 'ast is the lifetime of the source code (input), 'buf is the lifetime of the buffer (output)
pub(crate) type PyFormatter<'ast, 'buf> = Formatter<'buf, PyFormatContext<'ast>>;