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

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

Closed
danil51608 opened this issue Oct 3, 2023 · 6 comments
Closed

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

danil51608 opened this issue Oct 3, 2023 · 6 comments

Comments

@danil51608
Copy link

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
Copy link
Contributor

Delgan commented Oct 3, 2023

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
Copy link
Author

danil51608 commented Oct 23, 2023

@Delgan Hi!

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

@Delgan
Copy link
Contributor

Delgan commented Oct 23, 2023

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 pyscaffold/configupdater#123 to decide how I should implement the fix for .editorconfig files.

@danil51608
Copy link
Author

danil51608 commented Oct 24, 2023

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

@Delgan
Copy link
Contributor

Delgan commented Nov 18, 2023

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. 👍

@danil51608
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants