How to exclude files or file sections?
How to exclude files or file sections?
Hey, I have taken a look at the documentation for yamlfix and was not able to find anything regarding excluding files or file sections like you can do with most linting tools.
Therefore, how can I exclude an entire file via pyproject.toml?
This sadly does not work.
[tool.yamlfix] line_length = 240 sequence_style = "keep_style" exclude = dir1/subdir/example.yml
Also is it possible to disable linting for sections of the code like you can do with yamllint?
# yamllint disable and # yamllint enable
Thanks.
Hi @kinderlars thanks for taking the time to open the issue. As far as I remember there is not yet such a functionality built into the tool, but it would be awesome to have it!
Thanks for getting back. I noticed, that it is possible to exclude a single file via the pre-commit config directly so.
hooks:
- id: yamlfix
alias: lint
exclude: project_root/dir/sub_dir/example.yml
Any chance that might work for multiple files as well?
You can probably use project_root/dir/subdir/* but I'm not sure :S
Thanks to @GLeurquin you can now use --exclude and --include since 1.11.0
Hey @lyz-code thanks for yamlfix!
I'm also looking at using options from a config file pyproject.toml.
In particular to exclude and/or include, i.e.:
[tool.yamlfix]
exclude = ["path/to/dir/or/file"]
It would be even better if we could pass the files from the .gitignore as the argument to exclude.
[tool.yamlfix]
exclude_from_file = ".gitignore"
Let me know if this is something that could be implemented.
Thanks
Hi @MenSeb both suggestions look good to me to be implemented. I won't have time thought to do it, but I'll review any PR in this regard :)