Skip to content

Commit 466309d

Browse files
committed
replace itertools with yield from
1 parent 1121d0b commit 466309d

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

dsync/diff.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
limitations under the License.
1414
"""
1515

16-
import itertools
1716
from functools import total_ordering
1817
from typing import Iterator, Iterable, Optional
1918

@@ -76,17 +75,14 @@ def get_children(self) -> Iterator["DiffElement"]:
7675
"""
7776
order_default = "order_children_default"
7877

79-
children: Iterator["DiffElement"] = itertools.chain()
8078
for group in self.groups():
8179
order_method_name = f"order_children_{group}"
8280
if hasattr(self, order_method_name):
8381
order_method = getattr(self, order_method_name)
8482
else:
8583
order_method = getattr(self, order_default)
8684

87-
children = itertools.chain(children, order_method(self.children[group]))
88-
89-
return children
85+
yield from order_method(self.children[group])
9086

9187
@classmethod
9288
def order_children_default(cls, children: dict) -> Iterator["DiffElement"]:

examples/example1/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class MyDiff(Diff):
12-
"""Custom Diff class to control the order of the site objects"""
12+
"""Custom Diff class to control the order of the site objects."""
1313

1414
@classmethod
1515
def order_children_site(cls, children):

0 commit comments

Comments
 (0)