mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 13:34:46 +08:00
Black fixer should include --pyi for files with .pyi extension (#2705)
* black fixer should include --pyi for files with .pyi extension
This commit is contained in:
@@ -29,6 +29,10 @@ function! ale#fixers#black#Fix(buffer) abort
|
|||||||
|
|
||||||
let l:options = ale#Var(a:buffer, 'python_black_options')
|
let l:options = ale#Var(a:buffer, 'python_black_options')
|
||||||
|
|
||||||
|
if expand('#' . a:buffer . ':e') is? 'pyi'
|
||||||
|
let l:options .= '--pyi'
|
||||||
|
endif
|
||||||
|
|
||||||
return {
|
return {
|
||||||
\ 'command': l:cd_string . ale#Escape(l:executable) . l:exec_args
|
\ 'command': l:cd_string . ale#Escape(l:executable) . l:exec_args
|
||||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||||
|
|||||||
@@ -36,6 +36,14 @@ Execute(The black callback should include options):
|
|||||||
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --some-option -' },
|
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --some-option -' },
|
||||||
\ ale#fixers#black#Fix(bufnr(''))
|
\ ale#fixers#black#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The black callback should include --pyi for .pyi files):
|
||||||
|
let g:ale_python_black_change_directory = 0
|
||||||
|
|
||||||
|
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.pyi')
|
||||||
|
AssertEqual
|
||||||
|
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --pyi -' },
|
||||||
|
\ ale#fixers#black#Fix(bufnr(''))
|
||||||
|
|
||||||
Execute(Pipenv is detected when python_black_auto_pipenv is set):
|
Execute(Pipenv is detected when python_black_auto_pipenv is set):
|
||||||
let g:ale_python_black_auto_pipenv = 1
|
let g:ale_python_black_auto_pipenv = 1
|
||||||
let g:ale_python_black_change_directory = 0
|
let g:ale_python_black_change_directory = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user