question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom settings for black autoformat

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ccordoba12commented, Mar 7, 2022

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.

1reaction
rhkarlscommented, Mar 7, 2022

I’m pretty sure the Spyder plugin respects pyproject.toml and the black configuration in there. See https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-format

You 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 run black. I just tested with adjusting line-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/17143

PS: 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 )

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found