4 Commits
Author SHA1 Message Date
David Peter f64707592d bytes.translate: generalize delete parameter type (#14372)
bytes.translate: generalize 'delete' parameter type
2025-07-07 00:19:23 -07:00
David Peter ad8ecaf217 property.__get__: overload to model class-access behavior (#13769) 2025-04-02 15:09:56 +02:00
David Peter 15f98a8ab8 chr: Accept SupportsIndex argument (#13494)
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
2025-02-12 07:50:42 +00:00
David Peter 614e9499f1 Annotate sys.platform as LiteralString (#13378) 2025-01-09 18:58:44 +01:00