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

Whether lint.per-file-ignores is respected depends on the file pattern when working in multi-root workspaces #562

Open
shunichironomura opened this issue Jul 25, 2024 · 4 comments
Labels
bug Something isn't working server

Comments

@shunichironomura
Copy link

shunichironomura commented Jul 25, 2024

Description

When working in Multi-root Workspaces in Visual Studio Code, whether lint.per-file-ignores takes effect depends on the file pattern.

The extension settings are all set to defaults, except for the ruff.configuration.

Reproduction

Set-up

Follow the steps below or clone https://github.com/shunichironomura/ruff-vscode-ws

  1. Prepare a directory with the following structure and contents:

(EDIT: Fixed the structure by adding the subfolder/)

.
├── a.code-workspace
├── b
│   └── a.py
├── ruff.toml
├── subfolder/
└── t
    └── a.py

a.code-workspace:

{
    "folders": [
        {
            "name": "root",
            "path": "."
        },
        {
            "name": "subfolder",
            "path": "./subfolder"
        }
    ],
    "settings": {
        "ruff.configuration": "${workspaceFolder:root}/ruff.toml"
    }
}

b/a.py and t/a.py (both have the same contents):

import os

ruff.toml:

[lint.per-file-ignores]
"b/**.py" = ["F401"]
"t/**.py" = ["F401"]  # This can be `"t/*.py" = ...` and still get the same issue
  1. Open the directory as a multi-root workspace by code a.code-workspace

Expected behavior

  • Running ruff check . in the root results in reporting no error.
  • For both scripts (b/a.py and t/a.py), no error is shown in the editor.

Actual behavior

  • Running ruff check . in the root results in reporting no error. (As expected)
  • The error message of F401 is not shown in b/a.py, but is shown in t/a.py. (Unexpected)

Environment

  • Ruff version: 0.5.4
  • Ruff VS Code extension version: v2024.36.0
  • Operating system: WSL2 Linux (Ubuntu 22.04)
  • Python version: 3.12.4
@dhruvmanila dhruvmanila added the bug Something isn't working label Jul 26, 2024
@dhruvmanila
Copy link
Member

Thanks for preparing a way for us to reproduce this very easily! It really helps.

This seems like a bug. I can look at it later today.

@dhruvmanila
Copy link
Member

Ok, if I remove the ruff.configuration settings from a.code-workspace, then it works correctly.

    "settings": {
        "ruff.configuration": "${workspaceFolder:root}/ruff.toml"
    }

@dhruvmanila
Copy link
Member

I'm curious as to why do you want to specify the ruff.configuration setting as it's going to be taken by default even if you don't specify it.

@shunichironomura
Copy link
Author

In my actual codebase, specifying the ruff.configuration setting makes the extension show some rule (I001 to be specific) correctly in the editor (maybe it's another, related bug). I tried to make a minimal reproducible example but I couldn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server
Projects
None yet
Development

No branches or pull requests

3 participants