ruff/crates
Dhruv Manilawala 8f40928534
Enable token-based rules on source with syntax errors (#11950)
## Summary

This PR updates the linter, specifically the token-based rules, to work
on the tokens that come after a syntax error.

For context, the token-based rules only diagnose the tokens up to the
first lexical error. This PR builds up an error resilience by
introducing a `TokenIterWithContext` which updates the `nesting` level
and tries to reflect it with what the lexer is seeing. This isn't 100%
accurate because if the parser recovered from an unclosed parenthesis in
the middle of the line, the context won't reduce the nesting level until
it sees the newline token at the end of the line.

resolves: #11915

## Test Plan

* Add test cases for a bunch of rules that are affected by this change.
* Run the fuzzer for a long time, making sure to fix any other bugs.
2024-07-02 08:57:46 +00:00
..
red_knot Update Rust crate dashmap to v6 (#12126) 2024-07-01 08:48:26 +00:00
red_knot_module_resolver Introduce HasTy trait and SemanticModel facade (#11963) 2024-07-01 14:48:27 +02:00
red_knot_python_semantic Address review feedback from 11963 (#12145) 2024-07-02 09:05:55 +02:00
ruff Make requires-python inference robust to == (#12091) 2024-06-28 09:38:17 -04:00
ruff_benchmark Simplify LinterResult, avoid cloning ParseError (#11903) 2024-06-27 13:44:11 +02:00
ruff_cache
ruff_db Introduce HasTy trait and SemanticModel facade (#11963) 2024-07-01 14:48:27 +02:00
ruff_dev Drop deprecated nursery rule group (#10172) 2024-06-27 13:44:11 +02:00
ruff_diagnostics
ruff_formatter
ruff_index
ruff_linter Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
ruff_macros Drop deprecated nursery rule group (#10172) 2024-06-27 13:44:11 +02:00
ruff_notebook Add Jupyter Notebook document change snapshot test (#11944) 2024-06-21 05:29:27 +00:00
ruff_python_ast Use CompactString for Identifier (#12101) 2024-07-01 10:06:02 +02:00
ruff_python_ast_integration_tests
ruff_python_codegen Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
ruff_python_formatter Update Rust crate rustc-hash to v2 (#12001) 2024-06-23 20:46:42 -04:00
ruff_python_index Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
ruff_python_literal
ruff_python_parser Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
ruff_python_resolver
ruff_python_semantic Use CompactString for Identifier (#12101) 2024-07-01 10:06:02 +02:00
ruff_python_stdlib
ruff_python_trivia Mention that Cursor is based on rustc's implementation. (#12109) 2024-06-30 16:53:25 +01:00
ruff_python_trivia_integration_tests
ruff_server Remove E999 to find diagnostic severity (#12080) 2024-06-28 09:31:35 +05:30
ruff_source_file
ruff_text_size
ruff_wasm Show syntax errors on the playground (#12083) 2024-06-28 13:06:15 +05:30
ruff_workspace Use CompactString for Identifier (#12101) 2024-07-01 10:06:02 +02:00