Skip to content

TypeError in definitions when handling line and column values #623

Description

@liaochangmei

I’m encountering a TypeError in the definition.py file when the plugin attempts to calculate line - 1 for the start position in the definition response. The error occurs because d.line is None, even though I’ve verified that the line and column values passed to pylsp are valid integers.

Error Details:
Error from pylsp: File "/usr/local/python39/lib/python3.9/site-packages/pylsp/plugins/definition.py", line 69, in
Error from pylsp: "start": {"line": d.line - 1, "character": d.column},
Error from pylsp: TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

Steps to Reproduce:
Send a textDocument/definition request with valid line and column values (verified as integers),like this:
b'Content-Length: 202\r\n\r\n{"jsonrpc": "2.0", "method": "textDocument/definition", "params": {"textDocument": {"uri": "file:///home/dev/server/udc_tools_flask/public_project/wsj11.py", "position": {"line": 23, "character": 18}}}}'
The server processes the request but encounters the error when constructing the response.

Thank you for your attention to this issue. Let me know if you need further details or debugging information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions