mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Simplify by using yield from (#97831)
The issues were found by SIM104 flake8-simplify in a local run. I'll take a look on adding the check to the CI separately. Pull Request resolved: https://github.com/pytorch/pytorch/pull/97831 Approved by: https://github.com/Skylion007
This commit is contained in:
committed by
PyTorch MergeBot
parent
22b723132b
commit
477f3f555f
@ -110,8 +110,7 @@ def mapMaybe(func: Callable[[T], Optional[S]], xs: Iterable[T]) -> Iterator[S]:
|
||||
# Map over function that returns sequences and cat them all together
|
||||
def concatMap(func: Callable[[T], Sequence[S]], xs: Iterable[T]) -> Iterator[S]:
|
||||
for x in xs:
|
||||
for r in func(x):
|
||||
yield r
|
||||
yield from func(x)
|
||||
|
||||
|
||||
# Conveniently add error context to exceptions raised. Lets us
|
||||
|
Reference in New Issue
Block a user