B020 false positives with iterable attribute acess
Open
Nobody has claimed this yet.
bug
help wanted
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 123
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 5
Description
Both of these loops report that the iteration variable is being reassigned, which is it clearly not.
Both are a bit complex, but it is each to see that smoother has attribted accessed but not assigned to.
for smoother in smoother.smoothers:
train_basis = smoother.basis[train_index]
train_der_basis = smoother.der_basis[train_index]
train_der2_basis = smoother.der2_basis[train_index]
train_cov_der2 = smoother.cov_der2
# TODO: Double check this part. cov_der2 is calculated with all data
train_x = smoother.x[train_index]
train_smoothers.append(
UnivariateGenericSmoother(
train_x, train_basis, train_der_basis, train_der2_basis,
train_cov_der2, smoother.variable_name + ' train'))
test_basis = smoother.basis[test_index]
test_der_basis = smoother.der_basis[test_index]
test_cov_der2 = smoother.cov_der2
# TODO: Double check this part. cov_der2 is calculated with all data
test_x = smoother.x[test_index]
test_smoothers.append(
UnivariateGenericSmoother(
test_x, test_basis, test_der_basis, train_der2_basis,
test_cov_der2, smoother.variable_name + ' test'))
Here ax and series have attribute access but no assignment.
for i, (ax, (series, def_name)) in enumerate(zip(axs, series)):
if def_name != "residual":
ax.plot(series)
else:
ax.plot(series, marker="o", linestyle="none")
ax.plot(xlim, (0, 0), color="#000000", zorder=-3)
name = getattr(series, "name", def_name)
if def_name != "Observed":
name = name.capitalize()
title = ax.set_title if i == 0 and observed else ax.set_ylabel
title(name)
ax.set_xlim(xlim)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named in the issue. Reproduce the two loop examples and trace the B020 implementation to see how iterable attribute access is classified; done means the reported false positives no longer occur while genuine reassignment warnings remain covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100