Skip to content

Commit

Permalink
Update more snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Aug 23, 2024
1 parent aa73933 commit c923ffe
Show file tree
Hide file tree
Showing 1,413 changed files with 21,262 additions and 12,183 deletions.
5 changes: 1 addition & 4 deletions crates/ruff_linter/src/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ impl Message {
.map_or(TextSize::new(0), TextLen::text_len);

Message::SyntaxError(SyntaxErrorMessage {
message: format!(
"SyntaxError: {}",
DisplayParseErrorType::new(&parse_error.error)
),
message: DisplayParseErrorType::new(&parse_error.error).to_string(),
range: TextRange::at(parse_error.location.start(), len),
file,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
source: crates/ruff_linter/src/message/azure.rs
expression: content
---
##vso[task.logissue type=error;sourcepath=syntax_errors.py;linenumber=1;columnnumber=15;]SyntaxError: Expected one or more symbol names after import
##vso[task.logissue type=error;sourcepath=syntax_errors.py;linenumber=3;columnnumber=12;]SyntaxError: Expected ')', found newline
##vso[task.logissue type=error;sourcepath=syntax_errors.py;linenumber=1;columnnumber=15;]Expected one or more symbol names after import
##vso[task.logissue type=error;sourcepath=syntax_errors.py;linenumber=3;columnnumber=12;]Expected ')', found newline
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
source: crates/ruff_linter/src/message/github.rs
expression: content
---
::error title=Ruff,file=syntax_errors.py,line=1,col=15,endLine=2,endColumn=1::syntax_errors.py:1:15: SyntaxError: Expected one or more symbol names after import
::error title=Ruff,file=syntax_errors.py,line=3,col=12,endLine=4,endColumn=1::syntax_errors.py:3:12: SyntaxError: Expected ')', found newline
::error title=Ruff,file=syntax_errors.py,line=1,col=15,endLine=2,endColumn=1::syntax_errors.py:1:15: Expected one or more symbol names after import
::error title=Ruff,file=syntax_errors.py,line=3,col=12,endLine=4,endColumn=1::syntax_errors.py:3:12: Expected ')', found newline
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expression: redact_fingerprint(&content)
---
[
{
"description": "SyntaxError: Expected one or more symbol names after import",
"description": "Expected one or more symbol names after import",
"fingerprint": "<redacted>",
"location": {
"lines": {
Expand All @@ -16,7 +16,7 @@ expression: redact_fingerprint(&content)
"severity": "major"
},
{
"description": "SyntaxError: Expected ')', found newline",
"description": "Expected ')', found newline",
"fingerprint": "<redacted>",
"location": {
"lines": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ source: crates/ruff_linter/src/message/grouped.rs
expression: content
---
syntax_errors.py:
1:15 SyntaxError: Expected one or more symbol names after import
3:12 SyntaxError: Expected ')', found newline
1:15 Expected one or more symbol names after import
3:12 Expected ')', found newline
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ expression: content
"column": 15,
"row": 1
},
"message": "SyntaxError: Expected one or more symbol names after import",
"message": "Expected one or more symbol names after import",
"noqa_row": null,
"url": null
},
Expand All @@ -33,7 +33,7 @@ expression: content
"column": 12,
"row": 3
},
"message": "SyntaxError: Expected ')', found newline",
"message": "Expected ')', found newline",
"noqa_row": null,
"url": null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
source: crates/ruff_linter/src/message/json_lines.rs
expression: content
---
{"cell":null,"code":null,"end_location":{"column":1,"row":2},"filename":"syntax_errors.py","fix":null,"location":{"column":15,"row":1},"message":"SyntaxError: Expected one or more symbol names after import","noqa_row":null,"url":null}
{"cell":null,"code":null,"end_location":{"column":1,"row":4},"filename":"syntax_errors.py","fix":null,"location":{"column":12,"row":3},"message":"SyntaxError: Expected ')', found newline","noqa_row":null,"url":null}
{"cell":null,"code":null,"end_location":{"column":1,"row":2},"filename":"syntax_errors.py","fix":null,"location":{"column":15,"row":1},"message":"Expected one or more symbol names after import","noqa_row":null,"url":null}
{"cell":null,"code":null,"end_location":{"column":1,"row":4},"filename":"syntax_errors.py","fix":null,"location":{"column":12,"row":3},"message":"Expected ')', found newline","noqa_row":null,"url":null}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ expression: content
<testsuites name="ruff" tests="2" failures="2" errors="0">
<testsuite name="syntax_errors.py" tests="2" disabled="0" errors="0" failures="2" package="org.ruff">
<testcase name="org.ruff" classname="syntax_errors" line="1" column="15">
<failure message="SyntaxError: Expected one or more symbol names after import">line 1, col 15, SyntaxError: Expected one or more symbol names after import</failure>
<failure message="Expected one or more symbol names after import">line 1, col 15, Expected one or more symbol names after import</failure>
</testcase>
<testcase name="org.ruff" classname="syntax_errors" line="3" column="12">
<failure message="SyntaxError: Expected &apos;)&apos;, found newline">line 3, col 12, SyntaxError: Expected &apos;)&apos;, found newline</failure>
<failure message="Expected &apos;)&apos;, found newline">line 3, col 12, Expected &apos;)&apos;, found newline</failure>
</testcase>
</testsuite>
</testsuites>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
source: crates/ruff_linter/src/message/pylint.rs
expression: content
---
syntax_errors.py:1: SyntaxError: Expected one or more symbol names after import
syntax_errors.py:3: SyntaxError: Expected ')', found newline
syntax_errors.py:1: Expected one or more symbol names after import
syntax_errors.py:3: Expected ')', found newline
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ expression: content
}
}
},
"message": "SyntaxError: Expected one or more symbol names after import"
"message": "Expected one or more symbol names after import"
},
{
"code": {
Expand All @@ -42,7 +42,7 @@ expression: content
}
}
},
"message": "SyntaxError: Expected ')', found newline"
"message": "Expected ')', found newline"
}
],
"severity": "warning",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
source: crates/ruff_linter/src/message/text.rs
expression: content
---
error[F401]: fib.py:1:8: `os` imported but unused
error[F401]: 1:8: `os` imported but unused

