Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pyls/plugins/flake8_lint.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019 Palantir Technologies, Inc.
"""Linter pluging for flake8"""
import logging
from os import path
import os.path
import re
from subprocess import Popen, PIPE
from pyls import hookimpl, lsp
Expand Down Expand Up @@ -34,8 +34,8 @@ def pyls_lint(workspace, document):

# flake takes only absolute path to the config. So we should check and
# convert if necessary
if opts.get('config') and not path.isabs(opts.get('config')):
opts['config'] = path.abspath(path.expanduser(path.expandvars(
if opts.get('config') and not os.path.isabs(opts.get('config')):
opts['config'] = os.path.abspath(os.path.expanduser(os.path.expandvars(
opts.get('config')
)))
log.debug("using flake8 with config: %s", opts['config'])
Expand All @@ -56,6 +56,12 @@ def run_flake8(flake8_executable, args, document):
args = [(i if not i.startswith('--ignore=') else FIX_IGNORES_RE.sub('', i))
for i in args if i is not None]

# if executable looks like a path resolve it
if not os.path.isfile(flake8_executable) and os.sep in flake8_executable:
flake8_executable = os.path.abspath(
os.path.expanduser(os.path.expandvars(flake8_executable))
)

log.debug("Calling %s with args: '%s'", flake8_executable, args)
try:
cmd = [flake8_executable]
Expand Down