diff --git a/pyls/plugins/pycodestyle_lint.py b/pyls/plugins/pycodestyle_lint.py index c12f9f48..490b65d3 100644 --- a/pyls/plugins/pycodestyle_lint.py +++ b/pyls/plugins/pycodestyle_lint.py @@ -1,15 +1,19 @@ # Copyright 2017 Palantir Technologies, Inc. import logging import pycodestyle -from autopep8 import continued_indentation as autopep8_c_i from pyls import hookimpl, lsp -# Check if autopep8's continued_indentation implementation -# is overriding pycodestyle's and if so, re-register -# the check using pycodestyle's implementation as expected -if autopep8_c_i in pycodestyle._checks['logical_line']: - del pycodestyle._checks['logical_line'][autopep8_c_i] - pycodestyle.register_check(pycodestyle.continued_indentation) +try: + from autopep8 import continued_indentation as autopep8_c_i +except ImportError: + pass +else: + # Check if autopep8's continued_indentation implementation + # is overriding pycodestyle's and if so, re-register + # the check using pycodestyle's implementation as expected + if autopep8_c_i in pycodestyle._checks['logical_line']: + del pycodestyle._checks['logical_line'][autopep8_c_i] + pycodestyle.register_check(pycodestyle.continued_indentation) log = logging.getLogger(__name__)