Skip to content

Set soft_wrap in console.print json to prevent truncation#1654

Merged
willmcgugan merged 3 commits intoTextualize:masterfrom
jstvz:no-print_json-truncation
Nov 7, 2021
Merged

Set soft_wrap in console.print json to prevent truncation#1654
willmcgugan merged 3 commits intoTextualize:masterfrom
jstvz:no-print_json-truncation

Conversation

@jstvz
Copy link
Contributor

@jstvz jstvz commented Nov 6, 2021

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review. (😏 )

Description

This PR adds soft_wrap=True to print_json to prevent the truncation of values longer than the width of the console.

jstvz added 3 commits November 6, 2021 11:49
This commit adds soft_wrap=True to the invocation of print in
print_json. Without it, values wider than the console's width are
truncated, and the output will not be valid JSON.
@codecov
Copy link

codecov bot commented Nov 6, 2021

Codecov Report

Merging #1654 (07c6733) into master (25decd0) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1654   +/-   ##
=======================================
  Coverage   99.69%   99.69%           
=======================================
  Files          71       71           
  Lines        6862     6862           
=======================================
  Hits         6841     6841           
  Misses         21       21           
Flag Coverage Δ
unittests 99.69% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
rich/console.py 100.00% <100.00%> (ø)
rich/live.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b42555...07c6733. Read the comment docs.

@willmcgugan
Copy link
Member

Yep, thanks!

@willmcgugan willmcgugan merged commit 91224ff into Textualize:master Nov 7, 2021
@jstvz jstvz deleted the no-print_json-truncation branch November 7, 2021 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] print_json produces invalid JSON with long values

2 participants