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

fix: use --force-exclude with Ruff #348

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

dhruvmanila
Copy link
Contributor

@dhruvmanila dhruvmanila commented Mar 24, 2024

Hi 👋, thank you for this plugin!

This PR updates the arguments passed to Ruff to include --force-exclude to make exclusions work. To give some context, if the ruff command is invoked with a filename directly then the exclusions from the config file aren't taken into consideration. When --force-exclude is passed, only then it's used to determine whether to skip running ruff on the given file or not.

From the CLI help menu:

File selection:
      --exclude <FILE_PATTERN>
          List of paths, used to omit files and/or directories from analysis

      --force-exclude
          Enforce exclusions, even for paths passed to Ruff directly on the
          command-line. Use `--no-force-exclude` to disable

We also use the same when invoking the ruff command via the LSP implementation:

  1. Reference to ruff check command args: https://github.com/astral-sh/ruff-lsp/blob/145e36dbe62b80f0a5682f25782a7038da9a8621/ruff_lsp/server.py#L158
  2. Reference to ruff format command args: https://github.com/astral-sh/ruff-lsp/blob/145e36dbe62b80f0a5682f25782a7038da9a8621/ruff_lsp/server.py#L1918

In addition to that, the following changes were made:

  1. Update the documentation link
  2. Use full command-line arguments as it reads better
  3. Use the include the check subcommand as calling ruff via an implicit check command is now deprecated (warning: ruff <path> is deprecated. Use ruff check <path> instead.)
  4. Include .ruff.toml file to determine the current working directory

@github-actions github-actions bot requested a review from stevearc March 24, 2024 07:08
@stevearc
Copy link
Owner

LGTM, thanks for the updates!

@stevearc stevearc merged commit 93f3d4c into stevearc:master Mar 25, 2024
8 checks passed
@dhruvmanila dhruvmanila deleted the ruff-force-exclude branch March 25, 2024 19:09
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

Successfully merging this pull request may close these issues.

2 participants