astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
946 stars 45 forks source link

Support for intentionally using an older version of ruff #440

Open harshita-gupta opened 3 months ago

harshita-gupta commented 3 months ago

I work at an organization that (for various reasons) is currently on an older version of ruff - 0.1.6, to be exact. We're working on upgrading our codebase to be compatible with newer ruff versions, but until then, is there a way for me to tell the extension that it's ok to use an old version of ruff found in the environment?

zanieb commented 3 months ago

Generally, we support running with a version of Ruff you provide instead of the one in the environment.

I believe that version meets most of the requirements specified in our language server: https://github.com/astral-sh/ruff-lsp/blob/f4705a7664b0e41732bcd374614776c5c96ae124/ruff_lsp/server.py#L146-L153

Are you having difficulties providing the path to Ruff? https://github.com/astral-sh/ruff-vscode#settings

charliermarsh commented 3 months ago

v0.1.6 should work for most things, with the exception of range formatting:

# Require at least Ruff v0.0.291 for formatting, but allow older versions for linting.
VERSION_REQUIREMENT_FORMATTER = SpecifierSet(">=0.0.291")
VERSION_REQUIREMENT_LINTER = SpecifierSet(">=0.0.189")
VERSION_REQUIREMENT_RANGE_FORMATTING = SpecifierSet(">=0.2.1")
# Version requirement for use of the `--output-format` option
VERSION_REQUIREMENT_OUTPUT_FORMAT = SpecifierSet(">=0.0.291")
# Version requirement after which Ruff avoids writing empty output for excluded files.
VERSION_REQUIREMENT_EMPTY_OUTPUT = SpecifierSet(">=0.1.6")