From fc30512fa2aabe65ad9eddc0dce19fd5ff9e61fe Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Wed, 11 Oct 2023 14:30:42 -0700 Subject: [PATCH] Remove formatting settings --- README.md | 9 +-- build/test-requirements.txt | 5 -- package.json | 71 ------------------- package.nls.json | 21 ------ resources/report_issue_user_settings.json | 9 --- src/client/common/configSettings.ts | 31 -------- src/client/common/types.ts | 9 --- src/client/common/utils/localize.ts | 20 ------ src/client/telemetry/constants.ts | 2 - src/client/telemetry/index.ts | 39 +--------- src/test/.vscode/settings.json | 1 - .../configSettings.unit.test.ts | 61 ---------------- src/test/common/productsToTest.ts | 16 +---- src/testMultiRootWkspc/multi.code-workspace | 1 - 14 files changed, 6 insertions(+), 289 deletions(-) diff --git a/README.md b/README.md index 0a8766f086af..8029aa096587 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Open the Command Palette (Command+Shift+P on macOS and Ctrl+Shift+P on Windows/L | `Python: Select Interpreter` | Switch between Python interpreters, versions, and environments. | | `Python: Start REPL` | Start an interactive Python REPL using the selected interpreter in the VS Code terminal. | | `Python: Run Python File in Terminal` | Runs the active Python file in the VS Code terminal. You can also run a Python file by right-clicking on the file and selecting `Run Python File in Terminal`. | -| `Format Document` | Formats code using the provided [formatter](https://code.visualstudio.com/docs/python/editing#_formatting) in the `settings.json` file. | +| `Format Document` | Formats code using the provided [formatter](https://code.visualstudio.com/docs/python/formatting) in the `settings.json` file. | | `Python: Configure Tests` | Select a test framework and configure it to display the Test Explorer. | To see all available Python commands, open the Command Palette and type `Python`. For Jupyter extension commands, just type `Jupyter`. @@ -71,16 +71,11 @@ Learn more about the rich features of the Python extension: - [IntelliSense](https://code.visualstudio.com/docs/python/editing#_autocomplete-and-intellisense): Edit your code with auto-completion, code navigation, syntax checking and more - [Linting](https://code.visualstudio.com/docs/python/linting): Get additional code analysis with Pylint, Flake8 and more -- [Code formatting](https://code.visualstudio.com/docs/python/editing#_formatting): Format your code with black, autopep or yapf - +- [Code formatting](https://code.visualstudio.com/docs/python/formatting): Format your code with black, autopep or yapf - [Debugging](https://code.visualstudio.com/docs/python/debugging): Debug your Python scripts, web apps, remote or multi-threaded processes - - [Testing](https://code.visualstudio.com/docs/python/unit-testing): Run and debug tests through the Test Explorer with unittest or pytest. - - [Jupyter Notebooks](https://code.visualstudio.com/docs/python/jupyter-support): Create and edit Jupyter Notebooks, add and run code cells, render plots, visualize variables through the variable explorer, visualize dataframes with the data viewer, and more - - [Environments](https://code.visualstudio.com/docs/python/environments): Automatically activate and switch between virtualenv, venv, pipenv, conda and pyenv environments - - [Refactoring](https://code.visualstudio.com/docs/python/editing#_refactoring): Restructure your Python code with variable extraction and method extraction. Additionally, there is componentized support to enable additional refactoring, such as import sorting, through extensions including [isort](https://marketplace.visualstudio.com/items?itemName=ms-python.isort) and [Ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff). diff --git a/build/test-requirements.txt b/build/test-requirements.txt index 433bd0f86682..0650e86fb3d3 100644 --- a/build/test-requirements.txt +++ b/build/test-requirements.txt @@ -1,13 +1,8 @@ # pin setoptconf to prevent issue with 'use_2to3' setoptconf==0.3.0 -# Install flake8 first, as both flake8 and autopep8 require pycodestyle, -# but flake8 has a tighter pinning. flake8 -autopep8 bandit -black -yapf pylint pycodestyle pydocstyle diff --git a/package.json b/package.json index 88578a687853..20401cc43762 100644 --- a/package.json +++ b/package.json @@ -577,77 +577,6 @@ "type": "array", "uniqueItems": true }, - "python.formatting.autopep8Args": { - "default": [], - "description": "%python.formatting.autopep8Args.description%", - "items": { - "type": "string" - }, - "scope": "resource", - "type": "array", - "markdownDeprecationMessage": "%python.formatting.autopep8Args.markdownDeprecationMessage%", - "deprecationMessage": "%python.formatting.autopep8Args.deprecationMessage%" - }, - "python.formatting.autopep8Path": { - "default": "autopep8", - "description": "%python.formatting.autopep8Path.description%", - "scope": "machine-overridable", - "type": "string", - "markdownDeprecationMessage": "%python.formatting.autopep8Path.markdownDeprecationMessage%", - "deprecationMessage": "%python.formatting.autopep8Path.deprecationMessage%" - }, - "python.formatting.blackArgs": { - "default": [], - "description": "%python.formatting.blackArgs.description%", - "items": { - "type": "string" - }, - "scope": "resource", - "type": "array", - "markdownDeprecationMessage": "%python.formatting.blackArgs.markdownDeprecationMessage%", - "deprecationMessage": "%python.formatting.blackArgs.deprecationMessage%" - }, - "python.formatting.blackPath": { - "default": "black", - "description": "%python.formatting.blackPath.description%", - "scope": "machine-overridable", - "type": "string", - "markdownDeprecationMessage": "%python.formatting.blackPath.markdownDeprecationMessage%", - "deprecationMessage": "%python.formatting.blackPath.deprecationMessage%" - }, - "python.formatting.provider": { - "default": "autopep8", - "description": "%python.formatting.provider.description%", - "enum": [ - "autopep8", - "black", - "none", - "yapf" - ], - "scope": "resource", - "type": "string", - "markdownDeprecationMessage": "%python.formatting.provider.markdownDeprecationMessage%", - "deprecationMessage": "%python.formatting.provider.deprecationMessage%" - }, - "python.formatting.yapfArgs": { - "default": [], - "description": "%python.formatting.yapfArgs.description%", - "items": { - "type": "string" - }, - "scope": "resource", - "type": "array", - "markdownDeprecationMessage": "%python.formatting.yapfArgs.markdownDeprecationMessage%", - "deprecationMessage": "%python.formatting.yapfArgs.deprecationMessage%" - }, - "python.formatting.yapfPath": { - "default": "yapf", - "description": "%python.formatting.yapfPath.description%", - "scope": "machine-overridable", - "type": "string", - "markdownDeprecationMessage": "%python.formatting.yapfPath.markdownDeprecationMessage%", - "deprecationMessage": "%python.formatting.yapfPath.deprecationMessage%" - }, "python.globalModuleInstallation": { "default": false, "description": "%python.globalModuleInstallation.description%", diff --git a/package.nls.json b/package.nls.json index 5687e51ab9df..f843399e09c5 100644 --- a/package.nls.json +++ b/package.nls.json @@ -42,27 +42,6 @@ "python.experiments.pythonTerminalEnvVarActivation.description": "Enables use of environment variables to activate terminals instead of sending activation commands.", "python.experiments.pythonTestAdapter.description": "Denotes the Python Test Adapter experiment.", "python.experiments.pythonREPLSmartSend.description": "Denotes the Python REPL Smart Send experiment.", - "python.formatting.autopep8Args.description": "Arguments passed in. Each argument is a separate item in the array.", - "python.formatting.autopep8Args.markdownDeprecationMessage": "This setting will soon be deprecated. Please use the [Autopep8 extension](https://marketplace.visualstudio.com/items?itemName=ms-python.autopep8).
Learn more [here](https://aka.ms/AAlgvkb).", - "python.formatting.autopep8Args.deprecationMessage": "This setting will soon be deprecated. Please use the Autopep8 extension. Learn more here: https://aka.ms/AAlgvkb.", - "python.formatting.autopep8Path.description": "Path to autopep8, you can use a custom version of autopep8 by modifying this setting to include the full path.", - "python.formatting.autopep8Path.markdownDeprecationMessage": "This setting will soon be deprecated. Please use the [Autopep8 extension](https://marketplace.visualstudio.com/items?itemName=ms-python.autopep8).
Learn more [here](https://aka.ms/AAlgvkb).", - "python.formatting.autopep8Path.deprecationMessage": "This setting will soon be deprecated. Please use the Autopep8 extension. Learn more here: https://aka.ms/AAlgvkb.", - "python.formatting.blackArgs.description": "Arguments passed in. Each argument is a separate item in the array.", - "python.formatting.blackArgs.markdownDeprecationMessage": "This setting will soon be deprecated. Please use the [Black Formatter extension](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter).
Learn more [here](https://aka.ms/AAlgvkb).", - "python.formatting.blackArgs.deprecationMessage": "This setting will soon be deprecated. Please use the Black Formatter extension. Learn more here: https://aka.ms/AAlgvkb.", - "python.formatting.blackPath.description": "Path to Black, you can use a custom version of Black by modifying this setting to include the full path.", - "python.formatting.blackPath.markdownDeprecationMessage": "This setting will soon be deprecated. Please use the [Black Formatter extension](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter).
Learn more [here](https://aka.ms/AAlgvkb).", - "python.formatting.blackPath.deprecationMessage": "This setting will soon be deprecated. Please use the Black Formatter extension. Learn more here: https://aka.ms/AAlgvkb.", - "python.formatting.provider.description": "Provider for formatting. Possible options include 'autopep8', 'black', and 'yapf'.", - "python.formatting.provider.markdownDeprecationMessage": "This setting will soon be deprecated. Please use a dedicated formatter extension.
Learn more [here](https://aka.ms/AAlgvkb).", - "python.formatting.provider.deprecationMessage": "This setting will soon be deprecated. Please use a dedicated formatter extension. Learn more here: https://aka.ms/AAlgvkb.", - "python.formatting.yapfArgs.description": "Arguments passed in. Each argument is a separate item in the array.", - "python.formatting.yapfArgs.markdownDeprecationMessage": "Built-in Yapf support will soon be deprecated. Learn more [here](https://aka.ms/AAlgvkb).", - "python.formatting.yapfArgs.deprecationMessage": "Built-in Yapf support will soon be deprecated. Learn more here: https://aka.ms/AAlgvkb.", - "python.formatting.yapfPath.description": "Path to yapf, you can use a custom version of yapf by modifying this setting to include the full path.", - "python.formatting.yapfPath.markdownDeprecationMessage": "Yapf support will soon be deprecated.
Learn more [here](https://aka.ms/AAlgvkb).", - "python.formatting.yapfPath.deprecationMessage": "Built-in Yapf support will soon be deprecated. Learn more here: https://aka.ms/AAlgvkb.", "python.globalModuleInstallation.description": "Whether to install Python modules globally when not using an environment.", "python.languageServer.description": "Defines type of the language server.", "python.languageServer.defaultDescription": "Automatically select a language server: Pylance if installed and available, otherwise fallback to Jedi.", diff --git a/resources/report_issue_user_settings.json b/resources/report_issue_user_settings.json index 677e58d83f21..eea4ca007da6 100644 --- a/resources/report_issue_user_settings.json +++ b/resources/report_issue_user_settings.json @@ -69,15 +69,6 @@ "memory": true, "symbolsHierarchyDepthLimit": false }, - "formatting": { - "autopep8Args": "placeholder", - "autopep8Path": "placeholder", - "provider": true, - "blackArgs": "placeholder", - "blackPath": "placeholder", - "yapfArgs": "placeholder", - "yapfPath": "placeholder" - }, "testing": { "cwd": "placeholder", "debugPort": true, diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index 3e4b75b8b087..cadc1515f7e6 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -27,7 +27,6 @@ import { IAutoCompleteSettings, IDefaultLanguageServer, IExperiments, - IFormattingSettings, IInterpreterPathService, IInterpreterSettings, ILintingSettings, @@ -109,8 +108,6 @@ export class PythonSettings implements IPythonSettings { public linting!: ILintingSettings; - public formatting!: IFormattingSettings; - public autoComplete!: IAutoCompleteSettings; public tensorBoard: ITensorBoardSettings | undefined; @@ -395,34 +392,6 @@ export class PythonSettings implements IPythonSettings { this.linting.cwd = getAbsolutePath(systemVariables.resolveAny(this.linting.cwd), workspaceRoot); } - const formattingSettings = systemVariables.resolveAny(pythonSettings.get('formatting'))!; - if (this.formatting) { - Object.assign(this.formatting, formattingSettings); - } else { - this.formatting = formattingSettings; - } - // Support for travis. - this.formatting = this.formatting - ? this.formatting - : { - autopep8Args: [], - autopep8Path: 'autopep8', - provider: 'autopep8', - blackArgs: [], - blackPath: 'black', - yapfArgs: [], - yapfPath: 'yapf', - }; - this.formatting.autopep8Path = getAbsolutePath( - systemVariables.resolveAny(this.formatting.autopep8Path), - workspaceRoot, - ); - this.formatting.yapfPath = getAbsolutePath(systemVariables.resolveAny(this.formatting.yapfPath), workspaceRoot); - this.formatting.blackPath = getAbsolutePath( - systemVariables.resolveAny(this.formatting.blackPath), - workspaceRoot, - ); - const testSettings = systemVariables.resolveAny(pythonSettings.get('testing'))!; if (this.testing) { Object.assign(this.testing, testSettings); diff --git a/src/client/common/types.ts b/src/client/common/types.ts index 8b90443703c6..a33f437622fa 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -258,15 +258,6 @@ export interface ILintingSettings { banditArgs: string[]; banditPath: string; } -export interface IFormattingSettings { - readonly provider: string; - autopep8Path: string; - readonly autopep8Args: string[]; - blackPath: string; - readonly blackArgs: string[]; - yapfPath: string; - readonly yapfArgs: string[]; -} export interface ITerminalSettings { readonly executeInFileDir: boolean; diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index c6086071363f..bbb55a79ce40 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -516,24 +516,4 @@ export namespace ToolsExtensions { ); export const installPylintExtension = l10n.t('Install Pylint extension'); export const installFlake8Extension = l10n.t('Install Flake8 extension'); - - export const selectBlackFormatterPrompt = l10n.t( - 'You have the Black formatter extension installed, would you like to use that as the default formatter?', - ); - - export const selectAutopep8FormatterPrompt = l10n.t( - 'You have the Autopep8 formatter extension installed, would you like to use that as the default formatter?', - ); - - export const selectMultipleFormattersPrompt = l10n.t( - 'You have multiple formatters installed, would you like to select one as the default formatter?', - ); - - export const installBlackFormatterPrompt = l10n.t( - 'You triggered formatting with Black, would you like to install one of our new formatter extensions? This will also set it as the default formatter for Python.', - ); - - export const installAutopep8FormatterPrompt = l10n.t( - 'You triggered formatting with Autopep8, would you like to install one of our new formatter extension? This will also set it as the default formatter for Python.', - ); } diff --git a/src/client/telemetry/constants.ts b/src/client/telemetry/constants.ts index c680b91094cb..301502a0f6fa 100644 --- a/src/client/telemetry/constants.ts +++ b/src/client/telemetry/constants.ts @@ -4,8 +4,6 @@ 'use strict'; export enum EventName { - FORMAT_SORT_IMPORTS = 'FORMAT.SORT_IMPORTS', - FORMAT = 'FORMAT.FORMAT', FORMAT_ON_TYPE = 'FORMAT.FORMAT_ON_TYPE', EDITOR_LOAD = 'EDITOR.LOAD', LINTING = 'LINTING', diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 95496c828018..f69da6046254 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -859,33 +859,7 @@ export interface IEventNamePropertyMapping { */ scope: 'file' | 'selection'; }; - /** - * Telemetry event sent with details when formatting a document - */ - /* __GDPR__ - "format.format" : { - "duration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "karthiknadig" }, - "errorname" : { "classification": "CallstackOrException", "purpose": "PerformanceAndHealth", "owner": "karthiknadig" }, - "errorstack" : { "classification": "CallstackOrException", "purpose": "PerformanceAndHealth", "owner": "karthiknadig" }, - "tool" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "karthiknadig" }, - "hascustomargs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "karthiknadig" }, - "formatselection" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "karthiknadig" } - } - */ - [EventName.FORMAT]: { - /** - * Tool being used to format - */ - tool: 'autopep8' | 'black' | 'yapf'; - /** - * If arguments for formatter is provided in resource settings - */ - hasCustomArgs: boolean; - /** - * Carries `true` when formatting a selection of text, `false` otherwise - */ - formatSelection: boolean; - }; + /** * Telemetry event sent with the value of setting 'Format on type' */ @@ -902,16 +876,6 @@ export interface IEventNamePropertyMapping { */ enabled: boolean; }; - /** - * Telemetry event sent when sorting imports using formatter - */ - /* __GDPR__ - "format.sort_imports" : { - "duration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "karthiknadig" }, - "originaleventname" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "karthiknadig" } - } - */ - [EventName.FORMAT_SORT_IMPORTS]: never | undefined; /** * Telemetry event sent with details when tracking imports @@ -921,7 +885,6 @@ export interface IEventNamePropertyMapping { "hashedname" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "luabud" } } */ - [EventName.HASHED_PACKAGE_NAME]: { /** * Hash of the package name diff --git a/src/test/.vscode/settings.json b/src/test/.vscode/settings.json index 771962b5a909..faeb48ffa29c 100644 --- a/src/test/.vscode/settings.json +++ b/src/test/.vscode/settings.json @@ -11,7 +11,6 @@ "python.linting.pylamaEnabled": false, "python.linting.mypyEnabled": false, "python.linting.banditEnabled": false, - "python.formatting.provider": "yapf", // Don't set this to `Pylance`, for CI we want to use the LS that ships with the extension. "python.languageServer": "Jedi", "python.pythonPath": "C:\\GIT\\s p\\vscode-python\\.venv\\Scripts\\python.exe" diff --git a/src/test/common/configSettings/configSettings.unit.test.ts b/src/test/common/configSettings/configSettings.unit.test.ts index 113770122fbc..e43ac7b7fbd8 100644 --- a/src/test/common/configSettings/configSettings.unit.test.ts +++ b/src/test/common/configSettings/configSettings.unit.test.ts @@ -19,7 +19,6 @@ import { PersistentStateFactory } from '../../../client/common/persistentState'; import { IAutoCompleteSettings, IExperiments, - IFormattingSettings, IInterpreterSettings, ILintingSettings, ITerminalSettings, @@ -117,7 +116,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('formatting')).returns(() => sourceSettings.formatting); config.setup((c) => c.get('autoComplete')).returns(() => sourceSettings.autoComplete); config.setup((c) => c.get('testing')).returns(() => sourceSettings.testing); config.setup((c) => c.get('terminal')).returns(() => sourceSettings.terminal); @@ -264,63 +262,4 @@ suite('Python Settings', async () => { test('Experiments (not enabled)', () => testExperiments(false)); test('Experiments (enabled)', () => testExperiments(true)); - - test('Formatter Paths and args', () => { - expected.pythonPath = 'python3'; - - expected.formatting = { - autopep8Args: ['1', '2'], - autopep8Path: 'one', - blackArgs: ['3', '4'], - blackPath: 'two', - yapfArgs: ['5', '6'], - yapfPath: 'three', - provider: '', - }; - expected.formatting.blackPath = 'spam'; - initializeConfig(expected); - config - .setup((c) => c.get('formatting')) - .returns(() => expected.formatting) - .verifiable(TypeMoq.Times.once()); - - settings.update(config.object); - - for (const key of Object.keys(expected.formatting)) { - expect((settings.formatting as any)[key]).to.be.deep.equal((expected.formatting as any)[key]); - } - config.verifyAll(); - }); - test('Formatter Paths (paths relative to home)', () => { - expected.pythonPath = 'python3'; - - expected.formatting = { - autopep8Args: [], - autopep8Path: path.join('~', 'one'), - blackArgs: [], - blackPath: path.join('~', 'two'), - yapfArgs: [], - yapfPath: path.join('~', 'three'), - provider: '', - }; - expected.formatting.blackPath = 'spam'; - initializeConfig(expected); - config - .setup((c) => c.get('formatting')) - .returns(() => expected.formatting) - .verifiable(TypeMoq.Times.once()); - - settings.update(config.object); - - for (const key of Object.keys(expected.formatting)) { - if (!key.endsWith('path')) { - continue; - } - - const expectedPath = untildify((expected.formatting as any)[key]); - - expect((settings.formatting as any)[key]).to.be.equal(expectedPath); - } - config.verifyAll(); - }); }); diff --git a/src/test/common/productsToTest.ts b/src/test/common/productsToTest.ts index 861bab898509..e82d12bbd9eb 100644 --- a/src/test/common/productsToTest.ts +++ b/src/test/common/productsToTest.ts @@ -7,18 +7,8 @@ import { getNamesAndValues } from '../../client/common/utils/enum'; export function getProductsForInstallerTests(): { name: string; value: Product }[] { return getNamesAndValues(Product).filter( (p) => - ![ - 'pylint', - 'flake8', - 'pycodestyle', - 'pylama', - 'prospector', - 'pydocstyle', - 'yapf', - 'autopep8', - 'mypy', - 'black', - 'bandit', - ].includes(p.name), + !['pylint', 'flake8', 'pycodestyle', 'pylama', 'prospector', 'pydocstyle', 'mypy', 'bandit'].includes( + p.name, + ), ); } diff --git a/src/testMultiRootWkspc/multi.code-workspace b/src/testMultiRootWkspc/multi.code-workspace index 9d5c8ac77475..51d218783041 100644 --- a/src/testMultiRootWkspc/multi.code-workspace +++ b/src/testMultiRootWkspc/multi.code-workspace @@ -37,7 +37,6 @@ "python.linting.pylintEnabled": true, "python.linting.pycodestyleEnabled": false, "python.linting.prospectorEnabled": false, - "python.formatting.provider": "yapf", "python.linting.lintOnSave": false, "python.linting.enabled": true, "python.pythonPath": "python"