sqlfmt is an opinionated CLI tool that formats your sql files
Project description
sqlfmt
sqlfmt is an opinionated CLI tool that formats your dbt sql files. It is similar in nature to black, gofmt, and rustfmt.
sqlfmt is not configurable, except for line length. It enforces a single style. sqlfmt maintains comments and some extra newlines, but largely ignores all indentation and line breaks in the input file.
sqlfmt is not a linter. It does not parse your code; it just tokenizes it and tracks a small subset of tokens that impact formatting. This lets us "do one thing and do it well:" sqlfmt is very fast, and easier to extend than linters that need a full sql grammar.
sqlfmt is designed to work with sql files that contain jinja tags and blocks. It formats the code that users look at, and therefore doesn't need to know anything about what happens after the templates are rendered.
Contributing
Setting up Your Dev Environment and Running Tests
- Install Poetry if you don't have it already. You may also need or want pyenv, make, and gcc. A complete setup from a fresh install of Ubuntu can be found here
- Clone this repo into a directory (let's call it
sqlfmt
), thencd sqlfmt
- Use
poetry install
to install the project (editable) and its dependencies into a new virtual env - Use
poetry shell
to spawn a subshell - Type
make
to run all tests and linters, or runpytest
,black
,flake8
,isort
, andmypy
individually.
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
Hashes for shandy_sqlfmt-0.1.0a8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f3fc44f21cc219a1f09f266820b01afe962841327d44efb48963e25564653f8 |
|
MD5 | 2d96808e2fdc90de5976666d5fac4d9b |
|
BLAKE2b-256 | b8dc1d41afc5c90f4a982dd4289e2cdbd9dc27b955e81e6be08aed9e11d485f4 |