basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

Support `TypedDict` keys showing their docs on hover

Open Gobot1234 opened this issue 5 months ago • 2 comments

Description

from typing import TypedDict, Unpack

class Person(TypedDict):
    name: str
    """The name of the person."""
    age: int
    """The age of the person."""

def foo(**p: Unpack[Person]):
    print(p['age'])

foo(name="John", age=30)

Hovering over name would show "The name of the person." on the last line

Gobot1234 avatar Sep 30 '25 09:09 Gobot1234

it doesn't just happen with Unpack

Code sample in basedpyright playground

from typing import TypedDict

class Person(TypedDict):
    name: str
    """The name of the person."""
    age: int
    """The age of the person."""

person = Person(name="John", age=30)

person['age'] # no docstring on hover

DetachHead avatar Oct 01 '25 10:10 DetachHead

looks like my example will be addressed in #1533

DetachHead avatar Oct 21 '25 09:10 DetachHead

another thing: any plan of something like "go to definitions" working on literal key (subscript)?

NCBM avatar Dec 17 '25 14:12 NCBM

could you provide an example? go to definition on TypedDict keys works for me now

DetachHead avatar Dec 20 '25 04:12 DetachHead

could you provide an example? go to definition on TypedDict keys works for me now

@DetachHead oops sorry. I'm recently working on a project that uses pylance which does not have the capability. I just know basedpyright has already supported it.

NCBM avatar Dec 20 '25 04:12 NCBM