Skip to content

Commit

Permalink
Remove unused error type, fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Sep 5, 2023
1 parent 083f5fc commit 690f59c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions crates/ruff_python_parser/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,6 @@ pub enum FStringErrorType {
UnclosedLbrace,
/// An invalid conversion flag was encountered.
InvalidConversionFlag,
/// An empty expression was encountered.
EmptyExpression,
/// A single right brace was encountered.
SingleRbrace,
/// Unterminated string.
Expand All @@ -486,13 +484,12 @@ pub enum FStringErrorType {
impl std::fmt::Display for FStringErrorType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
use FStringErrorType::{
EmptyExpression, InvalidConversionFlag, SingleRbrace, UnclosedLbrace,
UnterminatedString, UnterminatedTripleQuotedString,
InvalidConversionFlag, SingleRbrace, UnclosedLbrace, UnterminatedString,
UnterminatedTripleQuotedString,
};
match self {
UnclosedLbrace => write!(f, "expecting '}}'"),
InvalidConversionFlag => write!(f, "invalid conversion character"),
EmptyExpression => write!(f, "empty expression not allowed"),
SingleRbrace => write!(f, "single '}}' is not allowed"),
UnterminatedString => write!(f, "unterminated string"),
UnterminatedTripleQuotedString => write!(f, "unterminated triple-quoted string"),
Expand Down Expand Up @@ -586,9 +583,7 @@ mod tests {
use FStringErrorType::InvalidConversionFlag;

assert_eq!(parse_fstring_error(r#"f"{5!x}""#), InvalidConversionFlag);

// TODO: check for InvalidExpression enum?
assert!(parse_suite("{class}", "<test>").is_err());
assert!(parse_suite(r#"f"{class}""#, "<test>").is_err());
}

#[test]
Expand Down

0 comments on commit 690f59c

Please sign in to comment.