yamlfix icon indicating copy to clipboard operation
yamlfix copied to clipboard

How to exclude files or file sections?

Open kinderlars opened this issue 2 years ago • 6 comments

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.

kinderlars avatar May 12 '23 06:05 kinderlars

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!

lyz-code avatar May 12 '23 09:05 lyz-code

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?

kinderlars avatar May 15 '23 12:05 kinderlars

You can probably use project_root/dir/subdir/* but I'm not sure :S

lyz-code avatar May 15 '23 15:05 lyz-code

Thanks to @GLeurquin you can now use --exclude and --include since 1.11.0

lyz-code avatar Jun 14 '23 17:06 lyz-code

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

MenSeb avatar Sep 05 '23 03:09 MenSeb

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 :)

lyz-code avatar Sep 05 '23 09:09 lyz-code