diff --git a/news/1 Enhancements/15003.md b/news/1 Enhancements/15003.md new file mode 100644 index 000000000000..b76b95285988 --- /dev/null +++ b/news/1 Enhancements/15003.md @@ -0,0 +1,3 @@ +Integration with the bandit linter will highlight the variable, function or method for an issue instead of the entire line. +Requires latest version of the bandit package to be installed. +(thanks [Anthony Shaw](https://github.com/tonybaloney)) diff --git a/src/client/linters/bandit.ts b/src/client/linters/bandit.ts index 137d95d48275..297d70ee130d 100644 --- a/src/client/linters/bandit.ts +++ b/src/client/linters/bandit.ts @@ -24,7 +24,15 @@ export class Bandit extends BaseLinter { protected async runLinter(document: TextDocument, cancellation: CancellationToken): Promise { // View all errors in bandit <= 1.5.1 (https://github.com/PyCQA/bandit/issues/371) const messages = await this.run( - ['-f', 'custom', '--msg-template', '{line},0,{severity},{test_id}:{msg}', '-n', '-1', document.uri.fsPath], + [ + '-f', + 'custom', + '--msg-template', + '{line},{col},{severity},{test_id}:{msg}', + '-n', + '-1', + document.uri.fsPath + ], document, cancellation ); diff --git a/src/test/linters/lint.args.test.ts b/src/test/linters/lint.args.test.ts index 0cac56804c11..0e06d7a7f8b0 100644 --- a/src/test/linters/lint.args.test.ts +++ b/src/test/linters/lint.args.test.ts @@ -202,7 +202,7 @@ suite('Linting - Arguments', () => { '-f', 'custom', '--msg-template', - '{line},0,{severity},{test_id}:{msg}', + '{line},{col},{severity},{test_id}:{msg}', '-n', '-1', fileUri.fsPath