macisamuele / language-formatters-pre-commit-hooks

Collection of custom pre-commit hooks.
Apache License 2.0
116 stars 58 forks source link

.editorconfig is not a valid INI file with root specified #184

Open danil51608 opened 1 year ago

danil51608 commented 1 year ago

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
Delgan commented 1 year ago

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:

danil51608 commented 11 months ago

@Delgan Hi!

I found out you had updated the config-formatter. Sadly it doesn't fix the issue. The error is still present.

Delgan commented 11 months ago

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.

danil51608 commented 11 months ago

oh, my bad. I thought you had updated it with this commit :)

Delgan commented 10 months ago

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:

danil51608 commented 10 months ago

@Delgan Hey! Thanks a lot! Works great! 😊