2016-04-08 8 views
1

Ich habe einen folgenden Code-Schnipsel, dass Pylint nicht verarbeiten kann:Pylint unendliche Rekursion in Astriod Paket

from celery import Celery 


def create_celery(application): 
    """ 
    Configures celery instance from application, using it's config 
    :param application: Flask application instance 
    :return: Celery instance 
    """ 
    celery = Celery(application.import_name) 
    celery.conf.update(application.config) 
    TaskBase = celery.Task 

    class ContextTask(TaskBase): 
     abstract = True 

     def __call__(self, *args, **kwargs): 
      with application.app_context(): 
       return TaskBase.__call__(self, *args, **kwargs) 

    celery.Task = ContextTask 
    return celery 

ich folgende Fehlermeldung erhalten:

File "/usr/local/lib/python3.4/dist-packages/astroid/context.py", line 49, in cache_generator 
    for result in generator: 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 302, in wrapped 
    for res in _func(node, context, **kwargs): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 325, in raise_if_nothing_inferred 
    for node in func(*args, **kwargs): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/inference.py", line 156, in infer_attribute 
    for owner in self.expr.infer(context): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/context.py", line 49, in cache_generator 
    for result in generator: 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 302, in wrapped 
    for res in _func(node, context, **kwargs): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 99, in _infer_stmts 
    for inferred in stmt.infer(context=context): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/context.py", line 49, in cache_generator 
    for result in generator: 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 302, in wrapped 
    for res in _func(node, context, **kwargs): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 99, in _infer_stmts 
    for inferred in stmt.infer(context=context): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/context.py", line 49, in cache_generator 
    for result in generator: 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 302, in wrapped 
    for res in _func(node, context, **kwargs): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 325, in raise_if_nothing_inferred 
    for node in func(*args, **kwargs): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/inference.py", line 100, in infer_call 
    for callee in self.func.infer(context): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/context.py", line 49, in cache_generator 
    for result in generator: 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 302, in wrapped 
    for res in _func(node, context, **kwargs): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 99, in _infer_stmts 
    for inferred in stmt.infer(context=context): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/context.py", line 49, in cache_generator 
    for result in generator: 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 302, in wrapped 
    for res in _func(node, context, **kwargs): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 99, in _infer_stmts 
    for inferred in stmt.infer(context=context): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/context.py", line 49, in cache_generator 
    for result in generator: 
    File "/usr/local/lib/python3.4/dist-packages/astroid/bases.py", line 302, in wrapped 
    for res in _func(node, context, **kwargs): 
    File "/usr/local/lib/python3.4/dist-packages/astroid/inference.py", line 144, in infer_import_from 
    context = contextmod.copy_context(context) 
    File "/usr/local/lib/python3.4/dist-packages/astroid/context.py", line 79, in copy_context 
    return context.clone() 
    File "/usr/local/lib/python3.4/dist-packages/astroid/context.py", line 42, in clone 
    clone = InferenceContext(self.path, inferred=self.inferred) 
RuntimeError: maximum recursion depth exceeded 

Ich benutze neueste Pylint 1.5.5 und Python 3.4

Ich habe versucht, logilab auf Issue Tracker zu kontaktieren, aber es scheint, dass sie eine gebrochene Login-Funktionalität haben.

fand ich für diese eine Abhilfe, für diese Datei eine --ignore Option verwenden, aber es löst nicht das Problem

Antwort

1

ich dies in meinen Projekten hatte und ich verbrachte eine ganze Weile für das Problem suchen in Astroid. Es stellte sich heraus (für mich), dass Pylint nur zutiefst rekursiv war und das Aufstoßen der Stapelgröße das Problem löst. Also habe ich vor dem Aufruf von pylint Folgendes hinzugefügt (ich rufe pylint vom Komponententestcode an).

# If we don't do this we get stack overflows running pylint!! 
# It's parsing and tests are deeply recursive. 
import sys 
sys.setrecursionlimit(8 * sys.getrecursionlimit()) 

Ich wurde informiert, dass Sie dies auf die pylintrc so hinzufügen können (nicht getestet).

init-hook='import sys; sys.setrecursionlimit(8 * sys.getrecursionlimit())'