python / python/cpython

help(typing.Annotated[foo, ...]) should return the doc for _AnnotatedAlias

Open
#97,796 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-typing type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Split off from #89543; the module issue is fixed but other issues raised in the comments still remain valid. For the following code

>>> from typing import Annotated, Callable
>>> t = Annotated[int | str, "Some metadata"]
>>> help(t)
Help on _AnnotatedAlias in module typing:

Annotated = int | str

We should arguably ignore the instance and return the same thing as help(typing._AnnotatedAlias), analogously to help(int | str) returning the docs for Union

Linked PRs
  • gh-97813

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 with the reproduced help(typing.Annotated[...]) behavior and compare it with help(typing._AnnotatedAlias) and help(int | str). The change is done when the Annotated instance returns the _AnnotatedAlias documentation rather than the current instance-specific output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.