Skip to content

fix: ignore list not being used when passing files/directories as arguments#810

Open
Zamiell wants to merge 1 commit into
adrienverge:masterfrom
Zamiell:fix-bug-with-specifying-files
Open

fix: ignore list not being used when passing files/directories as arguments#810
Zamiell wants to merge 1 commit into
adrienverge:masterfrom
Zamiell:fix-bug-with-specifying-files

Conversation

@Zamiell
Copy link
Copy Markdown

@Zamiell Zamiell commented Apr 7, 2026

Imagine that I put "1.yml" on the ignore list. Then, if I invoke yamllint like this:

yamllint 1.yml 2.yml 3.yml 4.yml 5.yml 6.yml

Then, instead of linting 2-6, it will actually lint 1-6! Which seems almost certainly to be a bug, because other industry-standard tools such as Prettier will correctly skip 1.yml.

The behavior occurs with both files and directories. I didn't bother opening an issue in favor of just fixing the bug myself in a pull request.

One other situation that I thought about was when the user does not know that "1.yml" is on the ignore list and types yamllint 1.yml, expecting it to find errors, but instead yamllint passes. This could lead the user to think that yamllint rules are turned off or yamllint is bugged in some way. To address this, I also decided to print a warning to standard error when this happens, to explicitly let the user know that the file is being skipped (as a quality of life feature). However, note that Prettier does not do this, so it might not be needed.

@DimitriPapadopoulos
Copy link
Copy Markdown
Contributor

But then other tools such as Ruff do override their exclude list when explicitely passing an ignored file as an argument. I'm not certain which behaviour is best, but It doesn't look like there's consensus on the subject.

@Zamiell
Copy link
Copy Markdown
Author

Zamiell commented May 4, 2026

@DimitriPapadopoulos Interesting, I didn't know that Ruff did that!

For context, in my company we have the following linting algorithm:

  1. Detect the file paths changed in the pull request.
  2. Feed them to uv run yamllint a.yml b.yml c.yml and so on.

Thus, the behavior in my pull request is preferable for this pattern. Because currently, when someone submits a pull request for a file on the ignore list, they erroneously get hit by yamllint errors!

Ruff's behavior does make more sense for humans typing in the command manually. But with that said, I think the explicit warning that I put into this PR is a great middle ground that covers both sides!

@DimitriPapadopoulos
Copy link
Copy Markdown
Contributor

DimitriPapadopoulos commented May 4, 2026

Ruff has exclude and force-exclude for that purpose.

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