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

Unstable formatting for jinja config block #191

Closed
ryanmeekins opened this issue Jun 3, 2022 · 3 comments
Closed

Unstable formatting for jinja config block #191

ryanmeekins opened this issue Jun 3, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@ryanmeekins
Copy link

Describe the bug
The formatter is unstable with dbt config blocks.

Likely related to #175 but not sure.

To Reproduce
Start with a simple file with a config block definition, such as config_block.txt, and make a minor change. Run the formatter and then make another minor change and run the formatter again. You should see the indentation of the config variables increasing each time (4 more spaces).

Expected behavior
The formatter should produce a stable result.

Actual behavior
The formatter is unstable because it keeps indenting the config variables.

Additional context
sqlfmt, version 0.9.0

@tconbeer tconbeer added the bug Something isn't working label Jun 3, 2022
@tconbeer
Copy link
Owner

tconbeer commented Jun 3, 2022

Thanks for the report!

This sounds more like #138 and #176 to me.

I have a few questions, since I can't reproduce:

  1. Did you install sqlfmt with the jinjafmt extra? (pip install sqlfmt[jinjafmt]) and/or do you otherwise have black installed?
  2. Does this still happen if you run sqlfmt with the --no-jinjafmt option? e.g., sqlfmt --no-jinjafmt myfile.sql?
  3. Rather than making small changes to your file, can you reproduce if you pass the -k option to sqlfmt? This clears the cache and forces reformatting, even if the source file is unchanged. sqlfmt -k myfile.sql
  4. Are you sure you're running 0.9.0? This was absolutely a bug in a previous release. You may have multiple versions installed? I would run which sqlfmt and sqlfmt --version to make sure that it's 0.9.0 that is producing this result

@ryanmeekins
Copy link
Author

Sorry, this was an issue with the version specified in my pre-commit hook (forgot that pre-commit had it's own config and it was using v0.5.1). Realized this after just using the sqlfmt command directly.

Thanks for the quick response and for providing the different commands that will be helpful to my team in the future. Keep up the great work!

@tconbeer
Copy link
Owner

tconbeer commented Jun 3, 2022

Ah yes, I wish there was a better way to keep pre-commit in sync with other dependencies. Thanks for using sqlfmt!

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