pylint icon indicating copy to clipboard operation
pylint copied to clipboard

False-positive E1137 (unsupported-assignment-operation) with np.empty_like

Open EmilyBourne opened this issue 1 year ago • 0 comments

An almost identical error has already been reported (#2767).

The example code from that issue:

"""X"""
import numpy as np

X = np.empty_like([1])
X[:] = 2

works as expected, but the almost identical code:

"""X"""
from numpy import empty_like

X = empty_like([1])
X[:] = 2

raises the error:

************* Module bug
bug.py:5:0: E1137: 'X' does not support item assignment (unsupported-assignment-operation)

pylint --version output

pylint 3.0.3
astroid 3.0.2
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

Originally posted by @EmilyBourne in https://github.com/pylint-dev/pylint/issues/2767#issuecomment-1884376916

EmilyBourne avatar Jan 23 '24 20:01 EmilyBourne