Skip to content

Commit 7fd9282

Browse files
committed
Try using a tuple for base class for better python 3.8 support
1 parent 5f5082d commit 7fd9282

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/posit/connect/_active.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
import posixpath
77
from abc import ABC, abstractmethod
88
from collections.abc import Mapping as Mapping_abc
9-
from collections.abc import Sequence as Sequence_abc
109
from typing import (
1110
Any,
1211
Generator,
1312
Iterator,
1413
Optional,
14+
SupportsIndex,
1515
Tuple,
1616
TypeVar,
1717
cast,
@@ -198,7 +198,7 @@ def __init__(
198198
self._path = path
199199

200200

201-
class ReadOnlySequence(Sequence_abc[ResourceDictT]):
201+
class ReadOnlySequence(Tuple[ResourceDictT, ...]):
202202
"""Read only Sequence."""
203203

204204
_data: Tuple[ResourceDictT, ...]
@@ -222,13 +222,17 @@ def __len__(self) -> int:
222222
return len(tuple(self._data))
223223

224224
@overload
225-
def __getitem__(self, index: int) -> ResourceDictT: ...
225+
def __getitem__(self, key: SupportsIndex, /) -> ResourceDictT: ...
226226

227227
@overload
228-
def __getitem__(self, index: slice) -> Tuple[ResourceDictT, ...]: ...
228+
def __getitem__(self, key: slice, /) -> tuple[ResourceDictT, ...]: ...
229229

230-
def __getitem__(self, index: int | slice) -> ResourceDictT | Tuple[ResourceDictT, ...]:
231-
return self._data[index]
230+
def __getitem__(
231+
self,
232+
key: SupportsIndex | slice,
233+
/,
234+
) -> ResourceDictT | tuple[ResourceDictT, ...]:
235+
return self._data[key]
232236

233237
def __iter__(self) -> Iterator[ResourceDictT]:
234238
return iter(self._data)

0 commit comments

Comments
 (0)