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

Bring back type annotation support of dunder methods in stub generator (fix #12717) #12828

Conversation

bluenote10
Copy link
Contributor

Have you read the Contributing Guidelines?

Yes.

Description

Fixes #12717 by making the "ignoring of dunder methods" more specific. As explained, __members__ is part of the official enum API and thus an essential type annotation to have. The complete removal of annotations of dunder methods in #12524 causes a big regression for pybind11 code bases involving lots of enums.

Test Plan

I didn't had time to add a specific test case preventing fully reverting #12524, but this modification should keep its behavior while fixing #12717.

@github-actions

This comment has been minimized.

@JelleZijlstra
Copy link
Member

Could you take a look at the failing tests?

@JelleZijlstra JelleZijlstra self-assigned this May 21, 2022
@bluenote10
Copy link
Contributor Author

It basically what @shubz1998 already mentioned in comment #12524 (comment):

We can also choose to not ignore dunder methods in generate_c_property_stub, in that case, we would have to update the below two tests since these will now generate stubs for dunder attributes

As an alternative we can also just re-use the is_skipped_attribute function to filter out dunder properties. Then we would consistently avoid generating:

image

which seems to make sense.

With this change, the tests should need no adaptation, and relevant dunder methods like __member__ should still be generated.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit f19a711 into python:master May 21, 2022
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.

Regression: Stub generator no longer generates __members__ for enum class
2 participants