mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 14:59:27 +00:00
fix(types): Buffer type hint (#5662)
* Fix Buffer type hint collections.abc.Buffer was added in Python 3.12. The previous behaviour should be used prior to this version. * Fix comment * Fix indentation * style: pre-commit fixes * Fix test * Add missing import * style: pre-commit fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import ctypes
|
||||
import io
|
||||
import struct
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -228,10 +229,11 @@ def test_ctypes_from_buffer():
|
||||
|
||||
|
||||
def test_buffer_docstring():
|
||||
assert (
|
||||
m.get_buffer_info.__doc__.strip()
|
||||
== "get_buffer_info(arg0: collections.abc.Buffer) -> pybind11_tests.buffers.buffer_info"
|
||||
)
|
||||
if sys.version_info >= (3, 12):
|
||||
docstring = "get_buffer_info(arg0: collections.abc.Buffer) -> pybind11_tests.buffers.buffer_info"
|
||||
else:
|
||||
docstring = "get_buffer_info(arg0: typing_extensions.Buffer) -> pybind11_tests.buffers.buffer_info"
|
||||
assert m.get_buffer_info.__doc__.strip() == docstring
|
||||
|
||||
|
||||
def test_buffer_exception():
|
||||
|
||||
Reference in New Issue
Block a user