lkmlfmt
lkmlfmt formats your LookML files including embedded SQL and HTML.
Installation
pip install lkmlfmt
CLI
Use lkmlfmt command to format your LookML file(s).
For further information, use --help option.
lkmlfmt [OPTIONS] [FILE]...
API
from lkmlfmt import fmt
lkml = fmt("""\
view: view_name {
derived_table: {
sql:
with cte as (
select col1, col2 from tablename
where ts between current_date()-7 and current_date())
select {% if true %} col1 {% else %} col2 {% endif %} from cte
;;
}
}
""")
assert lkml == """\
view: view_name {
derived_table: {
sql:
with
cte as (
select col1, col2
from tablename
where ts between current_date() - 7 and current_date()
)
select
{% if true %} col1
{% else %} col2
{% endif %}
from cte
;;
}
}
"""
GitHub Actions
To check if your LookML files are formatted.
on: [pull_request]
jobs:
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
# '>=3.11' is required
python-version: '3.11'
# you should specify the version of lkmlfmt!
- run: pip install lkmlfmt
- run: lkmlfmt --check path/to/lookml/file/or/directory
To format arbitrary branch and create pull request.
on: [workflow_dispatch]
jobs:
format-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
# '>=3.11' is required
python-version: '3.11'
# you should specify the version of lkmlfmt!
- run: pip install lkmlfmt
- run: lkmlfmt path/to/lookml/file/or/directory
# check the documentation especially about workflow permissions
# https://github.com/marketplace/actions/create-pull-request
- uses: peter-evans/create-pull-request@v5
with:
branch: format/${{ github.ref_name }}
Feedback
I'm not ready to accept pull requests, but your feedback is always welcome. If you find any bugs, please feel free to create an issue.
See also
In default, lkmlfmt formats embedded sql using sqlfmt.
You can install plugins to change the format of embeded looker expression, sql or html. They are distributed under their own licenses, so please check if they are suitable for your purpose.
Metadata
Release files for lkmlfmt 0.0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lkmlfmt-0.0.15.tar.gz | 9.9 kB | Without provenance | Details for lkmlfmt-0.0.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lkmlfmt-0.0.15-py3-none-any.whl | Python 3 | none | any | Details for lkmlfmt-0.0.15-py3-none-any.whl |
Total release size: 21.4 kB
Release files / lkmlfmt-0.0.15.tar.gz
| Download URL | lkmlfmt-0.0.15.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06e133a08adb71e4d8375ca156325ab1b485d25f18b15cc2823f1f1918056076
|
|
BLAKE2b-256 checksum How to use checksums |
9eb26b4f22fdd8e6503baf670cbc3da8a860d322932c9f31d42e250d034f7e14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure
|
Release files / lkmlfmt-0.0.15-py3-none-any.whl
| Download URL | lkmlfmt-0.0.15-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82f9dea471733141b56d0dabbe3a9a2079efd78bbcb2e20a3b55b198038a8e72
|
|
BLAKE2b-256 checksum How to use checksums |
031c3fd27cd595af54563332c6e8c2ffc6078833c86a40c0722efa7610b6eede
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure
|
Security for lkmlfmt 0.0.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.