Skip to content

Commit cabbee1

Browse files
authored
Fix for ruff 0.1.0 (#528)
Ruff just released [`v0.1.0`](https://github.com/astral-sh/ruff/releases/tag/v0.1.0). This includes a lot of changes, but namely deprecating the `--format` option in favor of `--output-format`. I plan to make a new release after this lands.
1 parent b9645e2 commit cabbee1

3 files changed

Lines changed: 128 additions & 0 deletions

File tree

linters/ruff/plugin.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ lint:
1111
- name: ruff
1212
files: [python]
1313
commands:
14+
- name: lint
15+
# As of ruff v0.1.0, --format is replaced with --output-format
16+
version: ">=0.1.0"
17+
run: ruff check --cache-dir ${cachedir} --output-format json ${target}
18+
output: sarif
19+
parser:
20+
runtime: python
21+
run: python3 ${cwd}/ruff_to_sarif.py 0
22+
batch: true
23+
success_codes: [0, 1]
1424
- name: lint
1525
# As of ruff v0.0.266, column edits are 1-indexed
1626
version: ">=0.0.266"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Testing linter ruff-nbqa test basic_nb 1`] = `
4+
{
5+
"issues": [
6+
{
7+
"code": "error",
8+
"file": "test_data/basic_nb.in.ipynb",
9+
"level": "LEVEL_HIGH",
10+
"linter": "ruff-nbqa",
11+
"message": "/tmp/plugins_/test_data/basic_nb.in.ipynb:cell_1:1:8: F401 [*] \`os\` imported but unused
12+
Found 1 error.
13+
[*] 1 fixable with the \`--fix\` option.",
14+
"targetType": "jupyter",
15+
},
16+
],
17+
"lintActions": [
18+
{
19+
"command": "lint",
20+
"fileGroupName": "jupyter",
21+
"linter": "ruff-nbqa",
22+
"paths": [
23+
"test_data/basic_nb.in.ipynb",
24+
],
25+
"verb": "TRUNK_VERB_CHECK",
26+
},
27+
],
28+
"taskFailures": [],
29+
"unformattedFiles": [],
30+
}
31+
`;
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Testing linter ruff test basic 1`] = `
4+
{
5+
"issues": [
6+
{
7+
"code": "E402",
8+
"column": "1",
9+
"file": "test_data/basic.in.py",
10+
"issueUrl": "https://docs.astral.sh/ruff/rules/#E402",
11+
"level": "LEVEL_HIGH",
12+
"line": "7",
13+
"linter": "ruff",
14+
"message": "Module level import not at top of file",
15+
"ranges": [
16+
{
17+
"filePath": "test_data/basic.in.py",
18+
"length": "10",
19+
"offset": "83",
20+
},
21+
],
22+
"targetType": "python",
23+
},
24+
{
25+
"autofixOptions": [
26+
{
27+
"message": "Remove unused import: \`sys\`",
28+
"replacements": [
29+
{
30+
"filePath": "test_data/basic.in.py",
31+
"length": "11",
32+
"offset": "83",
33+
},
34+
],
35+
},
36+
],
37+
"code": "F401",
38+
"column": "8",
39+
"file": "test_data/basic.in.py",
40+
"issueUrl": "https://docs.astral.sh/ruff/rules/#F401",
41+
"level": "LEVEL_HIGH",
42+
"line": "7",
43+
"linter": "ruff",
44+
"message": "\`sys\` imported but unused",
45+
"ranges": [
46+
{
47+
"filePath": "test_data/basic.in.py",
48+
"length": "3",
49+
"offset": "90",
50+
},
51+
],
52+
"targetType": "python",
53+
},
54+
{
55+
"code": "E402",
56+
"column": "1",
57+
"file": "test_data/basic.in.py",
58+
"issueUrl": "https://docs.astral.sh/ruff/rules/#E402",
59+
"level": "LEVEL_HIGH",
60+
"line": "9",
61+
"linter": "ruff",
62+
"message": "Module level import not at top of file",
63+
"ranges": [
64+
{
65+
"filePath": "test_data/basic.in.py",
66+
"length": "11",
67+
"offset": "120",
68+
},
69+
],
70+
"targetType": "python",
71+
},
72+
],
73+
"lintActions": [
74+
{
75+
"command": "lint",
76+
"fileGroupName": "python",
77+
"linter": "ruff",
78+
"paths": [
79+
"test_data/basic.in.py",
80+
],
81+
"verb": "TRUNK_VERB_CHECK",
82+
},
83+
],
84+
"taskFailures": [],
85+
"unformattedFiles": [],
86+
}
87+
`;

0 commit comments

Comments
 (0)