ruff/crates/ruff_python_parser/src
Dhruv Manilawala 4667d8697c
Remove duplication around `is_trivia` functions (#11956)
## Summary

This PR removes the duplication around `is_trivia` functions.

There are two of them in the codebase:
1. In `pycodestyle`, it's for newline, indent, dedent, non-logical
newline and comment
2. In the parser, it's for non-logical newline and comment

The `TokenKind::is_trivia` method used (1) but that's not correct in
that context. So, this PR introduces a new `is_non_logical_token` helper
method for the `pycodestyle` crate and updates the
`TokenKind::is_trivia` implementation with (2).

This also means we can remove `Token::is_trivia` method and the
standalone `token_source::is_trivia` function and use the one on
`TokenKind`.

## Test Plan

`cargo insta test`
2024-06-21 10:02:40 +00:00
..
lexer Maintain synchronicity between the lexer and the parser (#11457) 2024-06-03 18:23:50 +05:30
parser Use re-lexing for normal list parsing (#11871) 2024-06-18 12:14:41 +05:30
snapshots Lexer should consider BOM for the start offset (#11732) 2024-06-04 08:45:46 +00:00
error.rs Maintain synchronicity between the lexer and the parser (#11457) 2024-06-03 18:23:50 +05:30
lexer.rs Remove duplication around `is_trivia` functions (#11956) 2024-06-21 10:02:40 +00:00
lib.rs Update `E999` to show all syntax errors (#11900) 2024-06-19 13:09:54 +05:30
string.rs Maintain synchronicity between the lexer and the parser (#11457) 2024-06-03 18:23:50 +05:30
token.rs Remove duplication around `is_trivia` functions (#11956) 2024-06-21 10:02:40 +00:00
token_set.rs Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
token_source.rs Remove duplication around `is_trivia` functions (#11956) 2024-06-21 10:02:40 +00:00
typing.rs Update type annotation parsing API to return `Parsed` (#11739) 2024-06-05 12:59:43 +05:30