Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Tpt
Copy link
Contributor

@Tpt Tpt commented Apr 23, 2025

Implementation notes:

  • I am not sure about the decorators for class attributes. I am using the @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.
  • When we introspect the class definition (#[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.
  • We are generating a / after the self or cls argument even (if they are not other positional-only arguments). It's not nice but syntactically correct.
  • I have not tested all magic methods

@Tpt Tpt added the CI-skip-changelog Skip checking changelog entry label Apr 23, 2025
@bschoenmaeckers
Copy link
Member

I am not sure about the decorators for class attributes. I am using the @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.

Should we run a type-checker in the CI to verify the generated types?

@Tpt
Copy link
Contributor Author

Tpt commented Apr 23, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-skip-changelog Skip checking changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants