diff --git a/.github/dependabot.yml b/.github/dependabot.yml index de5ebfe9158b..14c8e18d475d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -37,7 +37,6 @@ updates: - dependency-name: prospector # Due to Python 2.7 and #14477. - dependency-name: pytest # Due to Python 2.7 and #13776. - dependency-name: py # Due to Python 2.7. - - dependency-name: isort - dependency-name: jedi-language-server labels: - 'no-changelog' diff --git a/.vscode/settings.json b/.vscode/settings.json index a5dbb4869fd9..6a9c299aa72b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -47,7 +47,6 @@ "typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version "python.linting.enabled": false, "python.formatting.provider": "black", - "python.sortImports.args": ["--profile", "black"], "typescript.preferences.quoteStyle": "single", "javascript.preferences.quoteStyle": "single", "typescriptHero.imports.stringQuoteStyle": "'", diff --git a/build/test-requirements.txt b/build/test-requirements.txt index c732b3bcb228..433bd0f86682 100644 --- a/build/test-requirements.txt +++ b/build/test-requirements.txt @@ -17,7 +17,6 @@ flask fastapi uvicorn django -isort # Integrated TensorBoard tests tensorboard diff --git a/package.json b/package.json index 47faec663015..074ae69bca5e 100644 --- a/package.json +++ b/package.json @@ -1161,23 +1161,6 @@ "scope": "machine-overridable", "type": "string" }, - "python.sortImports.args": { - "default": [], - "description": "%python.sortImports.args.description%", - "items": { - "type": "string" - }, - "scope": "resource", - "type": "array", - "deprecationMessage": "%python.sortImports.args.deprecationMessage%" - }, - "python.sortImports.path": { - "default": "", - "description": "%python.sortImports.path.description%", - "scope": "machine-overridable", - "type": "string", - "deprecationMessage": "%python.sortImports.path.deprecationMessage%" - }, "python.tensorBoard.logDirectory": { "default": "", "description": "%python.tensorBoard.logDirectory.description%", diff --git a/package.nls.json b/package.nls.json index 7d14baf40d64..7a6f789fdf2d 100644 --- a/package.nls.json +++ b/package.nls.json @@ -1,5 +1,4 @@ { - "python.command.python.sortImports.title": "Sort Imports", "python.command.python.startREPL.title": "Start REPL", "python.command.python.createEnvironment.title": "Create Environment...", "python.command.python.createNewFile.title": "New Python File", @@ -201,8 +200,6 @@ "python.missingPackage.severity.description": "Set severity of missing packages in requirements.txt or pyproject.toml", "python.pipenvPath.description": "Path to the pipenv executable to use for activation.", "python.poetryPath.description": "Path to the poetry executable.", - "python.sortImports.args.description": "Arguments passed in. Each argument is a separate item in the array.", - "python.sortImports.path.description": "Path to isort script, default using inner version", "python.tensorBoard.logDirectory.description": "Set this setting to your preferred TensorBoard log directory to skip log directory prompt when starting TensorBoard.", "python.terminal.activateEnvInCurrentTerminal.description": "Activate Python Environment in the current Terminal on load of the Extension.", "python.terminal.activateEnvironment.description": "Activate Python Environment in all Terminals created.", @@ -220,8 +217,6 @@ "python.testing.unittestEnabled.description": "Enable testing using unittest.", "python.venvFolders.description": "Folders in your home directory to look into for virtual environments (supports pyenv, direnv and virtualenvwrapper by default).", "python.venvPath.description": "Path to folder with a list of Virtual Environments (e.g. ~/.pyenv, ~/Envs, ~/.virtualenvs).", - "python.sortImports.args.deprecationMessage": "This setting will be removed soon. Use 'isort.args' instead.", - "python.sortImports.path.deprecationMessage": "This setting will be removed soon. Use 'isort.path' instead.", "walkthrough.pythonWelcome.title": "Get Started with Python Development", "walkthrough.pythonWelcome.description": "Your first steps to set up a Python project with all the powerful tools and features that the Python extension has to offer!", "walkthrough.step.python.createPythonFile.title": "Create a Python file", diff --git a/resources/report_issue_user_settings.json b/resources/report_issue_user_settings.json index 778434c5cf0d..677e58d83f21 100644 --- a/resources/report_issue_user_settings.json +++ b/resources/report_issue_user_settings.json @@ -69,10 +69,6 @@ "memory": true, "symbolsHierarchyDepthLimit": false }, - "sortImports": { - "args": "placeholder", - "path": "placeholder" - }, "formatting": { "autopep8Args": "placeholder", "autopep8Path": "placeholder", diff --git a/src/client/common/application/commands.ts b/src/client/common/application/commands.ts index d8944fe2b057..763fa4dde79d 100644 --- a/src/client/common/application/commands.ts +++ b/src/client/common/application/commands.ts @@ -93,7 +93,6 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu ['workbench.action.openIssueReporter']: [{ extensionId: string; issueBody: string }]; [Commands.GetSelectedInterpreterPath]: [{ workspaceFolder: string } | string[]]; [Commands.TriggerEnvironmentSelection]: [undefined | Uri]; - [Commands.Sort_Imports]: [undefined, Uri]; [Commands.Exec_In_Terminal]: [undefined, Uri]; [Commands.Exec_In_Terminal_Icon]: [undefined, Uri]; [Commands.Debug_In_Terminal]: [Uri]; diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index db5944cc794b..3e4b75b8b087 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -32,7 +32,6 @@ import { IInterpreterSettings, ILintingSettings, IPythonSettings, - ISortImportSettings, ITensorBoardSettings, ITerminalSettings, Resource, @@ -120,8 +119,6 @@ export class PythonSettings implements IPythonSettings { public terminal!: ITerminalSettings; - public sortImports!: ISortImportSettings; - public globalModuleInstallation = false; public experiments!: IExperiments; @@ -319,14 +316,6 @@ export class PythonSettings implements IPythonSettings { this.globalModuleInstallation = pythonSettings.get('globalModuleInstallation') === true; - const sortImportSettings = systemVariables.resolveAny(pythonSettings.get('sortImports'))!; - if (this.sortImports) { - Object.assign(this.sortImports, sortImportSettings); - } else { - this.sortImports = sortImportSettings; - } - // Support for travis. - this.sortImports = this.sortImports ? this.sortImports : { path: '', args: [] }; // Support for travis. this.linting = this.linting ? this.linting diff --git a/src/client/common/constants.ts b/src/client/common/constants.ts index c3705a3c6504..cd6d305f624a 100644 --- a/src/client/common/constants.ts +++ b/src/client/common/constants.ts @@ -58,7 +58,6 @@ export namespace Commands { export const ReportIssue = 'python.reportIssue'; export const Set_Interpreter = 'python.setInterpreter'; export const Set_ShebangInterpreter = 'python.setShebangInterpreter'; - export const Sort_Imports = 'python.sortImports'; export const Start_REPL = 'python.startREPL'; export const Tests_Configure = 'python.configureTests'; export const TriggerEnvironmentSelection = 'python.triggerEnvSelection'; diff --git a/src/client/common/types.ts b/src/client/common/types.ts index b48a2daadaa6..07f1fea6b86b 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -106,7 +106,6 @@ export enum Product { autopep8 = 10, mypy = 11, unittest = 12, - isort = 15, black = 16, bandit = 17, tensorboard = 24, @@ -190,7 +189,6 @@ export interface IPythonSettings { readonly testing: ITestingSettings; readonly autoComplete: IAutoCompleteSettings; readonly terminal: ITerminalSettings; - readonly sortImports: ISortImportSettings; readonly envFile: string; readonly globalModuleInstallation: boolean; readonly experiments: IExperiments; @@ -204,10 +202,6 @@ export interface IPythonSettings { export interface ITensorBoardSettings { logDirectory: string | undefined; } -export interface ISortImportSettings { - readonly path: string; - readonly args: string[]; -} export interface IPylintCategorySeverity { readonly convention: DiagnosticSeverity; diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index bc32c1078cad..c6086071363f 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -39,9 +39,6 @@ export namespace Diagnostics { 'Your settings needs to be updated to change the setting "python.unitTest." to "python.testing.", otherwise testing Python code using the extension may not work. Would you like to automatically update your settings now?', ); export const updateSettings = l10n.t('Yes, update settings'); - export const checkIsort5UpgradeGuide = l10n.t( - 'We found outdated configuration for sorting imports in this workspace. Check the [isort upgrade guide](https://aka.ms/AA9j5x4) to update your settings.', - ); export const pylanceDefaultMessage = l10n.t( "The Python extension now includes Pylance to improve completions, code navigation, overall performance and much more! You can learn more about the update and learn how to change your language server [here](https://aka.ms/new-python-bundle).\n\nRead Pylance's license [here](https://marketplace.visualstudio.com/items/ms-python.vscode-pylance/license).", ); @@ -517,12 +514,8 @@ export namespace ToolsExtensions { export const pylintPromptMessage = l10n.t( 'Use the Pylint extension to enable easier configuration and new features such as quick fixes.', ); - export const isortPromptMessage = l10n.t( - 'To use sort imports, install the isort extension. It provides easier configuration and new features such as code actions.', - ); export const installPylintExtension = l10n.t('Install Pylint extension'); export const installFlake8Extension = l10n.t('Install Flake8 extension'); - export const installISortExtension = l10n.t('Install isort extension'); export const selectBlackFormatterPrompt = l10n.t( 'You have the Black formatter extension installed, would you like to use that as the default formatter?', diff --git a/src/client/providers/codeActionProvider/isortPrompt.ts b/src/client/providers/codeActionProvider/isortPrompt.ts deleted file mode 100644 index ffef481b498d..000000000000 --- a/src/client/providers/codeActionProvider/isortPrompt.ts +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IApplicationEnvironment } from '../../common/application/types'; -import { IPersistentState, IPersistentStateFactory } from '../../common/types'; -import { Common, ToolsExtensions } from '../../common/utils/localize'; -import { executeCommand } from '../../common/vscodeApis/commandApis'; -import { isExtensionDisabled, isExtensionEnabled } from '../../common/vscodeApis/extensionsApi'; -import { showInformationMessage } from '../../common/vscodeApis/windowApis'; -import { IServiceContainer } from '../../ioc/types'; -import { sendTelemetryEvent } from '../../telemetry'; -import { EventName } from '../../telemetry/constants'; - -export const ISORT_EXTENSION = 'ms-python.isort'; -const ISORT_PROMPT_DONOTSHOW_KEY = 'showISortExtensionPrompt'; - -function doNotShowPromptState(serviceContainer: IServiceContainer, promptKey: string): IPersistentState { - const persistFactory: IPersistentStateFactory = serviceContainer.get( - IPersistentStateFactory, - ); - return persistFactory.createWorkspacePersistentState(promptKey, false); -} - -export class ISortExtensionPrompt { - private shownThisSession = false; - - public constructor(private readonly serviceContainer: IServiceContainer) {} - - public async showPrompt(): Promise { - const isEnabled = isExtensionEnabled(ISORT_EXTENSION); - if (isEnabled || isExtensionDisabled(ISORT_EXTENSION)) { - sendTelemetryEvent(EventName.TOOLS_EXTENSIONS_ALREADY_INSTALLED, undefined, { - extensionId: ISORT_EXTENSION, - isEnabled, - }); - return true; - } - - const doNotShow = doNotShowPromptState(this.serviceContainer, ISORT_PROMPT_DONOTSHOW_KEY); - if (this.shownThisSession || doNotShow.value) { - return false; - } - - sendTelemetryEvent(EventName.TOOLS_EXTENSIONS_PROMPT_SHOWN, undefined, { extensionId: ISORT_EXTENSION }); - this.shownThisSession = true; - const response = await showInformationMessage( - ToolsExtensions.isortPromptMessage, - ToolsExtensions.installISortExtension, - Common.doNotShowAgain, - ); - - if (response === Common.doNotShowAgain) { - await doNotShow.updateValue(true); - sendTelemetryEvent(EventName.TOOLS_EXTENSIONS_PROMPT_DISMISSED, undefined, { - extensionId: ISORT_EXTENSION, - dismissType: 'doNotShow', - }); - return false; - } - - if (response === ToolsExtensions.installISortExtension) { - sendTelemetryEvent(EventName.TOOLS_EXTENSIONS_INSTALL_SELECTED, undefined, { - extensionId: ISORT_EXTENSION, - }); - const appEnv: IApplicationEnvironment = this.serviceContainer.get( - IApplicationEnvironment, - ); - await executeCommand('workbench.extensions.installExtension', ISORT_EXTENSION, { - installPreReleaseVersion: appEnv.extensionChannel === 'insiders', - }); - return true; - } - - sendTelemetryEvent(EventName.TOOLS_EXTENSIONS_PROMPT_DISMISSED, undefined, { - extensionId: ISORT_EXTENSION, - dismissType: 'close', - }); - - return false; - } -} - -let _prompt: ISortExtensionPrompt | undefined; -export function getOrCreateISortPrompt(serviceContainer: IServiceContainer): ISortExtensionPrompt { - if (!_prompt) { - _prompt = new ISortExtensionPrompt(serviceContainer); - } - return _prompt; -} diff --git a/src/client/providers/codeActionProvider/main.ts b/src/client/providers/codeActionProvider/main.ts index 40afd4dbb2b2..259f42848606 100644 --- a/src/client/providers/codeActionProvider/main.ts +++ b/src/client/providers/codeActionProvider/main.ts @@ -4,23 +4,14 @@ import { inject, injectable } from 'inversify'; import * as vscodeTypes from 'vscode'; import { IExtensionSingleActivationService } from '../../activation/types'; -import { Commands } from '../../common/constants'; import { IDisposableRegistry } from '../../common/types'; -import { executeCommand, registerCommand } from '../../common/vscodeApis/commandApis'; -import { isExtensionEnabled } from '../../common/vscodeApis/extensionsApi'; -import { IServiceContainer } from '../../ioc/types'; -import { traceLog } from '../../logging'; -import { getOrCreateISortPrompt, ISORT_EXTENSION } from './isortPrompt'; import { LaunchJsonCodeActionProvider } from './launchJsonCodeActionProvider'; @injectable() export class CodeActionProviderService implements IExtensionSingleActivationService { public readonly supportedWorkspaceTypes = { untrustedWorkspace: false, virtualWorkspace: false }; - constructor( - @inject(IDisposableRegistry) private disposableRegistry: IDisposableRegistry, - @inject(IServiceContainer) private serviceContainer: IServiceContainer, - ) {} + constructor(@inject(IDisposableRegistry) private disposableRegistry: IDisposableRegistry) {} public async activate(): Promise { // eslint-disable-next-line global-require @@ -35,19 +26,5 @@ export class CodeActionProviderService implements IExtensionSingleActivationServ providedCodeActionKinds: [vscode.CodeActionKind.QuickFix], }), ); - this.disposableRegistry.push( - registerCommand(Commands.Sort_Imports, async () => { - const prompt = getOrCreateISortPrompt(this.serviceContainer); - await prompt.showPrompt(); - if (!isExtensionEnabled(ISORT_EXTENSION)) { - traceLog( - 'Sort Imports: Please install and enable `ms-python.isort` extension to use this feature.', - ); - return; - } - - executeCommand('editor.action.organizeImports'); - }), - ); } } diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 600f9a2d48ff..7883e0cd7555 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -2181,7 +2181,7 @@ export interface IEventNamePropertyMapping { } */ [EventName.TOOLS_EXTENSIONS_ALREADY_INSTALLED]: { - extensionId: 'ms-python.pylint' | 'ms-python.flake8' | 'ms-python.isort'; + extensionId: 'ms-python.pylint' | 'ms-python.flake8'; isEnabled: boolean; }; /** @@ -2193,7 +2193,7 @@ export interface IEventNamePropertyMapping { } */ [EventName.TOOLS_EXTENSIONS_PROMPT_SHOWN]: { - extensionId: 'ms-python.pylint' | 'ms-python.flake8' | 'ms-python.isort'; + extensionId: 'ms-python.pylint' | 'ms-python.flake8'; }; /** * Telemetry event sent when clicking to install linter or formatter extension from the suggestion prompt. @@ -2204,7 +2204,7 @@ export interface IEventNamePropertyMapping { } */ [EventName.TOOLS_EXTENSIONS_INSTALL_SELECTED]: { - extensionId: 'ms-python.pylint' | 'ms-python.flake8' | 'ms-python.isort'; + extensionId: 'ms-python.pylint' | 'ms-python.flake8'; }; /** * Telemetry event sent when dismissing prompt suggesting to install the linter or formatter extension. @@ -2216,7 +2216,7 @@ export interface IEventNamePropertyMapping { } */ [EventName.TOOLS_EXTENSIONS_PROMPT_DISMISSED]: { - extensionId: 'ms-python.pylint' | 'ms-python.flake8' | 'ms-python.isort'; + extensionId: 'ms-python.pylint' | 'ms-python.flake8'; dismissType: 'close' | 'doNotShow'; }; /* __GDPR__ diff --git a/src/test/.vscode/settings.json b/src/test/.vscode/settings.json index ef9292849a9d..771962b5a909 100644 --- a/src/test/.vscode/settings.json +++ b/src/test/.vscode/settings.json @@ -3,7 +3,6 @@ "python.linting.flake8Enabled": false, "python.testing.pytestArgs": [], "python.testing.unittestArgs": ["-s=./tests", "-p=test_*.py", "-v", "-s", ".", "-p", "*test*.py"], - "python.sortImports.args": [], "python.linting.lintOnSave": false, "python.linting.enabled": true, "python.linting.pycodestyleEnabled": false, diff --git a/src/test/common.ts b/src/test/common.ts index 95345f91e5e0..4cc985c795b6 100644 --- a/src/test/common.ts +++ b/src/test/common.ts @@ -53,7 +53,6 @@ export type PythonSettingKeys = | 'testing.pytestArgs' | 'testing.unittestArgs' | 'formatting.provider' - | 'sortImports.args' | 'testing.pytestEnabled' | 'testing.unittestEnabled' | 'envFile' diff --git a/src/test/common/configSettings/configSettings.unit.test.ts b/src/test/common/configSettings/configSettings.unit.test.ts index eeaed6aa996b..113770122fbc 100644 --- a/src/test/common/configSettings/configSettings.unit.test.ts +++ b/src/test/common/configSettings/configSettings.unit.test.ts @@ -22,7 +22,6 @@ import { IFormattingSettings, IInterpreterSettings, ILintingSettings, - ISortImportSettings, ITerminalSettings, } from '../../../client/common/types'; import { noop } from '../../../client/common/utils/misc'; @@ -118,7 +117,6 @@ suite('Python Settings', async () => { // complex settings config.setup((c) => c.get('interpreter')).returns(() => sourceSettings.interpreter); config.setup((c) => c.get('linting')).returns(() => sourceSettings.linting); - config.setup((c) => c.get('sortImports')).returns(() => sourceSettings.sortImports); config.setup((c) => c.get('formatting')).returns(() => sourceSettings.formatting); config.setup((c) => c.get('autoComplete')).returns(() => sourceSettings.autoComplete); config.setup((c) => c.get('testing')).returns(() => sourceSettings.testing); diff --git a/src/test/common/productsToTest.ts b/src/test/common/productsToTest.ts index 7fc06863f67c..861bab898509 100644 --- a/src/test/common/productsToTest.ts +++ b/src/test/common/productsToTest.ts @@ -17,7 +17,6 @@ export function getProductsForInstallerTests(): { name: string; value: Product } 'yapf', 'autopep8', 'mypy', - 'isort', 'black', 'bandit', ].includes(p.name), diff --git a/src/test/providers/codeActionProvider/main.unit.test.ts b/src/test/providers/codeActionProvider/main.unit.test.ts index 501c3c7eca2b..55644d80ae54 100644 --- a/src/test/providers/codeActionProvider/main.unit.test.ts +++ b/src/test/providers/codeActionProvider/main.unit.test.ts @@ -8,7 +8,6 @@ import rewiremock from 'rewiremock'; import * as typemoq from 'typemoq'; import { CodeActionKind, CodeActionProvider, CodeActionProviderMetadata, DocumentSelector } from 'vscode'; import { IDisposableRegistry } from '../../../client/common/types'; -import { IServiceContainer } from '../../../client/ioc/types'; import { LaunchJsonCodeActionProvider } from '../../../client/providers/codeActionProvider/launchJsonCodeActionProvider'; import { CodeActionProviderService } from '../../../client/providers/codeActionProvider/main'; @@ -38,10 +37,7 @@ suite('Code Action Provider service', async () => { }; rewiremock.enable(); rewiremock('vscode').with(vscodeMock); - const quickFixService = new CodeActionProviderService( - typemoq.Mock.ofType().object, - typemoq.Mock.ofType().object, - ); + const quickFixService = new CodeActionProviderService(typemoq.Mock.ofType().object); await quickFixService.activate(); diff --git a/src/testMultiRootWkspc/multi.code-workspace b/src/testMultiRootWkspc/multi.code-workspace index 1daf409a0836..9d5c8ac77475 100644 --- a/src/testMultiRootWkspc/multi.code-workspace +++ b/src/testMultiRootWkspc/multi.code-workspace @@ -38,10 +38,6 @@ "python.linting.pycodestyleEnabled": false, "python.linting.prospectorEnabled": false, "python.formatting.provider": "yapf", - "python.sortImports.args": [ - "-sp", - "/Users/donjayamanne/.vscode/extensions/pythonVSCode/src/test/pythonFiles/sorting/withconfig" - ], "python.linting.lintOnSave": false, "python.linting.enabled": true, "python.pythonPath": "python"