Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.
https://rich.readthedocs.io/en/latest/
MIT License
49.65k stars 1.73k forks source link

use sets #3546

Closed willmcgugan closed 3 weeks ago

willmcgugan commented 3 weeks ago
codecov-commenter commented 3 weeks ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.25%. Comparing base (60f3b61) to head (02f3d14). Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
rich/cells.py 90.00% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #3546 +/- ## ========================================== - Coverage 98.27% 98.25% -0.02% ========================================== Files 74 74 Lines 8096 8095 -1 ========================================== - Hits 7956 7954 -2 - Misses 140 141 +1 ``` | [Flag](https://app.codecov.io/gh/Textualize/rich/pull/3546/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/Textualize/rich/pull/3546/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `98.25% <90.00%> (-0.02%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ofek commented 3 weeks ago

I would recommend lazily defining constants like that so import time is not affected, especially since that is critical for command line applications. See PEP 562 https://peps.python.org/pep-0562/

willmcgugan commented 3 weeks ago

Agree in principle, but this data is used by virtually anything Rich does. So it is always needed.

It also turns out that it is faster to compute this than import it. 0.11ms to compute version 0.39ms to import.

So on my Macbook at least, it is a win to compute it.

ofek commented 3 weeks ago

Definitely makes sense if it's used everywhere, thanks! I'm just always looking for ways to reduce the import time of Rich, currently I think it could be better but I haven't had much time to look into that.