-
Notifications
You must be signed in to change notification settings - Fork 227
Description
Using flake8 with flake8-annotations plugin results in an invalid character position -1 in this simple snippet:
def myfun():
# erg
passThe pylsp server returns the following response:
[jsonrpc] e[22:41:37.731] <-- textDocument/publishDiagnostics
{
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
"uri": "file:////tmp/hu.py",
"diagnostics": [
{
"source": "flake8",
"code": "ANN201",
"range": {
"start": {
"line": 1,
"character": -1
},
"end": {
"line": 1,
"character": 10
}
},
"message": "ANN201 Missing return type annotation for public function",
"severity": 2
}
],
"version": 126
}
}As you can see, the ANN201 error starts at character -1. I assume this is invalid, because my client (eglot in Emacs) complains about it.
The issue seems connected to the comment line. An empty line also has the same issue. A docstring line does not.
The python-lsp-server config that I'm using at Emacs:
;; (...)
'((:pylsp . (:plugins (:mccabe (:enabled :json-false)
:pycodestyle (:enabled :json-false)
:pyflakes (:enabled :json-false)
:flake8 (:enabled t)
)
:configurationSources ["flake8"])))As said, flake8 and flake8-annotations are being used.
Using flake8 directly from CLI doesn't show anything weird, only ANN201 is reported.
> flake8 hu.py
hu.py:2:0: ANN201 Missing return type annotation for public functionVersions:
python-lsp-jsonrpc 1.1.2
python-lsp-server 1.12.0
flake8 7.1.1
flake8-annotations 3.1.1
Honestly I don't know where the source of the problem is, if the LSP server or flake8-annotations or somewhere else.