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

Auto Detect SqlFlulf executable from Python Virtual Environment #146

Open
aaronclong opened this issue Jul 10, 2024 · 1 comment
Open

Auto Detect SqlFlulf executable from Python Virtual Environment #146

aaronclong opened this issue Jul 10, 2024 · 1 comment

Comments

@aaronclong
Copy link

Background


Hard coding executable paths into settings.json makes the config completely unportable. People will have different operating systems, and even different folder structures depending how things are installed.

Defining a path variable would also be cumbersome.

It should be noted that different repos might even use different versions, further complicating this practice.

This all came from Issue 133.

Suggestion


It would be nice if the config could specify a dependencyManager and directory. The extension could load this.

settings.json

"sqlfluff.dependencyManager": "poetry",
"sqlfluff.projectRoot": "${workspace}/path"

Then the linter provider could spawn a child process and get exec from there.

With poetry, you can dynamically fetch the path from this poetry run which sqlfluff.

image
const { exec } = require('child_process');
return new Promise((resolve, reject) => {
  exec('poetry run which sqlfluff', (error, stdout, stderr) => {
     if (error || stderr) {
        reject(error || stderr);
        return;
     }

    resolve(stdout)
  });
});

In addition, this extension could talk to the Microsoft Python extension and get the virtual environment.

It is defiantly more complex. However, it allows for easy changes to the environment.

https://github.com/microsoft/vscode-python/blob/main/src/client/api.ts#L150C9-L150C21
https://stackoverflow.com/questions/50058517/how-to-communicate-between-vscode-extensions/50068416#50068416

@aaronclong
Copy link
Author

aaronclong commented Jul 25, 2024

There doesn't seem to any appetite by the maintainers for addressing these issues (totally fair).

For people struggling with this, I've noticed some over lap with Issue #18.

Likewise, there seems to be an alternative extension, vscode-dbt-power-user, that might better resolve these issues for the time being. However, it doesn't seem to be a true linter

Here are some discussions I found around the issue here:

AltimateAI/vscode-dbt-power-user#3 (comment)

AltimateAI/vscode-dbt-power-user#3 (comment)

#18

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

No branches or pull requests

1 participant