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

How to exclude files or file sections? #243

Open
kinderlars opened this issue May 12, 2023 · 6 comments
Open

How to exclude files or file sections? #243

kinderlars opened this issue May 12, 2023 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kinderlars
Copy link

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 kinderlars added the question Further information is requested label May 12, 2023
@lyz-code
Copy link
Owner

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 lyz-code added enhancement New feature or request help wanted Extra attention is needed and removed question Further information is requested labels May 12, 2023
@kinderlars
Copy link
Author

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?

@lyz-code
Copy link
Owner

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

@lyz-code
Copy link
Owner

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

@MenSeb
Copy link

MenSeb commented Sep 5, 2023

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

@lyz-code
Copy link
Owner

lyz-code commented Sep 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants