summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichyfish <richard.french.uk@googlemail.com>2019-08-18 15:45:15 +0100
committerw0rp <w0rp@users.noreply.github.com>2019-08-18 15:45:15 +0100
commitc4bdf165caf99706f439ecbe1a1d1865d53545a8 (patch)
tree546bd72eb8d8b4799294583773aa60f5c44bdb81
parentddb559b3bed31b81e8189c3caa8074842574f662 (diff)
downloadale-c4bdf165caf99706f439ecbe1a1d1865d53545a8.zip
Black fixer should include --pyi for files with .pyi extension (#2705)
* black fixer should include --pyi for files with .pyi extension
-rw-r--r--autoload/ale/fixers/black.vim4
-rw-r--r--test/command_callback/python_paths/with_virtualenv/subdir/foo/bar.pyi0
-rw-r--r--test/fixers/test_black_fixer_callback.vader8
3 files changed, 12 insertions, 0 deletions
diff --git a/autoload/ale/fixers/black.vim b/autoload/ale/fixers/black.vim
index 367b8d52..fba6c3b4 100644
--- a/autoload/ale/fixers/black.vim
+++ b/autoload/ale/fixers/black.vim
@@ -29,6 +29,10 @@ function! ale#fixers#black#Fix(buffer) abort
let l:options = ale#Var(a:buffer, 'python_black_options')
+ if expand('#' . a:buffer . ':e') is? 'pyi'
+ let l:options .= '--pyi'
+ endif
+
return {
\ 'command': l:cd_string . ale#Escape(l:executable) . l:exec_args
\ . (!empty(l:options) ? ' ' . l:options : '')
diff --git a/test/command_callback/python_paths/with_virtualenv/subdir/foo/bar.pyi b/test/command_callback/python_paths/with_virtualenv/subdir/foo/bar.pyi
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/python_paths/with_virtualenv/subdir/foo/bar.pyi
diff --git a/test/fixers/test_black_fixer_callback.vader b/test/fixers/test_black_fixer_callback.vader
index 25ad05db..75864479 100644
--- a/test/fixers/test_black_fixer_callback.vader
+++ b/test/fixers/test_black_fixer_callback.vader
@@ -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 -' },
\ 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):
let g:ale_python_black_auto_pipenv = 1
let g:ale_python_black_change_directory = 0