Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json: add support for default encoder #1547

Merged
merged 1 commit into from
Oct 16, 2021

Conversation

skshetry
Copy link
Contributor

@skshetry skshetry commented Oct 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

Please describe your changes here. If this fixes a bug, please link to the issue, if possible.

This adds a default encoder support for JSON.from_data which will be called for objects which json.dumps cannot serialize by default.

@codecov
Copy link

codecov bot commented Oct 16, 2021

Codecov Report

Merging #1547 (8375ccf) into master (79848f8) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1547      +/-   ##
==========================================
- Coverage   99.73%   99.69%   -0.04%     
==========================================
  Files          71       71              
  Lines        6788     6947     +159     
==========================================
+ Hits         6770     6926     +156     
- Misses         18       21       +3     
Flag Coverage Δ
unittests 99.69% <100.00%> (-0.04%) ⬇️

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

Impacted Files Coverage Δ
rich/json.py 100.00% <100.00%> (ø)
rich/pager.py 90.00% <0.00%> (-10.00%) ⬇️
rich/pretty.py 98.15% <0.00%> (-0.60%) ⬇️
rich/text.py 100.00% <0.00%> (ø)
rich/table.py 100.00% <0.00%> (ø)
rich/prompt.py 100.00% <0.00%> (ø)
rich/console.py 100.00% <0.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 473eac5...8375ccf. Read the comment docs.

@willmcgugan
Copy link
Collaborator

Thanks

@willmcgugan willmcgugan merged commit 735b60f into Textualize:master Oct 16, 2021
@skshetry skshetry deleted the json-default branch October 16, 2021 10:04
skshetry added a commit to skshetry/dvc that referenced this pull request Nov 7, 2021
It comes with the support for no. of parameters that matches with json.dumps.
See: Textualize/rich#1547 and
Textualize/rich#1644.

Also added support for printing json to stderr. Before we used to use json.dumps
and rich.json.JSON based on isatty. Now we use rich.print_json on both
tty and non-tty conditions, which may avoid different behaviours in the
future.
efiop pushed a commit to iterative/dvc that referenced this pull request Nov 7, 2021
It comes with the support for no. of parameters that matches with json.dumps.
See: Textualize/rich#1547 and
Textualize/rich#1644.

Also added support for printing json to stderr. Before we used to use json.dumps
and rich.json.JSON based on isatty. Now we use rich.print_json on both
tty and non-tty conditions, which may avoid different behaviours in the
future.
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.

None yet

2 participants