Skip to content

Commit 91a6003

Browse files
committed
First simple attempts to prevent the "@celery.task is not callable" error as well as initial project structure for tests and installation
1 parent fba3750 commit 91a6003

File tree

7 files changed

+90
-0
lines changed

7 files changed

+90
-0
lines changed

pylint_celery/__init__.py

Whitespace-only changes.

pylint_celery/py2celery.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from astroid import MANAGER
2+
from astroid.builder import AstroidBuilder
3+
from astroid import nodes
4+
5+
6+
MODULE_TRANSFORMS = {}
7+
8+
9+
def transform(module):
10+
try:
11+
tr = MODULE_TRANSFORMS[module.name]
12+
except KeyError:
13+
pass
14+
else:
15+
tr(module)
16+
MANAGER.register_transform(nodes.Module, transform)
17+
18+
19+
def celery_transform(module):
20+
fake = AstroidBuilder(MANAGER).string_build('''
21+
class task_dummy(object): pass
22+
''')
23+
module.locals['task'] = fake.locals['task_dummy']
24+
25+
26+
MODULE_TRANSFORMS['celery'] = celery_transform

setup.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: UTF-8 -*-
2+
from distutils.core import setup
3+
from setuptools import find_packages
4+
import time
5+
6+
7+
_version = "0.1.dev%s" % int(time.time())
8+
_packages = find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"])
9+
10+
_short_description = "pylint-celery is a Pylint plugin to aid Pylint in recognising and understanding" \
11+
"errors caused when using the Celery library"
12+
13+
14+
setup( name='pylint-celery',
15+
url='https://github.com/landscapeio/pylint-celery',
16+
author='landscape.io',
17+
author_email='code@landscape.io',
18+
description=_short_description,
19+
version=_version,
20+
packages=_packages,
21+
license='GPLv2',
22+
keywords=('pylint', 'celery', 'plugin')
23+
)

test/input/__init__.py

Whitespace-only changes.

test/input/func_noerror_celery.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""
2+
Checks that Pylint does not complain about certain aspects of the Celery library
3+
"""
4+
# pylint: disable=C0111,R0903,W0232
5+
__revision__ = ''
6+
7+
from celery import task
8+
9+
@task(queue='celery')
10+
def test_task(an_arg, another_arg):
11+
return an_arg + another_arg

test/test_func.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
from pylint_celery import py2celery
3+
4+
from os.path import join, dirname, abspath
5+
import unittest
6+
from logilab.common import testlib
7+
from pylint.testutils import make_tests, LintTestUsingModule, LintTestUsingFile, cb_test_gen
8+
import sys
9+
10+
11+
INPUT_DIR = join(dirname(abspath(__file__)), 'input')
12+
MESSAGES_DIR = join(dirname(abspath(__file__)), 'messages')
13+
CALLBACKS = [cb_test_gen(LintTestUsingModule), cb_test_gen(LintTestUsingFile)]
14+
FILTER_RGX = None
15+
16+
17+
def suite():
18+
return testlib.TestSuite([unittest.makeSuite(test, suiteClass=testlib.TestSuite)
19+
for test in make_tests(INPUT_DIR, MESSAGES_DIR,
20+
FILTER_RGX, CALLBACKS)])
21+
22+
if __name__=='__main__':
23+
if len(sys.argv) > 1:
24+
FILTER_RGX = sys.argv[1]
25+
del sys.argv[1]
26+
testlib.unittest_main(defaultTest='suite')
27+
28+

test_requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pylint>=1.0.0
2+
celery>=3.0.0

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy