|
4 | 4 | """Ringbuffer implementation with focus on time & memory efficiency.""" |
5 | 5 |
|
6 | 6 |
|
7 | | -from collections.abc import Iterable |
8 | 7 | from copy import deepcopy |
9 | 8 | from dataclasses import dataclass |
10 | 9 | from datetime import datetime, timedelta, timezone |
11 | | -from typing import Generic, SupportsFloat, SupportsIndex, TypeVar, overload |
| 10 | +from typing import Generic, SupportsIndex, TypeVar, overload |
12 | 11 |
|
13 | 12 | import numpy as np |
14 | 13 | import numpy.typing as npt |
@@ -498,60 +497,6 @@ def wrap(self, index: int) -> int: |
498 | 497 | """ |
499 | 498 | return index % self.maxlen |
500 | 499 |
|
501 | | - @overload |
502 | | - def __setitem__(self, index_or_slice: slice, value: Iterable[float]) -> None: |
503 | | - """Set values at the request slice positions. |
504 | | -
|
505 | | - No wrapping of the index will be done. |
506 | | - Create a feature request if you require this function. |
507 | | -
|
508 | | - Args: |
509 | | - index_or_slice: Slice specification of the requested data. |
510 | | - value: Sequence of value to set at the given range. |
511 | | - """ |
512 | | - |
513 | | - @overload |
514 | | - def __setitem__(self, index_or_slice: SupportsIndex, value: float) -> None: |
515 | | - """Set value at requested index. |
516 | | -
|
517 | | - No wrapping of the index will be done. |
518 | | - Create a feature request if you require this function. |
519 | | -
|
520 | | - Args: |
521 | | - index_or_slice: Index of the data. |
522 | | - value: Value to set at the given position. |
523 | | - """ |
524 | | - |
525 | | - def __setitem__( |
526 | | - self, index_or_slice: SupportsIndex | slice, value: float | Iterable[float] |
527 | | - ) -> None: |
528 | | - """Set item or slice at requested position. |
529 | | -
|
530 | | - No wrapping of the index will be done. |
531 | | - Create a feature request if you require this function. |
532 | | -
|
533 | | - Args: |
534 | | - index_or_slice: Index or slice specification of the requested data. |
535 | | - value: Value to set at the given position. |
536 | | - """ |
537 | | - # There seem to be 2 different mypy bugs at play here. |
538 | | - # First we need to check that the combination of input arguments are |
539 | | - # correct to make the type checker happy (I guess it could be inferred |
540 | | - # from the @overloads, but it's not currently working without this |
541 | | - # hack). |
542 | | - # Then we need to ignore a no-untyped-call error, for some reason it |
543 | | - # can't get the type for self._buffer.__setitem__() |
544 | | - if isinstance(index_or_slice, SupportsIndex) and isinstance( |
545 | | - value, SupportsFloat |
546 | | - ): |
547 | | - self._buffer.__setitem__(index_or_slice, value) # type: ignore[no-untyped-call] |
548 | | - elif isinstance(index_or_slice, slice) and isinstance(value, Iterable): |
549 | | - self._buffer.__setitem__(index_or_slice, value) # type: ignore[no-untyped-call] |
550 | | - else: |
551 | | - assert ( |
552 | | - False |
553 | | - ), f"Incompatible input arguments: {type(index_or_slice)=} {type(value)=}" |
554 | | - |
555 | 500 | @overload |
556 | 501 | def __getitem__(self, index_or_slice: SupportsIndex) -> float: |
557 | 502 | """Get item at requested position. |
|
0 commit comments