From 179822f191483e802495545db4629a1a70d000ab Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sat, 25 Jul 2026 12:48:31 -0400 Subject: [PATCH] fix: include `complex` in std::complex input annotation The input annotation for `std::complex` omitted the builtin `complex` type, which typeshed only makes a `typing.SupportsComplex` on Python 3.11+. Assisted-by: ClaudeCode:claude-opus-5 Claude-Session: https://claude.ai/code/session_013JABmnjt9oAh29p1pytAB3 --- include/pybind11/complex.h | 2 +- tests/test_builtin_casters.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pybind11/complex.h b/include/pybind11/complex.h index 8f285d778f..5b84ed9bc9 100644 --- a/include/pybind11/complex.h +++ b/include/pybind11/complex.h @@ -88,7 +88,7 @@ class type_caster> { PYBIND11_TYPE_CASTER( std::complex, - io_name("typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex", + io_name("complex | typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex", "complex")); }; PYBIND11_NAMESPACE_END(detail) diff --git a/tests/test_builtin_casters.py b/tests/test_builtin_casters.py index b232c087e0..ee7333918c 100644 --- a/tests/test_builtin_casters.py +++ b/tests/test_builtin_casters.py @@ -565,7 +565,7 @@ def cant_convert(v): assert ( doc(convert) - == "complex_convert(arg0: typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex) -> complex" + == "complex_convert(arg0: complex | typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex) -> complex" ) assert doc(noconvert) == "complex_noconvert(arg0: complex) -> complex"