Skip to content
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

pylint exceeds max recursion depth with setuptools.Command #3159

Closed
laplante-sean opened this issue Oct 3, 2019 · 2 comments
Closed

pylint exceeds max recursion depth with setuptools.Command #3159

laplante-sean opened this issue Oct 3, 2019 · 2 comments
Labels
Crash 💥 A bug that makes pylint crash

Comments

@laplante-sean
Copy link

laplante-sean commented Oct 3, 2019

This does not appear to be fixed on the preview release. I'm testing on a Windows 10 machine.

Winver: Version 1903 (OS Build 18362.356)

Steps to reproduce

  1. python -m venv .\venv
  2. .\venv\Scripts\activate.ps1
  3. pip install pylint
  4. pylint recurse_setup.py

recurse_setup.py

from setuptools import setup, find_packages, Command

class AnyCommand(Command):
    def initialize_options(self):
        pass
    def finalize_options(self):
        pass
    def run(self):
        print("Do anything")

setup(
    name='Thing',
    version='1.0',
    packages=find_packages(),
    cmdclass={
        'anycommand': AnyCommand
    },
)

The exception does not happen if you remove the AnyCommand from recurse_setup.py

works_setup.py

from setuptools import setup, find_packages

setup(
    name='Thing',
    version='1.0',
    packages=find_packages()
)

Current behavior

I didn't want to paste the entire error because it repeats and is crazy long:

    yield next(generator)
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\decorators.py", line 95, in wrapped
    res = next(generator)
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\bases.py", line 133, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\util.py", line 160, in limit_inference
    yield from islice(iterator, size)
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\context.py", line 113, in cache_generator
    for result in generator:
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\decorators.py", line 131, in raise_if_nothing_inferred
    yield next(generator)
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\decorators.py", line 95, in wrapped
    res = next(generator)
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\bases.py", line 133, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\util.py", line 160, in limit_inference
    yield from islice(iterator, size)
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\context.py", line 113, in cache_generator
    for result in generator:
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\decorators.py", line 131, in raise_if_nothing_inferred
    yield next(generator)
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\inference.py", line 920, in infer_ifexp
    test = next(self.test.infer(context=context))
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\node_classes.py", line 353, in infer
    return self._explicit_inference(self, context, **kwargs)
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\__init__.py", line 93, in _inference_tip_cached
    result = func(*args, **kwargs)
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\brain\brain_builtin_inference.py", line 129, in _transform_wrapper
    result = transform(node, context=context)
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\brain\brain_builtin_inference.py", line 615, in infer_isinstance
    call = arguments.CallSite.from_call(callnode)
  File "c:\users\me\documents\gitrepo\blah\venv\lib\site-packages\astroid\arguments.py", line 50, in from_call
    callcontext = contextmod.CallContext(call_node.args, call_node.keywords)
RecursionError: maximum recursion depth exceeded while calling a Python object

Expected behavior

In a prior version of pylint

(venv) > pylint recurse_setup.py
C:\Core

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

(venv) > pylint --version
pylint 2.3.1
astroid 2.2.3
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)]
(venv) >

pylint --version output

pylint 2.4.2
astroid 2.3.1
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)]

Other packages installed in venv

pip freeze

astroid==2.3.1
colorama==0.4.1
isort==4.3.21
lazy-object-proxy==1.4.2
mccabe==0.6.1
pylint==2.4.2
six==1.12.0
typed-ast==1.4.0
wrapt==1.11.2

Setuptools version

Reproduced issue in both 39.0.1 and the latest 41.2.0

@PCManticore PCManticore added this to the Next minor release milestone Oct 9, 2019
@PCManticore PCManticore added the Crash 💥 A bug that makes pylint crash label Oct 9, 2019
@PCManticore
Copy link
Contributor

Thanks for opening an issue! It's something we want to fix in a future bug fix release.

@PCManticore PCManticore modified the milestones: Next minor release, Next bug fix release Oct 9, 2019
PCManticore added a commit to pylint-dev/astroid that referenced this issue Oct 18, 2019
This should prevent a bunch of recursion errors happening in pylint.
Also refactor the inference of `IfExp` nodes to use separate contexts
for each potential branch.

Close pylint-dev/pylint#3152
Close pylint-dev/pylint#3159
@PCManticore
Copy link
Contributor

This is fixed in astroid and will be released shortly as 2.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 A bug that makes pylint crash
Projects
None yet
Development

No branches or pull requests

2 participants