From fdad5d6b6db6d3fbbb9a8b3bcc83143d6205b208 Mon Sep 17 00:00:00 2001 From: Chris Clearwater Date: Wed, 26 Feb 2025 12:08:00 -0800 Subject: [PATCH 1/2] --- linters/ruff/ruff_to_sarif.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/linters/ruff/ruff_to_sarif.py b/linters/ruff/ruff_to_sarif.py index 73e2afefc..844da131e 100755 --- a/linters/ruff/ruff_to_sarif.py +++ b/linters/ruff/ruff_to_sarif.py @@ -52,7 +52,13 @@ def get_region(entry, column_offset=0): "ruleId": rule_id, } - if "fix" in result and result["fix"] is not None: + have_fix = "fix" in result and result["fix"] is not None + # Skip autofixes specific to a jupyter notebook cell and they are difficult to apply. + have_cell = "cell" in result and result["cell"] is not None + + if have_fix and not have_cell: + # Locations for jupyter notebooks are not relative to the file, + # so we can not easily handle them. fixes = result["fix"] # TODO(Tyler): If output format changes any more substantially, consider version-specific parsers From 73e711c868258b1d1b396d4a83438fdb17f61cf4 Mon Sep 17 00:00:00 2001 From: Chris Clearwater Date: Wed, 26 Feb 2025 12:22:11 -0800 Subject: [PATCH 2/2] --- .../ruff/test_data/ruff_v0.6.0_basic_nb.check.shot | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/linters/ruff/test_data/ruff_v0.6.0_basic_nb.check.shot b/linters/ruff/test_data/ruff_v0.6.0_basic_nb.check.shot index 74225b28f..d6d22119b 100644 --- a/linters/ruff/test_data/ruff_v0.6.0_basic_nb.check.shot +++ b/linters/ruff/test_data/ruff_v0.6.0_basic_nb.check.shot @@ -4,17 +4,6 @@ exports[`Testing linter ruff test basic_nb 1`] = ` { "issues": [ { - "autofixOptions": [ - { - "message": "Remove unused import: \`os\`", - "replacements": [ - { - "filePath": "test_data/basic_nb.in.ipynb", - "length": "2", - }, - ], - }, - ], "code": "F401", "column": "1", "file": "test_data/basic_nb.in.ipynb",