(cls, real, imag=0, *args, **kwargs)
| 381 | __match_args__ = ("real", "imag") |
| 382 | |
| 383 | def __new__(cls, real, imag=0, *args, **kwargs): |
| 384 | if isinstance(real, str): |
| 385 | value = super().__new__(cls, strip_digit_separators(real)) |
| 386 | p1, _, p2 = real.lstrip("+-").replace("-", "+").partition("+") |
| 387 | check_inf_nan_cap(p1, value.imag if "j" in p1.lower() else value.real) |
| 388 | if p2: |
| 389 | check_inf_nan_cap(p2, value.imag) |
| 390 | return value |
| 391 | if isinstance(imag, complex): |
| 392 | raise TypeError("`imag` must be real") |
| 393 | if isinstance(real, complex): |
| 394 | # This is deprecated by Python 3.14's `complex`, so |
| 395 | # extract the imaginary part before passing through. |
| 396 | real, imag = real.real, imag + real.imag |
| 397 | return super().__new__(cls, real, imag) |
| 398 | |
| 399 | |
| 400 | _wrappers[complex] = Complex |
nothing calls this directly
no test coverage detected