-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add rich comparison methods for Text #2922
Add rich comparison methods for Text #2922
Conversation
rich/text.py
Outdated
return NotImplemented | ||
return self.plain > other.plain | ||
|
||
def __ne__(self, other: object) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have an __eq__
which takes in to account the spans (style information).
Having a __ne__
which is not the logical inverse of __eq__
is likely to create to have undesired effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmm I see. I'll address that to make __ne__
the logical inverse, np at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the docs:
By default, __ne__() delegates to __eq__() and inverts the result unless it is NotImplemented.
So I'm removing the unnecessary __ne__
implementation.
@willmcgugan is there anything else you would like me to address here? |
@willmcgugan any chance you could review this PR please? thanks |
@msempere was this deleted and closed for any particular reason? It'd be great to get this merged. |
@msempere I'd encourage you to re-open and give @willmcgugan and folks more time. They're quite busy but they will eventually review the PR, I think this would be a nice addition. |
@aaronst reopening this PR. Thanks for the ping. |
Type of changes
Checklist
Description
This pull request adds rich comparison methods to the
rich.Text
class in order to address the issue #2921. The added methods enable comparison of rich text objects using Python's rich comparison operators like <, <=, ==, !=, >= and >. These methods make it easy for users to compare rich text objects and perform conditional logic on them. With this addition, users can now leverage the full power of the Python programming language with rich text objects.Closes #2921