From d2e35257157ddae5f1fb2ce74d93889aba8ab780 Mon Sep 17 00:00:00 2001 From: Ken Kundert Date: Fri, 7 Feb 2025 11:37:00 -0800 Subject: [PATCH] nits --- clean | 2 +- doc/alternatives.rst | 6 ++---- examples/conversion-utilities/nestedtext-to-yaml | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/clean b/clean index ceeb407..917d8e6 100755 --- a/clean +++ b/clean @@ -1,7 +1,7 @@ #!/usr/bin/env sh shopt -s globstar -rm -rf generated_settings +rm -rf generated_settings .tox rm -rf .cache rm -rf data.nt tests/data.nt rm -rf /tmp/pytest-of-$USER diff --git a/doc/alternatives.rst b/doc/alternatives.rst index 86f0882..d129363 100644 --- a/doc/alternatives.rst +++ b/doc/alternatives.rst @@ -288,8 +288,7 @@ code more robust with little to no increase in complexity: The type of the value ``2`` is ambiguous; it may be integer or real. This may cause problems when combined into an array, such as ``[1.85, 1.94, 2, 2.09]``. A casually written program may choke on a non-homogeneous array - that consists of an integer among the floats. This is the reason that JSON - does not distinguish between integers and reals. + that consists of an integer among the floats. YAML is notorious for ambiguities because it allows unquoted strings. ``2`` is a valid integer, real, and string. Similarly, ``no`` is a valid Boolean @@ -390,8 +389,7 @@ code more robust with little to no increase in complexity: .. collapse:: Support for non-string types creates the requirement for quoting and - escaping, and ultimately leads to either verbosity (JSON) or ambiguity - (YAML). + escaping, and ultimately leads to either clutter (JSON) or ambiguity (YAML). Every additional supported data type brings a challenge; how to unambiguously distinguish it from the others. The challenge is particularly diff --git a/examples/conversion-utilities/nestedtext-to-yaml b/examples/conversion-utilities/nestedtext-to-yaml index 41d93db..b8aa0b8 100755 --- a/examples/conversion-utilities/nestedtext-to-yaml +++ b/examples/conversion-utilities/nestedtext-to-yaml @@ -41,7 +41,7 @@ try: if input_filename: input_path = Path(input_filename) data = nt.load(input_path, top='any', on_dup=on_dup) - yaml_content = yaml.dump(data) + yaml_content = yaml.dump(data, allow_unicode=True) output_path = input_path.with_suffix('.yaml') if output_path.exists(): if not cmdline['--force']: @@ -49,7 +49,7 @@ try: output_path.write_text(yaml_content, encoding='utf-8') else: data = nt.load(sys.stdin, top='any', on_dup=on_dup) - yaml_content = yaml.dump(data) + yaml_content = yaml.dump(data, allow_unicode=True) sys.stdout.write(yaml_content + '\n') except OSError as e: fatal(os_error(e))