Fix typos

---------

Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
This commit is contained in:
omahs 2025-05-09 20:57:14 +02:00 committed by GitHub
parent b4a1ebdfe3
commit 882a1a702e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 191 additions and 191 deletions

View file

@ -92,7 +92,7 @@ impl std::fmt::Display for IndentStyle {
} }
} }
/// The visual width of a indentation. /// The visual width of an indentation.
/// ///
/// Determines the visual width of a tab character (`\t`) and the number of /// Determines the visual width of a tab character (`\t`) and the number of
/// spaces per indent when using [`IndentStyle::Space`]. /// spaces per indent when using [`IndentStyle::Space`].
@ -207,7 +207,7 @@ pub trait FormatOptions {
/// What's the max width of a line. Defaults to 80. /// What's the max width of a line. Defaults to 80.
fn line_width(&self) -> LineWidth; fn line_width(&self) -> LineWidth;
/// Derives the print options from the these format options /// Derives the print options from these format options
fn as_print_options(&self) -> PrinterOptions; fn as_print_options(&self) -> PrinterOptions;
} }

View file

@ -144,14 +144,14 @@ def f():
def f(): def f():
# make sure that `tmp` is not deleted # make sure that `tmp` is not deleted
tmp = 1; result = [] # commment should be protected tmp = 1; result = [] # comment should be protected
for i in range(10): for i in range(10):
result.append(i + 1) # PERF401 result.append(i + 1) # PERF401
def f(): def f():
# make sure that `tmp` is not deleted # make sure that `tmp` is not deleted
result = []; tmp = 1 # commment should be protected result = []; tmp = 1 # comment should be protected
for i in range(10): for i in range(10):
result.append(i + 1) # PERF401 result.append(i + 1) # PERF401

View file

@ -93,7 +93,7 @@ PERF401.py:142:9: PERF401 Use a list comprehension to create a transformed list
PERF401.py:149:9: PERF401 Use a list comprehension to create a transformed list PERF401.py:149:9: PERF401 Use a list comprehension to create a transformed list
| |
147 | tmp = 1; result = [] # commment should be protected 147 | tmp = 1; result = [] # comment should be protected
148 | for i in range(10): 148 | for i in range(10):
149 | result.append(i + 1) # PERF401 149 | result.append(i + 1) # PERF401
| ^^^^^^^^^^^^^^^^^^^^ PERF401 | ^^^^^^^^^^^^^^^^^^^^ PERF401
@ -102,7 +102,7 @@ PERF401.py:149:9: PERF401 Use a list comprehension to create a transformed list
PERF401.py:156:9: PERF401 Use a list comprehension to create a transformed list PERF401.py:156:9: PERF401 Use a list comprehension to create a transformed list
| |
154 | result = []; tmp = 1 # commment should be protected 154 | result = []; tmp = 1 # comment should be protected
155 | for i in range(10): 155 | for i in range(10):
156 | result.append(i + 1) # PERF401 156 | result.append(i + 1) # PERF401
| ^^^^^^^^^^^^^^^^^^^^ PERF401 | ^^^^^^^^^^^^^^^^^^^^ PERF401

View file

