Skip to content

Commit 4bfd36a

Browse files
committed
Lint if config changes
1 parent 563575b commit 4bfd36a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pyls/python_ls.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
LINT_DEBOUNCE_S = 0.5 # 500 ms
1818
PARENT_PROCESS_WATCH_INTERVAL = 10 # 10 s
1919
MAX_WORKERS = 64
20+
# We also watch for changes in config files
21+
PYTHON_FILE_EXTENSIONS = ('.py', '.pyi', 'pycodestyle.cfg', 'setup.cfg', 'tox.ini', '.flake8')
2022

2123

2224
class _StreamHandlerWrapper(socketserver.StreamRequestHandler, object):
@@ -295,10 +297,12 @@ def m_workspace__did_change_configuration(self, settings=None):
295297
self.lint(doc_uri)
296298

297299
def m_workspace__did_change_watched_files(self, changes=None, **_kwargs):
298-
changed_py_files = set(d['uri'] for d in changes if d['uri'].endswith(('.py', '.pyi')))
299-
# Only externally changed python files may result in changed diagnostics
300+
changed_py_files = set(d['uri'] for d in changes if d['uri'].endswith(PYTHON_FILE_EXTENSIONS))
301+
# Only externally changed python files and lint configs may result in changed diagnostics.
300302
if not changed_py_files:
301303
return
304+
# TODO: We currently don't cache settings therefor we can just lint again.
305+
# Here would be the right point to update the settings after a change to config files.
302306
for doc_uri in self.workspace.documents:
303307
# Changes in doc_uri are already handled by m_text_document__did_save
304308
if doc_uri not in changed_py_files:

0 commit comments

Comments
 (0)