basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

don't show imports when syntax error

Open KotlinIsland opened this issue 1 year ago • 4 comments

1.pri

this should not show import errors.

it should show postfix snippits, when they are supported

KotlinIsland avatar Jul 26 '24 00:07 KotlinIsland

i dont get the point of writing a syntax error and expecting autocomplete to convert it to what you should've written to begin with. just write pri on its own, hit tab on the autocomplete suggestion, then type 1 (this is 1 less character anyway). print isn't a method of int so i don't get why a user would write it that way. such a feature sounds like unnecessary complexity that gets users into the habit of writing code in an invalid way for no reason.

so i think the fix for this is to just not show the autocomplete suggestions at all in this case

DetachHead avatar Jul 26 '24 00:07 DetachHead

there is a convenient feature in pycharm called postfix completions, it lets you create templates that are activated by typing a dot after an expression EXPR.<completion name> and picking from the intellisense popup. it's very convenient:

a = []

a.en  # pick "enum" from the completions, this completion only works on iterables

->

a = []

for i, e in enumerate(a):  

KotlinIsland avatar Jul 26 '24 01:07 KotlinIsland

just write pri on its own, hit tab on the autocomplete suggestion, then type 1 (this is 1 less character anyway).

this specific completion is useful when you have code that's already written, then it's much less keystrokes to add a print. if i'm writing a line from scratch i would start it with print, not use a postfix

print isn't a method of int

this feature is similar to extension functions, they are scoped to specific types, this particular one is scoped to object

habit of writing code in an invalid way for no reason.

it's a feature for template completions, it saves a lot of handwriting. you type the completion name into the editor because it's faster than summoning forth a dialogue and typing it into that

KotlinIsland avatar Jul 26 '24 01:07 KotlinIsland

i guess this discussion can be continued in #458. as i said there although i don't really use snippets i don't have a problem with supporting them. as for this issue, in the mean time it should just not show any suggestions at all

DetachHead avatar Jul 27 '24 03:07 DetachHead