djLint icon indicating copy to clipboard operation
djLint copied to clipboard

[BUG] supplied configuration in CLI overridden by default file

Open willemo opened this issue 1 year ago • 0 comments

System Info

  • OS: MacOS 14.2.1
  • Python Version (3.8.16)
  • djLint Version (1.34.1)
  • template language: Jinja

Issue

When you have a "default" config file in your project's root folder (e.g. a pyproject.toml file) and you provide a different config file in your CLI command (e.g. --configuration .djlintrc), the former will always override the latter. According to the docs this should not be the case:

Command line args will always override any settings in pyproject.toml.

I've found a possible cause of this: in the load_project_settings function there isn't a return after the provided config path has been loaded, causing the default paths to be checked, which will override the provided config.

How To Reproduce

Create two config files (pyproject.toml and .djlintrc) with different configuration (e.g. only add extend_exclude to the .djlintrc file) and run the following command:

djlint --configuration .djlintrc

The command will ignore the extend_exclude settings from .djlintrc.

Contents of .djlintrc/pyproject.toml [tool.djlint]

pyproject.toml

[tool.djlint]
profile = "jinja"

.djlintrc

{
    "profile": "jinja",
    "extend_exclude": "path/to/file.html"
}

willemo avatar Jan 16 '24 11:01 willemo