mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-16 09:35:07 +00:00
Pull in RustPython parser (#6099)
This commit is contained in:
parent
86539c1fc5
commit
40f54375cb
779 changed files with 108400 additions and 2078 deletions
180
crates/ruff_python_parser/src/context.rs
Normal file
180
crates/ruff_python_parser/src/context.rs
Normal file
|
@ -0,0 +1,180 @@
|
|||
use ruff_python_ast::{self as ast, Expr, ExprContext};
|
||||
|
||||
pub(crate) fn set_context(expr: Expr, ctx: ExprContext) -> Expr {
|
||||
match expr {
|
||||
Expr::Name(ast::ExprName { id, range, .. }) => ast::ExprName { range, id, ctx }.into(),
|
||||
Expr::Tuple(ast::ExprTuple { elts, range, .. }) => ast::ExprTuple {
|
||||
elts: elts.into_iter().map(|elt| set_context(elt, ctx)).collect(),
|
||||
range,
|
||||
ctx,
|
||||
}
|
||||
.into(),
|
||||
|
||||
Expr::List(ast::ExprList { elts, range, .. }) => ast::ExprList {
|
||||
elts: elts.into_iter().map(|elt| set_context(elt, ctx)).collect(),
|
||||
range,
|
||||
ctx,
|
||||
}
|
||||
.into(),
|
||||
Expr::Attribute(ast::ExprAttribute {
|
||||
value, attr, range, ..
|
||||
}) => ast::ExprAttribute {
|
||||
range,
|
||||
value,
|
||||
attr,
|
||||
ctx,
|
||||
}
|
||||
.into(),
|
||||
Expr::Subscript(ast::ExprSubscript {
|
||||
value,
|
||||
slice,
|
||||
range,
|
||||
..
|
||||
}) => ast::ExprSubscript {
|
||||
range,
|
||||
value,
|
||||
slice,
|
||||
ctx,
|
||||
}
|
||||
.into(),
|
||||
Expr::Starred(ast::ExprStarred { value, range, .. }) => ast::ExprStarred {
|
||||
value: Box::new(set_context(*value, ctx)),
|
||||
range,
|
||||
ctx,
|
||||
}
|
||||
.into(),
|
||||
_ => expr,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::Parse;
|
||||
use ruff_python_ast as ast;
|
||||
|
||||
#[test]
|
||||
fn test_assign_name() {
|
||||
let source = "x = (1, 2, 3)";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assign_tuple() {
|
||||
let source = "(x, y) = (1, 2, 3)";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assign_list() {
|
||||
let source = "[x, y] = (1, 2, 3)";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assign_attribute() {
|
||||
let source = "x.y = (1, 2, 3)";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assign_subscript() {
|
||||
let source = "x[y] = (1, 2, 3)";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assign_starred() {
|
||||
let source = "(x, *y) = (1, 2, 3)";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assign_for() {
|
||||
let source = "for x in (1, 2, 3): pass";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assign_list_comp() {
|
||||
let source = "x = [y for y in (1, 2, 3)]";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assign_set_comp() {
|
||||
let source = "x = {y for y in (1, 2, 3)}";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assign_with() {
|
||||
let source = "with 1 as x: pass";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assign_named_expr() {
|
||||
let source = "if x:= 1: pass";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ann_assign_name() {
|
||||
let source = "x: int = 1";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_aug_assign_name() {
|
||||
let source = "x += 1";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_aug_assign_attribute() {
|
||||
let source = "x.y += (1, 2, 3)";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_aug_assign_subscript() {
|
||||
let source = "x[y] += (1, 2, 3)";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_del_name() {
|
||||
let source = "del x";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_del_attribute() {
|
||||
let source = "del x.y";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_del_subscript() {
|
||||
let source = "del x[y]";
|
||||
let parse_ast = ast::Suite::parse(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
}
|
216
crates/ruff_python_parser/src/function.rs
Normal file
216
crates/ruff_python_parser/src/function.rs
Normal file
|
@ -0,0 +1,216 @@
|
|||
use std::hash::BuildHasherDefault;
|
||||
// Contains functions that perform validation and parsing of arguments and parameters.
|
||||
// Checks apply both to functions and to lambdas.
|
||||
use crate::lexer::{LexicalError, LexicalErrorType};
|
||||
use ruff_python_ast::{self as ast, Ranged};
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
pub(crate) struct ArgumentList {
|
||||
pub(crate) args: Vec<ast::Expr>,
|
||||
pub(crate) keywords: Vec<ast::Keyword>,
|
||||
}
|
||||
|
||||
// Perform validation of function/lambda arguments in a function definition.
|
||||
pub(crate) fn validate_arguments(arguments: &ast::Arguments) -> Result<(), LexicalError> {
|
||||
let mut all_arg_names = FxHashSet::with_capacity_and_hasher(
|
||||
arguments.posonlyargs.len()
|
||||
+ arguments.args.len()
|
||||
+ usize::from(arguments.vararg.is_some())
|
||||
+ arguments.kwonlyargs.len()
|
||||
+ usize::from(arguments.kwarg.is_some()),
|
||||
BuildHasherDefault::default(),
|
||||
);
|
||||
|
||||
let posonlyargs = arguments.posonlyargs.iter();
|
||||
let args = arguments.args.iter();
|
||||
let kwonlyargs = arguments.kwonlyargs.iter();
|
||||
|
||||
let vararg: Option<&ast::Arg> = arguments.vararg.as_deref();
|
||||
let kwarg: Option<&ast::Arg> = arguments.kwarg.as_deref();
|
||||
|
||||
for arg in posonlyargs
|
||||
.chain(args)
|
||||
.chain(kwonlyargs)
|
||||
.map(|arg| &arg.def)
|
||||
.chain(vararg)
|
||||
.chain(kwarg)
|
||||
{
|
||||
let range = arg.range;
|
||||
let arg_name = arg.arg.as_str();
|
||||
if !all_arg_names.insert(arg_name) {
|
||||
return Err(LexicalError {
|
||||
error: LexicalErrorType::DuplicateArgumentError(arg_name.to_string()),
|
||||
location: range.start(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn validate_pos_params(
|
||||
args: &(Vec<ast::ArgWithDefault>, Vec<ast::ArgWithDefault>),
|
||||
) -> Result<(), LexicalError> {
|
||||
let (posonlyargs, args) = args;
|
||||
#[allow(clippy::skip_while_next)]
|
||||
let first_invalid = posonlyargs
|
||||
.iter()
|
||||
.chain(args.iter()) // for all args
|
||||
.skip_while(|arg| arg.default.is_none()) // starting with args without default
|
||||
.skip_while(|arg| arg.default.is_some()) // and then args with default
|
||||
.next(); // there must not be any more args without default
|
||||
if let Some(invalid) = first_invalid {
|
||||
return Err(LexicalError {
|
||||
error: LexicalErrorType::DefaultArgumentError,
|
||||
location: invalid.def.range.start(),
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
type FunctionArgument = (
|
||||
Option<(TextSize, TextSize, Option<ast::Identifier>)>,
|
||||
ast::Expr,
|
||||
);
|
||||
|
||||
// Parse arguments as supplied during a function/lambda *call*.
|
||||
pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentList, LexicalError> {
|
||||
let mut args = vec![];
|
||||
let mut keywords = vec![];
|
||||
|
||||
let mut keyword_names =
|
||||
FxHashSet::with_capacity_and_hasher(func_args.len(), BuildHasherDefault::default());
|
||||
let mut double_starred = false;
|
||||
for (name, value) in func_args {
|
||||
if let Some((start, end, name)) = name {
|
||||
// Check for duplicate keyword arguments in the call.
|
||||
if let Some(keyword_name) = &name {
|
||||
if !keyword_names.insert(keyword_name.to_string()) {
|
||||
return Err(LexicalError {
|
||||
error: LexicalErrorType::DuplicateKeywordArgumentError(
|
||||
keyword_name.to_string(),
|
||||
),
|
||||
location: start,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
double_starred = true;
|
||||
}
|
||||
|
||||
keywords.push(ast::Keyword {
|
||||
arg: name,
|
||||
value,
|
||||
range: TextRange::new(start, end),
|
||||
});
|
||||
} else {
|
||||
// Positional arguments mustn't follow keyword arguments.
|
||||
if !keywords.is_empty() && !is_starred(&value) {
|
||||
return Err(LexicalError {
|
||||
error: LexicalErrorType::PositionalArgumentError,
|
||||
location: value.start(),
|
||||
});
|
||||
// Allow starred arguments after keyword arguments but
|
||||
// not after double-starred arguments.
|
||||
} else if double_starred {
|
||||
return Err(LexicalError {
|
||||
error: LexicalErrorType::UnpackedArgumentError,
|
||||
location: value.start(),
|
||||
});
|
||||
}
|
||||
|
||||
args.push(value);
|
||||
}
|
||||
}
|
||||
Ok(ArgumentList { args, keywords })
|
||||
}
|
||||
|
||||
// Check if an expression is a starred expression.
|
||||
const fn is_starred(exp: &ast::Expr) -> bool {
|
||||
exp.is_starred_expr()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{Parse, ParseErrorType};
|
||||
use ruff_python_ast::{self as ast};
|
||||
|
||||
macro_rules! function_and_lambda {
|
||||
($($name:ident: $code:expr,)*) => {
|
||||
$(
|
||||
#[test]
|
||||
fn $name() {
|
||||
let parse_ast = ast::Suite::parse($code, "<test>");
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
function_and_lambda! {
|
||||
test_function_no_args_with_ranges: "def f(): pass",
|
||||
test_function_pos_args_with_ranges: "def f(a, b, c): pass",
|
||||
}
|
||||
|
||||
function_and_lambda! {
|
||||
test_function_no_args: "def f(): pass",
|
||||
test_function_pos_args: "def f(a, b, c): pass",
|
||||
test_function_pos_args_with_defaults: "def f(a, b=20, c=30): pass",
|
||||
test_function_kw_only_args: "def f(*, a, b, c): pass",
|
||||
test_function_kw_only_args_with_defaults: "def f(*, a, b=20, c=30): pass",
|
||||
test_function_pos_and_kw_only_args: "def f(a, b, c, *, d, e, f): pass",
|
||||
test_function_pos_and_kw_only_args_with_defaults: "def f(a, b, c, *, d, e=20, f=30): pass",
|
||||
test_function_pos_and_kw_only_args_with_defaults_and_varargs: "def f(a, b, c, *args, d, e=20, f=30): pass",
|
||||
test_function_pos_and_kw_only_args_with_defaults_and_varargs_and_kwargs: "def f(a, b, c, *args, d, e=20, f=30, **kwargs): pass",
|
||||
test_lambda_no_args: "lambda: 1",
|
||||
test_lambda_pos_args: "lambda a, b, c: 1",
|
||||
test_lambda_pos_args_with_defaults: "lambda a, b=20, c=30: 1",
|
||||
test_lambda_kw_only_args: "lambda *, a, b, c: 1",
|
||||
test_lambda_kw_only_args_with_defaults: "lambda *, a, b=20, c=30: 1",
|
||||
test_lambda_pos_and_kw_only_args: "lambda a, b, c, *, d, e: 0",
|
||||
}
|
||||
|
||||
fn function_parse_error(src: &str) -> LexicalErrorType {
|
||||
let parse_ast = ast::Suite::parse(src, "<test>");
|
||||
parse_ast
|
||||
.map_err(|e| match e.error {
|
||||
ParseErrorType::Lexical(e) => e,
|
||||
_ => panic!("Expected LexicalError"),
|
||||
})
|
||||
.expect_err("Expected error")
|
||||
}
|
||||
|
||||
macro_rules! function_and_lambda_error {
|
||||
($($name:ident: $code:expr, $error:expr,)*) => {
|
||||
$(
|
||||
#[test]
|
||||
fn $name() {
|
||||
let error = function_parse_error($code);
|
||||
assert_eq!(error, $error);
|
||||
}
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
function_and_lambda_error! {
|
||||
// Check definitions
|
||||
test_duplicates_f1: "def f(a, a): pass", LexicalErrorType::DuplicateArgumentError("a".to_string()),
|
||||
test_duplicates_f2: "def f(a, *, a): pass", LexicalErrorType::DuplicateArgumentError("a".to_string()),
|
||||
test_duplicates_f3: "def f(a, a=20): pass", LexicalErrorType::DuplicateArgumentError("a".to_string()),
|
||||
test_duplicates_f4: "def f(a, *a): pass", LexicalErrorType::DuplicateArgumentError("a".to_string()),
|
||||
test_duplicates_f5: "def f(a, *, **a): pass", LexicalErrorType::DuplicateArgumentError("a".to_string()),
|
||||
test_duplicates_l1: "lambda a, a: 1", LexicalErrorType::DuplicateArgumentError("a".to_string()),
|
||||
test_duplicates_l2: "lambda a, *, a: 1", LexicalErrorType::DuplicateArgumentError("a".to_string()),
|
||||
test_duplicates_l3: "lambda a, a=20: 1", LexicalErrorType::DuplicateArgumentError("a".to_string()),
|
||||
test_duplicates_l4: "lambda a, *a: 1", LexicalErrorType::DuplicateArgumentError("a".to_string()),
|
||||
test_duplicates_l5: "lambda a, *, **a: 1", LexicalErrorType::DuplicateArgumentError("a".to_string()),
|
||||
test_default_arg_error_f: "def f(a, b=20, c): pass", LexicalErrorType::DefaultArgumentError,
|
||||
test_default_arg_error_l: "lambda a, b=20, c: 1", LexicalErrorType::DefaultArgumentError,
|
||||
|
||||
// Check some calls.
|
||||
test_positional_arg_error_f: "f(b=20, c)", LexicalErrorType::PositionalArgumentError,
|
||||
test_unpacked_arg_error_f: "f(**b, *c)", LexicalErrorType::UnpackedArgumentError,
|
||||
test_duplicate_kw_f1: "f(a=20, a=30)", LexicalErrorType::DuplicateKeywordArgumentError("a".to_string()),
|
||||
}
|
||||
}
|
1922
crates/ruff_python_parser/src/lexer.rs
Normal file
1922
crates/ruff_python_parser/src/lexer.rs
Normal file
File diff suppressed because it is too large
Load diff
107
crates/ruff_python_parser/src/lexer/cursor.rs
Normal file
107
crates/ruff_python_parser/src/lexer/cursor.rs
Normal file
|
@ -0,0 +1,107 @@
|
|||
use ruff_text_size::{TextLen, TextSize};
|
||||
use std::str::Chars;
|
||||
|
||||
pub(crate) const EOF_CHAR: char = '\0';
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(super) struct Cursor<'a> {
|
||||
chars: Chars<'a>,
|
||||
source_length: TextSize,
|
||||
#[cfg(debug_assertions)]
|
||||
prev_char: char,
|
||||
}
|
||||
|
||||
impl<'a> Cursor<'a> {
|
||||
pub(crate) fn new(source: &'a str) -> Self {
|
||||
Self {
|
||||
source_length: source.text_len(),
|
||||
chars: source.chars(),
|
||||
#[cfg(debug_assertions)]
|
||||
prev_char: EOF_CHAR,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the previous token. Useful for debug assertions.
|
||||
#[cfg(debug_assertions)]
|
||||
pub(super) const fn previous(&self) -> char {
|
||||
self.prev_char
|
||||
}
|
||||
|
||||
/// Peeks the next character from the input stream without consuming it.
|
||||
/// Returns [`EOF_CHAR`] if the file is at the end of the file.
|
||||
pub(super) fn first(&self) -> char {
|
||||
self.chars.clone().next().unwrap_or(EOF_CHAR)
|
||||
}
|
||||
|
||||
/// Peeks the second character from the input stream without consuming it.
|
||||
/// Returns [`EOF_CHAR`] if the position is past the end of the file.
|
||||
pub(super) fn second(&self) -> char {
|
||||
let mut chars = self.chars.clone();
|
||||
chars.next();
|
||||
chars.next().unwrap_or(EOF_CHAR)
|
||||
}
|
||||
|
||||
/// Returns the remaining text to lex.
|
||||
pub(super) fn rest(&self) -> &'a str {
|
||||
self.chars.as_str()
|
||||
}
|
||||
|
||||
// SAFETY: The `source.text_len` call in `new` would panic if the string length is larger than a `u32`.
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
pub(super) fn text_len(&self) -> TextSize {
|
||||
TextSize::new(self.chars.as_str().len() as u32)
|
||||
}
|
||||
|
||||
pub(super) fn token_len(&self) -> TextSize {
|
||||
self.source_length - self.text_len()
|
||||
}
|
||||
|
||||
pub(super) fn start_token(&mut self) {
|
||||
self.source_length = self.text_len();
|
||||
}
|
||||
|
||||
pub(super) fn is_eof(&self) -> bool {
|
||||
self.chars.as_str().is_empty()
|
||||
}
|
||||
|
||||
/// Consumes the next character
|
||||
pub(super) fn bump(&mut self) -> Option<char> {
|
||||
let prev = self.chars.next()?;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
self.prev_char = prev;
|
||||
}
|
||||
|
||||
Some(prev)
|
||||
}
|
||||
|
||||
pub(super) fn eat_char(&mut self, c: char) -> bool {
|
||||
if self.first() == c {
|
||||
self.bump();
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn eat_if<F>(&mut self, mut predicate: F) -> Option<char>
|
||||
where
|
||||
F: FnMut(char) -> bool,
|
||||
{
|
||||
if predicate(self.first()) && !self.is_eof() {
|
||||
self.bump()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Eats symbols while predicate returns true or until the end of file is reached.
|
||||
pub(super) fn eat_while(&mut self, mut predicate: impl FnMut(char) -> bool) {
|
||||
// It was tried making optimized version of this for eg. line comments, but
|
||||
// LLVM can inline all of this and compile it down to fast iteration over bytes.
|
||||
while predicate(self.first()) && !self.is_eof() {
|
||||
self.bump();
|
||||
}
|
||||
}
|
||||
}
|
126
crates/ruff_python_parser/src/lexer/indentation.rs
Normal file
126
crates/ruff_python_parser/src/lexer/indentation.rs
Normal file
|
@ -0,0 +1,126 @@
|
|||
use static_assertions::assert_eq_size;
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// The column index of an indentation.
|
||||
///
|
||||
/// A space increments the column by one. A tab adds up to 2 (if tab size is 2) indices, but just one
|
||||
/// if the column isn't even.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Default)]
|
||||
pub(super) struct Column(u32);
|
||||
|
||||
impl Column {
|
||||
pub(super) const fn new(column: u32) -> Self {
|
||||
Self(column)
|
||||
}
|
||||
}
|
||||
|
||||
/// The number of characters in an indentation. Each character accounts for 1.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Default)]
|
||||
pub(super) struct Character(u32);
|
||||
|
||||
impl Character {
|
||||
pub(super) const fn new(characters: u32) -> Self {
|
||||
Self(characters)
|
||||
}
|
||||
}
|
||||
|
||||
/// The [Indentation](https://docs.python.org/3/reference/lexical_analysis.html#indentation) of a logical line.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
|
||||
pub(super) struct Indentation {
|
||||
column: Column,
|
||||
character: Character,
|
||||
}
|
||||
|
||||
impl Indentation {
|
||||
const TAB_SIZE: u32 = 2;
|
||||
|
||||
pub(super) const fn root() -> Self {
|
||||
Self {
|
||||
column: Column::new(0),
|
||||
character: Character::new(0),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(super) const fn new(column: Column, character: Character) -> Self {
|
||||
Self { column, character }
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub(super) fn add_space(self) -> Self {
|
||||
Self {
|
||||
character: Character(self.character.0 + 1),
|
||||
column: Column(self.column.0 + 1),
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub(super) fn add_tab(self) -> Self {
|
||||
Self {
|
||||
character: Character(self.character.0 + 1),
|
||||
// Compute the column index:
|
||||
// * Adds `TAB_SIZE` if `column` is a multiple of `TAB_SIZE`
|
||||
// * Rounds `column` up to the next multiple of `TAB_SIZE` otherwise.
|
||||
// https://github.com/python/cpython/blob/2cf99026d6320f38937257da1ab014fc873a11a6/Parser/tokenizer.c#L1818
|
||||
column: Column((self.column.0 / Self::TAB_SIZE + 1) * Self::TAB_SIZE),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn try_compare(self, other: Indentation) -> Result<Ordering, UnexpectedIndentation> {
|
||||
let column_ordering = self.column.cmp(&other.column);
|
||||
let character_ordering = self.character.cmp(&other.character);
|
||||
|
||||
if column_ordering == character_ordering {
|
||||
Ok(column_ordering)
|
||||
} else {
|
||||
Err(UnexpectedIndentation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub(super) struct UnexpectedIndentation;
|
||||
|
||||
// The indentations stack is used to keep track of the current indentation level
|
||||
// [See Indentation](docs.python.org/3/reference/lexical_analysis.html#indentation).
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub(super) struct Indentations {
|
||||
stack: Vec<Indentation>,
|
||||
}
|
||||
|
||||
impl Indentations {
|
||||
pub(super) fn push(&mut self, indent: Indentation) {
|
||||
debug_assert_eq!(self.current().try_compare(indent), Ok(Ordering::Less));
|
||||
|
||||
self.stack.push(indent);
|
||||
}
|
||||
|
||||
pub(super) fn pop(&mut self) -> Option<Indentation> {
|
||||
self.stack.pop()
|
||||
}
|
||||
|
||||
pub(super) fn current(&self) -> &Indentation {
|
||||
static ROOT: Indentation = Indentation::root();
|
||||
self.stack.last().unwrap_or(&ROOT)
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq_size!(Indentation, u64);
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{Character, Column, Indentation};
|
||||
use std::cmp::Ordering;
|
||||
|
||||
#[test]
|
||||
fn indentation_try_compare() {
|
||||
let tab = Indentation::new(Column::new(8), Character::new(1));
|
||||
|
||||
assert_eq!(tab.try_compare(tab), Ok(Ordering::Equal));
|
||||
|
||||
let two_tabs = Indentation::new(Column::new(16), Character::new(2));
|
||||
assert_eq!(two_tabs.try_compare(tab), Ok(Ordering::Greater));
|
||||
assert_eq!(tab.try_compare(two_tabs), Ok(Ordering::Less));
|
||||
}
|
||||
}
|
|
@ -1,11 +1,134 @@
|
|||
use rustpython_ast::text_size::TextSize;
|
||||
use rustpython_ast::{CmpOp, Expr, Mod, ModModule, Ranged, Suite};
|
||||
use rustpython_parser as parser;
|
||||
use rustpython_parser::lexer::LexResult;
|
||||
use rustpython_parser::text_size::TextRange;
|
||||
use rustpython_parser::{lexer, Mode, ParseError, Tok};
|
||||
//! This crate can be used to parse Python source code into an Abstract
|
||||
//! Syntax Tree.
|
||||
//!
|
||||
//! ## Overview:
|
||||
//!
|
||||
//! The process by which source code is parsed into an AST can be broken down
|
||||
//! into two general stages: [lexical analysis] and [parsing].
|
||||
//!
|
||||
//! During lexical analysis, the source code is converted into a stream of lexical
|
||||
//! tokens that represent the smallest meaningful units of the language. For example,
|
||||
//! the source code `print("Hello world")` would _roughly_ be converted into the following
|
||||
//! stream of tokens:
|
||||
//!
|
||||
//! ```text
|
||||
//! Name("print"), LeftParen, String("Hello world"), RightParen
|
||||
//! ```
|
||||
//!
|
||||
//! these tokens are then consumed by the `ruff_python_parser`, which matches them against a set of
|
||||
//! grammar rules to verify that the source code is syntactically valid and to construct
|
||||
//! an AST that represents the source code.
|
||||
//!
|
||||
//! During parsing, the `ruff_python_parser` consumes the tokens generated by the lexer and constructs
|
||||
//! a tree representation of the source code. The tree is made up of nodes that represent
|
||||
//! the different syntactic constructs of the language. If the source code is syntactically
|
||||
//! invalid, parsing fails and an error is returned. After a successful parse, the AST can
|
||||
//! be used to perform further analysis on the source code. Continuing with the example
|
||||
//! above, the AST generated by the `ruff_python_parser` would _roughly_ look something like this:
|
||||
//!
|
||||
//! ```text
|
||||
//! node: Expr {
|
||||
//! value: {
|
||||
//! node: Call {
|
||||
//! func: {
|
||||
//! node: Name {
|
||||
//! id: "print",
|
||||
//! ctx: Load,
|
||||
//! },
|
||||
//! },
|
||||
//! args: [
|
||||
//! node: Constant {
|
||||
//! value: Str("Hello World"),
|
||||
//! kind: None,
|
||||
//! },
|
||||
//! ],
|
||||
//! keywords: [],
|
||||
//! },
|
||||
//! },
|
||||
//! },
|
||||
//!```
|
||||
//!
|
||||
//! Note: The Tokens/ASTs shown above are not the exact tokens/ASTs generated by the `ruff_python_parser`.
|
||||
//!
|
||||
//! ## Source code layout:
|
||||
//!
|
||||
//! The functionality of this crate is split into several modules:
|
||||
//!
|
||||
//! - token: This module contains the definition of the tokens that are generated by the lexer.
|
||||
//! - [lexer]: This module contains the lexer and is responsible for generating the tokens.
|
||||
//! - `ruff_python_parser`: This module contains an interface to the `ruff_python_parser` and is responsible for generating the AST.
|
||||
//! - Functions and strings have special parsing requirements that are handled in additional files.
|
||||
//! - mode: This module contains the definition of the different modes that the `ruff_python_parser` can be in.
|
||||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
//! For example, to get a stream of tokens from a given string, one could do this:
|
||||
//!
|
||||
//! ```
|
||||
//! use ruff_python_parser::{lexer::lex, Mode};
|
||||
//!
|
||||
//! let python_source = r#"
|
||||
//! def is_odd(i):
|
||||
//! return bool(i & 1)
|
||||
//! "#;
|
||||
//! let mut tokens = lex(python_source, Mode::Module);
|
||||
//! assert!(tokens.all(|t| t.is_ok()));
|
||||
//! ```
|
||||
//!
|
||||
//! These tokens can be directly fed into the `ruff_python_parser` to generate an AST:
|
||||
//!
|
||||
//! ```
|
||||
//! use ruff_python_parser::{lexer::lex, Mode, parse_tokens};
|
||||
//!
|
||||
//! let python_source = r#"
|
||||
//! def is_odd(i):
|
||||
//! return bool(i & 1)
|
||||
//! "#;
|
||||
//! let tokens = lex(python_source, Mode::Module);
|
||||
//! let ast = parse_tokens(tokens, Mode::Module, "<embedded>");
|
||||
//!
|
||||
//! assert!(ast.is_ok());
|
||||
//! ```
|
||||
//!
|
||||
//! Alternatively, you can use one of the other `parse_*` functions to parse a string directly without using a specific
|
||||
//! mode or tokenizing the source beforehand:
|
||||
//!
|
||||
//! ```
|
||||
//! use ruff_python_parser::{Parse};
|
||||
//! use ruff_python_ast as ast;
|
||||
//!
|
||||
//! let python_source = r#"
|
||||
//! def is_odd(i):
|
||||
//! return bool(i & 1)
|
||||
//! "#;
|
||||
//! let ast = ast::Suite::parse(python_source, "<embedded>");
|
||||
//!
|
||||
//! assert!(ast.is_ok());
|
||||
//! ```
|
||||
//!
|
||||
//! [lexical analysis]: https://en.wikipedia.org/wiki/Lexical_analysis
|
||||
//! [parsing]: https://en.wikipedia.org/wiki/Parsing
|
||||
//! [lexer]: crate::lexer
|
||||
|
||||
pub mod token_kind;
|
||||
use crate::lexer::LexResult;
|
||||
pub use parse::Parse;
|
||||
pub use parser::{parse, parse_starts_at, parse_tokens, ParseError, ParseErrorType};
|
||||
#[allow(deprecated)]
|
||||
pub use parser::{parse_expression, parse_expression_starts_at, parse_program};
|
||||
use ruff_python_ast::{CmpOp, Expr, Mod, ModModule, Ranged, Suite};
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
pub use string::FStringErrorType;
|
||||
pub use token::{StringKind, Tok, TokenKind};
|
||||
|
||||
mod function;
|
||||
// Skip flattening lexer to distinguish from full ruff_python_parser
|
||||
mod context;
|
||||
pub mod lexer;
|
||||
mod parse;
|
||||
mod parser;
|
||||
mod soft_keywords;
|
||||
mod string;
|
||||
mod token;
|
||||
pub mod typing;
|
||||
|
||||
/// Collect tokens up to and including the first error.
|
||||
|
@ -141,15 +264,97 @@ impl LocatedCmpOp {
|
|||
}
|
||||
}
|
||||
|
||||
/// Control in the different modes by which a source file can be parsed.
|
||||
/// The mode argument specifies in what way code must be parsed.
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub enum Mode {
|
||||
/// The code consists of a sequence of statements.
|
||||
Module,
|
||||
/// The code consists of a sequence of interactive statement.
|
||||
Interactive,
|
||||
/// The code consists of a single expression.
|
||||
Expression,
|
||||
/// The code consists of a sequence of statements which are part of a
|
||||
/// Jupyter Notebook and thus could include escape commands scoped to
|
||||
/// a single line.
|
||||
///
|
||||
/// ## Limitations:
|
||||
///
|
||||
/// For [Dynamic object information], the escape characters (`?`, `??`)
|
||||
/// must be used before an object. For example, `?foo` will be recognized,
|
||||
/// but `foo?` will not.
|
||||
///
|
||||
/// ## Supported escape commands:
|
||||
///
|
||||
/// - [Magic command system] which is limited to [line magics] and can start
|
||||
/// with `?` or `??`.
|
||||
/// - [Dynamic object information] which can start with `?` or `??`.
|
||||
/// - [System shell access] which can start with `!` or `!!`.
|
||||
/// - [Automatic parentheses and quotes] which can start with `/`, `;`, or `,`.
|
||||
///
|
||||
/// [Magic command system]: https://ipython.readthedocs.io/en/stable/interactive/reference.html#magic-command-system
|
||||
/// [line magics]: https://ipython.readthedocs.io/en/stable/interactive/magics.html#line-magics
|
||||
/// [Dynamic object information]: https://ipython.readthedocs.io/en/stable/interactive/reference.html#dynamic-object-information
|
||||
/// [System shell access]: https://ipython.readthedocs.io/en/stable/interactive/reference.html#system-shell-access
|
||||
/// [Automatic parentheses and quotes]: https://ipython.readthedocs.io/en/stable/interactive/reference.html#automatic-parentheses-and-quotes
|
||||
Jupyter,
|
||||
}
|
||||
|
||||
impl std::str::FromStr for Mode {
|
||||
type Err = ModeParseError;
|
||||
fn from_str(s: &str) -> Result<Self, ModeParseError> {
|
||||
match s {
|
||||
"exec" | "single" => Ok(Mode::Module),
|
||||
"eval" => Ok(Mode::Expression),
|
||||
"jupyter" => Ok(Mode::Jupyter),
|
||||
_ => Err(ModeParseError),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returned when a given mode is not valid.
|
||||
#[derive(Debug)]
|
||||
pub struct ModeParseError;
|
||||
|
||||
impl std::fmt::Display for ModeParseError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, r#"mode must be "exec", "eval", "jupyter", or "single""#)
|
||||
}
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[allow(unreachable_pub)]
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[allow(clippy::extra_unused_lifetimes)]
|
||||
#[allow(clippy::needless_lifetimes)]
|
||||
#[allow(clippy::unused_self)]
|
||||
#[allow(clippy::cast_sign_loss)]
|
||||
#[allow(clippy::default_trait_access)]
|
||||
#[allow(clippy::let_unit_value)]
|
||||
#[allow(clippy::just_underscores_and_digits)]
|
||||
#[allow(clippy::no_effect_underscore_binding)]
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
#[allow(clippy::option_option)]
|
||||
#[allow(clippy::unnecessary_wraps)]
|
||||
#[allow(clippy::uninlined_format_args)]
|
||||
#[allow(clippy::cloned_instead_of_copied)]
|
||||
mod python {
|
||||
|
||||
#[cfg(feature = "lalrpop")]
|
||||
include!(concat!(env!("OUT_DIR"), "/src/python.rs"));
|
||||
|
||||
#[cfg(not(feature = "lalrpop"))]
|
||||
include!("python.rs");
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::Parse;
|
||||
use crate::{first_colon_range, locate_cmp_ops, LocatedCmpOp};
|
||||
use anyhow::Result;
|
||||
use ruff_text_size::TextSize;
|
||||
use rustpython_ast::text_size::{TextLen, TextRange};
|
||||
use rustpython_ast::CmpOp;
|
||||
use rustpython_ast::Expr;
|
||||
use rustpython_parser::Parse;
|
||||
use ruff_python_ast::CmpOp;
|
||||
use ruff_python_ast::Expr;
|
||||
use ruff_text_size::{TextLen, TextRange, TextSize};
|
||||
|
||||
#[test]
|
||||
fn extract_first_colon_range() {
|
||||
|
|
1190
crates/ruff_python_parser/src/parse.rs
Normal file
1190
crates/ruff_python_parser/src/parse.rs
Normal file
File diff suppressed because it is too large
Load diff
1214
crates/ruff_python_parser/src/parser.rs
Normal file
1214
crates/ruff_python_parser/src/parser.rs
Normal file
File diff suppressed because it is too large
Load diff
1852
crates/ruff_python_parser/src/python.lalrpop
Normal file
1852
crates/ruff_python_parser/src/python.lalrpop
Normal file
File diff suppressed because it is too large
Load diff
72834
crates/ruff_python_parser/src/python.rs
Normal file
72834
crates/ruff_python_parser/src/python.rs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
AnnAssign(
|
||||
StmtAnnAssign {
|
||||
range: 0..10,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
annotation: Name(
|
||||
ExprName {
|
||||
range: 3..6,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
value: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 9..10,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
simple: true,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,66 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..15,
|
||||
targets: [
|
||||
Attribute(
|
||||
ExprAttribute {
|
||||
range: 0..3,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "y",
|
||||
range: 2..3,
|
||||
},
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 6..15,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 7..8,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 10..11,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 13..14,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,62 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
For(
|
||||
StmtFor {
|
||||
range: 0..24,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 4..5,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Tuple(
|
||||
ExprTuple {
|
||||
range: 9..18,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 10..11,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 13..14,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 16..17,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 20..24,
|
||||
},
|
||||
),
|
||||
],
|
||||
orelse: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..18,
|
||||
targets: [
|
||||
List(
|
||||
ExprList {
|
||||
range: 0..6,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 1..2,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 4..5,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 9..18,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 10..11,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 13..14,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 16..17,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,82 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..26,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: ListComp(
|
||||
ExprListComp {
|
||||
range: 4..26,
|
||||
elt: Name(
|
||||
ExprName {
|
||||
range: 5..6,
|
||||
id: "y",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
generators: [
|
||||
Comprehension {
|
||||
range: 7..25,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 11..12,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Tuple(
|
||||
ExprTuple {
|
||||
range: 16..25,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 17..18,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 20..21,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 23..24,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ifs: [],
|
||||
is_async: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,56 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..13,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 4..13,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 5..6,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 8..9,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 11..12,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
If(
|
||||
StmtIf {
|
||||
range: 0..14,
|
||||
test: NamedExpr(
|
||||
ExprNamedExpr {
|
||||
range: 3..8,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 3..4,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 7..8,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 10..14,
|
||||
},
|
||||
),
|
||||
],
|
||||
elif_else_clauses: [],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,82 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..26,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: SetComp(
|
||||
ExprSetComp {
|
||||
range: 4..26,
|
||||
elt: Name(
|
||||
ExprName {
|
||||
range: 5..6,
|
||||
id: "y",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
generators: [
|
||||
Comprehension {
|
||||
range: 7..25,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 11..12,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Tuple(
|
||||
ExprTuple {
|
||||
range: 16..25,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 17..18,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 20..21,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 23..24,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ifs: [],
|
||||
is_async: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,77 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..19,
|
||||
targets: [
|
||||
Tuple(
|
||||
ExprTuple {
|
||||
range: 0..7,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 1..2,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
Starred(
|
||||
ExprStarred {
|
||||
range: 4..6,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 5..6,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 10..19,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 11..12,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 14..15,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 17..18,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,69 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..16,
|
||||
targets: [
|
||||
Subscript(
|
||||
ExprSubscript {
|
||||
range: 0..4,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Name(
|
||||
ExprName {
|
||||
range: 2..3,
|
||||
id: "y",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 7..16,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 8..9,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 11..12,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 14..15,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..18,
|
||||
targets: [
|
||||
Tuple(
|
||||
ExprTuple {
|
||||
range: 0..6,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 1..2,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 4..5,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 9..18,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 10..11,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 13..14,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 16..17,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
With(
|
||||
StmtWith {
|
||||
range: 0..17,
|
||||
items: [
|
||||
WithItem {
|
||||
range: 5..11,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
range: 5..6,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
optional_vars: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 10..11,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 13..17,
|
||||
},
|
||||
),
|
||||
],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,64 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
AugAssign(
|
||||
StmtAugAssign {
|
||||
range: 0..16,
|
||||
target: Attribute(
|
||||
ExprAttribute {
|
||||
range: 0..3,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "y",
|
||||
range: 2..3,
|
||||
},
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 7..16,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 8..9,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 11..12,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 14..15,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
AugAssign(
|
||||
StmtAugAssign {
|
||||
range: 0..6,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 5..6,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,67 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
AugAssign(
|
||||
StmtAugAssign {
|
||||
range: 0..17,
|
||||
target: Subscript(
|
||||
ExprSubscript {
|
||||
range: 0..4,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Name(
|
||||
ExprName {
|
||||
range: 2..3,
|
||||
id: "y",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 8..17,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 9..10,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 12..13,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 15..16,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Delete(
|
||||
StmtDelete {
|
||||
range: 0..7,
|
||||
targets: [
|
||||
Attribute(
|
||||
ExprAttribute {
|
||||
range: 4..7,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 4..5,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "y",
|
||||
range: 6..7,
|
||||
},
|
||||
ctx: Del,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Delete(
|
||||
StmtDelete {
|
||||
range: 0..5,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 4..5,
|
||||
id: "x",
|
||||
ctx: Del,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Delete(
|
||||
StmtDelete {
|
||||
range: 0..8,
|
||||
targets: [
|
||||
Subscript(
|
||||
ExprSubscript {
|
||||
range: 4..8,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 4..5,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Name(
|
||||
ExprName {
|
||||
range: 6..7,
|
||||
id: "y",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Del,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,76 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..23,
|
||||
name: Identifier {
|
||||
id: "f",
|
||||
range: 4..5,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 5..17,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [
|
||||
ArgWithDefault {
|
||||
range: 9..10,
|
||||
def: Arg {
|
||||
range: 9..10,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 9..10,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 12..13,
|
||||
def: Arg {
|
||||
range: 12..13,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 12..13,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 15..16,
|
||||
def: Arg {
|
||||
range: 15..16,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 15..16,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 19..23,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,96 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..29,
|
||||
name: Identifier {
|
||||
id: "f",
|
||||
range: 4..5,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 5..23,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [
|
||||
ArgWithDefault {
|
||||
range: 9..10,
|
||||
def: Arg {
|
||||
range: 9..10,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 9..10,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 12..16,
|
||||
def: Arg {
|
||||
range: 12..13,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 12..13,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 14..16,
|
||||
value: Int(
|
||||
20,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 18..22,
|
||||
def: Arg {
|
||||
range: 18..19,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 18..19,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 20..22,
|
||||
value: Int(
|
||||
30,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 25..29,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..13,
|
||||
name: Identifier {
|
||||
id: "f",
|
||||
range: 4..5,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 5..7,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 9..13,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..13,
|
||||
name: Identifier {
|
||||
id: "f",
|
||||
range: 4..5,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 5..7,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 9..13,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,116 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..32,
|
||||
name: Identifier {
|
||||
id: "f",
|
||||
range: 4..5,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 5..26,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 6..7,
|
||||
def: Arg {
|
||||
range: 6..7,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 6..7,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 9..10,
|
||||
def: Arg {
|
||||
range: 9..10,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 9..10,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 12..13,
|
||||
def: Arg {
|
||||
range: 12..13,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 12..13,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [
|
||||
ArgWithDefault {
|
||||
range: 18..19,
|
||||
def: Arg {
|
||||
range: 18..19,
|
||||
arg: Identifier {
|
||||
id: "d",
|
||||
range: 18..19,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 21..22,
|
||||
def: Arg {
|
||||
range: 21..22,
|
||||
arg: Identifier {
|
||||
id: "e",
|
||||
range: 21..22,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 24..25,
|
||||
def: Arg {
|
||||
range: 24..25,
|
||||
arg: Identifier {
|
||||
id: "f",
|
||||
range: 24..25,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 28..32,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,136 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..38,
|
||||
name: Identifier {
|
||||
id: "f",
|
||||
range: 4..5,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 5..32,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 6..7,
|
||||
def: Arg {
|
||||
range: 6..7,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 6..7,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 9..10,
|
||||
def: Arg {
|
||||
range: 9..10,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 9..10,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 12..13,
|
||||
def: Arg {
|
||||
range: 12..13,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 12..13,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [
|
||||
ArgWithDefault {
|
||||
range: 18..19,
|
||||
def: Arg {
|
||||
range: 18..19,
|
||||
arg: Identifier {
|
||||
id: "d",
|
||||
range: 18..19,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 21..25,
|
||||
def: Arg {
|
||||
range: 21..22,
|
||||
arg: Identifier {
|
||||
id: "e",
|
||||
range: 21..22,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 23..25,
|
||||
value: Int(
|
||||
20,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 27..31,
|
||||
def: Arg {
|
||||
range: 27..28,
|
||||
arg: Identifier {
|
||||
id: "f",
|
||||
range: 27..28,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 29..31,
|
||||
value: Int(
|
||||
30,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 34..38,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,146 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..42,
|
||||
name: Identifier {
|
||||
id: "f",
|
||||
range: 4..5,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 5..36,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 6..7,
|
||||
def: Arg {
|
||||
range: 6..7,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 6..7,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 9..10,
|
||||
def: Arg {
|
||||
range: 9..10,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 9..10,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 12..13,
|
||||
def: Arg {
|
||||
range: 12..13,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 12..13,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: Some(
|
||||
Arg {
|
||||
range: 16..20,
|
||||
arg: Identifier {
|
||||
id: "args",
|
||||
range: 16..20,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
kwonlyargs: [
|
||||
ArgWithDefault {
|
||||
range: 22..23,
|
||||
def: Arg {
|
||||
range: 22..23,
|
||||
arg: Identifier {
|
||||
id: "d",
|
||||
range: 22..23,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 25..29,
|
||||
def: Arg {
|
||||
range: 25..26,
|
||||
arg: Identifier {
|
||||
id: "e",
|
||||
range: 25..26,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 27..29,
|
||||
value: Int(
|
||||
20,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 31..35,
|
||||
def: Arg {
|
||||
range: 31..32,
|
||||
arg: Identifier {
|
||||
id: "f",
|
||||
range: 31..32,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 33..35,
|
||||
value: Int(
|
||||
30,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 38..42,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,156 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..52,
|
||||
name: Identifier {
|
||||
id: "f",
|
||||
range: 4..5,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 5..46,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 6..7,
|
||||
def: Arg {
|
||||
range: 6..7,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 6..7,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 9..10,
|
||||
def: Arg {
|
||||
range: 9..10,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 9..10,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 12..13,
|
||||
def: Arg {
|
||||
range: 12..13,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 12..13,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: Some(
|
||||
Arg {
|
||||
range: 16..20,
|
||||
arg: Identifier {
|
||||
id: "args",
|
||||
range: 16..20,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
kwonlyargs: [
|
||||
ArgWithDefault {
|
||||
range: 22..23,
|
||||
def: Arg {
|
||||
range: 22..23,
|
||||
arg: Identifier {
|
||||
id: "d",
|
||||
range: 22..23,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 25..29,
|
||||
def: Arg {
|
||||
range: 25..26,
|
||||
arg: Identifier {
|
||||
id: "e",
|
||||
range: 25..26,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 27..29,
|
||||
value: Int(
|
||||
20,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 31..35,
|
||||
def: Arg {
|
||||
range: 31..32,
|
||||
arg: Identifier {
|
||||
id: "f",
|
||||
range: 31..32,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 33..35,
|
||||
value: Int(
|
||||
30,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
kwarg: Some(
|
||||
Arg {
|
||||
range: 39..45,
|
||||
arg: Identifier {
|
||||
id: "kwargs",
|
||||
range: 39..45,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 48..52,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,76 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..20,
|
||||
name: Identifier {
|
||||
id: "f",
|
||||
range: 4..5,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 5..14,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 6..7,
|
||||
def: Arg {
|
||||
range: 6..7,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 6..7,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 9..10,
|
||||
def: Arg {
|
||||
range: 9..10,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 9..10,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 12..13,
|
||||
def: Arg {
|
||||
range: 12..13,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 12..13,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 16..20,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,96 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..26,
|
||||
name: Identifier {
|
||||
id: "f",
|
||||
range: 4..5,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 5..20,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 6..7,
|
||||
def: Arg {
|
||||
range: 6..7,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 6..7,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 9..13,
|
||||
def: Arg {
|
||||
range: 9..10,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 9..10,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 11..13,
|
||||
value: Int(
|
||||
20,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 15..19,
|
||||
def: Arg {
|
||||
range: 15..16,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 15..16,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 17..19,
|
||||
value: Int(
|
||||
30,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 22..26,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,76 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..20,
|
||||
name: Identifier {
|
||||
id: "f",
|
||||
range: 4..5,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 5..14,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 6..7,
|
||||
def: Arg {
|
||||
range: 6..7,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 6..7,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 9..10,
|
||||
def: Arg {
|
||||
range: 9..10,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 9..10,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 12..13,
|
||||
def: Arg {
|
||||
range: 12..13,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 12..13,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 16..20,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,75 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..20,
|
||||
value: Lambda(
|
||||
ExprLambda {
|
||||
range: 0..20,
|
||||
args: Arguments {
|
||||
range: 7..17,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [
|
||||
ArgWithDefault {
|
||||
range: 10..11,
|
||||
def: Arg {
|
||||
range: 10..11,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 10..11,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 13..14,
|
||||
def: Arg {
|
||||
range: 13..14,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 13..14,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 16..17,
|
||||
def: Arg {
|
||||
range: 16..17,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 16..17,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
kwarg: None,
|
||||
},
|
||||
body: Constant(
|
||||
ExprConstant {
|
||||
range: 19..20,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,95 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..26,
|
||||
value: Lambda(
|
||||
ExprLambda {
|
||||
range: 0..26,
|
||||
args: Arguments {
|
||||
range: 7..23,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [
|
||||
ArgWithDefault {
|
||||
range: 10..11,
|
||||
def: Arg {
|
||||
range: 10..11,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 10..11,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 13..17,
|
||||
def: Arg {
|
||||
range: 13..14,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 13..14,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 15..17,
|
||||
value: Int(
|
||||
20,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 19..23,
|
||||
def: Arg {
|
||||
range: 19..20,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 19..20,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 21..23,
|
||||
value: Int(
|
||||
30,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
kwarg: None,
|
||||
},
|
||||
body: Constant(
|
||||
ExprConstant {
|
||||
range: 25..26,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..9,
|
||||
value: Lambda(
|
||||
ExprLambda {
|
||||
range: 0..9,
|
||||
args: Arguments {
|
||||
range: 6..6,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: Constant(
|
||||
ExprConstant {
|
||||
range: 8..9,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,102 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..26,
|
||||
value: Lambda(
|
||||
ExprLambda {
|
||||
range: 0..26,
|
||||
args: Arguments {
|
||||
range: 7..23,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 7..8,
|
||||
def: Arg {
|
||||
range: 7..8,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 7..8,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 10..11,
|
||||
def: Arg {
|
||||
range: 10..11,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 10..11,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 13..14,
|
||||
def: Arg {
|
||||
range: 13..14,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 13..14,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [
|
||||
ArgWithDefault {
|
||||
range: 19..20,
|
||||
def: Arg {
|
||||
range: 19..20,
|
||||
arg: Identifier {
|
||||
id: "d",
|
||||
range: 19..20,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 22..23,
|
||||
def: Arg {
|
||||
range: 22..23,
|
||||
arg: Identifier {
|
||||
id: "e",
|
||||
range: 22..23,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
kwarg: None,
|
||||
},
|
||||
body: Constant(
|
||||
ExprConstant {
|
||||
range: 25..26,
|
||||
value: Int(
|
||||
0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,75 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..17,
|
||||
value: Lambda(
|
||||
ExprLambda {
|
||||
range: 0..17,
|
||||
args: Arguments {
|
||||
range: 7..14,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 7..8,
|
||||
def: Arg {
|
||||
range: 7..8,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 7..8,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 10..11,
|
||||
def: Arg {
|
||||
range: 10..11,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 10..11,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 13..14,
|
||||
def: Arg {
|
||||
range: 13..14,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 13..14,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: Constant(
|
||||
ExprConstant {
|
||||
range: 16..17,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,95 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/function.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..23,
|
||||
value: Lambda(
|
||||
ExprLambda {
|
||||
range: 0..23,
|
||||
args: Arguments {
|
||||
range: 7..20,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 7..8,
|
||||
def: Arg {
|
||||
range: 7..8,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 7..8,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 10..14,
|
||||
def: Arg {
|
||||
range: 10..11,
|
||||
arg: Identifier {
|
||||
id: "b",
|
||||
range: 10..11,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 12..14,
|
||||
value: Int(
|
||||
20,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 16..20,
|
||||
def: Arg {
|
||||
range: 16..17,
|
||||
arg: Identifier {
|
||||
id: "c",
|
||||
range: 16..17,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 18..20,
|
||||
value: Int(
|
||||
30,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: Constant(
|
||||
ExprConstant {
|
||||
range: 22..23,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,76 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..34,
|
||||
name: Identifier {
|
||||
id: "test",
|
||||
range: 18..22,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 22..24,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 30..34,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [
|
||||
Decorator {
|
||||
range: 0..13,
|
||||
expression: Name(
|
||||
ExprName {
|
||||
range: 1..13,
|
||||
id: "my_decorator",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
ClassDef(
|
||||
StmtClassDef {
|
||||
range: 36..73,
|
||||
name: Identifier {
|
||||
id: "Abcd",
|
||||
range: 59..63,
|
||||
},
|
||||
bases: [],
|
||||
keywords: [],
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 69..73,
|
||||
},
|
||||
),
|
||||
],
|
||||
type_params: [],
|
||||
decorator_list: [
|
||||
Decorator {
|
||||
range: 36..52,
|
||||
expression: Name(
|
||||
ExprName {
|
||||
range: 37..52,
|
||||
id: "class_decorator",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Dict(
|
||||
ExprDict {
|
||||
range: 0..25,
|
||||
keys: [
|
||||
Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 1..4,
|
||||
value: Str(
|
||||
"a",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
None,
|
||||
Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 16..19,
|
||||
value: Str(
|
||||
"d",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 6..9,
|
||||
value: Str(
|
||||
"b",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 13..14,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 21..24,
|
||||
value: Str(
|
||||
"e",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
)
|
|
@ -0,0 +1,147 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Call(
|
||||
ExprCall {
|
||||
range: 0..141,
|
||||
func: Attribute(
|
||||
ExprAttribute {
|
||||
range: 0..8,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..3,
|
||||
value: Str(
|
||||
" ",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "join",
|
||||
range: 4..8,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
GeneratorExp(
|
||||
ExprGeneratorExp {
|
||||
range: 14..139,
|
||||
elt: Name(
|
||||
ExprName {
|
||||
range: 14..17,
|
||||
id: "sql",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
generators: [
|
||||
Comprehension {
|
||||
range: 22..139,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 26..29,
|
||||
id: "sql",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Tuple(
|
||||
ExprTuple {
|
||||
range: 33..139,
|
||||
elts: [
|
||||
IfExp(
|
||||
ExprIfExp {
|
||||
range: 43..80,
|
||||
test: Name(
|
||||
ExprName {
|
||||
range: 65..70,
|
||||
id: "limit",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
body: BinOp(
|
||||
ExprBinOp {
|
||||
range: 43..61,
|
||||
left: Constant(
|
||||
ExprConstant {
|
||||
range: 43..53,
|
||||
value: Str(
|
||||
"LIMIT %d",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
op: Mod,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 56..61,
|
||||
id: "limit",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
orelse: Constant(
|
||||
ExprConstant {
|
||||
range: 76..80,
|
||||
value: None,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
IfExp(
|
||||
ExprIfExp {
|
||||
range: 90..132,
|
||||
test: Name(
|
||||
ExprName {
|
||||
range: 116..122,
|
||||
id: "offset",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
body: BinOp(
|
||||
ExprBinOp {
|
||||
range: 91..111,
|
||||
left: Constant(
|
||||
ExprConstant {
|
||||
range: 91..102,
|
||||
value: Str(
|
||||
"OFFSET %d",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
op: Mod,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 105..111,
|
||||
id: "offset",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
orelse: Constant(
|
||||
ExprConstant {
|
||||
range: 128..132,
|
||||
value: None,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ifs: [],
|
||||
is_async: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
)
|
|
@ -0,0 +1,352 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Module(
|
||||
ModModule {
|
||||
range: 0..803,
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 21..42,
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 27..40,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 27..28,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Mod,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 39..40,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 66..73,
|
||||
kind: Help2,
|
||||
value: "a.foo",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 74..80,
|
||||
kind: Help,
|
||||
value: "a.foo",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 81..88,
|
||||
kind: Help,
|
||||
value: "a.foo?",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 89..100,
|
||||
kind: Help2,
|
||||
value: "a.foo()??",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 115..128,
|
||||
kind: Magic,
|
||||
value: "timeit a = b",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 129..147,
|
||||
kind: Magic,
|
||||
value: "timeit foo(b) % 3",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 148..176,
|
||||
kind: Magic,
|
||||
value: "alias showPath pwd && ls -a",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 177..205,
|
||||
kind: Magic,
|
||||
value: "timeit a = foo(b); b = 2",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 206..226,
|
||||
kind: Magic,
|
||||
value: "matplotlib --inline",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 227..253,
|
||||
kind: Magic,
|
||||
value: "matplotlib --inline",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 277..309,
|
||||
kind: Shell,
|
||||
value: "pwd && ls -a | sed 's/^/\\ /'",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 310..347,
|
||||
kind: Shell,
|
||||
value: "pwd && ls -a | sed 's/^/\\\\ /'",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 348..393,
|
||||
kind: ShCap,
|
||||
value: "cd /Users/foo/Library/Application\\ Support/",
|
||||
},
|
||||
),
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 566..626,
|
||||
name: Identifier {
|
||||
id: "foo",
|
||||
range: 570..573,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 573..575,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Return(
|
||||
StmtReturn {
|
||||
range: 581..626,
|
||||
value: Some(
|
||||
Compare(
|
||||
ExprCompare {
|
||||
range: 598..620,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 598..599,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ops: [
|
||||
NotEq,
|
||||
],
|
||||
comparators: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 619..620,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 656..664,
|
||||
kind: Paren,
|
||||
value: "foo 1 2",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 665..673,
|
||||
kind: Quote2,
|
||||
value: "foo 1 2",
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 674..682,
|
||||
kind: Quote,
|
||||
value: "foo 1 2",
|
||||
},
|
||||
),
|
||||
For(
|
||||
StmtFor {
|
||||
range: 701..727,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 705..706,
|
||||
id: "a",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Call(
|
||||
ExprCall {
|
||||
range: 710..718,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 710..715,
|
||||
id: "range",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 716..717,
|
||||
value: Int(
|
||||
5,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
body: [
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 724..727,
|
||||
kind: Shell,
|
||||
value: "ls",
|
||||
},
|
||||
),
|
||||
],
|
||||
orelse: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 729..738,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 729..731,
|
||||
id: "p1",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: LineMagic(
|
||||
ExprLineMagic {
|
||||
range: 734..738,
|
||||
kind: Shell,
|
||||
value: "pwd",
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
AnnAssign(
|
||||
StmtAnnAssign {
|
||||
range: 739..753,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 739..741,
|
||||
id: "p2",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
annotation: Name(
|
||||
ExprName {
|
||||
range: 743..746,
|
||||
id: "str",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
value: Some(
|
||||
LineMagic(
|
||||
ExprLineMagic {
|
||||
range: 749..753,
|
||||
kind: Shell,
|
||||
value: "pwd",
|
||||
},
|
||||
),
|
||||
),
|
||||
simple: true,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 754..774,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 754..757,
|
||||
id: "foo",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: LineMagic(
|
||||
ExprLineMagic {
|
||||
range: 760..774,
|
||||
kind: Magic,
|
||||
value: "foo bar",
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
LineMagic(
|
||||
StmtLineMagic {
|
||||
range: 776..781,
|
||||
kind: Magic,
|
||||
value: " foo",
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 782..803,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 782..785,
|
||||
id: "foo",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: LineMagic(
|
||||
ExprLineMagic {
|
||||
range: 788..803,
|
||||
kind: Magic,
|
||||
value: "foo # comment",
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
type_ignores: [],
|
||||
},
|
||||
)
|
|
@ -0,0 +1,440 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Match(
|
||||
StmtMatch {
|
||||
range: 1..73,
|
||||
subject: Dict(
|
||||
ExprDict {
|
||||
range: 7..18,
|
||||
keys: [
|
||||
Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 8..14,
|
||||
value: Str(
|
||||
"test",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 16..17,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
cases: [
|
||||
MatchCase {
|
||||
range: 24..73,
|
||||
pattern: MatchMapping(
|
||||
PatternMatchMapping {
|
||||
range: 29..52,
|
||||
keys: [],
|
||||
patterns: [],
|
||||
rest: Some(
|
||||
Identifier {
|
||||
id: "rest",
|
||||
range: 41..45,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
guard: None,
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 62..73,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 62..73,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 62..67,
|
||||
id: "print",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 68..72,
|
||||
id: "rest",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
Match(
|
||||
StmtMatch {
|
||||
range: 74..177,
|
||||
subject: Dict(
|
||||
ExprDict {
|
||||
range: 80..97,
|
||||
keys: [
|
||||
Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 81..88,
|
||||
value: Str(
|
||||
"label",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 90..96,
|
||||
value: Str(
|
||||
"test",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
cases: [
|
||||
MatchCase {
|
||||
range: 103..177,
|
||||
pattern: MatchMapping(
|
||||
PatternMatchMapping {
|
||||
range: 108..155,
|
||||
keys: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 118..125,
|
||||
value: Str(
|
||||
"label",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
patterns: [
|
||||
MatchAs(
|
||||
PatternMatchAs {
|
||||
range: 127..148,
|
||||
pattern: Some(
|
||||
MatchOr(
|
||||
PatternMatchOr {
|
||||
range: 127..139,
|
||||
patterns: [
|
||||
MatchClass(
|
||||
PatternMatchClass {
|
||||
range: 127..132,
|
||||
cls: Name(
|
||||
ExprName {
|
||||
range: 127..130,
|
||||
id: "str",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
patterns: [],
|
||||
kwd_attrs: [],
|
||||
kwd_patterns: [],
|
||||
},
|
||||
),
|
||||
MatchSingleton(
|
||||
PatternMatchSingleton {
|
||||
range: 135..139,
|
||||
value: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
),
|
||||
name: Some(
|
||||
Identifier {
|
||||
id: "label",
|
||||
range: 143..148,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
rest: None,
|
||||
},
|
||||
),
|
||||
guard: None,
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 165..177,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 165..177,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 165..170,
|
||||
id: "print",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 171..176,
|
||||
id: "label",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
Match(
|
||||
StmtMatch {
|
||||
range: 178..218,
|
||||
subject: Name(
|
||||
ExprName {
|
||||
range: 184..185,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
cases: [
|
||||
MatchCase {
|
||||
range: 191..218,
|
||||
pattern: MatchSequence(
|
||||
PatternMatchSequence {
|
||||
range: 196..203,
|
||||
patterns: [
|
||||
MatchValue(
|
||||
PatternMatchValue {
|
||||
range: 197..198,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 197..198,
|
||||
value: Int(
|
||||
0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
MatchValue(
|
||||
PatternMatchValue {
|
||||
range: 200..201,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 200..201,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
guard: None,
|
||||
body: [
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 213..218,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 213..214,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 217..218,
|
||||
value: Int(
|
||||
0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
Match(
|
||||
StmtMatch {
|
||||
range: 219..259,
|
||||
subject: Name(
|
||||
ExprName {
|
||||
range: 225..226,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
cases: [
|
||||
MatchCase {
|
||||
range: 232..259,
|
||||
pattern: MatchSequence(
|
||||
PatternMatchSequence {
|
||||
range: 237..244,
|
||||
patterns: [
|
||||
MatchValue(
|
||||
PatternMatchValue {
|
||||
range: 238..239,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 238..239,
|
||||
value: Int(
|
||||
0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
MatchValue(
|
||||
PatternMatchValue {
|
||||
range: 241..242,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 241..242,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
guard: None,
|
||||
body: [
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 254..259,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 254..255,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 258..259,
|
||||
value: Int(
|
||||
0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
Match(
|
||||
StmtMatch {
|
||||
range: 260..297,
|
||||
subject: Name(
|
||||
ExprName {
|
||||
range: 266..267,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
cases: [
|
||||
MatchCase {
|
||||
range: 273..297,
|
||||
pattern: MatchSequence(
|
||||
PatternMatchSequence {
|
||||
range: 278..282,
|
||||
patterns: [
|
||||
MatchValue(
|
||||
PatternMatchValue {
|
||||
range: 279..280,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 279..280,
|
||||
value: Int(
|
||||
0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
guard: None,
|
||||
body: [
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 292..297,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 292..293,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 296..297,
|
||||
value: Int(
|
||||
0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,807 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 2..17,
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 2..17,
|
||||
elts: [
|
||||
BinOp(
|
||||
ExprBinOp {
|
||||
range: 2..14,
|
||||
left: BinOp(
|
||||
ExprBinOp {
|
||||
range: 2..10,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 2..7,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Mult,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 9..10,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 13..14,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 16..17,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 43..60,
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 43..60,
|
||||
elts: [
|
||||
BinOp(
|
||||
ExprBinOp {
|
||||
range: 43..57,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 43..48,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Mult,
|
||||
right: BinOp(
|
||||
ExprBinOp {
|
||||
range: 51..56,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 51..52,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 55..56,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 59..60,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 86..103,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 86..103,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 86..91,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Starred(
|
||||
ExprStarred {
|
||||
range: 93..99,
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 94..99,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 94..95,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 98..99,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 101..102,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 130..146,
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 130..146,
|
||||
left: BinOp(
|
||||
ExprBinOp {
|
||||
range: 130..142,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 130..135,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Sub,
|
||||
right: BinOp(
|
||||
ExprBinOp {
|
||||
range: 137..142,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 137..138,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Mult,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 141..142,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 145..146,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 173..191,
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 173..191,
|
||||
left: BinOp(
|
||||
ExprBinOp {
|
||||
range: 173..187,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 173..178,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Sub,
|
||||
right: BinOp(
|
||||
ExprBinOp {
|
||||
range: 181..186,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 181..182,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Mult,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 185..186,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 190..191,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 218..236,
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 218..236,
|
||||
left: BinOp(
|
||||
ExprBinOp {
|
||||
range: 218..232,
|
||||
left: Call(
|
||||
ExprCall {
|
||||
range: 218..228,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 218..223,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
UnaryOp(
|
||||
ExprUnaryOp {
|
||||
range: 225..227,
|
||||
op: USub,
|
||||
operand: Name(
|
||||
ExprName {
|
||||
range: 226..227,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
op: Mult,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 231..232,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 235..236,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 264..274,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 264..274,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 264..272,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 264..269,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "a",
|
||||
range: 273..274,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 291..303,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 291..303,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 291..301,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 291..296,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Tuple(
|
||||
ExprTuple {
|
||||
range: 298..300,
|
||||
elts: [],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "a",
|
||||
range: 302..303,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 322..335,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 322..335,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 322..333,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 322..327,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Tuple(
|
||||
ExprTuple {
|
||||
range: 329..331,
|
||||
elts: [],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "a",
|
||||
range: 334..335,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 354..365,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 354..365,
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 354..363,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 354..359,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Name(
|
||||
ExprName {
|
||||
range: 361..362,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "b",
|
||||
range: 364..365,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 383..395,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 383..395,
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 383..393,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 383..388,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Tuple(
|
||||
ExprTuple {
|
||||
range: 390..392,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 390..391,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "b",
|
||||
range: 394..395,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 436..450,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 436..450,
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 436..448,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 436..441,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Tuple(
|
||||
ExprTuple {
|
||||
range: 443..447,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 444..445,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "b",
|
||||
range: 449..450,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 471..488,
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 471..488,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 471..478,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 471..476,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
slice: Slice(
|
||||
ExprSlice {
|
||||
range: 479..487,
|
||||
lower: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 479..480,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
upper: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 486..487,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
step: None,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
If(
|
||||
StmtIf {
|
||||
range: 508..527,
|
||||
test: NamedExpr(
|
||||
ExprNamedExpr {
|
||||
range: 511..521,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 511..516,
|
||||
id: "match",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 520..521,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 523..527,
|
||||
},
|
||||
),
|
||||
],
|
||||
elif_else_clauses: [],
|
||||
},
|
||||
),
|
||||
Match(
|
||||
StmtMatch {
|
||||
range: 528..582,
|
||||
subject: Name(
|
||||
ExprName {
|
||||
range: 534..539,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
cases: [
|
||||
MatchCase {
|
||||
range: 545..557,
|
||||
pattern: MatchValue(
|
||||
PatternMatchValue {
|
||||
range: 550..551,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 550..551,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
guard: None,
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 553..557,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
MatchCase {
|
||||
range: 562..582,
|
||||
pattern: MatchValue(
|
||||
PatternMatchValue {
|
||||
range: 567..568,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 567..568,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
guard: None,
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 578..582,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 583..619,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 583..588,
|
||||
id: "match",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Lambda(
|
||||
ExprLambda {
|
||||
range: 591..619,
|
||||
args: Arguments {
|
||||
range: 598..603,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 598..603,
|
||||
def: Arg {
|
||||
range: 598..603,
|
||||
arg: Identifier {
|
||||
id: "query",
|
||||
range: 598..603,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: Compare(
|
||||
ExprCompare {
|
||||
range: 605..619,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 605..610,
|
||||
id: "query",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ops: [
|
||||
Eq,
|
||||
],
|
||||
comparators: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 614..619,
|
||||
id: "event",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 620..636,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 620..636,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 620..625,
|
||||
id: "print",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Call(
|
||||
ExprCall {
|
||||
range: 626..635,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 626..631,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 632..634,
|
||||
value: Int(
|
||||
12,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,440 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..13,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 4..13,
|
||||
value: Int(
|
||||
123456789,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 14..24,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 14..15,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 18..24,
|
||||
value: Int(
|
||||
123456,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 25..31,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 25..26,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 29..31,
|
||||
value: Float(
|
||||
0.1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 32..38,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 32..33,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 36..38,
|
||||
value: Float(
|
||||
1.0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 39..47,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 39..40,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 43..47,
|
||||
value: Float(
|
||||
10.0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 48..56,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 48..49,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 52..56,
|
||||
value: Float(
|
||||
0.1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 57..73,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 57..58,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 61..73,
|
||||
value: Float(
|
||||
1.00000001,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 74..97,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 74..75,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 78..97,
|
||||
value: Float(
|
||||
123456789.12345679,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 98..131,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 98..99,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 102..131,
|
||||
value: Float(
|
||||
inf,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 132..155,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 132..133,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 136..155,
|
||||
value: Float(
|
||||
inf,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 156..170,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 156..157,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 160..170,
|
||||
value: Complex {
|
||||
real: 0.0,
|
||||
imag: 123456789.0,
|
||||
},
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 171..195,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 171..172,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 175..195,
|
||||
value: Complex {
|
||||
real: 0.0,
|
||||
imag: 123456789.12345679,
|
||||
},
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 196..207,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 196..197,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 200..207,
|
||||
value: Int(
|
||||
727756,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 208..218,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 208..209,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 212..218,
|
||||
value: Int(
|
||||
11,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 219..228,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 219..220,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 223..228,
|
||||
value: Int(
|
||||
511,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 229..244,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 229..230,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 233..244,
|
||||
value: Float(
|
||||
6e-9,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 245..254,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 245..246,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 249..254,
|
||||
value: Int(
|
||||
10000,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 255..265,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 255..256,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 259..265,
|
||||
value: Int(
|
||||
133333,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,672 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..19,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 4..19,
|
||||
func: Attribute(
|
||||
ExprAttribute {
|
||||
range: 4..17,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 4..6,
|
||||
value: Float(
|
||||
0.1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "is_integer",
|
||||
range: 7..17,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 20..32,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 20..21,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 24..32,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 24..26,
|
||||
value: Float(
|
||||
1.0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "imag",
|
||||
range: 28..32,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 33..46,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 33..34,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 37..46,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 37..41,
|
||||
value: Float(
|
||||
10.0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "imag",
|
||||
range: 42..46,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 47..60,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 47..48,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 51..60,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 51..55,
|
||||
value: Float(
|
||||
0.1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "real",
|
||||
range: 56..60,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 61..90,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 61..62,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 65..90,
|
||||
func: Attribute(
|
||||
ExprAttribute {
|
||||
range: 65..88,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 65..84,
|
||||
value: Float(
|
||||
123456789.12345679,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "hex",
|
||||
range: 85..88,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 91..130,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 91..92,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 95..130,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 95..124,
|
||||
value: Float(
|
||||
inf,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "real",
|
||||
range: 126..130,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 131..167,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 131..132,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 135..167,
|
||||
func: Attribute(
|
||||
ExprAttribute {
|
||||
range: 135..165,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 135..154,
|
||||
value: Float(
|
||||
inf,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "conjugate",
|
||||
range: 156..165,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 168..187,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 168..169,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 172..187,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 172..182,
|
||||
value: Complex {
|
||||
real: 0.0,
|
||||
imag: 123456789.0,
|
||||
},
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "real",
|
||||
range: 183..187,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 188..241,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 188..189,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 192..241,
|
||||
func: Attribute(
|
||||
ExprAttribute {
|
||||
range: 192..220,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 192..212,
|
||||
value: Complex {
|
||||
real: 0.0,
|
||||
imag: 123456789.12345679,
|
||||
},
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "__add__",
|
||||
range: 213..220,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Call(
|
||||
ExprCall {
|
||||
range: 221..240,
|
||||
func: Attribute(
|
||||
ExprAttribute {
|
||||
range: 221..238,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 221..227,
|
||||
value: Int(
|
||||
11,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "bit_length",
|
||||
range: 228..238,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 242..265,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 242..243,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 246..265,
|
||||
func: Attribute(
|
||||
ExprAttribute {
|
||||
range: 246..263,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 246..253,
|
||||
value: Int(
|
||||
727756,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "conjugate",
|
||||
range: 254..263,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 266..289,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 266..267,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 270..289,
|
||||
func: Attribute(
|
||||
ExprAttribute {
|
||||
range: 270..287,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 270..276,
|
||||
value: Int(
|
||||
11,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "conjugate",
|
||||
range: 278..287,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 290..305,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 290..291,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 294..305,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 294..299,
|
||||
value: Int(
|
||||
511,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "real",
|
||||
range: 301..305,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 306..329,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 306..307,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 310..329,
|
||||
func: Attribute(
|
||||
ExprAttribute {
|
||||
range: 310..327,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 310..321,
|
||||
value: Float(
|
||||
6e-9,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "hex",
|
||||
range: 324..327,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 330..344,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 330..331,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: UnaryOp(
|
||||
ExprUnaryOp {
|
||||
range: 334..344,
|
||||
op: USub,
|
||||
operand: Constant(
|
||||
ExprConstant {
|
||||
range: 335..344,
|
||||
value: Complex {
|
||||
real: 0.0,
|
||||
imag: 100.0,
|
||||
},
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
If(
|
||||
StmtIf {
|
||||
range: 346..366,
|
||||
test: Attribute(
|
||||
ExprAttribute {
|
||||
range: 349..357,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 349..351,
|
||||
value: Int(
|
||||
10,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "real",
|
||||
range: 353..357,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 363..366,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 363..366,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
elif_else_clauses: [],
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 368..379,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 368..369,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 372..379,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 372..375,
|
||||
value: Int(
|
||||
100,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
slice: Name(
|
||||
ExprName {
|
||||
range: 376..378,
|
||||
id: "no",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 380..391,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 380..381,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 384..391,
|
||||
func: Constant(
|
||||
ExprConstant {
|
||||
range: 384..387,
|
||||
value: Int(
|
||||
100,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 388..390,
|
||||
id: "no",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
BoolOp(
|
||||
ExprBoolOp {
|
||||
range: 0..7,
|
||||
op: And,
|
||||
values: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 6..7,
|
||||
id: "y",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
)
|
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
BoolOp(
|
||||
ExprBoolOp {
|
||||
range: 0..6,
|
||||
op: Or,
|
||||
values: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 5..6,
|
||||
id: "y",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
)
|
|
@ -0,0 +1,143 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||
---
|
||||
[
|
||||
ClassDef(
|
||||
StmtClassDef {
|
||||
range: 0..98,
|
||||
name: Identifier {
|
||||
id: "Foo",
|
||||
range: 6..9,
|
||||
},
|
||||
bases: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 10..11,
|
||||
id: "A",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 13..14,
|
||||
id: "B",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
body: [
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 18..44,
|
||||
name: Identifier {
|
||||
id: "__init__",
|
||||
range: 22..30,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 30..36,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 31..35,
|
||||
def: Arg {
|
||||
range: 31..35,
|
||||
arg: Identifier {
|
||||
id: "self",
|
||||
range: 31..35,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 40..44,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 46..98,
|
||||
name: Identifier {
|
||||
id: "method_with_default",
|
||||
range: 50..69,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 69..90,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 70..74,
|
||||
def: Arg {
|
||||
range: 70..74,
|
||||
arg: Identifier {
|
||||
id: "self",
|
||||
range: 70..74,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 76..89,
|
||||
def: Arg {
|
||||
range: 76..79,
|
||||
arg: Identifier {
|
||||
id: "arg",
|
||||
range: 76..79,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 80..89,
|
||||
value: Str(
|
||||
"default",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 94..98,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
type_params: [],
|
||||
decorator_list: [],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,388 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||
---
|
||||
[
|
||||
ClassDef(
|
||||
StmtClassDef {
|
||||
range: 10..29,
|
||||
name: Identifier {
|
||||
id: "Foo",
|
||||
range: 16..19,
|
||||
},
|
||||
bases: [],
|
||||
keywords: [],
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 26..29,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 26..29,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 20..21,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 20..21,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
},
|
||||
),
|
||||
ClassDef(
|
||||
StmtClassDef {
|
||||
range: 52..76,
|
||||
name: Identifier {
|
||||
id: "Foo",
|
||||
range: 58..61,
|
||||
},
|
||||
bases: [],
|
||||
keywords: [],
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 73..76,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 73..76,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 62..68,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 62..63,
|
||||
},
|
||||
bound: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 65..68,
|
||||
id: "str",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
},
|
||||
),
|
||||
ClassDef(
|
||||
StmtClassDef {
|
||||
range: 105..138,
|
||||
name: Identifier {
|
||||
id: "Foo",
|
||||
range: 111..114,
|
||||
},
|
||||
bases: [],
|
||||
keywords: [],
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 135..138,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 135..138,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 115..130,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 115..116,
|
||||
},
|
||||
bound: Some(
|
||||
Tuple(
|
||||
ExprTuple {
|
||||
range: 118..130,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 119..122,
|
||||
id: "str",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 124..129,
|
||||
id: "bytes",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
},
|
||||
),
|
||||
ClassDef(
|
||||
StmtClassDef {
|
||||
range: 159..181,
|
||||
name: Identifier {
|
||||
id: "Foo",
|
||||
range: 165..168,
|
||||
},
|
||||
bases: [],
|
||||
keywords: [],
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 178..181,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 178..181,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 169..170,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 169..170,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 172..173,
|
||||
name: Identifier {
|
||||
id: "U",
|
||||
range: 172..173,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
},
|
||||
),
|
||||
ClassDef(
|
||||
StmtClassDef {
|
||||
range: 200..223,
|
||||
name: Identifier {
|
||||
id: "Foo",
|
||||
range: 206..209,
|
||||
},
|
||||
bases: [],
|
||||
keywords: [],
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 220..223,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 220..223,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 210..211,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 210..211,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 213..214,
|
||||
name: Identifier {
|
||||
id: "U",
|
||||
range: 213..214,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
},
|
||||
),
|
||||
ClassDef(
|
||||
StmtClassDef {
|
||||
range: 240..261,
|
||||
name: Identifier {
|
||||
id: "Foo",
|
||||
range: 246..249,
|
||||
},
|
||||
bases: [],
|
||||
keywords: [],
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 258..261,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 258..261,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
type_params: [
|
||||
TypeVarTuple(
|
||||
TypeParamTypeVarTuple {
|
||||
range: 250..253,
|
||||
name: Identifier {
|
||||
id: "Ts",
|
||||
range: 251..253,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
},
|
||||
),
|
||||
ClassDef(
|
||||
StmtClassDef {
|
||||
range: 275..296,
|
||||
name: Identifier {
|
||||
id: "Foo",
|
||||
range: 281..284,
|
||||
},
|
||||
bases: [],
|
||||
keywords: [],
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 293..296,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 293..296,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
type_params: [
|
||||
ParamSpec(
|
||||
TypeParamParamSpec {
|
||||
range: 285..288,
|
||||
name: Identifier {
|
||||
id: "P",
|
||||
range: 287..288,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
},
|
||||
),
|
||||
ClassDef(
|
||||
StmtClassDef {
|
||||
range: 312..351,
|
||||
name: Identifier {
|
||||
id: "Foo",
|
||||
range: 318..321,
|
||||
},
|
||||
bases: [],
|
||||
keywords: [],
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 347..351,
|
||||
},
|
||||
),
|
||||
],
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 322..323,
|
||||
name: Identifier {
|
||||
id: "X",
|
||||
range: 322..323,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 325..331,
|
||||
name: Identifier {
|
||||
id: "Y",
|
||||
range: 325..326,
|
||||
},
|
||||
bound: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 328..331,
|
||||
id: "str",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeVarTuple(
|
||||
TypeParamTypeVarTuple {
|
||||
range: 333..335,
|
||||
name: Identifier {
|
||||
id: "U",
|
||||
range: 334..335,
|
||||
},
|
||||
},
|
||||
),
|
||||
ParamSpec(
|
||||
TypeParamParamSpec {
|
||||
range: 337..340,
|
||||
name: Identifier {
|
||||
id: "P",
|
||||
range: 339..340,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
DictComp(
|
||||
ExprDictComp {
|
||||
range: 0..19,
|
||||
key: Name(
|
||||
ExprName {
|
||||
range: 1..3,
|
||||
id: "x1",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 5..7,
|
||||
id: "x2",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
generators: [
|
||||
Comprehension {
|
||||
range: 8..18,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 12..13,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Name(
|
||||
ExprName {
|
||||
range: 17..18,
|
||||
id: "z",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ifs: [],
|
||||
is_async: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
|
@ -0,0 +1,124 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
ListComp(
|
||||
ExprListComp {
|
||||
range: 0..48,
|
||||
elt: Name(
|
||||
ExprName {
|
||||
range: 1..2,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
generators: [
|
||||
Comprehension {
|
||||
range: 3..17,
|
||||
target: Tuple(
|
||||
ExprTuple {
|
||||
range: 7..12,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 7..8,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 10..12,
|
||||
id: "y2",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Name(
|
||||
ExprName {
|
||||
range: 16..17,
|
||||
id: "z",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ifs: [],
|
||||
is_async: false,
|
||||
},
|
||||
Comprehension {
|
||||
range: 18..47,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 22..23,
|
||||
id: "a",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Name(
|
||||
ExprName {
|
||||
range: 27..28,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ifs: [
|
||||
Compare(
|
||||
ExprCompare {
|
||||
range: 32..37,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 32..33,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ops: [
|
||||
Lt,
|
||||
],
|
||||
comparators: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 36..37,
|
||||
value: Int(
|
||||
5,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
Compare(
|
||||
ExprCompare {
|
||||
range: 41..47,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 41..42,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ops: [
|
||||
Gt,
|
||||
],
|
||||
comparators: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 45..47,
|
||||
value: Int(
|
||||
10,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
],
|
||||
is_async: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[]
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..14,
|
||||
value: JoinedStr(
|
||||
ExprJoinedStr {
|
||||
range: 0..14,
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 2..13,
|
||||
value: Str(
|
||||
"Hello world",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,559 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||
---
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..20,
|
||||
name: Identifier {
|
||||
id: "func",
|
||||
range: 4..8,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 8..11,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 9..10,
|
||||
def: Arg {
|
||||
range: 9..10,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 9..10,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 17..20,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 17..20,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 22..53,
|
||||
name: Identifier {
|
||||
id: "func",
|
||||
range: 26..30,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 33..39,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 34..38,
|
||||
def: Arg {
|
||||
range: 34..38,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 34..35,
|
||||
},
|
||||
annotation: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 37..38,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 50..53,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 50..53,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 43..44,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 31..32,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 31..32,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 55..91,
|
||||
name: Identifier {
|
||||
id: "func",
|
||||
range: 59..63,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 71..77,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 72..76,
|
||||
def: Arg {
|
||||
range: 72..76,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 72..73,
|
||||
},
|
||||
annotation: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 75..76,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 88..91,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 88..91,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 81..82,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 64..70,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 64..65,
|
||||
},
|
||||
bound: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 67..70,
|
||||
id: "str",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 93..138,
|
||||
name: Identifier {
|
||||
id: "func",
|
||||
range: 97..101,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 118..124,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 119..123,
|
||||
def: Arg {
|
||||
range: 119..123,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 119..120,
|
||||
},
|
||||
annotation: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 122..123,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 135..138,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 135..138,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 128..129,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 102..117,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 102..103,
|
||||
},
|
||||
bound: Some(
|
||||
Tuple(
|
||||
ExprTuple {
|
||||
range: 105..117,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 106..109,
|
||||
id: "str",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 111..116,
|
||||
id: "bytes",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 140..171,
|
||||
name: Identifier {
|
||||
id: "func",
|
||||
range: 144..148,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 153..162,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: Some(
|
||||
Arg {
|
||||
range: 155..161,
|
||||
arg: Identifier {
|
||||
id: "a",
|
||||
range: 155..156,
|
||||
},
|
||||
annotation: Some(
|
||||
Starred(
|
||||
ExprStarred {
|
||||
range: 158..161,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 159..161,
|
||||
id: "Ts",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 168..171,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 168..171,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [
|
||||
TypeVarTuple(
|
||||
TypeParamTypeVarTuple {
|
||||
range: 149..152,
|
||||
name: Identifier {
|
||||
id: "Ts",
|
||||
range: 150..152,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 173..230,
|
||||
name: Identifier {
|
||||
id: "func",
|
||||
range: 177..181,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 186..221,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: Some(
|
||||
Arg {
|
||||
range: 188..200,
|
||||
arg: Identifier {
|
||||
id: "args",
|
||||
range: 188..192,
|
||||
},
|
||||
annotation: Some(
|
||||
Attribute(
|
||||
ExprAttribute {
|
||||
range: 194..200,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 194..195,
|
||||
id: "P",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "args",
|
||||
range: 196..200,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
kwonlyargs: [],
|
||||
kwarg: Some(
|
||||
Arg {
|
||||
range: 204..220,
|
||||
arg: Identifier {
|
||||
id: "kwargs",
|
||||
range: 204..210,
|
||||
},
|
||||
annotation: Some(
|
||||
Attribute(
|
||||
ExprAttribute {
|
||||
range: 212..220,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 212..213,
|
||||
id: "P",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "kwargs",
|
||||
range: 214..220,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 227..230,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 227..230,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [
|
||||
ParamSpec(
|
||||
TypeParamParamSpec {
|
||||
range: 182..185,
|
||||
name: Identifier {
|
||||
id: "P",
|
||||
range: 184..185,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 232..273,
|
||||
name: Identifier {
|
||||
id: "func",
|
||||
range: 236..240,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 261..263,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 269..273,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: None,
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 241..242,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 241..242,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 244..250,
|
||||
name: Identifier {
|
||||
id: "U",
|
||||
range: 244..245,
|
||||
},
|
||||
bound: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 247..250,
|
||||
id: "str",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeVarTuple(
|
||||
TypeParamTypeVarTuple {
|
||||
range: 252..255,
|
||||
name: Identifier {
|
||||
id: "Ts",
|
||||
range: 253..255,
|
||||
},
|
||||
},
|
||||
),
|
||||
ParamSpec(
|
||||
TypeParamParamSpec {
|
||||
range: 257..260,
|
||||
name: Identifier {
|
||||
id: "P",
|
||||
range: 259..260,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
GeneratorExp(
|
||||
ExprGeneratorExp {
|
||||
range: 0..14,
|
||||
elt: Name(
|
||||
ExprName {
|
||||
range: 1..2,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
generators: [
|
||||
Comprehension {
|
||||
range: 3..13,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 7..8,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Name(
|
||||
ExprName {
|
||||
range: 12..13,
|
||||
id: "z",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ifs: [],
|
||||
is_async: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
|
@ -0,0 +1,88 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
If(
|
||||
StmtIf {
|
||||
range: 0..28,
|
||||
test: Constant(
|
||||
ExprConstant {
|
||||
range: 3..4,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 6..8,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 6..8,
|
||||
value: Int(
|
||||
10,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
elif_else_clauses: [
|
||||
ElifElseClause {
|
||||
range: 9..19,
|
||||
test: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 14..15,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 17..19,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 17..19,
|
||||
value: Int(
|
||||
20,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
ElifElseClause {
|
||||
range: 20..28,
|
||||
test: None,
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 26..28,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 26..28,
|
||||
value: Int(
|
||||
30,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,56 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
GeneratorExp(
|
||||
ExprGeneratorExp {
|
||||
range: 0..26,
|
||||
elt: IfExp(
|
||||
ExprIfExp {
|
||||
range: 1..14,
|
||||
test: Name(
|
||||
ExprName {
|
||||
range: 6..7,
|
||||
id: "y",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
body: Name(
|
||||
ExprName {
|
||||
range: 1..2,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
orelse: Name(
|
||||
ExprName {
|
||||
range: 13..14,
|
||||
id: "y",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
generators: [
|
||||
Comprehension {
|
||||
range: 15..25,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 19..20,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Name(
|
||||
ExprName {
|
||||
range: 24..25,
|
||||
id: "z",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ifs: [],
|
||||
is_async: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
|
@ -0,0 +1,54 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..32,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 0..32,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 0..7,
|
||||
id: "my_func",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 8..20,
|
||||
value: Str(
|
||||
"positional",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [
|
||||
Keyword {
|
||||
range: 22..31,
|
||||
arg: Some(
|
||||
Identifier {
|
||||
id: "keyword",
|
||||
range: 22..29,
|
||||
},
|
||||
),
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 30..31,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..18,
|
||||
value: Lambda(
|
||||
ExprLambda {
|
||||
range: 0..18,
|
||||
args: Arguments {
|
||||
range: 7..11,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 7..8,
|
||||
def: Arg {
|
||||
range: 7..8,
|
||||
arg: Identifier {
|
||||
id: "x",
|
||||
range: 7..8,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
ArgWithDefault {
|
||||
range: 10..11,
|
||||
def: Arg {
|
||||
range: 10..11,
|
||||
arg: Identifier {
|
||||
id: "y",
|
||||
range: 10..11,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: BinOp(
|
||||
ExprBinOp {
|
||||
range: 13..18,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 13..14,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Mult,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 17..18,
|
||||
id: "y",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..9,
|
||||
value: Lambda(
|
||||
ExprLambda {
|
||||
range: 0..9,
|
||||
args: Arguments {
|
||||
range: 6..6,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: Constant(
|
||||
ExprConstant {
|
||||
range: 8..9,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
ListComp(
|
||||
ExprListComp {
|
||||
range: 0..14,
|
||||
elt: Name(
|
||||
ExprName {
|
||||
range: 1..2,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
generators: [
|
||||
Comprehension {
|
||||
range: 3..13,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 7..8,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Name(
|
||||
ExprName {
|
||||
range: 12..13,
|
||||
id: "z",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ifs: [],
|
||||
is_async: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
|
@ -0,0 +1,64 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
GeneratorExp(
|
||||
ExprGeneratorExp {
|
||||
range: 0..23,
|
||||
elt: NamedExpr(
|
||||
ExprNamedExpr {
|
||||
range: 1..11,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 1..2,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 6..11,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 6..7,
|
||||
id: "y",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Constant(
|
||||
ExprConstant {
|
||||
range: 10..11,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
generators: [
|
||||
Comprehension {
|
||||
range: 12..22,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 16..17,
|
||||
id: "y",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
iter: Name(
|
||||
ExprName {
|
||||
range: 21..22,
|
||||
id: "z",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ifs: [],
|
||||
is_async: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..23,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 0..23,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 0..5,
|
||||
id: "print",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 6..19,
|
||||
value: Str(
|
||||
"Hello world",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 21..22,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..20,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 0..20,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 0..5,
|
||||
id: "print",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 6..19,
|
||||
value: Str(
|
||||
"Hello world",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..13,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..13,
|
||||
value: Str(
|
||||
"Hello world",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,62 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..11,
|
||||
targets: [
|
||||
Tuple(
|
||||
ExprTuple {
|
||||
range: 0..4,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "a",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 3..4,
|
||||
id: "b",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 7..11,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 7..8,
|
||||
value: Int(
|
||||
4,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 10..11,
|
||||
value: Int(
|
||||
5,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,802 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||
---
|
||||
[
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 1..13,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 6..7,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 10..13,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 14..32,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 19..20,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 23..32,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 23..26,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: BitOr,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 29..32,
|
||||
id: "str",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 33..61,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 38..39,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 42..61,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 42..45,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: BitOr,
|
||||
right: Constant(
|
||||
ExprConstant {
|
||||
range: 48..61,
|
||||
value: Str(
|
||||
"ForwardRefY",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 62..88,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 67..68,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 69..70,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 69..70,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 74..88,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 74..75,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: BitOr,
|
||||
right: Subscript(
|
||||
ExprSubscript {
|
||||
range: 78..88,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 78..82,
|
||||
id: "list",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Subscript(
|
||||
ExprSubscript {
|
||||
range: 83..87,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 83..84,
|
||||
id: "X",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Name(
|
||||
ExprName {
|
||||
range: 85..86,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 102..117,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 107..108,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 109..110,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 109..110,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 114..117,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 118..146,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 123..124,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 125..126,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 125..126,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 130..146,
|
||||
left: Subscript(
|
||||
ExprSubscript {
|
||||
range: 130..137,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 130..134,
|
||||
id: "list",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Name(
|
||||
ExprName {
|
||||
range: 135..136,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: BitOr,
|
||||
right: Subscript(
|
||||
ExprSubscript {
|
||||
range: 140..146,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 140..143,
|
||||
id: "set",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Name(
|
||||
ExprName {
|
||||
range: 144..145,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 147..179,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 152..153,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 154..155,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 154..155,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
TypeVarTuple(
|
||||
TypeParamTypeVarTuple {
|
||||
range: 157..160,
|
||||
name: Identifier {
|
||||
id: "Ts",
|
||||
range: 158..160,
|
||||
},
|
||||
},
|
||||
),
|
||||
ParamSpec(
|
||||
TypeParamParamSpec {
|
||||
range: 162..165,
|
||||
name: Identifier {
|
||||
id: "P",
|
||||
range: 164..165,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 169..179,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 170..171,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 173..175,
|
||||
id: "Ts",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 177..178,
|
||||
id: "P",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 180..217,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 185..186,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 187..193,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 187..188,
|
||||
},
|
||||
bound: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 190..193,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeVarTuple(
|
||||
TypeParamTypeVarTuple {
|
||||
range: 195..198,
|
||||
name: Identifier {
|
||||
id: "Ts",
|
||||
range: 196..198,
|
||||
},
|
||||
},
|
||||
),
|
||||
ParamSpec(
|
||||
TypeParamParamSpec {
|
||||
range: 200..203,
|
||||
name: Identifier {
|
||||
id: "P",
|
||||
range: 202..203,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 207..217,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 208..209,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 211..213,
|
||||
id: "Ts",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 215..216,
|
||||
id: "P",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 218..262,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 223..224,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 225..238,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 225..226,
|
||||
},
|
||||
bound: Some(
|
||||
Tuple(
|
||||
ExprTuple {
|
||||
range: 228..238,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 229..232,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 234..237,
|
||||
id: "str",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeVarTuple(
|
||||
TypeParamTypeVarTuple {
|
||||
range: 240..243,
|
||||
name: Identifier {
|
||||
id: "Ts",
|
||||
range: 241..243,
|
||||
},
|
||||
},
|
||||
),
|
||||
ParamSpec(
|
||||
TypeParamParamSpec {
|
||||
range: 245..248,
|
||||
name: Identifier {
|
||||
id: "P",
|
||||
range: 247..248,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 252..262,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 253..254,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 256..258,
|
||||
id: "Ts",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 260..261,
|
||||
id: "P",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 293..308,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 298..302,
|
||||
id: "type",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 305..308,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 309..325,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 314..319,
|
||||
id: "match",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 322..325,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 326..341,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 331..335,
|
||||
id: "case",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 338..341,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 367..382,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 372..375,
|
||||
id: "foo",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 378..382,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 383..399,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 388..391,
|
||||
id: "foo",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 394..399,
|
||||
id: "match",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 400..415,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 405..408,
|
||||
id: "foo",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 411..415,
|
||||
id: "case",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 439..454,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 447..448,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 451..454,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 455..470,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 460..461,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 467..470,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 471..486,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 476..477,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 483..486,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 487..507,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 492..493,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 502..505,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 508..527,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 519..520,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 521..522,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 521..522,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 526..527,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 528..548,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 533..534,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 542..543,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 542..543,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 547..548,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
TypeAlias(
|
||||
StmtTypeAlias {
|
||||
range: 549..568,
|
||||
name: Name(
|
||||
ExprName {
|
||||
range: 554..555,
|
||||
id: "X",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
type_params: [
|
||||
TypeVar(
|
||||
TypeParamTypeVar {
|
||||
range: 556..557,
|
||||
name: Identifier {
|
||||
id: "T",
|
||||
range: 556..557,
|
||||
},
|
||||
bound: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 567..568,
|
||||
id: "T",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Subscript(
|
||||
ExprSubscript {
|
||||
range: 0..8,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 0..1,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Slice(
|
||||
ExprSlice {
|
||||
range: 2..7,
|
||||
lower: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 2..3,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
upper: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 4..5,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
step: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 6..7,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
)
|
|
@ -0,0 +1,271 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 0..36,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 0..11,
|
||||
id: "array_slice",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 14..36,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 14..19,
|
||||
id: "array",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Tuple(
|
||||
ExprTuple {
|
||||
range: 20..35,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 20..21,
|
||||
value: Int(
|
||||
0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Starred(
|
||||
ExprStarred {
|
||||
range: 23..31,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 24..31,
|
||||
id: "indexes",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
UnaryOp(
|
||||
ExprUnaryOp {
|
||||
range: 33..35,
|
||||
op: USub,
|
||||
operand: Constant(
|
||||
ExprConstant {
|
||||
range: 34..35,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 37..73,
|
||||
targets: [
|
||||
Subscript(
|
||||
ExprSubscript {
|
||||
range: 37..59,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 37..42,
|
||||
id: "array",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Tuple(
|
||||
ExprTuple {
|
||||
range: 43..58,
|
||||
elts: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 43..44,
|
||||
value: Int(
|
||||
0,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Starred(
|
||||
ExprStarred {
|
||||
range: 46..54,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 47..54,
|
||||
id: "indexes",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
UnaryOp(
|
||||
ExprUnaryOp {
|
||||
range: 56..58,
|
||||
op: USub,
|
||||
operand: Constant(
|
||||
ExprConstant {
|
||||
range: 57..58,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 62..73,
|
||||
id: "array_slice",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 74..119,
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 74..119,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 74..79,
|
||||
id: "array",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Tuple(
|
||||
ExprTuple {
|
||||
range: 80..118,
|
||||
elts: [
|
||||
Starred(
|
||||
ExprStarred {
|
||||
range: 80..98,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 81..98,
|
||||
id: "indexes_to_select",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Starred(
|
||||
ExprStarred {
|
||||
range: 100..118,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 101..118,
|
||||
id: "indexes_to_select",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 120..150,
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 120..150,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 120..125,
|
||||
id: "array",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Tuple(
|
||||
ExprTuple {
|
||||
range: 126..149,
|
||||
elts: [
|
||||
Slice(
|
||||
ExprSlice {
|
||||
range: 126..129,
|
||||
lower: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 126..127,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
upper: Some(
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 128..129,
|
||||
value: Int(
|
||||
5,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
),
|
||||
step: None,
|
||||
},
|
||||
),
|
||||
Starred(
|
||||
ExprStarred {
|
||||
range: 131..149,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 132..149,
|
||||
id: "indexes_to_select",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,223 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Try(
|
||||
StmtTry {
|
||||
range: 0..134,
|
||||
body: [
|
||||
Raise(
|
||||
StmtRaise {
|
||||
range: 9..28,
|
||||
exc: Some(
|
||||
Call(
|
||||
ExprCall {
|
||||
range: 15..28,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 15..25,
|
||||
id: "ValueError",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 26..27,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
),
|
||||
cause: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
handlers: [
|
||||
ExceptHandler(
|
||||
ExceptHandlerExceptHandler {
|
||||
range: 29..82,
|
||||
type_: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 36..45,
|
||||
id: "TypeError",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
name: Some(
|
||||
Identifier {
|
||||
id: "e",
|
||||
range: 49..50,
|
||||
},
|
||||
),
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 56..82,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 56..82,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 56..61,
|
||||
id: "print",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
JoinedStr(
|
||||
ExprJoinedStr {
|
||||
range: 62..81,
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 64..71,
|
||||
value: Str(
|
||||
"caught ",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 71..80,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 72..79,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 72..76,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 77..78,
|
||||
id: "e",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
ExceptHandler(
|
||||
ExceptHandlerExceptHandler {
|
||||
range: 83..134,
|
||||
type_: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 90..97,
|
||||
id: "OSError",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
name: Some(
|
||||
Identifier {
|
||||
id: "e",
|
||||
range: 101..102,
|
||||
},
|
||||
),
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 108..134,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 108..134,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 108..113,
|
||||
id: "print",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
JoinedStr(
|
||||
ExprJoinedStr {
|
||||
range: 114..133,
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 116..123,
|
||||
value: Str(
|
||||
"caught ",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 123..132,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 124..131,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 124..128,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 129..130,
|
||||
id: "e",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
],
|
||||
orelse: [],
|
||||
finalbody: [],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,393 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
TryStar(
|
||||
StmtTryStar {
|
||||
range: 0..260,
|
||||
body: [
|
||||
Raise(
|
||||
StmtRaise {
|
||||
range: 9..98,
|
||||
exc: Some(
|
||||
Call(
|
||||
ExprCall {
|
||||
range: 15..98,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 15..29,
|
||||
id: "ExceptionGroup",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 30..34,
|
||||
value: Str(
|
||||
"eg",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
List(
|
||||
ExprList {
|
||||
range: 44..97,
|
||||
elts: [
|
||||
Call(
|
||||
ExprCall {
|
||||
range: 45..58,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 45..55,
|
||||
id: "ValueError",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 56..57,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
Call(
|
||||
ExprCall {
|
||||
range: 60..72,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 60..69,
|
||||
id: "TypeError",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 70..71,
|
||||
value: Int(
|
||||
2,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
Call(
|
||||
ExprCall {
|
||||
range: 74..84,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 74..81,
|
||||
id: "OSError",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 82..83,
|
||||
value: Int(
|
||||
3,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
Call(
|
||||
ExprCall {
|
||||
range: 86..96,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 86..93,
|
||||
id: "OSError",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 94..95,
|
||||
value: Int(
|
||||
4,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
),
|
||||
cause: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
handlers: [
|
||||
ExceptHandler(
|
||||
ExceptHandlerExceptHandler {
|
||||
range: 99..180,
|
||||
type_: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 107..116,
|
||||
id: "TypeError",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
name: Some(
|
||||
Identifier {
|
||||
id: "e",
|
||||
range: 120..121,
|
||||
},
|
||||
),
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 127..180,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 127..180,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 127..132,
|
||||
id: "print",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
JoinedStr(
|
||||
ExprJoinedStr {
|
||||
range: 133..179,
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 135..142,
|
||||
value: Str(
|
||||
"caught ",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 142..151,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 143..150,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 143..147,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 148..149,
|
||||
id: "e",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 151..164,
|
||||
value: Str(
|
||||
" with nested ",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 164..178,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 165..177,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 165..166,
|
||||
id: "e",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "exceptions",
|
||||
range: 167..177,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
ExceptHandler(
|
||||
ExceptHandlerExceptHandler {
|
||||
range: 181..260,
|
||||
type_: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 189..196,
|
||||
id: "OSError",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
name: Some(
|
||||
Identifier {
|
||||
id: "e",
|
||||
range: 200..201,
|
||||
},
|
||||
),
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 207..260,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 207..260,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 207..212,
|
||||
id: "print",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
JoinedStr(
|
||||
ExprJoinedStr {
|
||||
range: 213..259,
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 215..222,
|
||||
value: Str(
|
||||
"caught ",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 222..231,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 223..230,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 223..227,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 228..229,
|
||||
id: "e",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 231..244,
|
||||
value: Str(
|
||||
" with nested ",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 244..258,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 245..257,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 245..246,
|
||||
id: "e",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "exceptions",
|
||||
range: 247..257,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
],
|
||||
orelse: [],
|
||||
finalbody: [],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,968 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 2..16,
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 2..16,
|
||||
elts: [
|
||||
BinOp(
|
||||
ExprBinOp {
|
||||
range: 2..13,
|
||||
left: BinOp(
|
||||
ExprBinOp {
|
||||
range: 2..9,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 2..6,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Mult,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 8..9,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 12..13,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 15..16,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 41..57,
|
||||
value: Tuple(
|
||||
ExprTuple {
|
||||
range: 41..57,
|
||||
elts: [
|
||||
BinOp(
|
||||
ExprBinOp {
|
||||
range: 41..54,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 41..45,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Mult,
|
||||
right: BinOp(
|
||||
ExprBinOp {
|
||||
range: 48..53,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 48..49,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 52..53,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 56..57,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 82..98,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 82..98,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 82..86,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Starred(
|
||||
ExprStarred {
|
||||
range: 88..94,
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 89..94,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 89..90,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 93..94,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 96..97,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 124..139,
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 124..139,
|
||||
left: BinOp(
|
||||
ExprBinOp {
|
||||
range: 124..135,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 124..128,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Sub,
|
||||
right: BinOp(
|
||||
ExprBinOp {
|
||||
range: 130..135,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 130..131,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Mult,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 134..135,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 138..139,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 165..182,
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 165..182,
|
||||
left: BinOp(
|
||||
ExprBinOp {
|
||||
range: 165..178,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 165..169,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Sub,
|
||||
right: BinOp(
|
||||
ExprBinOp {
|
||||
range: 172..177,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 172..173,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
op: Mult,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 176..177,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 181..182,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 208..225,
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
range: 208..225,
|
||||
left: BinOp(
|
||||
ExprBinOp {
|
||||
range: 208..221,
|
||||
left: Call(
|
||||
ExprCall {
|
||||
range: 208..217,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 208..212,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
UnaryOp(
|
||||
ExprUnaryOp {
|
||||
range: 214..216,
|
||||
op: USub,
|
||||
operand: Name(
|
||||
ExprName {
|
||||
range: 215..216,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
op: Mult,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 220..221,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
op: Add,
|
||||
right: Name(
|
||||
ExprName {
|
||||
range: 224..225,
|
||||
id: "c",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 252..261,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 252..261,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 252..259,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 252..256,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "a",
|
||||
range: 260..261,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 277..288,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 277..288,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 277..286,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 277..281,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Tuple(
|
||||
ExprTuple {
|
||||
range: 283..285,
|
||||
elts: [],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "a",
|
||||
range: 287..288,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 306..318,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 306..318,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 306..316,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 306..310,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Tuple(
|
||||
ExprTuple {
|
||||
range: 312..314,
|
||||
elts: [],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "a",
|
||||
range: 317..318,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 336..346,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 336..346,
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 336..344,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 336..340,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Name(
|
||||
ExprName {
|
||||
range: 342..343,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "b",
|
||||
range: 345..346,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 363..374,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 363..374,
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 363..372,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 363..367,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Tuple(
|
||||
ExprTuple {
|
||||
range: 369..371,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 369..370,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "b",
|
||||
range: 373..374,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 413..426,
|
||||
value: Attribute(
|
||||
ExprAttribute {
|
||||
range: 413..426,
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 413..424,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 413..417,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Tuple(
|
||||
ExprTuple {
|
||||
range: 419..423,
|
||||
elts: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 420..421,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
attr: Identifier {
|
||||
id: "b",
|
||||
range: 425..426,
|
||||
},
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 446..462,
|
||||
value: Subscript(
|
||||
ExprSubscript {
|
||||
range: 446..462,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 446..452,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 446..450,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
slice: Slice(
|
||||
ExprSlice {
|
||||
range: 453..461,
|
||||
lower: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 453..454,
|
||||
id: "a",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
upper: Some(
|
||||
Name(
|
||||
ExprName {
|
||||
range: 460..461,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
step: None,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
If(
|
||||
StmtIf {
|
||||
range: 481..499,
|
||||
test: NamedExpr(
|
||||
ExprNamedExpr {
|
||||
range: 484..493,
|
||||
target: Name(
|
||||
ExprName {
|
||||
range: 484..488,
|
||||
id: "type",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 492..493,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 495..499,
|
||||
},
|
||||
),
|
||||
],
|
||||
elif_else_clauses: [],
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 500..535,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 500..504,
|
||||
id: "type",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Lambda(
|
||||
ExprLambda {
|
||||
range: 507..535,
|
||||
args: Arguments {
|
||||
range: 514..519,
|
||||
posonlyargs: [],
|
||||
args: [
|
||||
ArgWithDefault {
|
||||
range: 514..519,
|
||||
def: Arg {
|
||||
range: 514..519,
|
||||
arg: Identifier {
|
||||
id: "query",
|
||||
range: 514..519,
|
||||
},
|
||||
annotation: None,
|
||||
type_comment: None,
|
||||
},
|
||||
default: None,
|
||||
},
|
||||
],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: Compare(
|
||||
ExprCompare {
|
||||
range: 521..535,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 521..526,
|
||||
id: "query",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ops: [
|
||||
Eq,
|
||||
],
|
||||
comparators: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 530..535,
|
||||
id: "event",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 536..551,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 536..551,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 536..541,
|
||||
id: "print",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Call(
|
||||
ExprCall {
|
||||
range: 542..550,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 542..546,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 547..549,
|
||||
value: Int(
|
||||
12,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 552..562,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 552..562,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 552..556,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 557..561,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 563..581,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 563..564,
|
||||
id: "a",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Compare(
|
||||
ExprCompare {
|
||||
range: 570..579,
|
||||
left: Name(
|
||||
ExprName {
|
||||
range: 570..574,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ops: [
|
||||
In,
|
||||
],
|
||||
comparators: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 578..579,
|
||||
id: "C",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 582..598,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 582..583,
|
||||
id: "a",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 589..596,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 589..593,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 594..595,
|
||||
id: "b",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
keywords: [],
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 599..616,
|
||||
value: Call(
|
||||
ExprCall {
|
||||
range: 599..616,
|
||||
func: Name(
|
||||
ExprName {
|
||||
range: 599..603,
|
||||
id: "type",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
args: [],
|
||||
keywords: [
|
||||
Keyword {
|
||||
range: 607..614,
|
||||
arg: Some(
|
||||
Identifier {
|
||||
id: "X",
|
||||
range: 607..608,
|
||||
},
|
||||
),
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 611..614,
|
||||
id: "int",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 617..625,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 617..621,
|
||||
id: "type",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 624..625,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 626..638,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 626..630,
|
||||
id: "type",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 633..634,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 637..638,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
range: 639..651,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 639..640,
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
Name(
|
||||
ExprName {
|
||||
range: 643..647,
|
||||
id: "type",
|
||||
ctx: Store,
|
||||
},
|
||||
),
|
||||
],
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 650..651,
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,92 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 1..49,
|
||||
name: Identifier {
|
||||
id: "args_to_tuple",
|
||||
range: 5..18,
|
||||
},
|
||||
args: Arguments {
|
||||
range: 18..30,
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: Some(
|
||||
Arg {
|
||||
range: 20..29,
|
||||
arg: Identifier {
|
||||
id: "args",
|
||||
range: 20..24,
|
||||
},
|
||||
annotation: Some(
|
||||
Starred(
|
||||
ExprStarred {
|
||||
range: 26..29,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 27..29,
|
||||
id: "Ts",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
kwonlyargs: [],
|
||||
kwarg: None,
|
||||
},
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 46..49,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 46..49,
|
||||
value: Ellipsis,
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [],
|
||||
returns: Some(
|
||||
Subscript(
|
||||
ExprSubscript {
|
||||
range: 34..44,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 34..39,
|
||||
id: "Tuple",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
slice: Starred(
|
||||
ExprStarred {
|
||||
range: 40..43,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 41..43,
|
||||
id: "Ts",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
),
|
||||
type_params: [],
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
]
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..15,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..15,
|
||||
value: Str(
|
||||
"\u{8}",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..9,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..9,
|
||||
value: Str(
|
||||
"\u{7}",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..21,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..21,
|
||||
value: Str(
|
||||
"\r",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..45,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..45,
|
||||
value: Str(
|
||||
"\u{89}",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..12,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..12,
|
||||
value: Str(
|
||||
"\u{7f}",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,277 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..738,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..738,
|
||||
value: Bytes(
|
||||
[
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
31,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
35,
|
||||
36,
|
||||
37,
|
||||
38,
|
||||
39,
|
||||
40,
|
||||
41,
|
||||
42,
|
||||
43,
|
||||
44,
|
||||
45,
|
||||
46,
|
||||
47,
|
||||
48,
|
||||
49,
|
||||
50,
|
||||
51,
|
||||
52,
|
||||
53,
|
||||
54,
|
||||
55,
|
||||
56,
|
||||
57,
|
||||
58,
|
||||
59,
|
||||
60,
|
||||
61,
|
||||
62,
|
||||
63,
|
||||
64,
|
||||
65,
|
||||
66,
|
||||
67,
|
||||
68,
|
||||
69,
|
||||
70,
|
||||
71,
|
||||
72,
|
||||
73,
|
||||
74,
|
||||
75,
|
||||
76,
|
||||
77,
|
||||
78,
|
||||
79,
|
||||
80,
|
||||
81,
|
||||
82,
|
||||
83,
|
||||
84,
|
||||
85,
|
||||
86,
|
||||
87,
|
||||
88,
|
||||
89,
|
||||
90,
|
||||
91,
|
||||
92,
|
||||
93,
|
||||
94,
|
||||
95,
|
||||
96,
|
||||
97,
|
||||
98,
|
||||
99,
|
||||
100,
|
||||
101,
|
||||
102,
|
||||
103,
|
||||
104,
|
||||
105,
|
||||
106,
|
||||
107,
|
||||
108,
|
||||
109,
|
||||
110,
|
||||
111,
|
||||
112,
|
||||
113,
|
||||
114,
|
||||
115,
|
||||
116,
|
||||
117,
|
||||
118,
|
||||
119,
|
||||
120,
|
||||
121,
|
||||
122,
|
||||
123,
|
||||
124,
|
||||
125,
|
||||
126,
|
||||
127,
|
||||
128,
|
||||
129,
|
||||
130,
|
||||
131,
|
||||
132,
|
||||
133,
|
||||
134,
|
||||
135,
|
||||
136,
|
||||
137,
|
||||
138,
|
||||
139,
|
||||
140,
|
||||
141,
|
||||
142,
|
||||
143,
|
||||
144,
|
||||
145,
|
||||
146,
|
||||
147,
|
||||
148,
|
||||
149,
|
||||
150,
|
||||
151,
|
||||
152,
|
||||
153,
|
||||
154,
|
||||
155,
|
||||
156,
|
||||
157,
|
||||
158,
|
||||
159,
|
||||
160,
|
||||
161,
|
||||
162,
|
||||
163,
|
||||
164,
|
||||
165,
|
||||
166,
|
||||
167,
|
||||
168,
|
||||
169,
|
||||
170,
|
||||
171,
|
||||
172,
|
||||
173,
|
||||
174,
|
||||
175,
|
||||
176,
|
||||
177,
|
||||
178,
|
||||
179,
|
||||
180,
|
||||
181,
|
||||
182,
|
||||
183,
|
||||
184,
|
||||
185,
|
||||
186,
|
||||
187,
|
||||
188,
|
||||
189,
|
||||
190,
|
||||
191,
|
||||
192,
|
||||
193,
|
||||
194,
|
||||
195,
|
||||
196,
|
||||
197,
|
||||
198,
|
||||
199,
|
||||
200,
|
||||
201,
|
||||
202,
|
||||
203,
|
||||
204,
|
||||
205,
|
||||
206,
|
||||
207,
|
||||
208,
|
||||
209,
|
||||
210,
|
||||
211,
|
||||
212,
|
||||
213,
|
||||
214,
|
||||
215,
|
||||
216,
|
||||
217,
|
||||
218,
|
||||
219,
|
||||
220,
|
||||
221,
|
||||
222,
|
||||
223,
|
||||
224,
|
||||
225,
|
||||
226,
|
||||
227,
|
||||
228,
|
||||
229,
|
||||
230,
|
||||
231,
|
||||
232,
|
||||
233,
|
||||
234,
|
||||
235,
|
||||
236,
|
||||
237,
|
||||
238,
|
||||
239,
|
||||
240,
|
||||
241,
|
||||
242,
|
||||
243,
|
||||
244,
|
||||
245,
|
||||
246,
|
||||
247,
|
||||
248,
|
||||
249,
|
||||
250,
|
||||
251,
|
||||
252,
|
||||
253,
|
||||
254,
|
||||
255,
|
||||
],
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..12,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..12,
|
||||
value: Str(
|
||||
"\u{1b}",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..13,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..13,
|
||||
value: Bytes(
|
||||
[
|
||||
111,
|
||||
109,
|
||||
107,
|
||||
109,
|
||||
111,
|
||||
107,
|
||||
92,
|
||||
88,
|
||||
97,
|
||||
97,
|
||||
],
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..14,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..14,
|
||||
value: Bytes(
|
||||
[
|
||||
35,
|
||||
97,
|
||||
4,
|
||||
83,
|
||||
52,
|
||||
],
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..15,
|
||||
value: Constant(
|
||||
ExprConstant {
|
||||
range: 0..15,
|
||||
value: Str(
|
||||
"\u{c}",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..22,
|
||||
value: JoinedStr(
|
||||
ExprJoinedStr {
|
||||
range: 0..22,
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 2..5,
|
||||
value: Str(
|
||||
"aaa",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 5..10,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 6..9,
|
||||
id: "bbb",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 10..13,
|
||||
value: Str(
|
||||
"ccc",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 13..18,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 14..17,
|
||||
id: "ddd",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 18..21,
|
||||
value: Str(
|
||||
"eee",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..8,
|
||||
value: JoinedStr(
|
||||
ExprJoinedStr {
|
||||
range: 0..8,
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 2..4,
|
||||
value: Str(
|
||||
"\\",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 4..7,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 5..6,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..8,
|
||||
value: JoinedStr(
|
||||
ExprJoinedStr {
|
||||
range: 0..8,
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 2..4,
|
||||
value: Str(
|
||||
"\n",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 4..7,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 5..6,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..9,
|
||||
value: JoinedStr(
|
||||
ExprJoinedStr {
|
||||
range: 0..9,
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 3..5,
|
||||
value: Str(
|
||||
"\\\n",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 5..8,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 6..7,
|
||||
id: "x",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 2..9,
|
||||
value: Str(
|
||||
"user=",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 2..9,
|
||||
value: Str(
|
||||
"",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 2..9,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 3..7,
|
||||
id: "user",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
conversion: Repr,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,88 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 2..6,
|
||||
value: Str(
|
||||
"mix ",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 6..13,
|
||||
value: Str(
|
||||
"user=",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 6..13,
|
||||
value: Str(
|
||||
"",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 6..13,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 7..11,
|
||||
id: "user",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
conversion: Repr,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 13..28,
|
||||
value: Str(
|
||||
" with text and ",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 28..37,
|
||||
value: Str(
|
||||
"second=",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 28..37,
|
||||
value: Str(
|
||||
"",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 28..37,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 29..35,
|
||||
id: "second",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
conversion: Repr,
|
||||
format_spec: None,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/string.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 2..13,
|
||||
value: Str(
|
||||
"user=",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 2..13,
|
||||
value: Str(
|
||||
"",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
FormattedValue(
|
||||
ExprFormattedValue {
|
||||
range: 2..13,
|
||||
value: Name(
|
||||
ExprName {
|
||||
range: 3..7,
|
||||
id: "user",
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
conversion: None,
|
||||
format_spec: Some(
|
||||
JoinedStr(
|
||||
ExprJoinedStr {
|
||||
range: 9..12,
|
||||
values: [
|
||||
Constant(
|
||||
ExprConstant {
|
||||
range: 9..12,
|
||||
value: Str(
|
||||
">10",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
]
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue