Skip to content
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

Enums with methods #86

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Conversation

yamoling
Copy link

Hello,

I was lacking the possibility of having methods and properties to enums, so here is a proposal that adds this functionality. Additionally, the documentation of documented members is now also present in the ".pyi" output.

Here is a summary of the few changes:

  • MemberInfo and MemberDef have a doc and a is_property attribute.
  • StubInfoBuilder::add_methods adds member properties for enums (but not for classes, the behaviour remains the same)
  • StubInfoBuilder::add_methods now looks for struct_id in module.enum_ in addition to module.class.

I would really like these changes to make it to a new release, please let me know if additional changes are required to comply with the current code base.

@yamoling
Copy link
Author

Hello @termoshtt,

Is there any progress on this ? Do you need any input from my side ?
I would really like to merge this feature such that my projects can depend on this repo instead of my current fork.

Here is an example of what the generated pyi looks like in one of my projects (for the Action enum class).

Best regards,
Yannick

@yamoling
Copy link
Author

Hello @termoshtt,

I've checked the workflows and addressed all of them except the one on semantic versioning.
Indeed, my changes are breaking in the sense that I've added attributes to the EnumDef struct (i.e. methods and members) and due to the fact that the EnumDef struct is publicly constructible (public attributes). Therefore, previous constructions of this structure are made invalid.

That being said, I do not believe that this change requires a major version bump, as there was a single place in the library where the EnumDef structure is build and this has been adapted accordingly.

Please let me know your opinion on this.

N.B.: There is a similar discussion for is_property and doc for MemberDef to which my arguments also apply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant