Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add showSyntaxErrors extension setting #504

Merged
merged 3 commits into from
Jun 27, 2024
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
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the default before. Did ruff always filter out syntax error diagnostics? I'm mainly asking to understand if this is a "breaking" change in the sense that the default changes

Copy link
Member Author

@dhruvmanila dhruvmanila Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, Ruff would always show syntax error diagnostics. I don't think this is a breaking change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good :) Unless someone used ignore=E999 but that "breaking" change is already handled by Ruff's changelog

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I assume you mean ruff.ignore server setting. Ruff would emit a warning in that case but it won't be displayed to the user, it'll be in the logs:

2024-06-27 12:34:00.546 [info] warning: Rule `E999` is deprecated and will be removed in a future release. Syntax errors will always be shown regardless of whether this rule is selected or not.

But, this won't work for ignore because it doesn't work in Ruff itself.

"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