Introspection: Basic pyclass(extends) support#5331
Conversation
3f497da to
0a01104
Compare
src/impl_/pyclass.rs
Outdated
| type Initializer: PyObjectInit<Self>; | ||
| type PyClassMutability: PyClassMutability; | ||
| /// Fully qualified name of the base class including modules | ||
| const BASE_NAME: &'static str; |
There was a problem hiding this comment.
I have not gated this associated constants with the experimental-inspect feature because it's an internal trait often generated using macro_rules!.
I have not reused IntoPyObject::OUTPUT_TYPE because they might be different (typing.Any vs object...)
Happy to rename the constant to something better.
There was a problem hiding this comment.
Is this information suitable to get from PyTypeInfo (which has name + module) ?
There was a problem hiding this comment.
Maybe. I would need to fix the NAME for a lot of types. Currently it's setup by the macro to be the same as the Rust type name. So, for example, <PyDict as PyTypeInfo>::NAME == "PyDict" and not dict. Happy to do it if you want.
There was a problem hiding this comment.
Hmm, that's a good point. I think that's probably just a historical mistake, it also leads to a lot of sad error messages where we leak the PyDict name out to consumers downstream that probably don't need to know about PyO3.
I think doing that as a precursor PR might be desirable? I can try to do so later, perhaps?
There was a problem hiding this comment.
Indeed. Thanks! It will actually be also useful to generate some type stubs. I hope to be able to do it today, feel free to focus on something else.
There was a problem hiding this comment.
Solved nicely with the PyTypeInfo::TYPE_HINT associated constnat
ae15fd0 to
057bfa1
Compare
e5d3ee2 to
fb793af
Compare
src/impl_/pyclass.rs
Outdated
| type Initializer: PyObjectInit<Self>; | ||
| type PyClassMutability: PyClassMutability; | ||
| /// Fully qualified name of the base class including modules | ||
| const BASE_NAME: &'static str; |
There was a problem hiding this comment.
Is this information suitable to get from PyTypeInfo (which has name + module) ?
|
I think this is blocked on #5352 ? Setting to draft for the moment. |
7433225 to
cdca8cf
Compare
davidhewitt
left a comment
There was a problem hiding this comment.
Great to see this one come unstuck with TypeHint too 🎉
|
(also looks like it now has merge conflicts 🙈) |
|
Merge done |
Rely on
PyTypeInfo::TYPE_HINTand the same system as decorators