You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `chr` function does accept objects that implement the
`SupportsIndex` protocol. The [implementation] of the builtin method
calls `PyLong_AsLongAndOverflow` on the argument, which in turn calls
`__index__()`, if present. The parameter of the `chr` function can
therefore be annotated with `int | SupportsIndex`.
It seems to me like `SupportsIndex` alone would be enough, since `int`
implements `SupportIndex`, but I chose `int | SupportIndex` to make it
consistent with the annotations on `hex`, `oct` and `bin`.
[implementation]: https://github.com/python/cpython/blob/b05fa90b21dd01bb836285cdd41920320b09e681/Python/bltinmodule.c#L725
[PyLong_AsLongAndOverflow]: https://docs.python.org/3.13/c-api/long.html#c.PyLong_AsLongAndOverflow
0 commit comments