Skip to content

Commit

Permalink
Merge pull request #2538 from onlyacat/fix_default_ensure_ascii
Browse files Browse the repository at this point in the history
fix default value of ensure_ascii to match comments
  • Loading branch information
willmcgugan committed Sep 23, 2022
2 parents f0d8435 + 4e704fa commit 0099f50
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -22,8 +22,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix NO_COLOR support on legacy Windows https://github.com/Textualize/rich/pull/2458
- Fix pretty printer handling of cyclic references https://github.com/Textualize/rich/pull/2524
- Fix missing `mode` property on file wrapper breaking uploads via `requests` https://github.com/Textualize/rich/pull/2495
- Fix mismatching default value of parameter `ensure_ascii` https://github.com/Textualize/rich/pull/2538
- Remove unused height parameter in `Layout` class https://github.com/Textualize/rich/pull/2540


### Changed

- Removed border from code blocks in Markdown
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Expand Up @@ -55,3 +55,4 @@ The following people have contributed to the development of Rich:
- [Motahhar Mokfi](https://github.com/motahhar)
- [Tomer Shalev](https://github.com/tomers)
- [Serkan UYSAL](https://github.com/uysalserkan)
- [Zhe Huang](https://github.com/onlyacat)
2 changes: 1 addition & 1 deletion rich/__init__.py
Expand Up @@ -81,7 +81,7 @@ def print_json(
indent: Union[None, int, str] = 2,
highlight: bool = True,
skip_keys: bool = False,
ensure_ascii: bool = True,
ensure_ascii: bool = False,
check_circular: bool = True,
allow_nan: bool = True,
default: Optional[Callable[[Any], Any]] = None,
Expand Down
2 changes: 1 addition & 1 deletion rich/console.py
Expand Up @@ -1722,7 +1722,7 @@ def print_json(
indent: Union[None, int, str] = 2,
highlight: bool = True,
skip_keys: bool = False,
ensure_ascii: bool = True,
ensure_ascii: bool = False,
check_circular: bool = True,
allow_nan: bool = True,
default: Optional[Callable[[Any], Any]] = None,
Expand Down
4 changes: 2 additions & 2 deletions rich/json.py
Expand Up @@ -27,7 +27,7 @@ def __init__(
indent: Union[None, int, str] = 2,
highlight: bool = True,
skip_keys: bool = False,
ensure_ascii: bool = True,
ensure_ascii: bool = False,
check_circular: bool = True,
allow_nan: bool = True,
default: Optional[Callable[[Any], Any]] = None,
Expand Down Expand Up @@ -56,7 +56,7 @@ def from_data(
indent: Union[None, int, str] = 2,
highlight: bool = True,
skip_keys: bool = False,
ensure_ascii: bool = True,
ensure_ascii: bool = False,
check_circular: bool = True,
allow_nan: bool = True,
default: Optional[Callable[[Any], Any]] = None,
Expand Down
9 changes: 9 additions & 0 deletions tests/test_console.py
Expand Up @@ -240,6 +240,15 @@ def test_print_json_ensure_ascii():
assert result == expected


def test_print_json_with_default_ensure_ascii():
console = Console(file=io.StringIO(), color_system="truecolor")
console.print_json(data={"foo": "💩"})
result = console.file.getvalue()
print(repr(result))
expected = '\x1b[1m{\x1b[0m\n \x1b[1;34m"foo"\x1b[0m: \x1b[32m"💩"\x1b[0m\n\x1b[1m}\x1b[0m\n'
assert result == expected


def test_print_json_indent_none():
console = Console(file=io.StringIO(), color_system="truecolor")
data = {"name": "apple", "count": 1}
Expand Down

0 comments on commit 0099f50

Please sign in to comment.