mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-08 05:35:22 +00:00
Format
This commit is contained in:
parent
f96642aac4
commit
b9d283fd2d
2 changed files with 12 additions and 12 deletions
|
@ -636,7 +636,6 @@ class Foo(A, B):
|
|||
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").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, "<embedded>").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::<Vec<_>>());
|
||||
use crate::lexer::lex;
|
||||
let lexer = lex(source, Mode::Module);
|
||||
println!(
|
||||
"tokens {:#?}",
|
||||
lexer.map(|x| x.unwrap().0).collect::<Vec<_>>()
|
||||
);
|
||||
|
||||
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
|
||||
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -956,7 +957,7 @@ match match:
|
|||
match = lambda query: query == event
|
||||
print(match(12))
|
||||
"#;
|
||||
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
|
||||
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -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<LexResult> {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue