Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions news/1 Enhancements/15003.md
Original file line number Diff line number Diff line change
@@ -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))
10 changes: 9 additions & 1 deletion src/client/linters/bandit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ export class Bandit extends BaseLinter {
protected async runLinter(document: TextDocument, cancellation: CancellationToken): Promise<ILintMessage[]> {
// 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
);
Expand Down
2 changes: 1 addition & 1 deletion src/test/linters/lint.args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down