Open mwichmann opened 1 month ago
Seems like a reasonable addition to me. Typeshed generally aims to model the runtime behavior as well as possible. Here it seems like you could just change the final overload to def __getitem__(self, pos: int | slice) -> Any: ...
, the only reason to add an additional overload for slice
would be to get the slightly more accurate return type tuple[Any, ...]
.
Feel free to open a pull request. If you need it in your own code and the addition doesn't negatively impact other users, it will generally be accepted.
The (relatively new - 3.5+)
FrameSummary
object does support slicing in a limited way like old frames did, as it indexes into a tuple, but the typeshed stubs don't have an@overload
for that, so checkers complain. The current implementation inFrameSummary
is:So this small snip, from old code that well precedes Python 3.5, continues to work:
but mypy grumps with:
I'm not entirely sold that this is something that should be added, so I've couched this as a question... (getting grumps from my project, of course).