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.28k stars 1.13k forks source link

Bug on pyreverse #3307

Closed fcabaud closed 2 years ago

fcabaud commented 4 years ago

I got this bug in pyreverse

pyreverse -c PyreverseCommand -a1 -s1 -f ALL -o png ../mypath/myfile.py

parsing ../src/py/deminer/deminer_orchestrator.py...

Traceback (most recent call last):
  File "/home/frederic/.local/share/virtualenvs/deminer-Z-KpghPu/bin/pyreverse", line 8, in <module>
    sys.exit(run_pyreverse())
  File "/home/frederic/.local/share/virtualenvs/deminer-Z-KpghPu/lib/python3.7/site-packages/pylint/__init__.py", line 37, in run_pyreverse
    PyreverseRun(sys.argv[1:])
  File "/home/frederic/.local/share/virtualenvs/deminer-Z-KpghPu/lib/python3.7/site-packages/pylint/pyreverse/main.py", line 184, in __init__
    sys.exit(self.run(args))
  File "/home/frederic/.local/share/virtualenvs/deminer-Z-KpghPu/lib/python3.7/site-packages/pylint/pyreverse/main.py", line 202, in run
    diadefs = handler.get_diadefs(project, linker)
  File "/home/frederic/.local/share/virtualenvs/deminer-Z-KpghPu/lib/python3.7/site-packages/pylint/pyreverse/diadefslib.py", line 233, in get_diadefs
    diagrams.append(generator.class_diagram(project, klass))
  File "/home/frederic/.local/share/virtualenvs/deminer-Z-KpghPu/lib/python3.7/site-packages/pylint/pyreverse/diadefslib.py", line 198, in class_diagram
    klass = next(module.ilookup(klass))
  File "/home/frederic/.local/share/virtualenvs/deminer-Z-KpghPu/lib/python3.7/site-packages/astroid/bases.py", line 146, in _infer_stmts
    context=context,
astroid.exceptions.InferenceError: Inference failed for all members of ().
ly3106 commented 2 years ago

Did you solve it? I also encountered the same one.

DudeNr33 commented 2 years ago

Can you provide a minimal example how to reproduce the crash, together with information which pylint version and OS you are using?

ly3106 commented 2 years ago

The source file I parsed is train.py on here.

Versions are as follows: ubuntu 18.04 pylint 2.13.5 astroid 2.11.2 Python 3.6.9 (default, Mar 15 2022, 13:55:28) [GCC 8.4.0]

And following is my command (but if I use pyreverse -f ALL -ASmy ./train.py, it works well)

.../Point-GNN$ pyreverse --module-names=y --class=module.entry.SumoRunner ./train.py
parsing ./train.py...
Traceback (most recent call last):
  File "/home/bit202/.local/bin/pyreverse", line 8, in <module>
    sys.exit(run_pyreverse())
  File "/home/bit202/.local/lib/python3.6/site-packages/pylint/__init__.py", line 44, in run_pyreverse
    PyreverseRun(argv or sys.argv[1:])
  File "/home/bit202/.local/lib/python3.6/site-packages/pylint/pyreverse/main.py", line 213, in __init__
    sys.exit(self.run(args))
  File "/home/bit202/.local/lib/python3.6/site-packages/pylint/pyreverse/main.py", line 228, in run
    diadefs = handler.get_diadefs(project, linker)
  File "/home/bit202/.local/lib/python3.6/site-packages/pylint/pyreverse/diadefslib.py", line 217, in get_diadefs
    diagrams.append(generator.class_diagram(project, klass))
  File "/home/bit202/.local/lib/python3.6/site-packages/pylint/pyreverse/diadefslib.py", line 185, in class_diagram
    klass = next(module.ilookup(klass))
  File "/home/bit202/.local/lib/python3.6/site-packages/astroid/bases.py", line 147, in _infer_stmts
    context=context,
astroid.exceptions.InferenceError: Inference failed for all members of ().
DudeNr33 commented 2 years ago

Thank you for the example. Where is module.entry.SumoRunner coming from? Is this an external dependency?

ly3106 commented 2 years ago

Thank you for your help. I think I make some mistakes as I am not so familiar with pyreverse. According to your hint, I changed the command to pyreverse --module-names=y -ASmy ./train.py, and it works very well. Thank you very much again.

Pierre-Sassoulas commented 2 years ago

I'm going to close as answered / hard to reproduce without precision.