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

Can ignore-from-file not error if file not found? #611

Open
paddyroddy opened this issue Nov 20, 2023 · 5 comments
Open

Can ignore-from-file not error if file not found? #611

paddyroddy opened this issue Nov 20, 2023 · 5 comments

Comments

@paddyroddy
Copy link

paddyroddy commented Nov 20, 2023

I'm aware this might sound like a rogue request, but I have a set of "master" pre-commit hooks where I have something like this as my args https://github.com/paddyroddy/.github/blob/2134df78ef3834b8af751fadc172a72ad3992d17/precommit/general/general-hooks.yml#L2-L16. However, when I use this in a repo without the .yamlignore file, I get FileNotFoundError: [Errno 2] No such file or directory: '.yamlignore'. Makes perfect sense, but what if I don't mind?

@adrienverge
Copy link
Owner

If I understood correctly, I assume you meant .yamlignore instead of .yamllint, and you want yamllint not to care if this file is referenced from the config file, but doesn't exist on disk.

This use-case is interesting, but I guess most users prefer yamllint to warn them if something from their conf file is wrong or missing.

If possible, I suggest dynamically adding ignore-from-file: .yamlignore in your --config-data depending whether the file exists or not.

@paddyroddy
Copy link
Author

paddyroddy commented Nov 21, 2023

If I understood correctly, I assume you meant .yamlignore instead of .yamllint, and you want yamllint not to care if this file is referenced from the config file, but doesn't exist on disk.

Yep, sorry that was a typo, I do mean .yamlignore.

This use-case is interesting, but I guess most users prefer yamllint to warn them if something from their conf file is wrong or missing.

Completely understand why most users wouldn't want this, but I think of it akin to a missing .gitignore - generally advisable, but not required.

If possible, I suggest dynamically adding ignore-from-file: .yamlignore in your --config-data depending whether the file exists or not.

Hmm... Good idea. Although not sure how I'd do it in practice.

@perlpunk
Copy link

I also think that in case of ignore-from-file it should not complain about a missing file.
One use case is: We would like to symlink a .yamllint file from an external, common repo (either used with git-submodule or git-subrepo) that has this:

ignore-from-file: [.gitignore, .yamlignore]

and the only thing which would differ for individual repos would be the files we want to ignore. By default linking .yamllint would just work, even if .yamlignore doesn't exist.
But I can understand the reasons for the current behaviour as well.

@adrienverge
Copy link
Owner

That's interesting, thanks for the feedback 👍

I'm curious about what more users think about this.

@42atomys
Copy link

We currently facing the same "issue" when using a dynamic lint across multiples repositories how don't have .gitignore or .yamlignore file.

The only workaround actually are to dynamically provide a config-data with a check of file exist before as @adrienverge say before. For us ignore this error are the good practice, but we can think about a warn log when the file are not found to alert the user (or create a flag to toggle between error and no-error. Not a big fan for me but that is a personal opinion)

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

No branches or pull requests

4 participants