ruff/crates/ruff_python_formatter/src/other
konsti 9a817a2922
Insert empty line between suite and alternative branch after def/class (#12294)
When there is a function or class definition at the end of a suite
followed by the beginning of an alternative block, we have to insert a
single empty line between them.

In the if-else-statement example below, we insert an empty line after
the `foo` in the if-block, but none after the else-block `foo`, since in
the latter case the enclosing suite already adds empty lines.

```python
if sys.version_info >= (3, 10):
    def foo():
        return "new"
else:
    def foo():
        return "old"
class Bar:
    pass
```

To do so, we track whether the current suite is the last one in the
current statement with a new option on the suite kind.

Fixes #12199

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
2024-07-15 12:59:33 +02:00
..
alias.rs Avoid printing continuations within import identifiers (#7744) 2023-10-02 09:51:07 -04:00
arguments.rs Upgrade to Rust 1.78 (#11260) 2024-05-03 12:46:21 +00:00
bytes_literal.rs Simplify formatting of strings by using flags from the AST nodes (#10489) 2024-03-20 16:16:54 +00:00
commas.rs Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
comprehension.rs Use space separator before parenthesiszed expressions in comprehensions with leading comments. (#12282) 2024-07-11 22:38:12 +02:00
decorator.rs Implement RUF028 to detect useless formatter suppression comments (#9899) 2024-02-28 19:21:06 +00:00
elif_else_clause.rs Insert empty line between suite and alternative branch after def/class (#12294) 2024-07-15 12:59:33 +02:00
except_handler_except_handler.rs Insert empty line between suite and alternative branch after def/class (#12294) 2024-07-15 12:59:33 +02:00
f_string.rs Implement a common trait for the string flags (#11564) 2024-05-27 16:02:01 +01:00
f_string_element.rs Implement a common trait for the string flags (#11564) 2024-05-27 16:02:01 +01:00
f_string_part.rs Split string formatting to individual nodes (#9058) 2023-12-14 12:55:10 -06:00
identifier.rs Range formatting: Fix invalid syntax after parenthesizing expression (#9751) 2024-02-02 17:56:25 +01:00
keyword.rs Introduce Token element (#7048) 2023-09-02 10:05:47 +02:00
match_case.rs Insert empty line between suite and alternative branch after def/class (#12294) 2024-07-15 12:59:33 +02:00
mod.rs Preview minimal f-string formatting (#9642) 2024-02-16 20:28:11 +05:30
parameter.rs Introduce Token element (#7048) 2023-09-02 10:05:47 +02:00
parameter_with_default.rs Formatter: Remove unnecessary group (#8455) 2023-11-03 04:14:29 +00:00
parameters.rs Upgrade to Rust 1.79 (#11875) 2024-06-17 07:15:10 +01:00
string_literal.rs Simplify formatting of strings by using flags from the AST nodes (#10489) 2024-03-20 16:16:54 +00:00
with_item.rs Upgrade to Rust 1.78 (#11260) 2024-05-03 12:46:21 +00:00