Skip to content

gh-97796: Special-case typing._AnnotatedAlias in pydoc.#97813

Closed
martindemello wants to merge 4 commits into
python:mainfrom
martindemello:annotated
Closed

gh-97796: Special-case typing._AnnotatedAlias in pydoc.#97813
martindemello wants to merge 4 commits into
python:mainfrom
martindemello:annotated

Conversation

@martindemello

@martindemello martindemello commented Oct 3, 2022

Copy link
Copy Markdown
Contributor

In general, pydoc.render_doc follows the __origin__ property to render the doc for the pointed-to object, but in the case of typing.Annotated[typ, ...] we want the docs for _AnnotatedAlias, not typ.

In general, pydoc.render_doc follows the `__origin__` property to render
the doc for the pointed-to object, but in the case of
`typing.Annotated[typ, ...]` we want the docs for `_AnnotatedAlias`, not
`typ`.

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Can you please show how new help looks like for Annotated[str, 'meta'] and Annotated[str | int, 'meta']?

Comment thread Lib/pydoc.py
Comment thread Lib/pydoc.py
@martindemello

Copy link
Copy Markdown
Contributor Author

help for Annotated[...] is just the help for _AnnotatedAlias without reference to the contents. I took my cue from the help for UnionType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants