-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Extend allowed dunder methods (PLW3201) #9716
Comments
Current list of known dunder methods: ruff/crates/ruff_linter/src/rules/pylint/helpers.rs Lines 205 to 337 in 541aef4
|
I feel like the
But having said that, I see we already include some third-party dunders in our list -- the
I have no objection to adding exemptions for these, since they're all ~public (some of them have less-than-ideal docs, but that's probably a CPython issue really). But I think they should only be allowed as properties -- defining them as methods would likely be a mistake. I see we treat methods decorated with |
Opened as a followup to discussion at #9706.
Kudos to @AlexWaygood for scraping all dunders from CPython:
In my opinion, it would be useful to add
__wrapped__
,__isabstractmethod__
and__signature__
to the list in case one wants to define those as properties (it's a niche use case though), especially since__class__
is in the list.__rich_*__
should definitely be supported, a lot of critical tools & libraries have integrations with rich (including pip or Pydantic).Some external libraries also implement their own dunders, such as pyarrow's
__arrow_array__
used in pandas or__attrs_post_init__
from attrs (among others) which I can see being supported now.How should we research and collect them? What criteria should we have?
The text was updated successfully, but these errors were encountered: