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

[BUG] rich.pretty.pprint is too eager to highlight a closing > #2468

Closed
davep opened this issue Aug 16, 2022 · 1 comment · Fixed by #2565
Closed

[BUG] rich.pretty.pprint is too eager to highlight a closing > #2468

davep opened this issue Aug 16, 2022 · 1 comment · Fixed by #2565
Assignees

Comments

@davep
Copy link
Contributor

davep commented Aug 16, 2022

Describe the bug

Given this code:

from rich.pretty import pprint as print

class TestClass:

    def __repr__( self ) -> str:
        return '<Outer: some: "value", plus: <Some: other: "child object">, and: 42>'

print( TestClass() )

pprint applies bold to the first instance of < and the first instance of '>', resulting in an unbalanced pair of highlights if there is another instance of a '</>'-wrapped object in the __repr__ return value.

Screenshot 2022-08-16 at 11 28 31

Platform
macOS, iTerm2.

davep added a commit to davep/rich that referenced this issue Oct 10, 2022
Addressing Textualize#2468; before this change the tag-matching code was non-greedy,
resulting in an unbalanced match if there were tags within tags. This
change makes this greedy to ensure that there's a better chance of the match
being balanced.
@davep davep linked a pull request Oct 11, 2022 that will close this issue
9 tasks
@github-actions
Copy link

Did I solve your problem?

Why not buy the devs a coffee to say thanks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant