Enforce Best Practices for all your Airflow DAGs. ⭐
Project description
airflint
Enforce Best Practices for all your Airflow DAGs. ⭐
🧑🏫 Rules
- Use function-level imports instead of top-level imports[^1][^2] (see Top level Python Code)
- Use jinja macro instead of
Variable.get
(see Airflow Variables)
[^1]: There is a PEP for Lazy Imports targeted to arrive in Python 3.12 which would supersede this rule.
[^2]: To remove top-level imports after running UseFunctionLevelImports
rule, use a tool such as autoflake.
based on official Best Practices
🚀 Get started
To install it from PyPI run:
pip install airflint
NOTE: It is recommended to install airflint into your existing airflow environment with all your providers included. This way
UseJinjaVariableGet
rule can detect alltemplate_fields
and airflint works as expected.
Then just call it like this:
pre-commit
Alternatively you can add the following repo to your pre-commit-config.yaml
:
- repo: https://github.com/feluelle/airflint
rev: v0.3.0-alpha
hooks:
- id: airflint
args: ["-a"] # Use -a for replacing inplace
additional_dependencies: # Add all package dependencies you have in your dags, preferable with version spec
- apache-airflow
- apache-airflow-providers-cncf-kubernetes
To complete the UseFunctionlevelImports
rule, please add the autoflake
hook after the airflint
hook, as below:
- repo: https://github.com/pycqa/autoflake
rev: v1.4
hooks:
- id: autoflake
args: ["--remove-all-unused-imports", "--in-place"]
This will remove unused imports.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file airflint-0.3.0a0.tar.gz
.
File metadata
- Download URL: airflint-0.3.0a0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.13 Linux/5.13.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0e4a560e6c8abe85e5acfbf1ed39d45e85cb56ff6adf18a7a5465eacc63b659 |
|
MD5 | dc579977893bddcf5579fbac310ec183 |
|
BLAKE2b-256 | ba5494c78d3340c016eba5314e5064887d01213588bb57b684d40fdeccd6a812 |
File details
Details for the file airflint-0.3.0a0-py3-none-any.whl
.
File metadata
- Download URL: airflint-0.3.0a0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.13 Linux/5.13.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63a9db7f39c86495147cb5631db893d3014bbd42262505524263caff22e962bb |
|
MD5 | 40037ed69bdfba5e69d61b224a535885 |
|
BLAKE2b-256 | 1cd728820cc6561a6a7948d8f62ca78b27e4243e1da53a42a8c01a2f2c1fc118 |