black-nvim
black-nvim copied to clipboard
TypeError while executing format_file_contents
my black version is 22.1.0
# pip list | grep black
black 22.1.0
when call Black(), I got the following error:
error caught in async handler '/root/.vim/plugged/black-nvim/rplugin/python3/blacken.py:function:Black [[]]'
Traceback (most recent call last):
File "/root/.vim/plugged/black-nvim/rplugin/python3/blacken.py", line 36, in black
self.format_buff(buf_str, options, start)
File "/root/.vim/plugged/black-nvim/rplugin/python3/blacken.py", line 59, in format_buff
new_buffer = black.format_file_contents(
File "src/black/__init__.py", line 974, in format_file_contents
TypeError: bool object expected; got int
The function is defined as follows:
def format_file_contents(src_contents: str, *, fast: bool, mode: Mode)
format_file_contents() need a bool type 'fast' rather than int, maybe fast=bool(opts["fast"]) will solve the problem.
new_buffer = black.format_file_contents(
to_format, fast=opts["fast"], mode=mode
)
https://github.com/psf/black/blob/stable/src/black/init.py#L974