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

Added __lt__ function to Text class to enable sort functionality #3016

Closed
wants to merge 5 commits into from

Conversation

sharkusk
Copy link

@sharkusk sharkusk commented Jul 2, 2023

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

Basic change to enable sort functionality in Textual DataTable. Copied structure of contains function. Textualize/textual/issues/2261

Please hold... I need to add the gt function as well to cover both "str < Text" and "Text < str". -- Done.

rich/text.py Outdated
return self.plain < other
elif isinstance(other, Text):
return self.plain < other.plain
return False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should return NotImplemeted rather than False.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I originally did this as a shortcut for comparing with None, but that is bad form. I also removed the test cases accordingly.

@sharkusk sharkusk requested a review from willmcgugan July 29, 2023 20:25
@willmcgugan
Copy link
Collaborator

Probably not needed now. The DataTable has grown more sorting functionality.

@willmcgugan willmcgugan closed this Jul 1, 2024
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.

2 participants