I came across a peculiar scenario at https://shinylive.io where the code edits made after accepting a LSP completion item is incorrect.
import random
import typing as t
myfunc: t.Callable[[], t.Literal['yes', 'no']] = lambda: random.choice(['yes', 'no'])
if myfunc() == ' # autocomplete is triggered here
Suggestions from LSP (as expected) -

Code after accepting the suggestion
