Introspection: Adds basic input type annotations#5089
Introspection: Adds basic input type annotations#5089davidhewitt merged 10 commits intoPyO3:mainfrom
Conversation
9367241 to
e3546aa
Compare
davidhewitt
left a comment
There was a problem hiding this comment.
Sorry for the slow-ish review by me. I guess we will miss the 0.25 release for this (my bad).
Overall looks great, with just a few suggestions. 👍
|
Thank you for the review.
There is still a bunch of follow ups to get something working properly so it's definitely not a big deal. |
davidhewitt
left a comment
There was a problem hiding this comment.
Thanks, given all the comments I think this is good to merge (and I guess I can rebase the 0.25 branch to include this after all 😂)
Amazing!
I would feel better to have it in 0.26 to get time to do more testing, add more types across the codebase, deprecate the |
|
@Tpt seems like there was a conflict introduced in the merge queue for this one? |
|
@abrisco Yes! Rebasing this MR encovered some edge cases I have not considered ( |
|
Rebase done. CI semverchecks is failing because this MR introduces a new associated constant to traits The relevant bit to review 42c0cc6 |
|
@davidhewitt This MR would love a second review after the rebases. The relevant additional commit is 42c0cc6 |
davidhewitt
left a comment
There was a problem hiding this comment.
Thanks, overall this looks good to me with one closing thought.
|
Thank you for the review! |
Implementation notes:
constcode (hence without macros), making advanced structs not possible. Moreover, because it is not possible to use generic types inconstcode, we won't be able to generatelist[int]types at the moment but onlylist. This limitation will be lifted ifmin_generic_const_argsunstable feature lands at some point. However it should be possible to write a macro that validates the types and wrap them in someTypeAnnotation(&'static str)struct. Note that because our macros are aware of theOption<T>parameters annotations likeT | Noneare properly generated. We might expand that to other common containers likeVecorHashMap.#[pyclass]. We will get that for free after merging Implements basic method introspection #5087typing.Any. It might be cleaner to makeINPUT_TYPEanOption<&'static str>and useNoneas the default value to not set an annotation instead.