107 questions
0
votes
0
answers
19
views
Black Python formatter - setting different line length for some files
I'm using Black Python formatter and I'm looking for a way to control line-length settings for some of the files. E.g. I'd like the default line length to be set in pyproject.toml to 120, but for some ...
0
votes
1
answer
71
views
Python black formatting only one file in project
I've installed black formatting in the venv directory of my project. In my project, I have, among other files:
.vscode/settings.json
and
djblogger/djblogger/settings/base.py
in the settings.json is ...
0
votes
1
answer
72
views
Why does black output a different format when code has comments?
what I want
My goal is not to keep the code the way I want it to be and disable black package formatting.
The point I want to learn is that the difference between the two pieces of code is just one ...
3
votes
1
answer
2k
views
How to prevent ruff formatter from adding a newline after module-level docstring?
I'm using ruff as a replacement to black formatter but I wanna keep the diff at minimum. I'm noticing that it automatically inserts a newline between the module-level docstring and the first import ...
0
votes
1
answer
140
views
WSL2 vscode black extension isn't formatting on save
I'm having some trouble getting the vscode black extension to work in vscode. I'm using python 3.10.12, ubuntu 22.04.3, vscode 1.90.1
Here's my user settings json (edited 6/26 to reflect answer ...
0
votes
1
answer
89
views
Task to formate an ipynb notebook using the black command-line tool
I am using vscode on windows and wsl (Ubuntu-22.04).
I am trying to define a task to formate an ipynb file using the black command-line tool (not the vscode extension), to workaround my issue https://...
0
votes
1
answer
220
views
Black formatter for Python gives a decoding error "not a utf-8 character" - how can I tell black to use 'UTF-16'?
NONE of the suggestions to get the file into utf-8 succeeded.
In desperation, I switched from black to ruff.py and am proceeding.
ruff had no trouble with the directory of files.
intelliJ IDEA 2023.2....
3
votes
0
answers
175
views
How do I configure Python "black" to sensibly format Polars?
How do I configure Black to sensibly auto-format Python code for the Polars library?
With the default settings, it likes to left-align .select/.with_columns calls with many arguments. I want the ...
0
votes
1
answer
1k
views
Configuration Error when formatting Python with Black in VSCode
I can't setup black to format when saving in VSCode.
I went through the steps in the black docs
Installed the VSCode plugins: black formatter and python
Setup personal configuration (I also tried ...
5
votes
0
answers
217
views
Black: formatting of fluent method calls
I'm using the black formatter, and I'm having trouble getting it to respect my wishes for fluent method chains like this:
result = (
data
.some_method()
...
0
votes
0
answers
691
views
Black formatter doesn't break long line
I have a python project with Flake8 and Black installed. I'm using VSCode, with the following workspace configuration in settings.json: "black-formatter.args": ["--line-length=80"],...
1
vote
1
answer
1k
views
Visual Studio Code - Microsoft Black Formatter from command line?
I have the Microsoft Black Formatter extension in VSCode (in WSL, inside Windows 11). I can format opened python files with no problem, one-by-one, either using keyboard shortcut or right click on the ...
1
vote
0
answers
480
views
How to prevent Black from adding a line break after union(`|`) type annotations
Black formats my code to:
operators: list[str]
| None = Query(
default=None,
description="operators",
),
but I want it to be formatted as:
operators: list[str] | None = Query(
...
0
votes
1
answer
291
views
Databricks "Format document" not adding newline to end of file
I'm using Databricks Runtime 13.3 LTS ML and for some reason the "Format document" black formatting is not adding a newline to the end of (python) file.
However, running same version of ...
6
votes
3
answers
4k
views
How to fix InvalidManifestError for pre-commit with black?
Running python pre-commit with black latest version 23.11.0 leads to a wired InvalidManifestError.
snippet from .pre-commit-config.yaml
repos:
- repo: https://github.com/psf/black
rev: 23.11.0
...