Custom settings for black autoformat
See original GitHub issueI wanted to use black autoformatting for some specific purposes only, i.e. disabling most of its functionality and just let it format some specific parts (e.g, whitespace managing and import sorting).
Is there any way to adapt the settings of the black
instance being used? I could not find a .toml
file anywhere?
btw: black
was a really bad choice of name by the authors. try searching for issues with black
and so much unrelated stuff pops up.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
VSCode: Using Black to automatically format Python
Open your VSCode settings, by going 'Code -> Preferences -> Settings'. Search for "python formatting provider" and select "black" from the ...
Read more >psf/black: The uncompromising Python code formatter - GitHub
Blackened code looks the same regardless of the project you're reading. Formatting becomes transparent after a while and you can focus on the...
Read more >Black 22.12.0 documentation
Black makes code review faster by producing the smallest diffs possible. Blackened code looks the same regardless of the project you're reading. Formatting ......
Read more >Setting up python Black on Visual Studio Code | by Marco Belo
Type “format on save” at the search bar on top of the Settings tab and check the box. Search for “python formatting provider”...
Read more >In python, how to tweak Black formatter, if possible?
If you're paid by the line of code you write, you can pass --line-length with a lower number. Black will try to respect...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Auto-sorting of imports needs that functionality added to the Python language server first (as I said in the other issues you posted earlier).
We’ll try to implement it in the future.
I’m pretty sure the Spyder plugin respects
pyproject.toml
and theblack
configuration in there. See https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-formatYou can then place your
pyproject.toml
in the same folder as the file you want to format (see https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#where-black-looks-for-the-file), and runblack
. I just tested with adjustingline-length
in the toml file, and that works.Note that
black
in Spyder is not behaving entirely as it should https://github.com/spyder-ide/spyder/issues/17143PS: I feel the pain re searching issues with common works, if its of help I recently discovered adding
in:title
to the filter (for example,is:issue is:open in:title black
)