Skip to content

Commit

Permalink
Try using a tuple for base class for better python 3.8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Nov 14, 2024
1 parent 5f5082d commit 7fd9282
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/posit/connect/_active.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -198,7 +198,7 @@ def __init__(
self._path = path


class ReadOnlySequence(Sequence_abc[ResourceDictT]):
class ReadOnlySequence(Tuple[ResourceDictT, ...]):
"""Read only Sequence."""

_data: Tuple[ResourceDictT, ...]
Expand All @@ -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)
Expand Down

0 comments on commit 7fd9282

Please sign in to comment.