Skip to content

fix: include complex in std::complex input annotation#6113

Draft
henryiii wants to merge 1 commit into
pybind:masterfrom
henryiii:fix/complex-input-annotation
Draft

fix: include complex in std::complex input annotation#6113
henryiii wants to merge 1 commit into
pybind:masterfrom
henryiii:fix/complex-input-annotation

Conversation

@henryiii

@henryiii henryiii commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

See #6112.

🤖 AI text below 🤖

Description

Fixes #6102

The std::complex<T> caster declared its input annotation as
typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex, which
omits the builtin complex. In typeshed, complex only gets __complex__ on
Python 3.11+, so on Python 3.10 a strict type checker rejects passing a plain
complex literal, although the caster accepts it. The input annotation now starts
with complex |, and the signature test was updated.

Suggested changelog entry:

  • Include the builtin complex type in the input annotation of the
    std::complex<T> type caster.

https://claude.ai/code/session_013JABmnjt9oAh29p1pytAB3

The input annotation for `std::complex<T>` 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: type_caster<std::complex<T>>'s parameter annotation omits builtin complex for Python 3.10

1 participant