language-formatters-pre-commit-hooks
language-formatters-pre-commit-hooks copied to clipboard
.editorconfig is not a valid INI file with root specified
The hook works well if root is not present in my .editconfig file. However it breaks with the below message if I add root = true to my .editconfig:
Pretty format INI....................................................................Failed
- hook id: pretty-format-ini
- exit code: 1
Input File .editorconfig is not a valid INI file: File contains no section headers.
file: '<string>', line: 1
'root = true\n'
My .editconfig
root = true
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 4
max_line_length = 80
Hi @danil51608.
This is because INI files with global values (such as root in your case) isn't valid as per Python configparser module.
I'll try to update the config-formatter library on which language-formatters-pre-commit-hooks depends to support this feature.
References:
@Delgan Hi!
I found out you had updated the config-formatter. Sadly it doesn't fix the issue. The error is still present.
Actually, I haven't updated config-formatter yet, so it's not surprising that the issue isn't fixed.
My library depends on another one, namely ConfigUpdater, and I was waiting for an answer in https://github.com/pyscaffold/configupdater/issues/123 to decide how I should implement the fix for .editorconfig files.
oh, my bad. I thought you had updated it with this commit :)
Hey @danil51608.
I just published version 1.2.0 of config-formatter which now supports INI files with no section headers.
If you force re-installation of language-formatters-pre-commit-hooks by clearing the cache of pre-commit, your .editorconfig should now be formatted as expected without error. :+1:
@Delgan Hey! Thanks a lot! Works great! 😊