language-formatters-pre-commit-hooks icon indicating copy to clipboard operation
language-formatters-pre-commit-hooks copied to clipboard

Upstream bug causes trailing spaces in pretty-format-yaml

Open maresb opened this issue 8 months ago • 1 comments
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.

maresb avatar Mar 15 '25 13:03 maresb

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.

maresb avatar Mar 15 '25 14:03 maresb