pylint icon indicating copy to clipboard operation
pylint copied to clipboard

Infinite recursion of Pyreverse when numpy.array is in class

Open SpookyYomo opened this issue 9 months ago • 1 comments

Bug description

MWE:

import numpy as np

class A:
    foo = np.array([1, 2])

and then run the following:

pyreverse -ASmy fail.py

Configuration

No response

Command used

pyreverse -ASmy fail.py

Pylint output

After about 3 minutes of waiting...

Ouput:
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c06773a6600>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c06773c33e0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0677287e00>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c067729c8c0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0677109b20>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0677095790>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c06770ae540>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0677072f60>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676fe39e0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676e58440>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676d1fc80>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676d68ad0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676d355b0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676d5dfd0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676d429f0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676bfa2d0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676bff080>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676ae7aa0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676af0560>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c0676a84fe0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c06768a0800>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c06768b5670>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c06768aa030>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c06768d2a50>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c067667b410>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c06763a9ca0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c06763c66c0>).
Some functionality will be missing unless the system recursion limit is lifted.
From pylint, try: --init-hook='import sys; sys.setrecursionlimit(2000)' or higher.
  warnings.warn(
/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/transforms.py:118: UserWarning: Astroid was unable to transform Return(value=<Tuple.tuple l.31 at 0x7c06763d70e0>).
Some functionality will be missing unless the system recursion limit is lifted.
...
  File "/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/rebuilder.py", line 1154, in _visit_functiondef
    position=self._get_position_info(node, newnode),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/my_username/.local/share/pyenv/versions/3.12.1/lib/python3.12/site-packages/astroid/rebuilder.py", line 153, in _get_position_info
    return Position(
           ^^^^^^^^^
  File "<string>", line 1, in <lambda>
KeyboardInterrupt

Expected behavior

The pyreverse module should generate a UML class A with foo. However, it loops forever when processing np.array. I have been unable to create a MWE without using np.array.

Pylint version

pylint 3.2.2
astroid 3.2.2
Python 3.12.1 (main, Feb  9 2024, 14:00:11) [GCC 13.2.1 20230801]

numpy 1.26.4

OS / Environment

OS: Arch Linux x86_64 Kernel: Linux 6.9.2-arch1-1

Additional dependencies

astroid==3.2.2
dill==0.3.8
isort==5.13.2
mccabe==0.7.0
numpy==1.26.4
platformdirs==4.2.2
pylint==3.2.2
tomlkit==0.12.5

SpookyYomo avatar May 31 '24 15:05 SpookyYomo