@ -223,7 +223,7 @@ PERF401.py:142:9: PERF401 [*] Use a list comprehension to create a transformed l
PERF401.py:149:9: PERF401 [*] Use a list comprehension to create a transformed list PERF401.py:149:9: PERF401 [*] Use a list comprehension to create a transformed list
| |
147 | tmp = 1; result = [] # commment should be protected 147 | tmp = 1; result = [] # comment should be protected
148 | for i in range(10): 148 | for i in range(10):
149 | result.append(i + 1) # PERF401 149 | result.append(i + 1) # PERF401
| ^^^^^^^^^^^^^^^^^^^^ PERF401 | ^^^^^^^^^^^^^^^^^^^^ PERF401
@ -234,10 +234,10 @@ PERF401.py:149:9: PERF401 [*] Use a list comprehension to create a transformed l
144 144 | 144 144 |
145 145 | def f(): 145 145 | def f():
146 146 | # make sure that `tmp` is not deleted 146 146 | # make sure that `tmp` is not deleted
147 |- tmp = 1; result = [] # commment should be protected 147 |- tmp = 1; result = [] # comment should be protected
148 |- for i in range(10): 148 |- for i in range(10):
149 |- result.append(i + 1) # PERF401 149 |- result.append(i + 1) # PERF401
147 |+ tmp = 1 # commment should be protected 147 |+ tmp = 1 # comment should be protected
148 |+ result = [i + 1 for i in range(10)] # PERF401 148 |+ result = [i + 1 for i in range(10)] # PERF401
150 149 | 150 149 |
151 150 | 151 150 |
@ -245,7 +245,7 @@ PERF401.py:149:9: PERF401 [*] Use a list comprehension to create a transformed l
PERF401.py:156:9: PERF401 [*] Use a list comprehension to create a transformed list PERF401.py:156:9: PERF401 [*] Use a list comprehension to create a transformed list
| |
154 | result = []; tmp = 1 # commment should be protected 154 | result = []; tmp = 1 # comment should be protected
155 | for i in range(10): 155 | for i in range(10):
156 | result.append(i + 1) # PERF401 156 | result.append(i + 1) # PERF401
| ^^^^^^^^^^^^^^^^^^^^ PERF401 | ^^^^^^^^^^^^^^^^^^^^ PERF401
@ -256,10 +256,10 @@ PERF401.py:156:9: PERF401 [*] Use a list comprehension to create a transformed l
151 151 | 151 151 |
152 152 | def f(): 152 152 | def f():
153 153 | # make sure that `tmp` is not deleted 153 153 | # make sure that `tmp` is not deleted
154 |- result = []; tmp = 1 # commment should be protected 154 |- result = []; tmp = 1 # comment should be protected
155 |- for i in range(10): 155 |- for i in range(10):
156 |- result.append(i + 1) # PERF401 156 |- result.append(i + 1) # PERF401
154 |+ tmp = 1 # commment should be protected 154 |+ tmp = 1 # comment should be protected
155 |+ result = [i + 1 for i in range(10)] # PERF401 155 |+ result = [i + 1 for i in range(10)] # PERF401
157 156 | 157 156 |
158 157 | 158 157 |

View file

