jorgenschaefer/elpy

elpy-black-fix-code ignores black configuration if python package `toml` is not installed

Closed this issue · 2 comments

Since #1611, elpy relies on the toml package to read black configuration files, which was a dependency of black at the time.

However, since version 21.7b0, black does not depend on toml anymore (cf psf/black#2301), thus toml is not installed automatically. If toml is not found, the black configuration file is ignored by elpy-black-fix-code.

I stumbled upon this after recreating the RPC venv for elpy, and it took me quite some time to understand why my code was not formatted according to my configuration, so I thought I'd let you know.

Workaround

Install toml in the elpy RPC venv:

source $HOME/.emacs.d/elpy/rpc-venv/bin/activate
pip install toml

Additional notes

Might be relevant: black now uses tomli to read toml files for python < 3.11, and the standard module tomllib for python >= 3.11.

Apologies, I just realized this was already reported in #2004. I missed it because it doesn't mention "black" in the title.

I let you triage as you see fit. :-)

thank you! this was driving me crazy