wbolster / emacs-python-black

Emacs package to reformat Python using black-macchiato
BSD 3-Clause "New" or "Revised" License
95 stars 11 forks source link

Run with `-S, --skip-string-normalization` flag #7

Closed jidicula closed 3 years ago

jidicula commented 3 years ago

This is a pretty nice package that has faster execution than blacken! I especially like that it's still being actively developed 😉

I'm trying to set some project-specific Black configs without using a pyproject.toml, so naturally I'd like to use .dir-locals.el. Specifically, I want to skip string normalization in some projects by running black -S. How can I do this with this package? I already tried setting python-black-command to "black -S" in .dir-locals.el, but this didn't seem to do it. Neither did setting python-black-extra-args to "-S". The following block is my .dir-locals.el and I tried toggling each of the lines.

(
 (python-black-command . "black -S")
 ;; (python-black-extra-args . "-S")
 )

Is this a configuration that's possible with this package, or am I misusing these variables?

wbolster commented 3 years ago

the extra args variable seems the right place. it should be a list of strings, not a single string, though: '("-S")

jidicula commented 3 years ago

My .dir-locals.el looks like this now:

(
 (python-black-extra-args . '("-S"))
 )

but this didn't result in the expected change, and the package's autoformatting still normalizes strings 😦.

However, when I execute (setq python-black-extra-args '("-S")), the autoformatting doesn't normalize strings as expected...

jidicula commented 3 years ago

Never mind, I got it to work with the following .dir-locals.el 🎉

(
 (python-mode . (
         (python-black-extra-args . ("-S"))
         )
          )
 )