You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code terminates before the refactoring but not after:
from itertools import count, product
def loop():
for x in count():
for y in range(5):
if x == 3:
return y
print(loop())
This is because itertools.product tries to exhaust the iterators before outputting anything, so does not work with infinite iterators, as in python/cpython#54318.
I'm really not sure what the right thing to do is, since it's a useful refactoring in most cases. Maybe the safe solution is to only trigger if each of the iterables is known to be a finite iterator (eg list, tuple, range, ...)?
Debug Information
IDE Version:
PyCharm Professional Edition 2022.2.1
Sourcery Version:
Sourcery 0.12.8
Operating system and Version:
Fedora Linux 36
The text was updated successfully, but these errors were encountered:
Description
The following code terminates before the refactoring but not after:
This is because
itertools.product
tries to exhaust the iterators before outputting anything, so does not work with infinite iterators, as in python/cpython#54318.I'm really not sure what the right thing to do is, since it's a useful refactoring in most cases. Maybe the safe solution is to only trigger if each of the iterables is known to be a finite iterator (eg list, tuple, range, ...)?
Debug Information
IDE Version:
PyCharm Professional Edition 2022.2.1
Sourcery Version:
Sourcery 0.12.8
Operating system and Version:
Fedora Linux 36
The text was updated successfully, but these errors were encountered: