macisamuele / language-formatters-pre-commit-hooks

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

Update pretty-format-ini tool #106

Closed macisamuele closed 2 years ago

macisamuele commented 2 years ago

⚠: This PR is in draft mode as some details still need to be addressed, once for all the following ini file is considered invalid ¯_(ツ)_/¯

[flake8]
extend-ignore =
    E203

This PR aims to address the ini parsing regression identified in #99.

The regression, as mentioned in the issue, was caused by the fact that we were hacking around to preserve comments in ini files.

In the original issue, #26, there was a possible recommendation on using configobj library as alternative.

After some analysis I came to realise that the suggested library is actually ensuring that the generated output is valid, proper indentation is enforced and comments are preserved.

Notable changes from this PR is that ini files like

key = value

would no longer be considered pretty because ini files need always to have sections, and if the section is missing then root is assumed. With the new change, the default section would still be made explicit, hence

[root]
key = value

would be the prettified version of the previous content

Closes #99 and #100

codecov[bot] commented 2 years ago

Codecov Report

Merging #106 (7c2da19) into master (9b73ca2) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #106   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          316       314    -2     
=========================================
- Hits           316       314    -2     
Impacted Files Coverage Δ
...e_formatters_pre_commit_hooks/pretty_format_ini.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9b73ca2...7c2da19. Read the comment docs.

macisamuele commented 2 years ago

113 fixed the issue in a much more elegant and accurate way :)

Thanks @Delgan for your effort.