microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.72k stars 769 forks source link

Better string completions #5915

Open InSyncWithFoo opened 6 months ago

InSyncWithFoo commented 6 months ago

Setup code:

from typing import Literal, TypedDict

class D(TypedDict):
    first: int
    second: str

v: Literal['first', 'second']
d: D

Currently, Pyright offers 'first' and 'second' at all of the following caret positions:

v = '|'
v = '''|'''
d = {'|': ''}
d = {'''|''': ''}

For the second and fourth cases, this leads to the caret eventually being placed in the middle of the trailing quote sequence, a most unfortunate position:

v = '''first'|''
d = {'''second'|'': ''}

Pyright should take the quote sequence into account and offer '''first'''/'''second''' as applicable:

v = 'first'|
v = '''first'''|
d = {'second'|: ''}
d = {'''second'''|: ''}
erictraut commented 6 months ago

Since this is a language server feature request and not related to core type checking, I'll leave it to the pylance team to decide whether they want to implement it.

Could someone from the pylance team please transfer this from pyright to pylance-release and triage and prioritize it as you see fit? Thanks! @rchiodo, @debonte