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

ValueError: max() arg is an empty sequence #426

Closed
smcgivern opened this issue May 29, 2023 · 0 comments · Fixed by #427
Closed

ValueError: max() arg is an empty sequence #426

smcgivern opened this issue May 29, 2023 · 0 comments · Fixed by #427

Comments

@smcgivern
Copy link
Contributor

Describe the bug
When given a relative path and absolute path, sqlfmt fails with:

$ sqlfmt data/models/foo.sql /Users/smcgivern/Code/linear-app/data/models/bar.sql
Traceback (most recent call last):
  File "/Users/smcgivern/.asdf/installs/python/3.11.3/bin/sqlfmt", line 8, in <module>
    sys.exit(sqlfmt())
             ^^^^^^^^
  File "/Users/smcgivern/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smcgivern/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/smcgivern/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smcgivern/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smcgivern/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smcgivern/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/sqlfmt/cli.py", line 176, in sqlfmt
    config = load_config_file(files)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smcgivern/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/sqlfmt/config.py", line 23, in load_config_file
    common_parents = _get_common_parents(files)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smcgivern/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/sqlfmt/config.py", line 55, in _get_common_parents
    root_dir = max(common_parents, key=lambda p: p.parts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: max() arg is an empty sequence

To Reproduce

Run sqlfmt with two paths, one relative and one absolute.

Expected behavior

It doesn't crash 🙂 More precisely, it converts the relative path to an absolute one first.

Actual behavior

Crashes as above.

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

$ sqlfmt --version
sqlfmt, version 0.18.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant