Skip to content

Commit

Permalink
Add showSyntaxErrors extension setting (#504)
Browse files Browse the repository at this point in the history
## Summary

This PR adds a `ruff.showSyntaxErrors` config option for
astral-sh/ruff#12059.

## Test Plan

Refer to the test plan in astral-sh/ruff#12059.

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
  • Loading branch information
dhruvmanila and MichaReiser committed Jun 27, 2024
1 parent f4e5105 commit eafae85
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ This requires Ruff version `v0.1.3` or later.
| `organizeImports` | `"explicit"` | Whether to register Ruff as capable of handling `source.organizeImports` actions. |
| `path` | `[]` | Path to a custom `ruff` executable, e.g., `["/path/to/ruff"]`. |
| `showNotifications` | `off` | Setting to control when a notification is shown: `off`, `onError`, `onWarning`, `always`. |
| `showSyntaxErrors` | `true` | Whether to show syntax error diagnostics. _New in Ruff v0.5.0_ |
| `nativeServer` | `false` | Whether to use the Rust-based language server. |

The following settings are exclusive to the Rust-based language server (`nativeServer: true`), and
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@
"additionalProperties": false,
"markdownDescription": "Whether to display Quick Fix actions to disable rules via `noqa` suppression comments."
},
"ruff.showSyntaxErrors": {
"default": true,
"markdownDescription": "Whether to show syntax error diagnostics.",
"scope": "window",
"type": "boolean"
},
"ruff.ignoreStandardLibrary": {
"default": true,
"markdownDescription": "Whether to ignore files that are inferred to be part of the Python standard library.",
Expand Down
4 changes: 4 additions & 0 deletions src/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface ISettings {
exclude?: string[];
lineLength?: number;
configurationPreference?: ConfigPreference;
showSyntaxErrors: boolean;
}

export function getExtensionSettings(namespace: string): Promise<ISettings[]> {
Expand Down Expand Up @@ -156,6 +157,7 @@ export async function getWorkspaceSettings(
lineLength: config.get<number>("lineLength"),
configurationPreference:
config.get<ConfigPreference>("configurationPreference") ?? "editorFirst",
showSyntaxErrors: config.get<boolean>("showSyntaxErrors") ?? true,
};
}

Expand Down Expand Up @@ -205,6 +207,7 @@ export async function getGlobalSettings(namespace: string): Promise<ISettings> {
"configurationPreference",
"editorFirst",
),
showSyntaxErrors: getGlobalValue<boolean>(config, "showSyntaxErrors", true),
};
}

Expand Down Expand Up @@ -234,6 +237,7 @@ export function checkIfConfigurationChanged(
`${namespace}.exclude`,
`${namespace}.lineLength`,
`${namespace}.configurationPreference`,
`${namespace}.showSyntaxErrors`,
// Deprecated settings (prefer `lint.args`, etc.).
`${namespace}.args`,
`${namespace}.run`,
Expand Down

0 comments on commit eafae85

Please sign in to comment.