flatpak-external-data-checker
flatpak-external-data-checker copied to clipboard
Prevent line truncation in YAML manifests
Hello,
In this pull request, the bot unnecessarily truncates line 34.
I'm not sure if Flathub has a "max line-length" guideline, but nevertheless this can be properly configured using the width
option of ruamel, e.g. at:
https://github.com/flathub/flatpak-external-data-checker/blob/88e46ff8ee3176b4fea752876304e4a249765462/src/lib/utils.py#L417-L422
We'd add:
# allows lines to have at most one thousand characters
_yaml.width = 1000
Thanks!
The code to write manifests back supports reading format preferences from .editorconfig
and applying them to JSON files.
It seems that a max_line_length
property is defined.
You could teach the dump_manifest
function to check for such a key and apply it?
Something like this except tested and passing checks and maybe not modifying global state?
diff --git a/src/lib/utils.py b/src/lib/utils.py
index c5f767f..1b83604 100644
--- a/src/lib/utils.py
+++ b/src/lib/utils.py
@@ -456,6 +456,10 @@ def dump_manifest(contents: t.Dict, manifest_path: t.Union[Path, str]):
else:
indent = 4
+ max_line_length = conf.get("max_line_length")
+ if isinstance(max_line_length, int):
+ _yaml.width = max_line_length
+
# Determine trailing newline preference
newline: t.Optional[bool]
if "insert_final_newline" in conf: