1
1
# Copyright 2019 Palantir Technologies, Inc.
2
2
"""Linter pluging for flake8"""
3
3
import logging
4
- from os import path
4
+ import os . path
5
5
import re
6
6
from subprocess import Popen , PIPE
7
7
from pyls import hookimpl , lsp
@@ -34,8 +34,8 @@ def pyls_lint(workspace, document):
34
34
35
35
# flake takes only absolute path to the config. So we should check and
36
36
# convert if necessary
37
- if opts .get ('config' ) and not path .isabs (opts .get ('config' )):
38
- opts ['config' ] = path .abspath (path .expanduser (path .expandvars (
37
+ if opts .get ('config' ) and not os . path .isabs (opts .get ('config' )):
38
+ opts ['config' ] = os . path .abspath (os . path .expanduser (os . path .expandvars (
39
39
opts .get ('config' )
40
40
)))
41
41
log .debug ("using flake8 with config: %s" , opts ['config' ])
@@ -56,6 +56,12 @@ def run_flake8(flake8_executable, args, document):
56
56
args = [(i if not i .startswith ('--ignore=' ) else FIX_IGNORES_RE .sub ('' , i ))
57
57
for i in args if i is not None ]
58
58
59
+ # if executable looks like a path resolve it
60
+ if not os .path .isfile (flake8_executable ) and os .sep in flake8_executable :
61
+ flake8_executable = os .path .abspath (
62
+ os .path .expanduser (os .path .expandvars (flake8_executable ))
63
+ )
64
+
59
65
log .debug ("Calling %s with args: '%s'" , flake8_executable , args )
60
66
try :
61
67
cmd = [flake8_executable ]
0 commit comments