diff --git a/src/posit/connect/_active.py b/src/posit/connect/_active.py index bfd78513..052c3aba 100644 --- a/src/posit/connect/_active.py +++ b/src/posit/connect/_active.py @@ -6,12 +6,12 @@ import posixpath from abc import ABC, abstractmethod from collections.abc import Mapping as Mapping_abc -from collections.abc import Sequence as Sequence_abc from typing import ( Any, Generator, Iterator, Optional, + SupportsIndex, Tuple, TypeVar, cast, @@ -198,7 +198,7 @@ def __init__( self._path = path -class ReadOnlySequence(Sequence_abc[ResourceDictT]): +class ReadOnlySequence(Tuple[ResourceDictT, ...]): """Read only Sequence.""" _data: Tuple[ResourceDictT, ...] @@ -222,13 +222,17 @@ def __len__(self) -> int: return len(tuple(self._data)) @overload - def __getitem__(self, index: int) -> ResourceDictT: ... + def __getitem__(self, key: SupportsIndex, /) -> ResourceDictT: ... @overload - def __getitem__(self, index: slice) -> Tuple[ResourceDictT, ...]: ... + def __getitem__(self, key: slice, /) -> tuple[ResourceDictT, ...]: ... - def __getitem__(self, index: int | slice) -> ResourceDictT | Tuple[ResourceDictT, ...]: - return self._data[index] + def __getitem__( + self, + key: SupportsIndex | slice, + /, + ) -> ResourceDictT | tuple[ResourceDictT, ...]: + return self._data[key] def __iter__(self) -> Iterator[ResourceDictT]: return iter(self._data)