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

Pick up pyproject.toml based on file path or workspace #3

Closed
charliermarsh opened this issue Nov 8, 2022 · 6 comments
Closed

Pick up pyproject.toml based on file path or workspace #3

charliermarsh opened this issue Nov 8, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@charliermarsh
Copy link
Member

No description provided.

@charliermarsh charliermarsh added the enhancement New feature or request label Nov 9, 2022
@TommasoAmici
Copy link

TommasoAmici commented Nov 25, 2022

This would be quite useful for me, would you accept a PR implementing it?

EDIT: it seems like this already works actually

@charliermarsh
Copy link
Member Author

I wonder how that works, I would've expected it not to since we don't use the passed-in path to infer the project root 🤔

@charliermarsh
Copy link
Member Author

Oh, we pass the stdin filename, of course...

@fredrikaverpil
Copy link

fredrikaverpil commented Jan 6, 2023

@charliermarsh does this issue mean that the selected rules from pyproject.toml would supersede/take precedence over what you have in your vscode settings?

I don't think this works currently but I would really like to see this.

When working in a team where everyone has individual vscode settings, it's confusing to talk about which ruff rules you want in your project - when you don't see warnings in vscode based on the pyproject.toml for that project.
The expected behavior would be to get warnings shown to you and autofixes applied automatically for stuff that the project (pyproject.toml) desires/requires.

I appreciate that different people might desire different behavior here so maybe a ruff-vscode setting would be preferable here which makes it possible to specify which takes precedence; pyproject.toml or vscode settings.

I also posted about this over at mastodon (here).

@charliermarsh
Copy link
Member Author

I don't think this works currently but I would really like to see this.

Yeah, that's correct -- the pyproject.toml in the project path doesn't override the settings from the VS Code extension. Which is not ideal, for the reasons you described.

The best way to solve this today is to use a user-specific pyproject.toml rather than going through the VS Code extension. For example, if you're on macOS, you can create a pyproject.toml at ~/Library/Application\ Support/ruff/pyproject.toml. Then, when linting, if Ruff can't find a pyproject.toml in the current file path, it will use that as the default settings.

@fredrikaverpil
Copy link

@charliermarsh thanks for this - great that there's this workaround. Is this pyproject.toml fallback documented somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants