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
I tried PLC0208 on my codebase, and found several spots where iterating over a set was clearly intentional. Here is a salient example:
forrgin {dtype.is_floating_point, False}:
This will would get corrected to a sequence, when I want this test case to run over True and False is dtype.is_floating_point is true. Otherwise, only False.
Where I want to loop over all unique values. If the sparse.shape[dim] is 2, then I only go over index (0, 1) instead of (0, 1, 1). It doesn't seem like this fix can be safe if it doesn't know what it's referencing. At the very least, the fix should be marked unsafe.
The text was updated successfully, but these errors were encountered:
I think this is different than #4907? My read is that change was about comprehensions and set calls. Pylint does flag the cases you've included here, though we could consider changing our rule.
I’ve also just encountered PLC0208 on code like this:
dt: datetime.datetime = ...
slightly_earlier = dt - datetime.timedelta(hours=4)
for day in {dt.date(), slightly_earlier.date()}:
... # could be the same date or two consecutive dates
where the intention is for the loop body to handle each distinct date exactly once.
Please consider restricting the rule to literals only.
I tried PLC0208 on my codebase, and found several spots where iterating over a set was clearly intentional. Here is a salient example:
This will would get corrected to a sequence, when I want this test case to run over
True
andFalse
isdtype.is_floating_point
is true. Otherwise, only False.Another useful idiom is:
Where I want to loop over all unique values. If the
sparse.shape[dim]
is 2, then I only go over index (0, 1) instead of (0, 1, 1). It doesn't seem like this fix can be safe if it doesn't know what it's referencing. At the very least, the fix should be marked unsafe.The text was updated successfully, but these errors were encountered: