Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlfmt from dbt power user doesn't read configuration from pyproject.toml #1323

Open
1 task
albton opened this issue Jul 24, 2024 · 1 comment
Open
1 task
Labels
bug Something isn't working

Comments

@albton
Copy link

albton commented Jul 24, 2024

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

  1. Create a project with dbt init, add a pyproject.toml file with this content at the root of the project
[tool.sqlfmt]
line_length = 120
  1. 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
  1. with dbt power user installed, format the file with the VSCode shortcut, the line is truncated at char 83 (unexpected behaviour)

  2. 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!
@albton albton added the bug Something isn't working label Jul 24, 2024
@FulcronZ
Copy link

I have the same issue in v0.44.2, and this is annoying.
To config, I have to edit sqlfmt arguments in the extension instead of having it read the pyproject.toml.
This forces one's editor preference into settings for the whole team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants