language-formatters-pre-commit-hooks
language-formatters-pre-commit-hooks copied to clipboard
Upstream bug causes trailing spaces in pretty-format-yaml
trafficstars
Annoyingly I'm hitting this bug in ruamel.yaml when using the --line-width parameter:
https://sourceforge.net/p/ruamel-yaml/tickets/508/
For a simple example, there is a space after the : in the following:
conversion_rate_url:
https://www.banque-france.fr/fr/statistiques/taux-et-cours/taux-de-change-parites-fin-de-mois-2025-01
This conflicts with the trailing-whitespace pre-commit hook.
I worked around this by removing --line-width from the pretty-format-yaml arguments and correspondingly in my Python code by setting yaml.width = sys.maxsize in my ruamel yaml object to match the pre-commit hook.
Another (hacky) approach could be to trim newlines within this formatter as a second post-processing step, but I don't have the time.