PyCharm
PyCharm can be configured to format and lint on save. Doing so requires some manual configuration as outlined below.
Setup File Watchers
- Navigate to File -> Settings -> Plugins
- Download and install File Watchers
- Navigate to File -> Settings -> Tools -> Black
- Confirm 'Use Black Formatter' is unchecked for both 'On code reformat' and 'On save'
Setup flake8 Watcher
- Navigate to File -> Settings -> Tools -> File Watchers
- Click the '+' to add a new watcher.
-
Configure the watcher as below.
-
Navigate to File -> Settings -> Editor -> Inspections -> File watcher problems
- Under Severity select 'Edit Severities'
- Click the '+' to add a severity calling it 'Linting Error'
-
Configure a background and effect as below.
Setup isort
- Navigate to File -> Settings -> Tools -> File Watchers
- Click the '+' to add a new watcher.
-
Configure the watcher as below.
Setup yapf
- Navigate to File -> Settings -> Tools -> File Watchers
- Click the '+' to add a new watcher.
-
Configure the watcher as below.
Hint
Adding a comma at the end of a list will trigger yapf to put each element of the list on a new line
Setup prettier
- Navigate to File -> Settings -> Tools -> File Watchers
- Click the '+' to add a new watcher.
- Change 'File Type' to 'Any'.
- Click the three dots next to 'Scope' to create a custom scope.
-
Click '+' to add a new scope
-
Name: prettier
-
Pattern:
file:vue/src//*||file:vue3/src//*||file:docs//*
-
Configure the watcher as below.
-
Arguments:
--cwd $ProjectFileDir$\vue prettier -w --config $ProjectFileDir$\.prettierrc $FilePath$