#127559·tensorflow

PyLint presubmit fails with false-positive E1130 on nn_test.py (numpy 2.0.2 + pylint 2.13.9)

Author: Phoebus-LiuCreated Sep 17, 2026Updated Sep 17, 2026
Labelstype:bug

Issue type

Bug (CI tooling)

Source

pylint-presubmit.yml (the PyLint check) on any PR touching tensorflow/python/ops/nn_test.py

Description

The PyLint presubmit fails with two E1130 reports that point at pre-existing upstream code, not at the contributor's own change:

tensorflow/python/ops/nn_test.py:879:13: E1130: bad operand type for unary -: NoneType (invalid-unary-operand-type)
tensorflow/python/ops/nn_test.py:936:13: E1130: bad operand type for unary -: NoneType (invalid-unary-operand-type)

Both lines are return -np.sum(targets * np.log(pred + 1.0e-20), axis=1), inside the sampled-softmax-loss reference implementations used by testSampledSoftmaxLoss and testSampledSoftmaxLossBf16.

Because the workflow runs pylint over the entire changed file, every PR that modifies nn_test.py inherits this failure.

Root cause

.github/workflows/pylint-presubmit.yml pins pylint==2.13.9 but leaves numpy unpinned:

bash
pip install pylint==2.13.9 numpy wheel

The job runs on Python 3.9, where unpinned numpy resolves to 2.0.2 (the last release that supports 3.9). astroid 2.11.7 (the inference engine behind pylint 2.13.9) fails to resolve np.sum under numpy 2.0.2 and infers it as NoneType, so the unary minus is reported as an invalid operand.

Verified locally with pylint 2.13.9 and the repository's own tensorflow/tools/ci_build/pylintrc:

numpy result
2.0.2 9.93/10 — exactly these two E1130 reports (exit 2)
2.5.3 10.00/10 — no reports

The Python version is not a factor: the same split reproduces on Python 3.12, which isolates numpy as the trigger.

Suggested fix

Either:

  1. Rewrite the two expressions as -1.0 * np.sum(...), which I verified restores 10.00/10 under numpy 2.0.2 with no behaviour change; or
  2. Pin numpy in the workflow (or upgrade the pinned pylint) so that inference works again.

I am happy to send the one-line fix if that is preferred.