Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Completion for values created with annotated assign could use the value itself #15035

@krassowski

Description

@krassowski

Currently we extract the type from the AnnAssign node e.g. from:

x: str | int = 5

we would extract str | int. In such case the type annotation has more information than the value (when it comes to tab completion).

However, sometimes the value will have more information. Consider:

y: dict = {'long_key': 1, 'longer_key': 2}

For y completions the dict annotation is redundant with respect to the value and the value contains more information as it will allow us to complete the keys of the dictionary as in:

y["<tab>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions