continuous-integrationtomlpyproject.tomlsqlfluff

How to enable Core-Rules in SQL-Fluff and solve TomlDecodeError?


I want to enable only the core group of rules in SQL-Fluff. So I added this line to my pyproject.toml file:

[tool.sqlfluff]
rules = "core"

This results in the following error message:

 File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\toml\decoder.py", line 134, in load
    return loads(ffile.read(), _dict, decoder)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\toml\decoder.py", line 478, in loads
    raise TomlDecodeError("What? " + group +
toml.decoder.TomlDecodeError: What? rules already exists?{'rules': 'core', 'core': {'dialect': 'tsql', 'exclude_rules': 'L016,L057,L029'}} (line 24 column 1 char 483)

What does this error mean and how do i solve it to achieve my task?


Solution

  • Found the answer myself. I will post it here since i still don't find it intuitive and others may have the same problem.

    So, if you only want to use the core set of SQL-Fluff rules, add the following to your pyproject.toml

    [tool.sqlfluff.core]
    rules = "core"