diff --git a/pylsp/plugins/pyflakes_lint.py b/pylsp/plugins/pyflakes_lint.py index 404f045c..28a37b3f 100644 --- a/pylsp/plugins/pyflakes_lint.py +++ b/pylsp/plugins/pyflakes_lint.py @@ -52,6 +52,9 @@ def syntaxError(self, _filename, msg, lineno, offset, text): # We've seen that lineno and offset can sometimes be None lineno = lineno or 1 offset = offset or 0 + # could be None if the error is due to an invalid encoding + # see e.g. https://github.com/python-lsp/python-lsp-server/issues/429 + text = text or "" err_range = { "start": {"line": lineno - 1, "character": offset},