yamlfix icon indicating copy to clipboard operation
yamlfix copied to clipboard

impossible to define exclude and include properties at the pyproject level

Open jeremycohensolal opened this issue 7 months ago • 0 comments

Description

If you want to use include or exclude filter defined in your pyproject... it won't be applied

Steps to reproduce

Add this section in your pyproject.toml

[tool.yamlfix]
# https://lyz-code.github.io/yamlfix
allow_duplicate_keys = true
line_length = 120
none_representation = "null"
explicit_start = false
sequence_style = "block_style"
section_whitelines = 1
exclude=["dbt_packages/**/*"]

Current behavior

Exclude is not applied to file selection.

Desired behavior

Excluded globs should be used the same way than with --exclude cli argument

Environment

Tested on 1.16.9

Tech deep dive

It seems that the issue is located in your "endpoints/cli.py"

Here you collect elligible files specifying exclude/include from cli arguments

real_files.extend(_find_all_yaml_files(provided_file, include, exclude))

but the loading of the pyproject.toml config (with maison) is made later in the file... so the file collect has already been made, and it's too late to filter it again...

jeremycohensolal avatar Jul 11 '24 15:07 jeremycohensolal