From 50e1fa10855a97ee8afd98a89eda663afbe26276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Sun, 1 Jan 2023 19:57:42 +0100 Subject: [PATCH] v2.23.0 fix ListWrapperIterator --- CHANGELOG.md | 4 ++-- satella/__init__.py | 2 +- satella/coding/sequences/iterators.py | 11 ++++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a7572ac..1bd2d038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -# v2.23 +# v2.23.0 * smart_zip to be deprecated in 2.23.0 * removed SIGINT from hang_unti_signal - +* updated ListWrapperIterator's signature \ No newline at end of file diff --git a/satella/__init__.py b/satella/__init__.py index 1d5a1bba..df438184 100644 --- a/satella/__init__.py +++ b/satella/__init__.py @@ -1 +1 @@ -__version__ = '2.23' +__version__ = '2.23.0a1' diff --git a/satella/coding/sequences/iterators.py b/satella/coding/sequences/iterators.py index e24c2c52..944ab26a 100644 --- a/satella/coding/sequences/iterators.py +++ b/satella/coding/sequences/iterators.py @@ -2,6 +2,7 @@ import collections import itertools import typing as tp import warnings +from typing import _T_co from ..decorators import for_argument, wraps from ..recast_exceptions import rethrow_as, silence_excs @@ -478,7 +479,7 @@ def skip_first(iterator: Iteratable, n: int) -> tp.Iterator[T]: class _ListWrapperIteratorIterator(tp.Iterator[T]): - __slots__ = ('parent', 'pos') + __slots__ = 'parent', 'pos' def __init__(self, parent): self.parent = parent @@ -499,7 +500,7 @@ class _ListWrapperIteratorIterator(tp.Iterator[T]): return item -class ListWrapperIterator(tp.Generic[T]): +class ListWrapperIterator(tp.Iterator[T]): """ A wrapped for an iterator, enabling using it as a normal list. @@ -513,7 +514,11 @@ class ListWrapperIterator(tp.Generic[T]): This is additionally a generic class. """ - __slots__ = ('iterator', 'exhausted', 'list') + + def __next__(self) -> _T_co: + return self.next() + + __slots__ = 'iterator', 'exhausted', 'list' def __init__(self, iterator: Iteratable): self.iterator = iter(iterator) -- GitLab