--> fib.py:1:8
|
1 | import os
| ^^
|
= help: Remove unused import: `os`
error[F841]: fib.py:6:5: Local variable `x` is assigned to but never used
error[F841]: 6:5: Local variable `x` is assigned to but never used

--> fib.py:6:5
|
4 | def fibonacci(n):
5 | """Compute the nth number in the Fibonacci sequence."""
Expand All @@ -20,8 +22,9 @@ error[F841]: fib.py:6:5: Local variable `x` is assigned to but never used
8 | return 0
|
= help: Remove assignment to unused variable `x`
error[F821]: undef.py:1:4: Undefined name `a`
error[F821]: 1:4: Undefined name `a`

--> undef.py:1:4
|
1 | if a == 1: pass
| ^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
source: crates/ruff_linter/src/message/text.rs
expression: content
---
error[F401]: fib.py:1:8: `os` imported but unused
error[F401]: 1:8: `os` imported but unused

--> fib.py:1:8
|
1 | import os
| ^^
|
= help: Remove unused import: `os`
error[F841]: fib.py:6:5: Local variable `x` is assigned to but never used
error[F841]: 6:5: Local variable `x` is assigned to but never used

--> fib.py:6:5
|
4 | def fibonacci(n):
5 | """Compute the nth number in the Fibonacci sequence."""
Expand All @@ -20,8 +22,9 @@ error[F841]: fib.py:6:5: Local variable `x` is assigned to but never used
8 | return 0
|
= help: Remove assignment to unused variable `x`
error[F821]: undef.py:1:4: Undefined name `a`
error[F821]: 1:4: Undefined name `a`

--> undef.py:1:4
|
1 | if a == 1: pass
| ^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
source: crates/ruff_linter/src/message/text.rs
expression: content
---
error[F401]: fib.py:1:8: [*] `os` imported but unused
error[F401]: 1:8: [*] `os` imported but unused

--> fib.py:1:8
|
1 | import os
| ^^
|
= help: Remove unused import: `os`
error[F841]: fib.py:6:5: [*] Local variable `x` is assigned to but never used
error[F841]: 6:5: [*] Local variable `x` is assigned to but never used

--> fib.py:6:5
|
4 | def fibonacci(n):
5 | """Compute the nth number in the Fibonacci sequence."""
Expand All @@ -20,8 +22,9 @@ error[F841]: fib.py:6:5: [*] Local variable `x` is assigned to but never used
8 | return 0
|
= help: Remove assignment to unused variable `x`
error[F821]: undef.py:1:4: Undefined name `a`
error[F821]: 1:4: Undefined name `a`

--> undef.py:1:4
|
1 | if a == 1: pass
| ^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
source: crates/ruff_linter/src/message/text.rs
expression: content
---
error[F401]: notebook.ipynb:cell 1:2:8: [*] `os` imported but unused
error[F401]: cell 1:2:8: [*] `os` imported but unused

--> notebook.ipynb:2:8
|
1 | # cell 1
2 | import os
| ^^
|
= help: Remove unused import: `os`
error[F401]: notebook.ipynb:cell 2:2:8: [*] `math` imported but unused
error[F401]: cell 2:2:8: [*] `math` imported but unused

