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 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",