Pylint Celery Plugin
pylint-celery is a Pylint plugin designed to enhance Pylint's ability to recognize and understand common patterns and potential errors when analyzing code that uses the Celery distributed task queue library. It aims to reduce false positives and provide more accurate linting for Celery-specific constructs. The current version is 0.3, with the last PyPI release dating back to 2014, suggesting a low-cadence, maintenance-focused development cycle, though the GitHub repository under pylint-dev sees ongoing issue tracking.
Warnings
- gotcha The project lacks a `pyproject.toml` file, leading to a `DEPRECATION` warning when installed using newer `pip` versions, as it defaults to the legacy `setup.py install` method.
- gotcha Pylint-celery's compatibility with newer Pylint versions is uncertain. An old issue (2017) indicated test failures with Pylint 1.7+. Users may encounter unexpected warnings or errors if using `pylint-celery` with significantly newer Pylint versions without official updates.
- gotcha Pylint (even with the plugin) can sometimes fail to resolve Celery imports (e.g., `E0401: Unable to import 'celery'`) if the Python environment or `PYTHONPATH` is not correctly configured or the virtual environment is not properly activated when running Pylint.
- gotcha The plugin's primary role is to fix 'celery.task is not callable' warnings. However, Pylint might still issue `E1120: No value for argument 'self'` for `bind=True` Celery tasks if the plugin doesn't fully cover specific class-based task definitions or complex scenarios, requiring manual disables.
Install
-
pip install pylint-celery
Imports
- pylint_celery
pylint --load-plugins pylint_celery
Quickstart
# 1. Install pylint-celery
pip install pylint-celery
# 2. Create a dummy Celery task file (e.g., myapp/tasks.py)
# Ensure Celery and Pylint are in your environment
# Example: myapp/tasks.py
# from celery import Celery
#
# app = Celery('myapp', broker='redis://localhost:6379/0')
#
# @app.task
# def add(x, y):
# return x + y
# 3. Run Pylint with the plugin loaded
# Navigate to your project root or where your code resides
pylint --load-plugins pylint_celery myapp/tasks.py