vscode-dbt-power-user
vscode-dbt-power-user copied to clipboard
sqlfmt from dbt power user doesn't read configuration from pyproject.toml
Expected behavior
The line_length configuration set in a pyproject.toml file is taken into consideration by the sqlfmt brought by dbt power user.
Actual behavior
The line_length configuration set in a pyproject.toml file is taken into consideration by the sqlfmt brought by dbt power user.
Steps To Reproduce
- Create a project with
dbt init, add apyproject.tomlfile with this content at the root of the project
[tool.sqlfmt]
line_length = 120
- Create a model containing the following line and save it in
models/example/test.sql
-- test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
-
with dbt power user installed, format the file with the VSCode shortcut, the line is truncated at char 83 (unexpected behaviour)
-
from the root of the project run
sqlfmt models/example/my_second_dbt_model.sql, the line is truncated at char 118 (expected behaviour)
Notice that in the docs of sqlfmt it is mentioned that
sqlfmt will search for the pyproject.toml file using the files passed to it as arguments. It starts in the lowest (most specific) common parent directory to all the files and recurses up to the root directory. It will load settings from the first pyproject.toml file it finds in this search.
The behaviour is fairly annoying for my team since we have a pre-commit that uses sqlfmt to check the formatting based on the pyproject.toml file. It would be amazing if dbt power user could use by default the same configuration specified in pyproject.toml without the need to modify the settings 🙏
Log output/Screenshots
No response
Operating System
macOS 14.5 (23F79)
dbt version
1.7.17
dbt Adapter
bigquery
dbt Power User version
v0.42.3
Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!