Skip to content

Commit

Permalink
[pylint] Add buffer methods to bad-dunder-method-name (PLW3201)…
Browse files Browse the repository at this point in the history
… exclusions (#8190)

## Summary

Python 3.12 added the `__buffer__()`/`__release_buffer_()` special
methods, which are incorrectly flagged as invalid dunder methods by
`PLW3201`.

## Test Plan

Added definitions to the test suite, and confirmed they failed without
the fix and are ignored after the fix was done.
  • Loading branch information
TeamSpen210 authored Oct 25, 2023
1 parent 6f31e9c commit 8304c41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ def __private_method(self):
def __doc__(self):
return "Docstring"

# Added in Python 3.12
def __buffer__(self):
return memoryview(b'')

def __release_buffer__(self, buf):
pass

# Allow dunder methods recommended by attrs.
def __attrs_post_init__(self):
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ fn is_known_dunder_method(method: &str) -> bool {
| "__attrs_pre_init__"
| "__await__"
| "__bool__"
| "__buffer__"
| "__bytes__"
| "__call__"
| "__ceil__"
Expand Down Expand Up @@ -166,6 +167,7 @@ fn is_known_dunder_method(method: &str) -> bool {
| "__rdivmod__"
| "__reduce__"
| "__reduce_ex__"
| "__release_buffer__"
| "__repr__"
| "__reversed__"
| "__rfloordiv__"
Expand Down

0 comments on commit 8304c41

Please sign in to comment.