Repository navigation
Further improve docs for typing.Annotated - #105498
Conversation
typing.Annotatedtyping.Annotated
|
@erlend-aasland, it would be great to get some non-typing-expert eyes on this, if you have the time to take a look :) |
|
@AlexWaygood, I'll have a look! |
|
|
||
| For example: | ||
| where ``T1``, ``T2``, etc. are :class:`TypeVars <TypeVar>`. This would be | ||
| invalid: only one type should be passed to Annotated. |
There was a problem hiding this comment.
This looks misindented, as it's indented by one space less than the next paragraph.
There was a problem hiding this comment.
Hmm, it seems the bulleted list is inconsistent about whether there should be one or two spaces after a bullet point.
There was a problem hiding this comment.
I decided it was probably the next paragraph that had the wrong indentation -- does it look better after 2cd15fe?
JelleZijlstra
left a comment
There was a problem hiding this comment.
Looks good, one formatting nit
erlend-aasland
left a comment
There was a problem hiding this comment.
The new text is definitely easier to read for a typing newbie like me. Thanks!
Great to hear! |
|
Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
|
GH-105503 is a backport of this pull request to the 3.12 branch. |
(cherry picked from commit d213c29) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
GH-105504 is a backport of this pull request to the 3.11 branch. |
(cherry picked from commit d213c29) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
A significant followup PR to #105365.
Annotatedisn't a type, you can't use it directly as a type annotation.__metadata__attribute at runtime, rather than "annotations" or "types", which were being used before... attribute::directive for the__metadata__attribute. It's not being rendered correctly -- Sphinx thinks it's a module attribute rather than an attribute ofAnnotated[X, "foo"]. Current rendering. This is because we don't mark upAnnotatedas a class in the docs. (It actually is a class at runtime, at the moment, but that's an implementation detail. I don't think we should mark it as a class in the docs.)Annotatedtype cannot be made generic over aTypeVarTuple.get_type_hintsis to strip metadata fromAnnotatedannotations, and add an example... seealso::box.Annotated, which was incorrect: you subscriptAnnotated, you don't call it.📚 Documentation preview 📚: https://cpython-previews--105498.org.readthedocs.build/