Skip to content

RecursionError in pylint #3982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aabramovrepo opened this issue Dec 14, 2020 · 6 comments
Closed

RecursionError in pylint #3982

aabramovrepo opened this issue Dec 14, 2020 · 6 comments
Labels
Bug 🪲 Duplicate 🐫 Duplicate of an already existing issue performance

Comments

@aabramovrepo
Copy link

Dear All,

I'm facing the following issue with pylint in my GitHub Actions CI chain:

Run find . -name "*.py" | xargs pylint
  find . -name "*.py" | xargs pylint
  shell: /bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.7.9/x64
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/astroid/decorators.py", line 32, in cached
    return cache[func]
KeyError: <bound method ClassDef._get_assign_nodes of <ClassDef.DatetimeIndex l.72 at 0x7fe5703f6890>>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/astroid/decorators.py", line 32, in cached
    return cache[func]
KeyError: <bound method MultiLineBlockMixin._get_assign_nodes of <FunctionDef.union_many l.360 at 0x7fe5700cbed0>>

...

RecursionError: maximum recursion depth exceeded
Error: Process completed with exit code 123.

any ideas what goes wrong here? It worked before without any problems, pylint version is 2.6.0.

Thanks in advance for your help!

Best,
Alexey

@dickreuter
Copy link
Contributor

dickreuter commented Dec 15, 2020

Having the same problem. And it occurs randomly, sometimes rerunning the same test fixes the problem. Downgrading Astroid to 2.2.5 solves the problem.

@aabramovrepo
Copy link
Author

@dickreuter thanks for your feedback, I think we should keep this ticket open, since downgrading packages can't be the right way. Is there any alternative in pylint >= 2.0 for --optimize-ast option? Thanks!

@juliangilbey
Copy link

Ah, interesting - I just stumbled upon this problem as well. I was using pylint on this minimal test case:

from tqdm import tqdm


def progress_wrap(it_list, progress):
    if progress:
        wrapped = tqdm(it_list)
    else:
        wrapped = it_list
    return wrapped

pylint version 2.6.0, astroid version 2.4.2 (running Debian testing). I get similar behaviour (consistently) running pylint on the tqdm package's file tqdm/asyncio.py. What is more interesting still is that I'm running this on two different machines, both running Debian testing with packages at the same versions, and on the other machine, pylint runs without difficulty.

@Pierre-Sassoulas
Copy link
Member

I can't reproduce the crash with @juliangilbey code but the analysis is slow. Upgrading to current master only make it marginally faster (3.77s vs 3.81s). It was taking 2,70s in pylint 2.3.0 with astroid 2.2.5.

@cjvirtucio87
Copy link

As a datapoint, we're unable to reproduce the recursion error in python3.6:

pylint 2.8.3
astroid 2.5.6
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
...
------------------------------------------------------------------
Your code has been rated at 9.79/10 (previous run: 9.79/10, +0.00)


--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)


--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)


--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Perhaps something in python3.7 may have affected pylint 's algorithm?

@Pierre-Sassoulas
Copy link
Member

I'm closing as it's an old issue that is hard to reproduce, and we have other issues with "modern examples" of genuinely large recursion that are discussed in astroid.

@Pierre-Sassoulas Pierre-Sassoulas closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2022
@Pierre-Sassoulas Pierre-Sassoulas added the Duplicate 🐫 Duplicate of an already existing issue label Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Duplicate 🐫 Duplicate of an already existing issue performance
Projects
None yet
Development

No branches or pull requests

6 participants