vscode-ruff icon indicating copy to clipboard operation
vscode-ruff copied to clipboard

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

Open shunichironomura opened this issue 7 months ago • 4 comments

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

shunichironomura avatar Jul 25 '24 15:07 shunichironomura