Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
marc-legendre opened this issue Jan 3, 2023 · 2 comments

Comments

@marc-legendre
Copy link

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.

@marc-legendre
Copy link
Author

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

@jmccreight
Copy link

thank you! this was driving me crazy

gopar added a commit that referenced this issue Jul 19, 2023
Adds a note about the requirement of 'toml' to be installed for the use of the `elpy-black-fix-code`
function.

Closes #2004 and #2008
@gopar gopar closed this as completed Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants