pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.31k stars 1.14k forks source link

`source-roots` + jobs > 1: occasional `no-member` false positives #9224

Open zimtkeks opened 11 months ago

zimtkeks commented 11 months ago

Bug description

We're using a large proprietary code base (which I can't share) with Python 3.10.12 and pylint 2.17.7 (dependency versions given below).

In a monorepo with ~20 packages we run pylint as pre-commit. The packages are namespace packages.

In that context, I have observed occasional no-member-errors (false positives) when using multiple jobs and source-roots. E.g. -j4 and source-roots = packages/* (expands to ~20 paths).

When run repeatedly, the no-member errors vary in count and code location. Sometimes there are none (pylint passes), sometimes there are 3-5 in different places.

To reproduce, while true ; pre-commit run pylint --all-files ; done was sufficient.

The problem disappear if I change to -j1 or remove the source-roots parameter.

The hook's configuration:

- id: pylint
  name: pylint
  entry: pylint
  language: python
  types: [python]
  require_serial: true
  args: [-j4, --rcfile=pylintrc.precommit]

Configuration

[MASTER]
source-roots = packages/*

Command used

pre-commit run pylint --all-files

Pylint output

Example false positive:

************* Module tests.backends.torch.models.test_onnx
tests/backends/torch/models/test_onnx.py:22:8: E1101: Module 'torchvision' has no 'models' member (no-member)

Expected behavior

Deterministic behavior that is identical to result when run with -j1

Pylint version

pylint==2.17.7

OS / Environment

Linux, Python 3.10.12

Additional dependencies

astroid==2.15.8
dill==0.3.7
isort==5.11.5
lazy-object-proxy==1.9.0
mccabe==0.7.0
platformdirs==3.11.0
tomli==2.0.1
tomlkit==0.11.8
typing_extensions==4.8.0
wrapt==1.15.0
jacobtylerwalls commented 11 months ago

Thanks for the report! We did some work addressing indeterminacy when running with --jobs=n in pylint 3.0. Do you observe the same problem when upgrading?

zimtkeks commented 11 months ago

I tried but unfortunately with pylint 3.0.2 and astroid 3.0.1 I got RecursionError: maximum recursion depth exceeded while calling a Python object even unchanged configuration. I'll try again with future releases.