diff --git a/parser/src/parser.rs b/parser/src/parser.rs index 8077458..0859c37 100644 --- a/parser/src/parser.rs +++ b/parser/src/parser.rs @@ -636,7 +636,6 @@ class Foo(A, B): insta::assert_debug_snapshot!(ast::Suite::parse(source, "").unwrap()); } - #[test] #[cfg(feature = "all-nodes-with-ranges")] fn test_parse_class_generic_types() { @@ -895,7 +894,6 @@ except* OSError as e: assert!(parse(source, Mode::Interactive, "").is_ok()); } - #[test] #[cfg(feature = "all-nodes-with-ranges")] fn test_parse_type_declaration() { @@ -923,11 +921,14 @@ type = lambda query: query == event print(type(12)) "#; - use crate::lexer::lex; - let lexer = lex(source, Mode::Module); - println!("tokens {:#?}", lexer.map(|x| x.unwrap().0).collect::>()); + use crate::lexer::lex; + let lexer = lex(source, Mode::Module); + println!( + "tokens {:#?}", + lexer.map(|x| x.unwrap().0).collect::>() + ); - insta::assert_debug_snapshot!(ast::Suite::parse(source, "").unwrap()); + insta::assert_debug_snapshot!(ast::Suite::parse(source, "").unwrap()); } #[test] @@ -956,7 +957,7 @@ match match: match = lambda query: query == event print(match(12)) "#; - insta::assert_debug_snapshot!(ast::Suite::parse(source, "").unwrap()); + insta::assert_debug_snapshot!(ast::Suite::parse(source, "").unwrap()); } #[test] diff --git a/parser/src/soft_keywords.rs b/parser/src/soft_keywords.rs index ec430ce..7507700 100644 --- a/parser/src/soft_keywords.rs +++ b/parser/src/soft_keywords.rs @@ -8,9 +8,9 @@ use itertools::{Itertools, MultiPeek}; /// as soft keywords, meaning that they can be used as identifiers (e.g., variable names) in certain /// contexts. /// -/// Later, [PEP 695](https://peps.python.org/pep-0695/#generic-type-alias) introduced the `type` +/// Later, [PEP 695](https://peps.python.org/pep-0695/#generic-type-alias) introduced the `type` /// soft keyword. -/// +/// /// This function modifies a token stream to accommodate this change. In particular, it replaces /// soft keyword tokens with `identifier` tokens if they are used as identifiers. /// @@ -46,10 +46,10 @@ where fn next(&mut self) -> Option { let mut next = self.underlying.next(); if let Some(Ok((tok, range))) = next.as_ref() { - // If the token is a soft keyword e.g. `type`, `match`, or `case`, check if it's + // If the token is a soft keyword e.g. `type`, `match`, or `case`, check if it's // used as an identifier. We assume every soft keyword use is an identifier unless // a heuristic is met. - + // For `match` and `case`, all of the following conditions must be met: // 1. The token is at the start of a logical line. // 2. The logical line contains a top-level colon (that is, a colon that is not nested @@ -112,7 +112,6 @@ where next = Some(Ok((soft_to_name(tok), *range))); } } - } }