summaryrefslogtreecommitdiff
path: root/ale_linters/python
diff options
context:
space:
mode:
authorKevin Locke <kevin@kevinlocke.name>2019-02-17 10:12:24 -0700
committerKevin Locke <kevin@kevinlocke.name>2019-02-17 10:40:50 -0700
commit3300b1aca7f53a8468547194d074e1cb5bc55e15 (patch)
treeb91fa66db7c68e172c26ea6739a02ddb1786af2a /ale_linters/python
parentc3d4e0983b4b08e61692cdd88990a79525a78707 (diff)
downloadale-3300b1aca7f53a8468547194d074e1cb5bc55e15.zip
python/pylint: Change directory to project root
Pylint only [checks for pylintrc] (and .pylintrc) files in the packages aboves its current directory before falling back to user and global pylintrc. For projects with a src dir, running pylint from the directory containing the file will not use the project pylintrc. Adopt the convention used by many other Python linters of running from the project root, which solves this issue. Add pylintrc and .pylintrc to FindProjectRoot. Update docs. [checks for pylintrc]: https://github.com/PyCQA/pylint/blob/pylint-2.2.2/pylint/config.py#L106 Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Diffstat (limited to 'ale_linters/python')
-rw-r--r--ale_linters/python/pylint.vim14
1 files changed, 11 insertions, 3 deletions
diff --git a/ale_linters/python/pylint.vim b/ale_linters/python/pylint.vim
index da845b7a..f0f79cd7 100644
--- a/ale_linters/python/pylint.vim
+++ b/ale_linters/python/pylint.vim
@@ -17,9 +17,17 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort
endfunction
function! ale_linters#python#pylint#GetCommand(buffer) abort
- let l:cd_string = ale#Var(a:buffer, 'python_pylint_change_directory')
- \ ? ale#path#BufferCdString(a:buffer)
- \ : ''
+ let l:cd_string = ''
+
+ if ale#Var(a:buffer, 'python_pylint_change_directory')
+ " pylint only checks for pylintrc in the packages above its current
+ " directory before falling back to user and global pylintrc.
+ " Run from project root, if found, otherwise buffer dir.
+ let l:project_root = ale#python#FindProjectRoot(a:buffer)
+ let l:cd_string = l:project_root isnot# ''
+ \ ? ale#path#CdString(l:project_root)
+ \ : ale#path#BufferCdString(a:buffer)
+ endif
let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer)