Andrew Gallant
28b1aa201b
ruff_python_formatter: fix 'dynamic' mode with doctests ( #9129 )
...
This fixes a bug where the current indent level was not calculated
correctly for doctests. Namely, it didn't account for the extra indent
level (in terms of ASCII spaces) used by by the PS1 (`>>> `) and PS2
(`... `) prompts. As a result, lines could extend up to 4 spaces beyond
the configured line length limit.
We fix that by passing the `CodeExampleKind` to the `format` routine
instead of just the code itself. In this way, `format` can query whether
there will be any extra indent added _after_ formatting the code and
take that into account for its line length setting.
We add a few regression tests, taken directly from @stinodego's
examples.
Fixes #9126
2023-12-14 09:53:43 -05:00
..
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 21:49:28 -05:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-12-06 07:15:06 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-12-06 07:15:06 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-12-13 03:43:23 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-12-06 07:15:06 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-12-01 02:57:05 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-12-13 03:43:23 +00:00
2023-11-30 00:09:55 +00:00
2023-12-13 03:43:23 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-12-13 03:43:23 +00:00
2023-11-30 21:49:28 -05:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 21:49:28 -05:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-30 21:11:14 -05:00
2023-11-09 01:49:24 +00:00
2023-12-13 11:02:11 -05:00
2023-12-14 09:53:43 -05:00
2023-12-13 11:02:11 -05:00
2023-12-13 11:02:11 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-17 12:24:19 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-12-14 04:58:17 +00:00
2023-11-09 01:49:24 +00:00
2023-12-13 11:02:11 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-30 21:11:14 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-12-13 03:43:23 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-30 21:11:14 -05:00
2023-11-09 01:49:24 +00:00
2023-12-13 11:02:11 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-12-13 11:02:11 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-12-13 11:02:11 -05:00
2023-11-09 01:49:24 +00:00
2023-12-13 11:02:11 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-30 21:49:28 -05:00
2023-12-13 11:02:11 -05:00
2023-12-13 11:02:11 -05:00
2023-12-13 11:02:11 -05:00
2023-12-13 03:43:23 +00:00
2023-11-09 01:49:24 +00:00
2023-12-13 03:43:23 +00:00
2023-12-13 11:02:11 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-12-03 19:15:40 -05:00
2023-11-09 01:49:24 +00:00
2023-12-09 18:03:31 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-30 21:49:28 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-12-04 05:27:04 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-12-13 11:02:11 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00