-
Notifications
You must be signed in to change notification settings - Fork 56
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
Use in projects that use Hatch project builder #665
Comments
You can create a project or user level Ruff configuration or specify a configuration file in VS code |
As I said in the original post 'the config is extremely verbose'. To quote the Hatch docs: "There are 525 selected stable rules and 129 selected preview rules... There are 175 unselected rules" What's worse the rule set changes with each release of Hatch. Your right, I could cobble together a matching (v.large) Ruff config from the Hatch documentation. But with the Hatch project manager now running at 150k downloads per day I'd imagine there's an increasing need for the ruff-vscode plugin to recognise that Hatch is being used as the project builder and mirror the Hatch rule base automatically. |
We wouldn't want to hard code the hatch config because it introduces a dependency on hatch itself. Do you know if the hatch default config exists as a toml file somehwere on disk? |
I've had a quick look already and found nothing obvious. I'll do some more investigations. Cheers. |
Oh nice find. Yeah, we don't want to read that because it would require executing or at least parsing python code. I don't see an obvious way on how this could be supported other than allowing other VS Code extensions to provide setting overrides (which seems complicated and I doubt that hatch wants to release a vs code extension). I suggest raising this issue on the hatch repository |
https://github.com/pypa/hatch/blob/64031c1cf5d02d85203f68cb7a4fd5db2aa7a004/ruff_defaults.toml is the same but unfortunately it doesn't make it into the published hatch package. |
The hatch exe command:
Conveniently emits the the ruff command and the location of the config being used.
It would be possible for the ruff-vscode plugin to read this without parsing of executing python. |
Thanks for the extra information. I don't think this is something we want to read because it introduces quiet some complexity:
A workaround for you is to specify this very path in your own vscode settings as the ruff configuration. |
I tried to set ruff.configuration in settings.json to the hatch generated pyproject.toml to no effect. When I set ruff.configuration to non-existent file (eg: "$workspaceFolder/pyproject-undefined.toml") no errors are reported in Is ruff.configuration ignored if a pyproject.toml is present in the project root? |
Hmm, this might be the case. @dhruvmanila will know better than I. |
I think this depends on the Ruff version that you have. Hatch will use the following Ruff version: On the latest Ruff version (
It should report an error in the server logs:
There were some observability issues in the past which has been fixed in the latest version of the extension (
No, the settings are merged as per the strategy specified in |
## Summary I noticed this while trying out astral-sh/ruff-vscode#665 that we use the `Display` implementation to show the error which hides the context. This PR changes it to use the `Debug` implementation and adds the message as a context. ## Test Plan **Before:** ``` 0.001228084s ERROR main ruff_server::session::index::ruff_settings: Unable to find editor-specified configuration file: Failed to parse /private/tmp/hatch-test/ruff.toml ``` **After:** ``` 0.002348750s ERROR main ruff_server::session::index::ruff_settings: Unable to load editor-specified configuration file Caused by: 0: Failed to parse /private/tmp/hatch-test/ruff.toml 1: TOML parse error at line 2, column 18 | 2 | extend-select = ["ASYNC101"] | ^^^^^^^^^^ Unknown rule selector: `ASYNC101` ```
The python Hatch builder command hatch fix uses an internal ruff rule configuration. This config is extremely verbose.
I'd like to configure ruff-vscode so that it mirrors the linting rules applied by hatch.
I there currently a way to do this?
The text was updated successfully, but these errors were encountered: