Open
Description
I have this little module:
'xxx'
import typing
def main() -> None:
'collapse rows if the first column is empty'
rows: typing.Iterable[typing.List[str]] = [['foo', 'bar'], ['', 'baz']]
itor = iter(rows)
prev: typing.Optional[typing.List[str]] = None
while True:
try:
row = next(itor)
except StopIteration:
break
if row[0]:
if prev is not None:
print(prev)
prev = row
else:
assert prev is not None
for i, cell in enumerate(row):
if i == 0:
continue
prev[i] += ' ' + cell
if prev is not None:
print(prev)
if __name__ == '__main__':
main()
while it does what I expect (it prints ['foo', 'bar baz']
), pylint says that there is an error:
>pylint falsepositive.py
************* Module falsepositive
falsepositive.py:29:16: E1137: 'prev' does not support item assignment (unsupported-assignment-operation)
------------------------------------------------------------------
Your code has been rated at 7.83/10 (previous run: 7.83/10, +0.00)
pylint --version output
>pylint --version
pylint 2.6.0
astroid 2.4.2
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)]