File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4646 disabled :
4747 - pylint # pylint diagnostics are too strict
4848 - semgrep
49+ - trivy # investigating issues with shared cachedir
4950
5051 ignore :
5152 - linters : [ALL]
Original file line number Diff line number Diff line change 99lint :
1010 definitions :
1111 - name : ruff
12- files : [python, python-interface]
1312 description : A Python linter and formatter
1413 commands :
14+ - name : lint
15+ # As of ruff v0.6.0, ruff runs by default on jupyter notebooks
16+ version : " >=0.6.0"
17+ files : [python, python-interface, jupyter]
18+ run : ruff check --cache-dir ${cachedir} --output-format json ${target}
19+ output : sarif
20+ parser :
21+ runtime : python
22+ run : python3 ${cwd}/ruff_to_sarif.py 0
23+ batch : true
24+ success_codes : [0, 1]
1525 - name : lint
1626 # As of ruff v0.1.0, --format is replaced with --output-format
1727 version : " >=0.1.0"
28+ files : [python, python-interface]
1829 run : ruff check --cache-dir ${cachedir} --output-format json ${target}
1930 output : sarif
2031 parser :
2536 - name : lint
2637 # As of ruff v0.0.266, column edits are 1-indexed
2738 version : " >=0.0.266"
39+ files : [python, python-interface]
2840 run : ruff check --cache-dir ${cachedir} --format json ${target}
2941 output : sarif
3042 parser :
3345 batch : true
3446 success_codes : [0, 1]
3547 - name : lint
48+ files : [python, python-interface]
3649 run : ruff check --cache-dir ${cachedir} --format json ${target}
3750 output : sarif
3851 parser :
4154 batch : true
4255 success_codes : [0, 1]
4356 - name : format
57+ files : [python, python-interface]
4458 output : rewrite
4559 run : ruff format ${target}
4660 success_codes : [0]
6377 parse_regex : ruff ${semver}
6478 run : ruff --version
6579
80+ # Not necessary if ruff>=0.6.0
6681 - name : ruff-nbqa
6782 description : A Python linter for Jupyter notebooks
6883 files : [jupyter]
Original file line number Diff line number Diff line change 1+ import semver from "semver" ;
12import { linterCheckTest , linterFmtTest } from "tests" ;
23import { TrunkLintDriver } from "tests/driver" ;
34import { skipOS } from "tests/utils" ;
45
56linterCheckTest ( { linterName : "ruff" , namedTestPrefixes : [ "basic" , "interface" ] } ) ;
67
8+ const skipJupyterTestIf = ( version ?: string ) => {
9+ if ( ! version || ! semver . valid ( version ) ) {
10+ // Run if version is KGV or a string, or error loudly if malformed.
11+ return false ;
12+ }
13+ return semver . lt ( version , "0.6.0" ) ;
14+ } ;
15+
16+ linterCheckTest ( {
17+ linterName : "ruff" ,
18+ namedTestPrefixes : [ "basic_nb" ] ,
19+ skipTestIf : skipJupyterTestIf ,
20+ } ) ;
21+
722// ruff-nbqa still runs correctly on Windows, but the diagnostics are slightly different from the assertions.
823linterCheckTest ( {
924 linterName : "ruff-nbqa" ,
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports[`Testing linter ruff test basic_nb 1`] = `
4+ {
5+ "issues": [],
6+ "lintActions": [],
7+ "taskFailures": [],
8+ "unformattedFiles": [],
9+ }
10+ `;
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports[`Testing linter ruff test basic_nb 1`] = `
4+ {
5+ "issues": [
6+ {
7+ "autofixOptions": [
8+ {
9+ "message": "Remove unused import: \`os\`",
10+ "replacements": [
11+ {
12+ "filePath": "test_data/basic_nb.in.ipynb",
13+ "length": "2",
14+ },
15+ ],
16+ },
17+ ],
18+ "code": "F401",
19+ "column": "1",
20+ "file": "test_data/basic_nb.in.ipynb",
21+ "issueClass": "ISSUE_CLASS_EXISTING",
22+ "issueUrl": "https://docs.astral.sh/ruff/rules/#F401",
23+ "level": "LEVEL_HIGH",
24+ "line": "1",
25+ "linter": "ruff",
26+ "message": "\`os\` imported but unused",
27+ "targetType": "jupyter",
28+ },
29+ ],
30+ "lintActions": [
31+ {
32+ "command": "lint",
33+ "fileGroupName": "jupyter",
34+ "linter": "ruff",
35+ "paths": [
36+ "test_data/basic_nb.in.ipynb",
37+ ],
38+ "verb": "TRUNK_VERB_CHECK",
39+ },
40+ {
41+ "command": "lint",
42+ "fileGroupName": "jupyter",
43+ "linter": "ruff",
44+ "paths": [
45+ "test_data/basic_nb.in.ipynb",
46+ ],
47+ "upstream": true,
48+ "verb": "TRUNK_VERB_CHECK",
49+ },
50+ ],
51+ "taskFailures": [],
52+ "unformattedFiles": [],
53+ }
54+ `;
You can’t perform that action at this time.
0 commit comments