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

Parse escape codes in Pretty repr #2470

Merged
merged 6 commits into from
Aug 17, 2022
Merged

Parse escape codes in Pretty repr #2470

merged 6 commits into from
Aug 17, 2022

Conversation

darrenburns
Copy link
Member

@darrenburns darrenburns commented Aug 16, 2022

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

Given the class:

    class Thing:
        def __repr__(self) -> str:
            return "Hello\x1b[38;5;239m World!"

Rich outputs:

Old version without ANSI parsing in pretty repr:
image

New version with ANSI parsing in pretty repr:
image

@codecov-commenter
Copy link

codecov-commenter commented Aug 17, 2022

Codecov Report

Merging #2470 (2c3180f) into master (3b7728b) will increase coverage by 2.88%.
The diff coverage is 55.55%.

@@            Coverage Diff             @@
##           master    #2470      +/-   ##
==========================================
+ Coverage   95.67%   98.55%   +2.88%     
==========================================
  Files          72       72              
  Lines        7767     7771       +4     
==========================================
+ Hits         7431     7659     +228     
+ Misses        336      112     -224     
Flag Coverage Δ
unittests 98.55% <55.55%> (+2.88%) ⬆️

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

Impacted Files Coverage Δ
rich/box.py 100.00% <ø> (ø)
rich/scope.py 100.00% <ø> (ø)
rich/console.py 97.36% <42.85%> (+0.64%) ⬆️
rich/pretty.py 99.22% <100.00%> (ø)
rich/repr.py 100.00% <100.00%> (ø)
rich/_win32_console.py 89.94% <0.00%> (+86.93%) ⬆️
rich/_windows_renderer.py 100.00% <0.00%> (+100.00%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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.

3 participants