|
1 |
| -.. raw:: html |
| 1 | +############## |
| 2 | +Pylint-Airflow |
| 3 | +############## |
2 | 4 |
|
3 |
| - <img src="images/pylint-airflow.png" align="right" /> |
| 5 | +.. image:: https://img.shields.io/badge/code%20style-black-000000.svg |
| 6 | + :alt: Code style: Black |
| 7 | + :target: https://github.com/ambv/black |
4 | 8 |
|
5 |
| -.. Split in README_noraw because PyPi doesn't allow the raw directive. |
6 |
| -.. include:: README_noraw.rst |
| 9 | +.. image:: https://img.shields.io/badge/License-MIT-blue.svg |
| 10 | + :alt: License: MIT |
| 11 | + :target: https://github.com/BasPH/airflow-examples/blob/master/LICENSE |
| 12 | + |
| 13 | +.. image:: https://img.shields.io/circleci/project/github/BasPH/pylint-airflow/master.svg |
| 14 | + :target: https://circleci.com/gh/BasPH/workflows/pylint-airflow/tree/master |
| 15 | + |
| 16 | +.. image:: images/pylint-airflow.png |
| 17 | + :align: right |
| 18 | + |
| 19 | +Pylint plugin for static code analysis on Airflow code. |
| 20 | + |
| 21 | +***** |
| 22 | +Usage |
| 23 | +***** |
| 24 | + |
| 25 | +Installation: |
| 26 | + |
| 27 | +.. code-block:: bash |
| 28 | +
|
| 29 | + pip install pylint-airflow |
| 30 | +
|
| 31 | +Usage: |
| 32 | + |
| 33 | +.. code-block:: bash |
| 34 | +
|
| 35 | + pylint --load-plugins=pylint_airflow [your_file] |
| 36 | +
|
| 37 | +This plugin runs on Python 3.6 and higher. |
| 38 | + |
| 39 | +*********** |
| 40 | +Error codes |
| 41 | +*********** |
| 42 | + |
| 43 | +The Pylint-Airflow codes follow the structure ``{I,C,R,W,E,F}83{0-9}{0-9}``, where: |
| 44 | + |
| 45 | +- The characters show: |
| 46 | + |
| 47 | + - ``I`` = Info |
| 48 | + - ``C`` = Convention |
| 49 | + - ``R`` = Refactor |
| 50 | + - ``W`` = Warning |
| 51 | + - ``E`` = Error |
| 52 | + - ``F`` = Fatal |
| 53 | + |
| 54 | +- ``83`` is the base id (see all here https://github.com/PyCQA/pylint/blob/master/pylint/checkers/__init__.py) |
| 55 | +- ``{0-9}{0-9}`` is any number 00-99 |
| 56 | + |
| 57 | +The current codes are: |
| 58 | + |
| 59 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 60 | +| Code | Symbol | Description | |
| 61 | ++=======+===================================+=================================================================================================================================================================+ |
| 62 | +| C8300 | different-operator-varname-taskid | For consistency assign the same variable name and task_id to operators. | |
| 63 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 64 | +| C8301 | match-callable-taskid | For consistency name the callable function '_[task_id]', e.g. PythonOperator(task_id='mytask', python_callable=_mytask). | |
| 65 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 66 | +| C8302 | mixed-dependency-directions | For consistency don't mix directions in a single statement, instead split over multiple statements. | |
| 67 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 68 | +| C8303 | task-no-dependencies | Sometimes a task without any dependency is desired, however often it is the result of a forgotten dependency. | |
| 69 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 70 | +| C8304 | task-context-argname | Indicate you expect Airflow task context variables in the \*\*kwargs argument by renaming to \*\*context. | |
| 71 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 72 | +| C8305 | task-context-separate-arg | To avoid unpacking kwargs from the Airflow task context in a function, you can set the needed variables as arguments in the function. | |
| 73 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 74 | +| C8306 | match-dagid-filename | For consistency match the DAG filename with the dag_id. | |
| 75 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 76 | +| R8300 | unused-xcom | Return values from a python_callable function or execute() method are automatically pushed as XCom. | |
| 77 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 78 | +| W8300 | basehook-top-level | Airflow executes DAG scripts periodically and anything at the top level of a script is executed. Therefore, move BaseHook calls into functions/hooks/operators. | |
| 79 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 80 | +| E8300 | duplicate-dag-name | DAG name should be unique. | |
| 81 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 82 | +| E8301 | duplicate-task-name | Task name within a DAG should be unique. | |
| 83 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 84 | +| E8302 | duplicate-dependency | Task dependencies can be defined only once. | |
| 85 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 86 | +| E8303 | dag-with-cycles | A DAG is acyclic and cannot contain cycles. | |
| 87 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 88 | +| E8304 | task-no-dag | A task must know a DAG instance to run. | |
| 89 | ++-------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 90 | + |
| 91 | +************* |
| 92 | +Documentation |
| 93 | +************* |
| 94 | + |
| 95 | +Documentation is available on `Read the Docs <https://pylint-airflow.readthedocs.io>`_. |
| 96 | + |
| 97 | +************ |
| 98 | +Contributing |
| 99 | +************ |
| 100 | + |
| 101 | +Suggestions for more checks are always welcome, please create an issue on GitHub. Read `CONTRIBUTING.rst <https://github.com/BasPH/pylint-airflow/blob/master/CONTRIBUTING.rst>`_ for more details. |
0 commit comments