jorgenschaefer/elpy

elpy-black-fix-code does not use the pytoml config file located in the same folder

Opened this issue · 0 comments

Summary

First of all thanks so much for creating and supporting elpy! I use it for many years, and it's beautiful!
As a small issue, I have seen that elpy-black-fix-code does not use the pytoml config file located in the same folder
when it formats a code after autosave. (In particular the line length limit defined there is not respected).

Running black . in the terminal works just fine and uses the config file.

Steps to reproduce

  • Download black in mac
  • Add the snippet in init.el for elpy-black-fix-code (pasted below)
  • Save a python file

My configuration

I'm using macOS 13.4.1, emacs 28.2, black 23.7.0

Result of (elpy-config)

Elpy Configuration

Emacs.............: 28.2
Elpy..............: 1.35.0
Virtualenv........: None
Interactive Python: ipython 8.14.0 (/opt/homebrew/bin/ipython)
RPC virtualenv....: rpc-venv (/Users/okankoc/.emacs.d/elpy/rpc-venv)
 Python...........: python3 3.9.6 (/Users/okankoc/.emacs.d/elpy/rpc-venv/bin/python3)
 Jedi.............: 0.19.0
 Autopep8.........: 2.0.2
 Yapf.............: 0.40.1
 Black............: 23.7.0
Syntax checker....: black (/opt/homebrew/bin/black)

Elpy configuration in my init.el

Elpy related config in my init file:

(elpy-enable)
(custom-set-variables
 '(elpy-syntax-check-command "/opt/homebrew/bin/black"))
(add-hook 'elpy-mode-hook (lambda ()
                             (add-hook 'before-save-hook
                                       'elpy-black-fix-code nil t)))