-
Notifications
You must be signed in to change notification settings - Fork 827
Implements basic method introspection #5087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Should we run a type-checker in the CI to verify the generated types? |
Yes, I am planning to do it when the implementation will be a bit more feature complete. At this stage it will complain a lot about missing elements in the stubs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me. Same as #5025, sorry I have been a bit slow here. I have just a few comments.
I am not sure about the decorators for class attributes.
I suspect the solution lies in either typing.Final
or typing.ClassVar
.
Let's send this to merge, I guess it might conflict with #5089 👍 I lost track, do we have an issue listing all the future refinements to the introspection code? It would be helpful to record all the pieces which might be improved, both soon and once Rust supports them. |
Thank you! Yes! It will conflict.
Not yet, I am going to do it |
Done: #5137 |
@davidhewitt I have pushed a fix for the CI in this branch. The branches are conflicting, what about merging this one first and the next one after I do a rebase? |
Implementation notes:
@classmethod\n@property
combination that got removed in Python 3.11. I don't see a clean way to do it in the next Python versions. It's possible that type checkers work properly with it, we will need to check but I would prefer to focus on other things for now.#[pyclass]
macro) we don't know the list of method so each method is generating its own introspection fragment with a"parent"
attribute that connects a method to its class. We will likely reuse it again for nested classes used in complex enums./
after theself
orcls
argument even (if they are not other positional-only arguments). It's not nice but syntactically correct.