ruff/crates/ruff_python_trivia/src
Charlie Marsh ee5b07d4ca
Skip empty lines when determining base indentation (#9795)
## Summary

It turns out we saw a panic in cases when dedenting blocks like the `def
wrapper` here:

```python
def instrument_url(f: UrlFuncT) -> UrlFuncT:
    # TODO: Type this with ParamSpec to preserve the function signature.
    if not INSTRUMENTING:  # nocoverage -- option is always enabled; should we remove?
        return f
    else:

        def wrapper(
            self: "ZulipTestCase", url: str, info: object = {}, **kwargs: Union[bool, str]
        ) -> HttpResponseBase:
```

Since we relied on the first line to determine the indentation, instead
of the first non-empty line.

## Test Plan

`cargo test`
2024-02-02 19:42:47 +00:00
..
snapshots Tokenizer: Emit only a single bogus token (#7425) 2023-09-19 16:06:03 +02:00
comment_ranges.rs Skip LibCST parsing for standard dedent adjustments (#9769) 2024-02-02 18:13:46 +00:00
cursor.rs Use CommentRanges in backwards lexing (#7360) 2023-09-16 03:21:45 +00:00
lib.rs Extend pragma comment cases (#7687) 2023-09-28 18:55:19 +00:00
pragmas.rs Extend pragma comment cases (#7687) 2023-09-28 18:55:19 +00:00
textwrap.rs Skip empty lines when determining base indentation (#9795) 2024-02-02 19:42:47 +00:00
tokenizer.rs Add an explicit fast path for whitespace to is_identifier_continuation (#9532) 2024-01-16 08:23:43 +00:00
whitespace.rs Remove source path from parser errors (#9322) 2023-12-30 20:33:05 +00:00