Skip to content

Commit 2dc19c2

Browse files
authored
Remove pycodestyle plugin's dependency on autopep8 (#813)
1 parent 4217971 commit 2dc19c2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pyls/plugins/pycodestyle_lint.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# Copyright 2017 Palantir Technologies, Inc.
22
import logging
33
import pycodestyle
4-
from autopep8 import continued_indentation as autopep8_c_i
54
from pyls import hookimpl, lsp
65

7-
# Check if autopep8's continued_indentation implementation
8-
# is overriding pycodestyle's and if so, re-register
9-
# the check using pycodestyle's implementation as expected
10-
if autopep8_c_i in pycodestyle._checks['logical_line']:
11-
del pycodestyle._checks['logical_line'][autopep8_c_i]
12-
pycodestyle.register_check(pycodestyle.continued_indentation)
6+
try:
7+
from autopep8 import continued_indentation as autopep8_c_i
8+
except ImportError:
9+
pass
10+
else:
11+
# Check if autopep8's continued_indentation implementation
12+
# is overriding pycodestyle's and if so, re-register
13+
# the check using pycodestyle's implementation as expected
14+
if autopep8_c_i in pycodestyle._checks['logical_line']:
15+
del pycodestyle._checks['logical_line'][autopep8_c_i]
16+
pycodestyle.register_check(pycodestyle.continued_indentation)
1317

1418
log = logging.getLogger(__name__)
1519

0 commit comments

Comments
 (0)