ruff/crates/ruff_python_formatter/resources/test/fixtures/ruff
Dhruv Manilawala 13ffb5bc19
Replace LALRPOP parser with hand-written parser (#10036)
(Supersedes #9152, authored by @LaBatata101)

## Summary

This PR replaces the current parser generated from LALRPOP to a
hand-written recursive descent parser.

It also updates the grammar for [PEP
646](https://peps.python.org/pep-0646/) so that the parser outputs the
correct AST. For example, in `data[*x]`, the index expression is now a
tuple with a single starred expression instead of just a starred
expression.

Beyond the performance improvements, the parser is also error resilient
and can provide better error messages. The behavior as seen by any
downstream tools isn't changed. That is, the linter and formatter can
still assume that the parser will _stop_ at the first syntax error. This
will be updated in the following months.

For more details about the change here, refer to the PR corresponding to
the individual commits and the release blog post.

## Test Plan

Write _lots_ and _lots_ of tests for both valid and invalid syntax and
verify the output.

## Acknowledgements

- @MichaReiser for reviewing 100+ parser PRs and continuously providing
guidance throughout the project
- @LaBatata101 for initiating the transition to a hand-written parser in
#9152
- @addisoncrump for implementing the fuzzer which helped
[catch](https://github.com/astral-sh/ruff/pull/10903)
[a](https://github.com/astral-sh/ruff/pull/10910)
[lot](https://github.com/astral-sh/ruff/pull/10966)
[of](https://github.com/astral-sh/ruff/pull/10896)
[bugs](https://github.com/astral-sh/ruff/pull/10877)

---------

Co-authored-by: Victor Hugo Gomes <labatata101@linuxmail.org>
Co-authored-by: Micha Reiser <micha@reiser.io>
2024-04-18 17:57:39 +05:30
..
carriage_return Normalize '\r' in string literals to '\n' 2023-06-30 10:13:23 +02:00
expression Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
fmt_on_off Spellcheck & grammar (#10375) 2024-03-13 02:34:23 +00:00
fmt_skip Allow `# fmt: skip` with interspersed same-line comments (#9395) 2024-01-04 19:39:37 -05:00
parentheses Comments outside expression parentheses (#7873) 2023-10-19 09:24:11 +00:00
range_formatting Spellcheck & grammar (#10375) 2024-03-13 02:34:23 +00:00
statement Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
stub_files Implement `blank_line_after_nested_stub_class` preview style (#9155) 2024-01-31 00:09:38 +05:30
.editorconfig Docstring formatting: Preserve tab indentation when using `indent-style=tabs` (#9915) 2024-02-12 16:09:13 +01:00
blank_line_before_class_docstring.options.json Implement `no_blank_line_before_class_docstring` preview style (#9154) 2023-12-19 00:43:20 -06:00
blank_line_before_class_docstring.py Implement `no_blank_line_before_class_docstring` preview style (#9154) 2023-12-19 00:43:20 -06:00
docstring.options.json Use double quotes for all docstrings, including single-quoted docstrings (#9020) 2023-12-07 04:41:00 +00:00
docstring.py Spellcheck & grammar (#10375) 2024-03-13 02:34:23 +00:00
docstring_code_examples.options.json ruff_python_formatter: implement "dynamic" line width mode for docstring code formatting (#9098) 2023-12-12 09:58:07 -05:00
docstring_code_examples.py Fix typos found by codespell (#9346) 2024-01-02 02:08:15 +00:00
docstring_code_examples_crlf.options.json format doctests in docstrings (#8811) 2023-11-27 11:14:55 -05:00
docstring_code_examples_crlf.py format doctests in docstrings (#8811) 2023-11-27 11:14:55 -05:00
docstring_code_examples_dynamic_line_width.options.json ruff_python_formatter: implement "dynamic" line width mode for docstring code formatting (#9098) 2023-12-12 09:58:07 -05:00
docstring_code_examples_dynamic_line_width.py ruff_python_formatter: fix 'dynamic' mode with doctests (#9129) 2023-12-14 09:53:43 -05:00
docstring_newlines.py Don't trim last empty line in docstrings (#9813) 2024-02-05 13:29:24 +00:00
docstring_tab_indentation.options.json Docstring formatting: Preserve tab indentation when using `indent-style=tabs` (#9915) 2024-02-12 16:09:13 +01:00
docstring_tab_indentation.py Docstring formatting: Preserve tab indentation when using `indent-style=tabs` (#9915) 2024-02-12 16:09:13 +01:00
empty_multiple_trailing_newlines.py Fix handling of newlines in empty files (#7473) 2023-09-18 06:08:10 +00:00
empty_now_newline.py Fix handling of newlines in empty files (#7473) 2023-09-18 06:08:10 +00:00
empty_trailing_newline.py Fix handling of newlines in empty files (#7473) 2023-09-18 06:08:10 +00:00
empty_whitespace.py Fix handling of newlines in empty files (#7473) 2023-09-18 06:08:10 +00:00
form_feed.py Treat form feed as whitespace in `SimpleTokenizer` (#7626) 2023-09-25 14:34:59 +00:00
module_dangling_comment1.py Format empty lines in stub files like black's preview style (#7206) 2023-09-11 08:03:59 +00:00
module_dangling_comment2.py Format empty lines in stub files like black's preview style (#7206) 2023-09-11 08:03:59 +00:00
multiline_string_deviations.py Hug multiline-strings preview style (#9243) 2024-01-10 12:47:34 +01:00
newlines.py Improve `dummy_implementations` preview style formatting (#9240) 2023-12-22 03:44:14 +00:00
newlines.pyi Truncate to one empty line in stub files (#7558) 2023-09-21 16:24:42 -04:00
notebook_docstring.options.json Disable top-level docstring formatting for notebooks (#9957) 2024-02-12 18:14:02 +00:00
notebook_docstring.py Disable top-level docstring formatting for notebooks (#9957) 2024-02-12 18:14:02 +00:00
preview.options.json Add test and basic implementation for formatter preview mode (#8044) 2023-10-26 15:33:26 +00:00
preview.py Add test and basic implementation for formatter preview mode (#8044) 2023-10-26 15:33:26 +00:00
quote_style.options.json Add "preserve" quote-style to mimic Black's skip-string-normalization (#8822) 2023-12-07 23:59:22 +00:00
quote_style.py Preview Style: Format module level docstring (#9725) 2024-02-05 15:03:34 +00:00
skip_magic_trailing_comma.options.json Add tests for skip magic trailing comma 2023-06-26 14:15:55 +02:00
skip_magic_trailing_comma.py Improve `with` statement comment handling and expression breaking (#6621) 2023-08-18 03:30:38 +00:00
tab_width.options.json Introduce `IndentWidth` (#7301) 2023-09-13 14:52:24 +02:00
tab_width.py Introduce `IndentWidth` (#7301) 2023-09-13 14:52:24 +02:00
trailing_comments.py Extend pragma comment cases (#7687) 2023-09-28 18:55:19 +00:00
trivia.py Use `pass` over ellipsis in non-function/class contexts (#8049) 2023-10-19 11:11:17 +02:00