Skip to content

Commit

Permalink
Work around type of yaml.safe_dump's width parameter
Browse files Browse the repository at this point in the history
It works with inf, but doesn't officially support float. I'm not aware
of another way to prevent line wrapping though.
  • Loading branch information
dseomn committed Sep 24, 2023
1 parent c0d33e5 commit 3394c20
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
9 changes: 7 additions & 2 deletions rock_paper_sand/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import dataclasses
import difflib
import functools
import typing
from typing import Any, Self

from google.protobuf import json_format
Expand Down Expand Up @@ -97,10 +98,14 @@ def _lint_sort(self) -> Mapping[str, Any]:
"sort": "".join(
difflib.unified_diff(
yaml.safe_dump(
names, allow_unicode=True, width=float("inf")
names,
allow_unicode=True,
width=typing.cast(int, float("inf")),
).splitlines(keepends=True),
yaml.safe_dump(
names_sorted, allow_unicode=True, width=float("inf")
names_sorted,
allow_unicode=True,
width=typing.cast(int, float("inf")),
).splitlines(keepends=True),
fromfile="media-names",
tofile="media-names-sorted",
Expand Down
3 changes: 2 additions & 1 deletion rock_paper_sand/config_subcommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import argparse
import sys
import typing

import yaml

Expand All @@ -38,7 +39,7 @@ def run(self, args: argparse.Namespace):
default_style="|",
sort_keys=False,
allow_unicode=True,
width=float("inf"),
width=typing.cast(int, float("inf")),
),
end="",
)
Expand Down
3 changes: 2 additions & 1 deletion rock_paper_sand/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import email.message
import json
import subprocess
import typing
from typing import Any

import yaml
Expand Down Expand Up @@ -67,7 +68,7 @@ def _dump_for_email(results: Any) -> str:
results,
sort_keys=False,
allow_unicode=True,
width=float("inf"),
width=typing.cast(int, float("inf")),
)


Expand Down
3 changes: 2 additions & 1 deletion rock_paper_sand/reports_subcommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""Reports commands."""

import argparse
import typing

import yaml

Expand Down Expand Up @@ -71,7 +72,7 @@ def run(self, args: argparse.Namespace):
results,
sort_keys=False,
allow_unicode=True,
width=float("inf"),
width=typing.cast(int, float("inf")),
),
end="",
)
Expand Down

0 comments on commit 3394c20

Please sign in to comment.