mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-13 16:15:07 +00:00
Add support for help end IPython escape commands (#6358)
## Summary This PR adds support for a stricter version of help end escape commands[^1] in the parser. By stricter, I mean that the escape tokens are only at the end of the command and there are no tokens at the start. This makes it difficult to implement it in the lexer without having to do a lot of look aheads or keeping track of previous tokens. Now, as we're adding this in the parser, the lexer needs to recognize and emit a new token for `?`. So, `Question` token is added which will be recognized only in `Jupyter` mode. The conditions applied are the same as the ones in the original implementation in IPython codebase (which is a regex): * There can only be either 1 or 2 question mark(s) at the end * The node before the question mark can be a `Name`, `Attribute`, `Subscript` (only with integer constants in slice position), or any combination of the 3 nodes. ## Test Plan Added test cases for various combination of the possible nodes in the command value position and update the snapshots. fixes: #6359 fixes: #5030 (This is the final piece) [^1]: https://github.com/astral-sh/ruff/pull/6272#issue-1833094281
This commit is contained in:
parent
887a47cad9
commit
e257c5af32
6 changed files with 40274 additions and 34786 deletions
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue