Skip to content

Commit c2dec14

Browse files
authored
Update warning for the deprecated settings in python (microsoft#22345)
close microsoft#22272
1 parent fe22958 commit c2dec14

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/client/common/vscodeApis/windowApis.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,23 @@ export function showErrorMessage<T>(message: string, ...items: any[]): Thenable<
5454
return window.showErrorMessage(message, ...items);
5555
}
5656

57+
export function showWarningMessage<T extends string>(message: string, ...items: T[]): Thenable<T | undefined>;
58+
export function showWarningMessage<T extends string>(
59+
message: string,
60+
options: MessageOptions,
61+
...items: T[]
62+
): Thenable<T | undefined>;
63+
export function showWarningMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
64+
export function showWarningMessage<T extends MessageItem>(
65+
message: string,
66+
options: MessageOptions,
67+
...items: T[]
68+
): Thenable<T | undefined>;
69+
70+
export function showWarningMessage<T>(message: string, ...items: any[]): Thenable<T | undefined> {
71+
return window.showWarningMessage(message, ...items);
72+
}
73+
5774
export function showInformationMessage<T extends string>(message: string, ...items: T[]): Thenable<T | undefined>;
5875
export function showInformationMessage<T extends string>(
5976
message: string,

src/client/logging/settingLogs.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import { l10n } from 'vscode';
55
import { traceError, traceInfo } from '.';
66
import { Commands, PVSC_EXTENSION_ID } from '../common/constants';
7-
import { showErrorMessage } from '../common/vscodeApis/windowApis';
7+
import { showWarningMessage } from '../common/vscodeApis/windowApis';
88
import { getConfiguration, getWorkspaceFolders } from '../common/vscodeApis/workspaceApis';
9+
import { Common } from '../common/utils/localize';
10+
import { executeCommand } from '../common/vscodeApis/commandApis';
911

1012
function logOnLegacyFormatterSetting(): boolean {
1113
let usesLegacyFormatter = false;
@@ -21,6 +23,9 @@ function logOnLegacyFormatterSetting(): boolean {
2123
traceInfo(`Default formatter is set to ${formatter} for workspace ${workspace.uri.fsPath}`);
2224
if (formatter === PVSC_EXTENSION_ID) {
2325
usesLegacyFormatter = true;
26+
traceError(
27+
'The setting "editor.defaultFormatter" for Python is set to "ms-python.python" which is deprecated.',
28+
);
2429
traceError('Formatting features have been moved to separate formatter extensions.');
2530
traceError('See here for more information: https://code.visualstudio.com/docs/python/formatting');
2631
traceError('Please install the formatter extension you prefer and set it as the default formatter.');
@@ -60,6 +65,10 @@ function logOnLegacyLinterSetting(): boolean {
6065
const linterEnabled = config.get<boolean>(`linting.${linter}Enabled`, false);
6166
if (linterEnabled) {
6267
usesLegacyLinter = true;
68+
traceError(`Following setting is deprecated: "python.linting.${linter}Enabled"`);
69+
traceError(
70+
`All settings starting with "python.linting." are deprecated and can be removed from settings.`,
71+
);
6372
traceError('Linting features have been moved to separate linter extensions.');
6473
traceError('See here for more information: https://code.visualstudio.com/docs/python/linting');
6574
if (linter === 'pylint' || linter === 'flake8') {
@@ -72,7 +81,7 @@ function logOnLegacyLinterSetting(): boolean {
7281
);
7382
} else if (['pydocstyle', 'pylama', 'pycodestyle', 'bandit'].includes(linter)) {
7483
traceError(
75-
`selected linter "${linter}" may be supported by extensions like "Ruff", which include several linter rules: https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff`,
84+
`Selected linter "${linter}" may be supported by extensions like "Ruff", which include several linter rules: https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff`,
7685
);
7786
}
7887
}
@@ -88,11 +97,15 @@ async function notifyLegacySettings(): Promise<void> {
8897
return;
8998
}
9099
_isShown = true;
91-
showErrorMessage(
100+
const response = await showWarningMessage(
92101
l10n.t(
93-
`Formatting and linting features have been deprecated from the Python extension. Please install a linter or a formatter extension. [Open logs](command:${Commands.ViewOutput}) for more information.`,
102+
`You have deprecated linting or formatting settings for Python. Please see the [logs](command:${Commands.ViewOutput}) for more details.`,
94103
),
104+
Common.learnMore,
95105
);
106+
if (response === Common.learnMore) {
107+
executeCommand('vscode.open', 'https://aka.ms/AAlgvkb');
108+
}
96109
}
97110

98111
export function logAndNotifyOnLegacySettings(): void {

0 commit comments

Comments
 (0)