Skip to content

Commit 0c922ce

Browse files
Recognize buffer protocol special methods (#19581)
The special methods `__buffer__` and `__release_buffer__` were [added in Python 3.12](https://docs.python.org/3/reference/datamodel.html#emulating-buffer-types). Both are [implemented with slot descriptors](https://docs.python.org/3/c-api/typeobj.html#:~:text=__buffer__), and so should be treated as being implicitly positional-only like other slot special methods.
1 parent 555edf3 commit 0c922ce

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mypy/sharedparse.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"__call__",
1111
"__complex__",
1212
"__contains__",
13+
"__buffer__",
1314
"__del__",
1415
"__delattr__",
1516
"__delitem__",
@@ -31,6 +32,7 @@
3132
"__new__",
3233
"__oct__",
3334
"__pos__",
35+
"__release_buffer__",
3436
"__repr__",
3537
"__reversed__",
3638
"__setattr__",

0 commit comments

Comments
 (0)