A Visual Studio Code extension with support for the autopep8 formatter. The extension ships with autopep8=2.0.2.
Note:
- This extension is supported for all actively supported versions of the
pythonlanguage (i.e., python >= 3.7). - The bundled
autopep8is only used if there is no installed version ofautopep8found in the selectedpythonenvironment. - Minimum supported version of
autopep8is1.7.0. - This extension is experimental. The plan is that it will eventually replace the
autopep8formatting functionality of the Python extension.
Once installed in Visual Studio Code, "autopep8" will be available as a formatter for python files. Please select "autopep8" (extension id:ms-python.autopep8) as the default formatter. You can do this either by using the context menu (right click on a open python file in the editor) and select "Format Document With...", or you can add the following to your settings:
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
}and change the following, if set:
"python.formatting.provider": "none"You can enable format on save for python by having the following values in your settings:
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8",
"editor.formatOnSave": true
}If you want to disable autopep8 formatter, you can disable this extension per workspace in Visual Studio Code.
| Settings | Default | Description |
|---|---|---|
| autopep8.args | [] |
Custom arguments passed to autopep8. E.g "autopep8.args" = ["--config", "<file>"] |
| autopep8.path | [] |
Setting to provide custom autopep8 executable. This will slow down formatting, since we will have to run autopep8 executable every time or file save or open. Example 1: ["~/global_env/autopep8"] Example 2: ["conda", "run", "-n", "lint_env", "python", "-m", "autopep8"] |
| autopep8.interpreter | [] |
Path to a python interpreter to use to run the linter server. |
| autopep8.importStrategy | useBundled |
Setting to choose where to load autopep8 from. useBundled picks autopep8 bundled with the extension. fromEnvironment uses autopep8 available in the environment. |
| autopep8.showNotification | off |
Setting to control when a notification is shown. |
| Command | Description |
|---|---|
| autopep8: Restart | Force re-start the format server. |
Use Developer : Set Log Level... command from the Command Palette, and select autopep8 from the extensions list to set the Log Level for the extension. For detailed LSP traces, add "autopep8.trace.server" : "verbose" to your User settings.json file.