ruff/crates/ruff_python_parser/src
Dhruv Manilawala 69b8136463
Avoid curly brace escape in f-string format spec (#7780)
## Summary

This PR fixes a bug in the lexer for f-string format spec where it would
consider the `{{` (double curly braces) as an escape pattern.

This is not the case as evident by the
[PEP](https://peps.python.org/pep-0701/#how-to-produce-these-new-tokens)
as well but I missed the part:

> [..]
> * **If in “format specifier mode” (see step 3), an opening brace ({)
or a closing brace (}).**
> * If not in “format specifier mode” (see step 3), an opening brace ({)
or a closing brace (}) that is not immediately followed by another
opening/closing brace.

## Test Plan

Add a test case to verify the fix and update the snapshot.

fixes: #7778
2023-10-03 19:38:03 +05:30
..
lexer Add support for PEP 701 (#7376) 2023-09-29 02:55:39 +00:00
snapshots Avoid curly brace escape in f-string format spec (#7780) 2023-10-03 19:38:03 +05:30
context.rs Remove Parse trait (#6235) 2023-08-01 18:35:03 +02:00
function.rs Move Ranged into ruff_text_size (#6919) 2023-08-27 14:12:51 -04:00
lexer.rs Avoid curly brace escape in f-string format spec (#7780) 2023-10-03 19:38:03 +05:30
lib.rs Skip all bracketed expressions when locating comparison ops (#7740) 2023-10-01 14:57:40 +00:00
parser.rs Use crates.io unicode_names2 0.6.0 (#6478) 2023-10-02 18:17:38 -04:00
python.lalrpop Add support for PEP 701 (#7376) 2023-09-29 02:55:39 +00:00
python.rs Add support for PEP 701 (#7376) 2023-09-29 02:55:39 +00:00
soft_keywords.rs Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
string.rs Remove escaped mac/windows eol from AST string value (#7724) 2023-10-01 07:37:59 +05:30
token.rs Add support for PEP 701 (#7376) 2023-09-29 02:55:39 +00:00
typing.rs Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00