Closed avatar-lavventura closed 2 years ago
i do not understand your question/problem. please give more details and examples
i've fixed the broken link in the readme in 01f1f4269136cfb36938567854383628730faaab
I want to use python-black inside emacs only to fix extra new lines and nothing else, if possible.
Example:
def mkdir(path) -> None:
if not os.path.isdir(path):
os.makedirs(path)
def mkdirs(paths) -> None:
for path in paths:
mkdir(path)
converted into:
def mkdir(path) -> None:
if not os.path.isdir(path):
os.makedirs(path)
def mkdirs(paths) -> None:
for path in paths:
mkdir(path)
I just want to use this behavior of python-black inside emacs
, is it possible?
i still don't understand what this means:
and nothing else
this package (or actually, black itself) happily converts your example input into your example output. so what exactly doesn't work which you expect/wish to work?
Actually main problem was after each save when python-black
reformats a change the cursor location also changes to the location where the format occurs, which makes my job very difficult during coding. For that reason. I just want to apply convert formant only for removing extra new-lines.
nothing else
=> example I don't want black
to be applied on:# in:
j = [1,
2,
3
]
# out:
j = [1, 2, 3]
your example input is not black compliant so if you run black it will obviously change it. if you don't want that to happen on save, don't use the -on-save
mode, e.g. use a shortcut instead to do it manually.
i am not sure what ‘removing extra newlines’ really means, but in any case black is an all-or-nothing approach (but see readme notes on black-macchiato for partial formatting) so doing only a subset of formatting is impossible.
I was wondering would it be possible to set
python-black
only to remove the extra new-lines?Following link was dead I was not able to open it: https://black.readthedocs.io/en/stable/pyproject_toml.html