Skip to content

pyslp_completions emits an invalid kind key with objects named Kind #472

Open

Description

@kstrauser

I'm using the current HEAD 728929c commit.

I have a code snippet:

#!/usr/bin/env python
from enum import StrEnum, auto

class Kind(StrEnum):
    something = auto()

def foo():
    a = {'some_key': Kind.something}

If I go to the end of the file, with pyslp -vvv, and type a['some_key'], I get a log message:

2023-10-26 11:32:06,833 PDT - DEBUG - pylsp.config.config -   finish pylsp_completions --> [[{'label': "'some_key", 'kind': None, 'sortText': "a'some_key", 'insertText': "'some_key", 'data': {'doc_uri': 'file:///private/tmp/repro.py'}}]] [hook]

Note that 'kind': None is invalid, per https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItemKind

If I rename the Kind class to something else, like Foo, then the log message looks like:

2023-10-26 11:34:56,793 PDT - DEBUG - pylsp.config.config -   finish pylsp_completions --> [[{'label': 'value', 'kind': 18, 'sortText': 'avalue', 'insertText': 'value', 'data': {'doc_uri': 'file:///private/tmp/repro.py'}}]] [hook]

with 'kind': 18, which is a legitimate value.

It appears as if the name Kind from the code is getting injected into the dictionary and overwriting the kind key.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions