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

Exclude config in pyproject.toml stopped working in 0.18.3 #431

Closed
cmcnicoll opened this issue Jun 7, 2023 · 9 comments
Closed

Exclude config in pyproject.toml stopped working in 0.18.3 #431

cmcnicoll opened this issue Jun 7, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@cmcnicoll
Copy link

Describe the bug
Upgraded to 0.18.3 and ran sqlfmt -k ., which ignored the exclude config. Reverted to 0.18.1 and exclude config works again. Do I have to update my pyproject.toml?

To Reproduce
I'm using Windows 11 Pro, Visual Studio Code, venv, powershell terminal.

[tool.sqlfmt]
exclude = [
    "dbt/.dbtenv/**/*",
    "dbt/dbt_packages/**/*",
    "dbt/macros/marts/**/*",
    "dbt/macros/staging/**/*",
    "dbt/macros/util/**/*",
    "dbt/snapshots/**/*",
    "dbt/target/**/*",
    "dbt/tests/generic/**/*",
    "etc/**/*",
    "lib/**/*",
    "sql/**/*",
    "src/**/*",
    "tests/**/*"
]

Additional context
What is the output of sqlfmt --version?
sqlfmt, version 0.18.3

@tconbeer
Copy link
Owner

tconbeer commented Jun 7, 2023

There was a change in that version with making paths absolute.

Can you add a "./" before your paths and see if that fixes the issue for you?

@cmcnicoll
Copy link
Author

That didn't work for me. I also can't get the --exclude option to work: sqlfmt . --check --exclude ./dbt/target/**/*.

@tconbeer
Copy link
Owner

tconbeer commented Jun 7, 2023

ok, thanks!

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

tconbeer commented Jun 7, 2023

related to #427

@tconbeer
Copy link
Owner

tconbeer commented Jun 9, 2023

@cmcnicoll Would love it if you could give v0.19.0 a spin -- I'm pretty sure it'll fix your issue but I didn't have a perfect repro on my machine, so I'm not 100% sure.

@cmcnicoll
Copy link
Author

My exclude config in pyproject.toml is working again as-is. Thanks!

sqlfmt . --check -k -q               
1 file failed formatting check.
176 files passed formatting check.

However, I still can't get the --exclude option to work.

sqlfmt . --check -k -q --exclude ./dbt/**/* --exclude ./sql/**/*
192 files had errors while formatting.
1681 files failed formatting check.
1234 files passed formatting check.

@tconbeer
Copy link
Owner

Depending on your she'll, you might have to quote those paths?

@cmcnicoll
Copy link
Author

That didn't work for me. I tried path, ./path, .\path, "path", "./path", ".\path".

The --exclude behavior is the same for bash and cmd except for one case, which threw an error:

(.dbtenv) 
aaa@aaa MINGW64 /c/aaa-aaa/dbt/tests (aaa)
$ sqlfmt . --check -k -q --exclude .\integration_tests\**\*
Traceback (most recent call last):
  File "C:\Users\aaa\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\aaa\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\users\aaa\.local\bin\sqlfmt.exe\__main__.py", line 7, in <module>
  File "C:\Users\aaa\.local\pipx\venvs\shandy-sqlfmt\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\aaa\.local\pipx\venvs\shandy-sqlfmt\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\aaa\.local\pipx\venvs\shandy-sqlfmt\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\aaa\.local\pipx\venvs\shandy-sqlfmt\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\aaa\.local\pipx\venvs\shandy-sqlfmt\lib\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\aaa\.local\pipx\venvs\shandy-sqlfmt\lib\site-packages\sqlfmt\cli.py", line 185, in sqlfmt
    matched_files = api.get_matching_paths(files, mode=mode)
  File "C:\Users\aaa\.local\pipx\venvs\shandy-sqlfmt\lib\site-packages\sqlfmt\api.py", line 105, in get_matching_paths
    exclude_set.update(mode.exclude_root.glob(s))
  File "C:\Users\aaa\AppData\Local\Programs\Python\Python310\lib\pathlib.py", line 1033, in glob
    selector = _make_selector(tuple(pattern_parts), self._flavour)
  File "C:\Users\aaa\AppData\Local\Programs\Python\Python310\lib\pathlib.py", line 374, in _make_selector
    raise ValueError("Invalid pattern: '**' can only be an entire path component")
ValueError: Invalid pattern: '**' can only be an entire path component

@tconbeer
Copy link
Owner

I can repro on Powershell, I'm going to create a new issue for this

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