@ -2844,7 +2844,7 @@ impl Arguments {
self.find_argument(name, position).map(ArgOrKeyword::value) self.find_argument(name, position).map(ArgOrKeyword::value)
} }
/// Return the the argument with the given name or at the given position, or `None` if no such /// Return the argument with the given name or at the given position, or `None` if no such
/// argument exists. Used to retrieve arguments that can be provided _either_ as keyword or /// argument exists. Used to retrieve arguments that can be provided _either_ as keyword or
/// positional arguments. /// positional arguments.
pub fn find_argument(&self, name: &str, position: usize) -> Option<ArgOrKeyword> { pub fn find_argument(&self, name: &str, position: usize) -> Option<ArgOrKeyword> {

View file

@ -590,7 +590,7 @@ pub fn walk_except_handler<'a, V: Visitor<'a> + ?Sized>(
} }
pub fn walk_arguments<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, arguments: &'a Arguments) { pub fn walk_arguments<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, arguments: &'a Arguments) {
// Note that the there might be keywords before the last arg, e.g. in // Note that there might be keywords before the last arg, e.g. in
// f(*args, a=2, *args2, **kwargs)`, but we follow Python in evaluating first `args` and then // f(*args, a=2, *args2, **kwargs)`, but we follow Python in evaluating first `args` and then
// `keywords`. See also [Arguments::arguments_source_order`]. // `keywords`. See also [Arguments::arguments_source_order`].
for arg in &*arguments.args { for arg in &*arguments.args {

View file

@ -576,7 +576,7 @@ pub fn walk_except_handler<V: Transformer + ?Sized>(
} }
pub fn walk_arguments<V: Transformer + ?Sized>(visitor: &V, arguments: &mut Arguments) { pub fn walk_arguments<V: Transformer + ?Sized>(visitor: &V, arguments: &mut Arguments) {
// Note that the there might be keywords before the last arg, e.g. in // Note that there might be keywords before the last arg, e.g. in
// f(*args, a=2, *args2, **kwargs)`, but we follow Python in evaluating first `args` and then // f(*args, a=2, *args2, **kwargs)`, but we follow Python in evaluating first `args` and then
// `keywords`. See also [Arguments::arguments_source_order`]. // `keywords`. See also [Arguments::arguments_source_order`].
for arg in &mut *arguments.args { for arg in &mut *arguments.args {

View file

@ -1,5 +1,5 @@
# For tuple expression, the minimum binding power of star expression is bitwise or. # For tuple expression, the minimum binding power of star expression is bitwise or.
# Test the first and any other element as the there are two separate calls. # Test the first and any other element as there are two separate calls.
(*x in y, z, *x in y) (*x in y, z, *x in y)
(*not x, z, *not x) (*not x, z, *not x)

View file

@ -7,24 +7,24 @@ input_file: crates/ruff_python_parser/resources/invalid/expressions/parenthesize
``` ```
Module( Module(
ModModule { ModModule {
range: 0..536, range: 0..532,
body: [ body: [
Expr( Expr(
StmtExpr { StmtExpr {
range: 161..182, range: 157..178,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 161..182, range: 157..178,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 162..169, range: 158..165,
value: Compare( value: Compare(
ExprCompare { ExprCompare {
range: 163..169, range: 159..165,
left: Name( left: Name(
ExprName { ExprName {
range: 163..164, range: 159..160,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -35,7 +35,7 @@ Module(
comparators: [ comparators: [
Name( Name(
ExprName { ExprName {
range: 168..169, range: 164..165,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -48,20 +48,20 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 171..172, range: 167..168,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 174..181, range: 170..177,
value: Compare( value: Compare(
ExprCompare { ExprCompare {
range: 175..181, range: 171..177,
left: Name( left: Name(
ExprName { ExprName {
range: 175..176, range: 171..172,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -72,7 +72,7 @@ Module(
comparators: [ comparators: [
Name( Name(
ExprName { ExprName {
range: 180..181, range: 176..177,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -92,21 +92,21 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 183..202, range: 179..198,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 183..202, range: 179..198,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 184..190, range: 180..186,
value: UnaryOp( value: UnaryOp(
ExprUnaryOp { ExprUnaryOp {
range: 185..190, range: 181..186,
op: Not, op: Not,
operand: Name( operand: Name(
ExprName { ExprName {
range: 189..190, range: 185..186,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -118,21 +118,21 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 192..193, range: 188..189,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 195..201, range: 191..197,
value: UnaryOp( value: UnaryOp(
ExprUnaryOp { ExprUnaryOp {
range: 196..201, range: 192..197,
op: Not, op: Not,
operand: Name( operand: Name(
ExprName { ExprName {
range: 200..201, range: 196..197,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -151,29 +151,29 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 203..226, range: 199..222,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 203..226, range: 199..222,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 204..212, range: 200..208,
value: BoolOp( value: BoolOp(
ExprBoolOp { ExprBoolOp {
range: 205..212, range: 201..208,
op: And, op: And,
values: [ values: [
Name( Name(
ExprName { ExprName {
range: 205..206, range: 201..202,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
Name( Name(
ExprName { ExprName {
range: 211..212, range: 207..208,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -186,29 +186,29 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 214..215, range: 210..211,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 217..225, range: 213..221,
value: BoolOp( value: BoolOp(
ExprBoolOp { ExprBoolOp {
range: 218..225, range: 214..221,
op: And, op: And,
values: [ values: [
Name( Name(
ExprName { ExprName {
range: 218..219, range: 214..215,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
Name( Name(
ExprName { ExprName {
range: 224..225, range: 220..221,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -228,29 +228,29 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 227..248, range: 223..244,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 227..248, range: 223..244,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 228..235, range: 224..231,
value: BoolOp( value: BoolOp(
ExprBoolOp { ExprBoolOp {
range: 229..235, range: 225..231,
op: Or, op: Or,
values: [ values: [
Name( Name(
ExprName { ExprName {
range: 229..230, range: 225..226,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
Name( Name(
ExprName { ExprName {
range: 234..235, range: 230..231,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -263,29 +263,29 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 237..238, range: 233..234,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 240..247, range: 236..243,
value: BoolOp( value: BoolOp(
ExprBoolOp { ExprBoolOp {
range: 241..247, range: 237..243,
op: Or, op: Or,
values: [ values: [
Name( Name(
ExprName { ExprName {
range: 241..242, range: 237..238,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
Name( Name(
ExprName { ExprName {
range: 246..247, range: 242..243,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -305,33 +305,33 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 249..290, range: 245..286,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 249..290, range: 245..286,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 250..267, range: 246..263,
value: If( value: If(
ExprIf { ExprIf {
range: 251..267, range: 247..263,
test: BooleanLiteral( test: BooleanLiteral(
ExprBooleanLiteral { ExprBooleanLiteral {
range: 256..260, range: 252..256,
value: true, value: true,
}, },
), ),
body: Name( body: Name(
ExprName { ExprName {
range: 251..252, range: 247..248,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
orelse: Name( orelse: Name(
ExprName { ExprName {
range: 266..267, range: 262..263,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -343,33 +343,33 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 269..270, range: 265..266,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 272..289, range: 268..285,
value: If( value: If(
ExprIf { ExprIf {
range: 273..289, range: 269..285,
test: BooleanLiteral( test: BooleanLiteral(
ExprBooleanLiteral { ExprBooleanLiteral {
range: 278..282, range: 274..278,
value: true, value: true,
}, },
), ),
body: Name( body: Name(
ExprName { ExprName {
range: 273..274, range: 269..270,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
orelse: Name( orelse: Name(
ExprName { ExprName {
range: 288..289, range: 284..285,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -388,29 +388,29 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 291..322, range: 287..318,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 291..322, range: 287..318,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 292..304, range: 288..300,
value: Lambda( value: Lambda(
ExprLambda { ExprLambda {
range: 293..304, range: 289..300,
parameters: Some( parameters: Some(
Parameters { Parameters {
range: 300..301, range: 296..297,
posonlyargs: [], posonlyargs: [],
args: [ args: [
ParameterWithDefault { ParameterWithDefault {
range: 300..301, range: 296..297,
parameter: Parameter { parameter: Parameter {
range: 300..301, range: 296..297,
name: Identifier { name: Identifier {
id: Name("x"), id: Name("x"),
range: 300..301, range: 296..297,
}, },
annotation: None, annotation: None,
}, },
@ -424,7 +424,7 @@ Module(
), ),
body: Name( body: Name(
ExprName { ExprName {
range: 303..304, range: 299..300,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -436,29 +436,29 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 306..307, range: 302..303,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 309..321, range: 305..317,
value: Lambda( value: Lambda(
ExprLambda { ExprLambda {
range: 310..321, range: 306..317,
parameters: Some( parameters: Some(
Parameters { Parameters {
range: 317..318, range: 313..314,
posonlyargs: [], posonlyargs: [],
args: [ args: [
ParameterWithDefault { ParameterWithDefault {
range: 317..318, range: 313..314,
parameter: Parameter { parameter: Parameter {
range: 317..318, range: 313..314,
name: Identifier { name: Identifier {
id: Name("x"), id: Name("x"),
range: 317..318, range: 313..314,
}, },
annotation: None, annotation: None,
}, },
@ -472,7 +472,7 @@ Module(
), ),
body: Name( body: Name(
ExprName { ExprName {
range: 320..321, range: 316..317,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -491,20 +491,20 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 323..344, range: 319..340,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 323..344, range: 319..340,
elts: [ elts: [
Named( Named(
ExprNamed { ExprNamed {
range: 324..331, range: 320..327,
target: Starred( target: Starred(
ExprStarred { ExprStarred {
range: 324..326, range: 320..322,
value: Name( value: Name(
ExprName { ExprName {
range: 325..326, range: 321..322,
id: Name("x"), id: Name("x"),
ctx: Store, ctx: Store,
}, },
@ -514,7 +514,7 @@ Module(
), ),
value: NumberLiteral( value: NumberLiteral(
ExprNumberLiteral { ExprNumberLiteral {
range: 330..331, range: 326..327,
value: Int( value: Int(
2, 2,
), ),
@ -524,20 +524,20 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 333..334, range: 329..330,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Named( Named(
ExprNamed { ExprNamed {
range: 336..343, range: 332..339,
target: Starred( target: Starred(
ExprStarred { ExprStarred {
range: 336..338, range: 332..334,
value: Name( value: Name(
ExprName { ExprName {
range: 337..338, range: 333..334,
id: Name("x"), id: Name("x"),
ctx: Store, ctx: Store,
}, },
@ -547,7 +547,7 @@ Module(
), ),
value: NumberLiteral( value: NumberLiteral(
ExprNumberLiteral { ExprNumberLiteral {
range: 342..343, range: 338..339,
value: Int( value: Int(
2, 2,
), ),
@ -564,20 +564,20 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 367..386, range: 363..382,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 367..386, range: 363..382,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 367..374, range: 363..370,
value: Compare( value: Compare(
ExprCompare { ExprCompare {
range: 368..374, range: 364..370,
left: Name( left: Name(
ExprName { ExprName {
range: 368..369, range: 364..365,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -588,7 +588,7 @@ Module(
comparators: [ comparators: [
Name( Name(
ExprName { ExprName {
range: 373..374, range: 369..370,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -601,20 +601,20 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 376..377, range: 372..373,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 379..386, range: 375..382,
value: Compare( value: Compare(
ExprCompare { ExprCompare {
range: 380..386, range: 376..382,
left: Name( left: Name(
ExprName { ExprName {
range: 380..381, range: 376..377,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -625,7 +625,7 @@ Module(
comparators: [ comparators: [
Name( Name(
ExprName { ExprName {
range: 385..386, range: 381..382,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -645,21 +645,21 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 387..404, range: 383..400,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 387..404, range: 383..400,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 387..393, range: 383..389,
value: UnaryOp( value: UnaryOp(
ExprUnaryOp { ExprUnaryOp {
range: 388..393, range: 384..389,
op: Not, op: Not,
operand: Name( operand: Name(
ExprName { ExprName {
range: 392..393, range: 388..389,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -671,21 +671,21 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 395..396, range: 391..392,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 398..404, range: 394..400,
value: UnaryOp( value: UnaryOp(
ExprUnaryOp { ExprUnaryOp {
range: 399..404, range: 395..400,
op: Not, op: Not,
operand: Name( operand: Name(
ExprName { ExprName {
range: 403..404, range: 399..400,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -704,29 +704,29 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 405..426, range: 401..422,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 405..426, range: 401..422,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 405..413, range: 401..409,
value: BoolOp( value: BoolOp(
ExprBoolOp { ExprBoolOp {
range: 406..413, range: 402..409,
op: And, op: And,
values: [ values: [
Name( Name(
ExprName { ExprName {
range: 406..407, range: 402..403,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
Name( Name(
ExprName { ExprName {
range: 412..413, range: 408..409,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -739,29 +739,29 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 415..416, range: 411..412,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 418..426, range: 414..422,
value: BoolOp( value: BoolOp(
ExprBoolOp { ExprBoolOp {
range: 419..426, range: 415..422,
op: And, op: And,
values: [ values: [
Name( Name(
ExprName { ExprName {
range: 419..420, range: 415..416,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
Name( Name(
ExprName { ExprName {
range: 425..426, range: 421..422,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -781,29 +781,29 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 427..446, range: 423..442,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 427..446, range: 423..442,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 427..434, range: 423..430,
value: BoolOp( value: BoolOp(
ExprBoolOp { ExprBoolOp {
range: 428..434, range: 424..430,
op: Or, op: Or,
values: [ values: [
Name( Name(
ExprName { ExprName {
range: 428..429, range: 424..425,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
Name( Name(
ExprName { ExprName {
range: 433..434, range: 429..430,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -816,29 +816,29 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 436..437, range: 432..433,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 439..446, range: 435..442,
value: BoolOp( value: BoolOp(
ExprBoolOp { ExprBoolOp {
range: 440..446, range: 436..442,
op: Or, op: Or,
values: [ values: [
Name( Name(
ExprName { ExprName {
range: 440..441, range: 436..437,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
Name( Name(
ExprName { ExprName {
range: 445..446, range: 441..442,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -858,33 +858,33 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 447..486, range: 443..482,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 447..486, range: 443..482,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 447..464, range: 443..460,
value: If( value: If(
ExprIf { ExprIf {
range: 448..464, range: 444..460,
test: BooleanLiteral( test: BooleanLiteral(
ExprBooleanLiteral { ExprBooleanLiteral {
range: 453..457, range: 449..453,
value: true, value: true,
}, },
), ),
body: Name( body: Name(
ExprName { ExprName {
range: 448..449, range: 444..445,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
orelse: Name( orelse: Name(
ExprName { ExprName {
range: 463..464, range: 459..460,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -896,33 +896,33 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 466..467, range: 462..463,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 469..486, range: 465..482,
value: If( value: If(
ExprIf { ExprIf {
range: 470..486, range: 466..482,
test: BooleanLiteral( test: BooleanLiteral(
ExprBooleanLiteral { ExprBooleanLiteral {
range: 475..479, range: 471..475,
value: true, value: true,
}, },
), ),
body: Name( body: Name(
ExprName { ExprName {
range: 470..471, range: 466..467,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
), ),
orelse: Name( orelse: Name(
ExprName { ExprName {
range: 485..486, range: 481..482,
id: Name("y"), id: Name("y"),
ctx: Load, ctx: Load,
}, },
@ -941,29 +941,29 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 487..516, range: 483..512,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 487..516, range: 483..512,
elts: [ elts: [
Starred( Starred(
ExprStarred { ExprStarred {
range: 487..499, range: 483..495,
value: Lambda( value: Lambda(
ExprLambda { ExprLambda {
range: 488..499, range: 484..495,
parameters: Some( parameters: Some(
Parameters { Parameters {
range: 495..496, range: 491..492,
posonlyargs: [], posonlyargs: [],
args: [ args: [
ParameterWithDefault { ParameterWithDefault {
range: 495..496, range: 491..492,
parameter: Parameter { parameter: Parameter {
range: 495..496, range: 491..492,
name: Identifier { name: Identifier {
id: Name("x"), id: Name("x"),
range: 495..496, range: 491..492,
}, },
annotation: None, annotation: None,
}, },
@ -977,7 +977,7 @@ Module(
), ),
body: Name( body: Name(
ExprName { ExprName {
range: 498..499, range: 494..495,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -989,29 +989,29 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 501..502, range: 497..498,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 504..516, range: 500..512,
value: Lambda( value: Lambda(
ExprLambda { ExprLambda {
range: 505..516, range: 501..512,
parameters: Some( parameters: Some(
Parameters { Parameters {
range: 512..513, range: 508..509,
posonlyargs: [], posonlyargs: [],
args: [ args: [
ParameterWithDefault { ParameterWithDefault {
range: 512..513, range: 508..509,
parameter: Parameter { parameter: Parameter {
range: 512..513, range: 508..509,
name: Identifier { name: Identifier {
id: Name("x"), id: Name("x"),
range: 512..513, range: 508..509,
}, },
annotation: None, annotation: None,
}, },
@ -1025,7 +1025,7 @@ Module(
), ),
body: Name( body: Name(
ExprName { ExprName {
range: 515..516, range: 511..512,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -1044,13 +1044,13 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 517..519, range: 513..515,
value: Starred( value: Starred(
ExprStarred { ExprStarred {
range: 517..519, range: 513..515,
value: Name( value: Name(
ExprName { ExprName {
range: 518..519, range: 514..515,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -1062,14 +1062,14 @@ Module(
), ),
Expr( Expr(
StmtExpr { StmtExpr {
range: 523..536, range: 519..532,
value: Tuple( value: Tuple(
ExprTuple { ExprTuple {
range: 523..536, range: 519..532,
elts: [ elts: [
NumberLiteral( NumberLiteral(
ExprNumberLiteral { ExprNumberLiteral {
range: 523..524, range: 519..520,
value: Int( value: Int(
2, 2,
), ),
@ -1077,17 +1077,17 @@ Module(
), ),
Name( Name(
ExprName { ExprName {
range: 526..527, range: 522..523,
id: Name("z"), id: Name("z"),
ctx: Load, ctx: Load,
}, },
), ),
Starred( Starred(
ExprStarred { ExprStarred {
range: 529..531, range: 525..527,
value: Name( value: Name(
ExprName { ExprName {
range: 530..531, range: 526..527,
id: Name("x"), id: Name("x"),
ctx: Load, ctx: Load,
}, },
@ -1097,7 +1097,7 @@ Module(
), ),
NumberLiteral( NumberLiteral(
ExprNumberLiteral { ExprNumberLiteral {
range: 535..536, range: 531..532,
value: Int( value: Int(
2, 2,
), ),
@ -1117,7 +1117,7 @@ Module(
## Errors ## Errors
| |
2 | # Test the first and any other element as the there are two separate calls. 2 | # Test the first and any other element as there are two separate calls.
3 | 3 |
4 | (*x in y, z, *x in y) 4 | (*x in y, z, *x in y)
| ^^^^^^ Syntax Error: Comparison expression cannot be used here | ^^^^^^ Syntax Error: Comparison expression cannot be used here
@ -1127,7 +1127,7 @@ Module(
| |
2 | # Test the first and any other element as the there are two separate calls. 2 | # Test the first and any other element as there are two separate calls.
3 | 3 |
4 | (*x in y, z, *x in y) 4 | (*x in y, z, *x in y)
| ^^^^^^ Syntax Error: Comparison expression cannot be used here | ^^^^^^ Syntax Error: Comparison expression cannot be used here

View file

@ -1389,7 +1389,7 @@ X: bool = True
```py ```py
def f(): def f():
# TODO: we should emit a syntax errror here (tracked by https://github.com/astral-sh/ruff/issues/11934) # TODO: we should emit a syntax error here (tracked by https://github.com/astral-sh/ruff/issues/17412)
from exporter import * from exporter import *
# error: [unresolved-reference] # error: [unresolved-reference]

View file

@ -163,7 +163,7 @@ other
## Based on type inference ## Based on type inference
For the the rest of this test suite, we will mostly use `True` and `False` literals to indicate For the rest of this test suite, we will mostly use `True` and `False` literals to indicate
statically known conditions, but here, we show that the results are truly based on type inference, statically known conditions, but here, we show that the results are truly based on type inference,
not some special handling of specific conditions in semantic index building. We use two modules to not some special handling of specific conditions in semantic index building. We use two modules to
demonstrate this, since semantic index building is inherently single-module: demonstrate this, since semantic index building is inherently single-module:

View file

@ -1824,7 +1824,7 @@ where
// Save the state immediately *after* visiting the `try` block // Save the state immediately *after* visiting the `try` block
// but *before* we prepare for visiting the `except` block(s). // but *before* we prepare for visiting the `except` block(s).
// //
// We will revert to this state prior to visiting the the `else` block, // We will revert to this state prior to visiting the `else` block,
// as there necessarily must have been 0 `except` blocks executed // as there necessarily must have been 0 `except` blocks executed
// if we hit the `else` block. // if we hit the `else` block.
let post_try_block_state = self.flow_snapshot(); let post_try_block_state = self.flow_snapshot();

View file

@ -9,7 +9,7 @@ pub(crate) struct CallArguments<'a>(Vec<Argument<'a>>);
impl<'a> CallArguments<'a> { impl<'a> CallArguments<'a> {
/// Prepend an optional extra synthetic argument (for a `self` or `cls` parameter) to the front /// Prepend an optional extra synthetic argument (for a `self` or `cls` parameter) to the front
/// of this argument list. (If `bound_self` is none, we return the the argument list /// of this argument list. (If `bound_self` is none, we return the argument list
/// unmodified.) /// unmodified.)
pub(crate) fn with_self(&self, bound_self: Option<Type<'_>>) -> Cow<Self> { pub(crate) fn with_self(&self, bound_self: Option<Type<'_>>) -> Cow<Self> {
if bound_self.is_some() { if bound_self.is_some() {
@ -87,7 +87,7 @@ impl<'a, 'db> CallArgumentTypes<'a, 'db> {
} }
/// Prepend an optional extra synthetic argument (for a `self` or `cls` parameter) to the front /// Prepend an optional extra synthetic argument (for a `self` or `cls` parameter) to the front
/// of this argument list. (If `bound_self` is none, we return the the argument list /// of this argument list. (If `bound_self` is none, we return the argument list
/// unmodified.) /// unmodified.)
pub(crate) fn with_self(&self, bound_self: Option<Type<'db>>) -> Cow<Self> { pub(crate) fn with_self(&self, bound_self: Option<Type<'db>>) -> Cow<Self> {
if let Some(bound_self) = bound_self { if let Some(bound_self) = bound_self {

View file

@ -492,7 +492,7 @@ impl std::ops::DerefMut for DiagnosticGuard<'_, '_> {
/// ///
/// # Panics /// # Panics
/// ///
/// This panics when the the underlying diagnostic lacks a primary /// This panics when the underlying diagnostic lacks a primary
/// annotation, or if it has one and its file doesn't match the file /// annotation, or if it has one and its file doesn't match the file
/// being type checked. /// being type checked.
impl Drop for DiagnosticGuard<'_, '_> { impl Drop for DiagnosticGuard<'_, '_> {

View file

@ -8277,7 +8277,7 @@ impl<'db> TypeInferenceBuilder<'db> {
let callable_type = Type::Callable(callable_type); let callable_type = Type::Callable(callable_type);
// `Signature` / `Parameters` are not a `Type` variant, so we're storing // `Signature` / `Parameters` are not a `Type` variant, so we're storing
// the outer callable type on the these expressions instead. // the outer callable type on these expressions instead.
self.store_expression_type(arguments_slice, callable_type); self.store_expression_type(arguments_slice, callable_type);
if let Some(first_argument) = first_argument { if let Some(first_argument) = first_argument {
self.store_expression_type(first_argument, callable_type); self.store_expression_type(first_argument, callable_type);