A Visual Studio Code extension with support for the autopep8
formatter. The extension ships with autopep8=2.0.1
.
Note:
- This extension is supported for all actively supported versions of the
python
language (i.e., python >= 3.7).
- The bundled
autopep8
is only used if there is no installed version of autopep8
found in the selected python
environment.
- Minimum supported version of
autopep8
is 1.7.0
.
- This extension is experimental. The plan is that it will eventually replace the
autopep8
formatting functionality of the Python extension.
Usage
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
Settings |
Default |
Description |
autopep8.args |
[] |
Custom arguments passed to autopep8 . E.g "autopep8.args" = ["--config", "<file>"] |
autopep8.logLevel |
error |
Sets the tracing level for the extension. |
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. |
Commands
Command |
Description |
autopep8: Restart |
Force re-start the format server. |