I'm using the Sort Imports function of the Python extension for VS Code. I'd like to configure the line length for this to 100; however, I've been unable to properly set this in my settings.json
file. From the documentation, it seems like "python.sortImports.args": ["-l", "100"]
should work, but it's giving me an error: Invalid patch string: Skipped 1 files
.
Any ideas?
This is largely true, but if you have Black set up to work in VSCode, you can configure the line length. In VSCode, go 'Code -> Preferences -> Settings' and search for "python formatting black args". A few notes about line lengths in Python: PEP8 recommends a line length of 79 characters (72 for docstrings)
You can run the extension using the shortcut Ctrl + Alt + O , or you can use the command palette Ctrl + Shift + P -> Dart: Sort Imports .
Organize imports into groups: first standard library imports, then third-party imports, and finally local application or library imports. Order imports alphabetically within each group. Prefer absolute imports over relative imports. Avoid wildcard imports like from module import * .
There is a known bug with using Sort Imports on __init__.py
files. Here is the full solution:
"python.sortImports.args": ["-ns", "__init__.py", "-l", "100"],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With