astral-sh/ruff-vscode

Issue with Jupyter Notebooks

andrew-kovalenk0 opened this issue · 6 comments

I installed Ruff, configured it, but there is no highlits in the code where they should be (for example: line is too long).

ruff.toml:

# Ignore specific rules.
ignore = [

]

extend-include = ["*.ipynb"]

# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "venv",
]

# Same as Black.
line-length = 79

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]

[per-file-ignores]
# Ignore specific rules for specific files or patterns
"tests/*" = ["E402"]
"**/__init__.py" = ["F401"]

[pydocstyle]
convention = "numpy"

[pycodestyle]
max-doc-length = 79

[pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true

[pylint]
max-args = 8

[pep8-naming]
classmethod-decorators = ["classmethod", "pydantic.validator"]

Logs:

2024-10-12 21:56:55.063 [info] Name: Ruff
2024-10-12 21:56:55.063 [info] Module: ruff
2024-10-12 21:56:55.063 [info] Python extension loading
2024-10-12 21:56:55.063 [info] Waiting for interpreter from python extension.
2024-10-12 21:56:55.063 [info] Python extension loaded
2024-10-12 21:56:55.063 [info] Using interpreter: /home/Priomptipy/.venv/bin/python
2024-10-12 21:56:55.063 [info] Server run command: /home/Priomptipy/.venv/bin/python /root/.cursor-server/extensions/charliermarsh.ruff-2024.50.0-linux-x64/bundled/tool/server.py
2024-10-12 21:56:55.063 [info] Server: Start requested.
2024-10-12 21:56:55.949 [info] 2024-10-12 21:56:55,830 INFO Starting IO server

2024-10-12 21:56:55.965 [info] Workspace settings: [
    {
        "nativeServer": "off",
        "cwd": "/home/Priomptipy",
        "workspace": "file:///home/Priomptipy",
        "path": [],
        "ignoreStandardLibrary": true,
        "interpreter": [
            "/home/Priomptipy/.venv/bin/python"
        ],
        "configuration": null,
        "importStrategy": "fromEnvironment",
        "codeAction": {
            "fixViolation": {
                "enable": true
            },
            "disableRuleComment": {
                "enable": true
            }
        },
        "lint": {
            "enable": true,
            "run": "onType",
            "args": [],
            "preview": null,
            "select": null,
            "extendSelect": null,
            "ignore": null
        },
        "format": {
            "args": [],
            "preview": null
        },
        "enable": true,
        "organizeImports": true,
        "fixAll": true,
        "showNotifications": "off",
        "exclude": null,
        "lineLength": null,
        "configurationPreference": "editorFirst",
        "showSyntaxErrors": true,
        "logLevel": null,
        "logFile": null
    }
]
2024-10-12 21:56:55.967 [info] Global settings: {
    "nativeServer": "off",
    "cwd": "/mnt/c/Users/andre/AppData/Local/Programs/cursor",
    "workspace": "/mnt/c/Users/andre/AppData/Local/Programs/cursor",
    "path": [],
    "ignoreStandardLibrary": true,
    "interpreter": [],
    "configuration": null,
    "importStrategy": "fromEnvironment",
    "codeAction": {
        "fixViolation": {
            "enable": true
        },
        "disableRuleComment": {
            "enable": true
        }
    },
    "lint": {
        "enable": true,
        "run": "onType",
        "args": []
    },
    "format": {
        "args": []
    },
    "enable": true,
    "organizeImports": true,
    "fixAll": true,
    "showNotifications": "off",
    "configurationPreference": "editorFirst",
    "showSyntaxErrors": true
}
2024-10-12 21:56:56.167 [info] Interpreter executable (/home/Priomptipy/.venv/bin/ruff) not found
2024-10-12 21:56:56.988 [info] Falling back to bundled executable: /root/.cursor-server/extensions/charliermarsh.ruff-2024.50.0-linux-x64/bundled/libs/bin/ruff
2024-10-12 21:56:57.006 [info] Inferred version 0.6.6 for: /root/.cursor-server/extensions/charliermarsh.ruff-2024.50.0-linux-x64/bundled/libs/bin/ruff
2024-10-12 21:56:57.136 [info] Found ruff 0.6.6 at /root/.cursor-server/extensions/charliermarsh.ruff-2024.50.0-linux-x64/bundled/libs/bin/ruff
2024-10-12 21:56:57.148 [info] Running Ruff with: /root/.cursor-server/extensions/charliermarsh.ruff-2024.50.0-linux-x64/bundled/libs/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', '/home/Priomptipy/few_shot.ipynb']

"Line too long" isn't an enabled rule by default. What about, e.g., an unused import?

Nothing was highlighted for some reason. This setting in the ruff.toml helped:

select = [
    "ALL",
]

So this issue could be closed.

These are the default rules that are enabled out of the 900+ that are currently available:

select = ["E4", "E7", "E9", "F"]

Ref: https://github.com/astral-sh/ruff#configuration

Yes, I checked config page. None of errors from there was highlighted. I made these mistakes on purpose, but there was no result.

Can you confirm whether adding a single import statement like import os raises the F401 (unused-import) diagnostic?

Screenshot 2024-10-14 at 20 26 07

изображение
Okay, now it's working even without 'select' config, but before I tried select = ["ALL"] it wasn't working. select = ["F401"] now also produce highlight.