Giter VIP home page Giter VIP logo

pytest-sqlfluff's Introduction

pytest-sqlfluff

PyPI version Python versions See Build Status on Github Workflows Code Style: Black

A pytest plugin to use sqlfluff to enable format checking of sql files.


Features

  • Tests any sql files found in project.
  • Leverages existing sqlfluff configurations.
  • Skips unchanged sql files.

Requirements

Installation

You can install pytest-sqlfluff via pip from PyPI:

$ pip install pytest-sqlfluff

Usage

Out of the box, you can run pytest-sqlfluff as argument to pytest:

$ pytest --sqlfluff
====================================== test session starts ======================================
platform darwin -- Python 3.9.6, pytest-7.2.0, pluggy-1.0.0
rootdir: /code/github.com/prsutherland/pytest-sqlfluff
plugins: sqlfluff-0.1.0
collected 1 item

tests/file.sql .                                                                          [100%]

======================================= 1 passed in 0.45s =======================================

To configure your sqlfluff linting, use the standard sqlfluff configuration mechanisms. At the very least, you'll likely need to set the dialect.:

[sqlfluff]
dialect = postgres
...

Contributing

Contributions are very welcome. Tests can be run with pytest, please ensure the coverage at least stays the same before you submit a pull request.

To get started:

$ git clone https://github.com/prsutherland/pytest-sqlfluff.git
$ cd pytest-sqlfluff
$ poetry install

Run tests:

$ poetry run pytest

License

Distributed under the terms of the MIT license, "pytest-sqlfluff" is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

pytest-sqlfluff's People

Contributors

prsutherland avatar

Stargazers

Benjamin avatar Christian Ledermann avatar  avatar

Watchers

 avatar

pytest-sqlfluff's Issues

Configuration change does not invalidate cache

The sqlfluff plugin caches the mtimes of the sql files it lints. However, if you change your configuration (either in pyproject.toml or .sqlfluff), the sql files will not be re-linted if they were already passing.

Support disabling sqlfluff via the command line

Typical pytest usage will add command line flags via setup.cfg or pyproject.toml like:

[tool:pytest]
addopts = --sqlfluff

It would be useful to be able to skip sqlfluff tests when doing local development without having to edit the setup.cfg or pyproject.toml.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.