sphinx-doc / sphinx-doc/sphinx

Inherited docstrings of TypeDict subclasses are missing

Open
#9,290 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

extensions:autodoc type:enhancement
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem? Please describe.
Currently sphinx understands to produce the documented annotations of a TypedDict subclass thanks to #7486

TypedDict subclasses can themselves be used as parent classes of another. A problem arises here in that sphinx will inline the members of the parent class, but doesn't include the docstrings for those members.

Describe the solution you'd like
I'd like the docstrings to carry over into the subclass

Describe alternatives you've considered
Copying all of the member annotations from the parent into the child, ie. not using inheritance at all.

Additional context
Contrived example:

class Food(TypedDict):
  """ this is a food """

  cook_name: str
  """ The name of the maker of the food """

  price: int
  """ How much the food cost """

class Tacos(Food):
  """ a taco variety of food """

  toppings: List[str]
  """ things that go on the taco"""

When generating autoclasses, the Tacos doc includes mention of the cook_name and price, but not their docstrings

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Sphinx's autoclass handling for TypedDict subclasses and how inherited annotations are currently inlined. Use the Food/Tacos example to verify the inherited cook_name and price docstrings are preserved, while the subclass's own documentation remains present.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.