--> notebook.ipynb:2:8
|
1 | # cell 2
2 | import math
Expand All @@ -20,8 +22,9 @@ error[F401]: notebook.ipynb:cell 2:2:8: [*] `math` imported but unused
4 | print('hello world')
|
= help: Remove unused import: `math`
error[F841]: notebook.ipynb:cell 3:4:5: [*] Local variable `x` is assigned to but never used
error[F841]: cell 3:4:5: [*] Local variable `x` is assigned to but never used

--> notebook.ipynb:4:5
|
2 | def foo():
3 | print()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
source: crates/ruff_linter/src/message/text.rs
expression: content
---
syntax_errors.py:1:15: SyntaxError: Expected one or more symbol names after import
error[syntax-error]: 1:15: Expected one or more symbol names after import

--> syntax_errors.py:1:15
|
1 | from os import
| ^
2 |
3 | if call(foo
4 | def bar():
|
error[syntax-error]: 3:12: Expected ')', found newline

syntax_errors.py:3:12: SyntaxError: Expected ')', found newline
--> syntax_errors.py:3:12
|
1 | from os import
2 |
Expand Down
31 changes: 10 additions & 21 deletions crates/ruff_linter/src/message/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,12 @@ impl Emitter for TextEmitter {
) -> anyhow::Result<()> {
for message in messages {
let mut title = String::new();
write!(
title,
"{path}{sep}",
path = relativize_path(message.filename()).bold(),
sep = ":".cyan(),
)?;

let start_location = message.compute_start_location();
let notebook_index = context.notebook_index(message.filename());

// Check if we're working on a jupyter notebook and translate positions with cell accordingly
// TODO: Only append location to title if there are no snippets
let diagnostic_location = if let Some(notebook_index) = notebook_index {
write!(
title,
Expand Down Expand Up @@ -118,7 +113,7 @@ impl Emitter for TextEmitter {
let code = message
.rule()
.map(|rule| rule.noqa_code().to_string())
.unwrap_or_default();
.unwrap_or_else(|| "syntax-error".to_string());
let mut snippet_message = Level::Error.title(&title).id(&code);

// The `0..0` range is used to highlight file-level diagnostics.
Expand Down Expand Up @@ -172,9 +167,6 @@ impl Display for RuleCodeAndBody<'_> {
if let Some(fix) = self.message.fix() {
// Do not display an indicator for unapplicable fixes
if fix.applies(self.unsafe_fixes.required_applicability()) {
if let Some(rule) = self.message.rule() {
write!(f, "{} ", rule.noqa_code().to_string().red().bold())?;
}
return write!(
f,
"{fix}{body}",
Expand All @@ -185,21 +177,13 @@ impl Display for RuleCodeAndBody<'_> {
}
};

if let Some(rule) = self.message.rule() {
write!(
f,
"{code} {body}",
code = rule.noqa_code().to_string().red().bold(),
body = self.message.body(),
)
} else {
f.write_str(self.message.body())
}
f.write_str(self.message.body())
}
}

struct CodeFrameSnippet<'a> {
pub(crate) source: SourceCode<'a>,
file_name: String,
line_start: OneIndexed,
}

Expand Down Expand Up @@ -281,11 +265,16 @@ impl<'a> CodeFrameSnippet<'a> {
},
);

Self { line_start, source }
Self {
line_start,
source,
file_name: relativize_path(message.filename()),
}
}

pub(super) fn as_snippet(&self) -> Snippet {
Snippet::source(&self.source.text)
.origin(&self.file_name)
.line_start(self.line_start.get())
.annotation(Level::Error.span(self.source.annotation_range.into()))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
---
source: crates/ruff_linter/src/rules/airflow/mod.rs
---
error[AIR001]: AIR001.py:11:1: Task variable name should match the `task_id`: "my_task"
error[AIR001]: 11:1: Task variable name should match the `task_id`: "my_task"

--> AIR001.py:10:1
|
9 | my_task_2 = PythonOperator(callable=my_callable, task_id="my_task_2")
10 |
11 | incorrect_name = PythonOperator(task_id="my_task")
| ^^^^^^^^^^^^^^
12 | incorrect_name_2 = PythonOperator(callable=my_callable, task_id="my_task_2")
|
error[AIR001]: AIR001.py:12:1: Task variable name should match the `task_id`: "my_task_2"
error[AIR001]: 12:1: Task variable name should match the `task_id`: "my_task_2"

--> AIR001.py:11:51
|
11 | incorrect_name = PythonOperator(task_id="my_task")
12 | incorrect_name_2 = PythonOperator(callable=my_callable, task_id="my_task_2")
Expand Down
Loading

0 comments on commit c923ffe

Please sign in to comment.