8000 Disallow right child from being iterator of dict · matplotlib/cycler@d19e475 · GitHub
[go: up one dir, main page]

Skip to content

Commit d19e475

Browse files
committed
Disallow right child from being iterator of dict
1 parent 52506c6 commit d19e475

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

cycler/__init__.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def __call__(self):
150150
def __init__(
151151
self,
152152
left: Cycler[K, V] | Iterable[dict[K, V]] | None,
153-
right: Cycler[K, V] | Iterable[dict[K, V]] | None = None,
153+
right: Cycler[K, V] | None = None,
154154
op: Any = None,
155155
):
156156
"""
@@ -170,13 +170,9 @@ def __init__(
170170
self._left = []
171171

172172
if isinstance(right, Cycler):
173-
self._right: Cycler[K, V] | list[dict[K, V]] | None = Cycler(
173+
self._right: Cycler[K, V] | None = Cycler(
174174
right._left, right._right, right._op
175175
)
176-
elif right is not None:
177-
# Need to copy the dictionary or else that will be a residual
178-
# mutable that could lead to strange errors
179-
self._right = [copy.copy(v) for v in right]
180176
else:
181177
self._right = None
182178

@@ -214,11 +210,7 @@ def change_key(self, old: K, new: K) -> None:
214210
self._keys.remove(old)
215211
self._keys.add(new)
216212

217-
if (
218-
self._right is not None
219-
and isinstance(self._right, Cycler)
220-
and old in self._right.keys
221-
):
213+
if self._right is not None and old in self._right.keys:
222214
self._right.change_key(old, new)
223215

224216
# self._left should always be non-None

test_cycler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ def test_cycler_exceptions():
289289
pytest.raises(TypeError, cycler, 'c', 'rgb', 'lw', range(3))
290290

291291

292-
def test_starange_init():
292+
def test_strange_init():
293293
c = cycler('r', 'rgb')
294294
c2 = cycler('lw', range(3))
295-
cy = Cycler(list(c), list(c2), zip)
295+
cy = Cycler(list(c), c2, zip)
296296
assert cy == c + c2
297297

298298

0 commit comments

Comments
 (0)
0