parent
ba64fc757c
commit
a2f6706a1e
@ -98,15 +98,14 @@ if _initialize_black_env():
|
|||||||
def Black():
|
def Black():
|
||||||
start = time.time()
|
start = time.time()
|
||||||
fast = bool(int(vim.eval("g:black_fast")))
|
fast = bool(int(vim.eval("g:black_fast")))
|
||||||
line_length = int(vim.eval("g:black_linelength"))
|
mode = black.FileMode(
|
||||||
mode = black.FileMode.AUTO_DETECT
|
line_length=int(vim.eval("g:black_linelength")),
|
||||||
if bool(int(vim.eval("g:black_skip_string_normalization"))):
|
string_normalization=not bool(int(vim.eval("g:black_skip_string_normalization"))),
|
||||||
mode |= black.FileMode.NO_STRING_NORMALIZATION
|
is_pyi=vim.current.buffer.name.endswith('.pyi'),
|
||||||
if vim.current.buffer.name.endswith('.pyi'):
|
)
|
||||||
mode |= black.FileMode.PYI
|
|
||||||
buffer_str = '\n'.join(vim.current.buffer) + '\n'
|
buffer_str = '\n'.join(vim.current.buffer) + '\n'
|
||||||
try:
|
try:
|
||||||
new_buffer_str = black.format_file_contents(buffer_str, line_length=line_length, fast=fast, mode=mode)
|
new_buffer_str = black.format_file_contents(buffer_str, fast=fast, mode=mode)
|
||||||
except black.NothingChanged:
|
except black.NothingChanged:
|
||||||
print(f'Already well formatted, good job. (took {time.time() - start:.4f}s)')
|
print(f'Already well formatted, good job. (took {time.time() - start:.4f}s)')
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
Loading…
Reference in New Issue
Block a user