Skip to main content

sqlfmt is an opinionated CLI tool that formats your sql files

Project description

sqlfmt

Code style: black Imports: isort Checked with mypy

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

  1. 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
  2. Clone this repo into a directory (let's call it sqlfmt), then cd sqlfmt
  3. Use poetry install to install the project (editable) and its dependencies into a new virtual env
  4. Use poetry shell to spawn a subshell
  5. Type make to run all tests and linters, or run pytest, black, flake8, isort, and mypy individually.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shandy-sqlfmt-0.1.0a8.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shandy_sqlfmt-0.1.0a8-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file shandy-sqlfmt-0.1.0a8.tar.gz.

File metadata

  • Download URL: shandy-sqlfmt-0.1.0a8.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.11.0-1020-azure

File hashes

Hashes for shandy-sqlfmt-0.1.0a8.tar.gz
Algorithm Hash digest
SHA256 25771a5d13559d65a8c5d2f865fe1ede42ec9fa495568247550b36ce9ab1a2d2
MD5 98c92228f94757768e7882684a63cc72
BLAKE2b-256 25f0bac57b799af4b9d3e41c2d8997e0f1cd6bffbe285fe7b981bd68d359cca1

See more details on using hashes here.

File details

Details for the file shandy_sqlfmt-0.1.0a8-py3-none-any.whl.

File metadata

  • Download URL: shandy_sqlfmt-0.1.0a8-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.11.0-1020-azure

File hashes

Hashes for shandy_sqlfmt-0.1.0a8-py3-none-any.whl
Algorithm Hash digest
SHA256 3f3fc44f21cc219a1f09f266820b01afe962841327d44efb48963e25564653f8
MD5 2d96808e2fdc90de5976666d5fac4d9b
BLAKE2b-256 b8dc1d41afc5c90f4a982dd4289e2cdbd9dc27b955e81e6be08aed9e11d485f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page