Skip to content

Nested workspace omits sub configs, probably because of extend-exclude #753

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

Open
Jangberry-pro opened this issue May 14, 2025 · 2 comments

Comments

@Jangberry-pro
Copy link

Jangberry-pro commented May 14, 2025

Hey,

I'm working on a complex project, with submodules, with different settings and the meta project excludes the sub ones with extend-exclude. We use it so that CI only care about its repository but while developing we do use the whole collection of repo, even when developing in submodules.

As excluding sub project is an intended behavior, I opened sub projects as new folder in the workspace, awaiting it to force include the sub directories, but it doesn't work as I intended.

The closest issue I found is #414, except this time it is for a whole child folder opened in a workspace.

I've reproduced a minimal exemple to clarify:

ex/
├── .ruff.toml
├── sub
│   ├── .ruff.toml
│   ├── test.py
│   └── foo
│       └── test.py
└── test.py

Where the test.py files are filled with

print("That's a pretty long long long long long long long long long long long long long long long long long long long long long long line")

-> cat ex/.ruff.toml

target-version = "py312"
line-length = 120

extend-exclude = [
    "sub",
]

-> cat ex/sub/.ruff.toml

target-version = "py312"
line-length = 120

extend-exclude = [
    "foo",
]

What I get:

  • formatting temp/sub/foo/test.py does nothing as expected
  • formatting temp/test.py break the long line as expected
  • formatting temp/sub/test.py does nothing instead of breaking the line

In the extension output I get (I changed my home to <$HOME> for privacy):

DEBUG main ruff_server::session::index::ruff_settings: Indexing settings for workspace: <$HOME>/ex
2025-05-14 10:05:51.825783382 DEBUG ThreadId(04) ruff_server::session::index::ruff_settings: Loaded settings from: `<$HOME>/ex/.ruff.toml` for `<$HOME>/ex`
2025-05-14 10:05:51.825915250 DEBUG ThreadId(04) ruff_server::session::index::ruff_settings: Ignored path via `extend-exclude`: <$HOME>/ex/sub
2025-05-14 10:05:51.826834994  INFO main ruff_server::session::index: Registering workspace: <$HOME>/ex
2025-05-14 10:05:51.826868981 DEBUG main ruff_server::session::index::ruff_settings: Indexing settings for workspace: <$HOME>/ex/sub
2025-05-14 10:05:51.827300462 DEBUG main ruff_server::session::index::ruff_settings: Loaded settings from: `<$HOME>/ex/.ruff.toml`
2025-05-14 10:05:51.827922641 DEBUG ThreadId(16) ruff_server::session::index::ruff_settings: Ignored path via `extend-exclude`: <$HOME>/ex/sub
2025-05-14 10:05:51.830188073  INFO main ruff_server::session::index: Registering workspace: <$HOME>/ex/sub
2025-05-14 10:05:51.836248830  INFO ruff:main ruff_server::server: Configuration file watcher successfully registered

It seems to me a bug occurs right after the Indexing settings for workspace: <$HOME>/ex/sub, I feel like the intended behavior would be loading ex/sub/.ruff.toml.

Also feel free to edit the title I struggle to find a representative one

@MichaReiser
Copy link
Member

Thanks for the detailed write up. I think this is working as intended for performance reasons.

Ruff tries to skip over directories that are excluded. For example, ruff skips over .venv and it won't show any lint warnings even if there's a ruff.toml in one of the packages that you installed (there shouldn't be any but there could).

What you're asking for would require ruff to always walk the entire directory tree because, maybe, there's some .ruff.toml somewhere. This would be very expensive because folders like .venv tend to contain many files.

Ruff's behavior here is consistent with git's where you can't unignore files in a previously ignored directory because git doesn't traverse the directory (for performance reasons).

You could make use of VS code's multi folder feature and adding individual folders (e.g. opening sub explicitly)

@Jangberry-pro
Copy link
Author

Hum there might be a misunderstanding, I get the performance reasons and tried to force include the folder :

As excluding sub project is an intended behavior, I opened sub projects as new folder in the workspace, awaiting it to force include the sub directories, but it doesn't work as I intended.

Except if what you call multi folder feature is different of what I call Workspace ? I must admit that I don't use this kind of feature really often...

But the sequence

2025-05-14 10:05:51.826868981 DEBUG main ruff_server::session::index::ruff_settings: Indexing settings for workspace: <$HOME>/ex/sub
2025-05-14 10:05:51.827300462 DEBUG main ruff_server::session::index::ruff_settings: Loaded settings from: `<$HOME>/ex/.ruff.toml`

really make me feel something went wrong.

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

2 participants