Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypedDict : Suggestion issues #1981

Open
yoann9344 opened this issue Feb 4, 2024 · 2 comments
Open

TypedDict : Suggestion issues #1981

yoann9344 opened this issue Feb 4, 2024 · 2 comments
Labels

Comments

@yoann9344
Copy link

yoann9344 commented Feb 4, 2024

I'm making tests about python typing's state of art, and I noticed few issues with TypedDict.
I will use -> for start completion and _ for next cursor position.

import typing as t


class Table(t.TypedDict):
    a: int
    b: str


def create(v: Table) -> Table:
    v["a"] += 1  # v["->"] Suggestion and completion are correct 
    v["a"] += 1  # v["->"] Suggestion contains 2 times the row : « "a" string "a" »
    v["a"] += 1  # v["->"] Suggestion contains 3 times the row : « "a" string "a" »
    # and so on, and it is the same for b, each assignment add a suggestion
    print(v["a"])  # print(v["->"] Suggestion contains « "a?!?jedi=1, " »
    # it seems to be caused by a previous assignment
    return v


create()  # create(->) Global suggestion ; should complete with `{_}` or `dict(_)` ?
create({})  # create({->}) Global suggestion :
# should suggest « "a" string "a" » or « "b" string "b" » ?
# should complete with `"a": _` or  `"b": ` ?
# I guess TypedDict's total should not change anything unless we add the coma :
# Total=True : should complete with `"a": _,` or  `"b": "_",` ?
# Total=False : should complete with `"a": _` or  `"b": "_"` ?
create({"a": 5,})
# create({"a": 5,->}) should complete with `b": "_"` (last attribute so without coma)

I'm using jedi through vim-jedi. And I don't think I'm able to fix the issues (at least in a descent amount of time).

@davidhalter
Copy link
Owner

davidhalter commented Feb 4, 2024

What do you mean with completion vs. suggestion?

print(v["->"] Suggestion contains « "a?!?jedi=1, " »

I'm pretty sure this is related to call signatures. You can either change the setting there to show it differently or turn it off. This sometimes bugs out, but it's definitely not a Jedi bug.

I'm using jedi through vim-jedi. And I don't think I'm able to fix the issues (at least in a descent amount of time).

Yes, these are not easy issues. Some of them however are doable, like the create(->) Global suggestion ; should complete with {}ordict() ?

@yoann9344
Copy link
Author

What do you mean with completion vs. suggestion?

print(v["->"] Suggestion contains « "a?!?jedi=1, " »

It is the propositions for completions, and completions are results when accept proposition :
1981_suggestion_duplicated
1981_suggestion_wrong

Indeed, :let g:jedi#show_call_signatures=2 solved the "a?!?jedi=1, " suggestion but I still have duplicated suggestions for "a" for each previous assignment.

Yes, these are not easy issues. Some of them however are doable, like the create(->) Global suggestion ; should complete with {}ordict() ?

I'll try to start with it !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants