Skip to content

Commit

Permalink
Merge branch 'master' into progress-reader
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Mar 30, 2022
2 parents 76953e2 + 9f43ccc commit 7a870e4
Show file tree
Hide file tree
Showing 145 changed files with 2,824 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ jobs:
- uses: actions/checkout@v2
- run: python3 -m pip install codespell
- run: codespell --ignore-words-list="ba,fo,hel,revered,womens"
--skip="./README.de.md,./README.es.md,./README.sv.md,./README.fr.md,./README.de-ch.md,./README.hi.md,./README.pt-br.md,./README.it.md,*.svg"
--skip="./README.de.md,./README.es.md,./README.sv.md,./README.fr.md,./README.de-ch.md,./README.hi.md,./README.pt-br.md,./README.it.md,*.svg,./benchmarks/snippets.py"
24 changes: 24 additions & 0 deletions .github/workflows/update_benchmark_website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
release:
types: [ released ]


jobs:
asv-publish-and-copy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.10.2'
- run: 'pip install asv'
- run: 'asv publish'
- uses: cpina/github-action-push-to-another-repository@v1.4.1
name: 'Copy files to Textualize/rich-benchmarks repo'
env:
API_TOKEN_GITHUB: ${{ secrets.PUBLISH_ASV }}
with:
source-directory: /benchmarks/html
destination-github-username: Textualize
destination-repository-name: rich-benchmarks
user-email: darren@textualize.io
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,7 @@ venv.bak/

# mypy
.mypy_cache/

# airspeed velocity
benchmarks/env/
benchmarks/html/
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ repos:
rev: 22.1.0
hooks:
- id: black
exclude: ^benchmarks/
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
exclude: ^benchmarks/
args: ["--profile", "black"]
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Progress.open and Progress.wrap_file method to track the progress while reading from a file or file-like object https://github.com/willmcgugan/rich/pull/1759

### Added

- SVG export functionality https://github.com/Textualize/rich/pull/2101

### Fixed

- Add missing `end` keyword argument to `Text.from_markup`
- Fixed issue with decoding ANSI reset https://github.com/Textualize/rich/issues/2112

## [12.0.1] - 2022-03-22

### Changed

- Improve performance of cell_length https://github.com/Textualize/rich/pull/2061
- Improve performance of chop_cells https://github.com/Textualize/rich/pull/2077

### Fixed

- Fix capturing stdout on legacy Windows https://github.com/Textualize/rich/pull/2055
- Fix capturing stdout on legacy Windows https://github.com/Textualize/rich/pull/2066

## [12.0.0] - 2022-03-10

Expand Down Expand Up @@ -1677,7 +1689,8 @@ Major version bump for a breaking change to `Text.stylize signature`, which corr

- First official release, API still to be stabilized

[unreleased]: https://github.com/willmcgugan/rich/compare/v12.0.0...HEAD
[unreleased]: https://github.com/willmcgugan/rich/compare/v12.0.1...HEAD
[12.0.1]: https://github.com/willmcgugan/rich/compare/v12.0.0...v12.0.1
[12.0.0]: https://github.com/willmcgugan/rich/compare/v11.2.0...v12.0.0
[11.2.0]: https://github.com/willmcgugan/rich/compare/v11.1.0...v11.2.0
[11.1.0]: https://github.com/willmcgugan/rich/compare/v11.0.0...v11.1.0
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The following people have contributed to the development of Rich:
- [Andrew Kettmann](https://github.com/akettmann)
- [Martin Larralde](https://github.com/althonos)
- [Hedy Li](https://github.com/hedythedev)
- [Luka Mamukashvili](https://github.com/UltraStudioLTD)
- [Alexander Mancevice](https://github.com/amancevice)
- [Will McGugan](https://github.com/willmcgugan)
- [Paul McGuire](https://github.com/ptmcg)
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ format-check:
format:
black .
typecheck:
mypy -p rich --strict --no-incremental
mypy -p rich --no-incremental
typecheck-report:
mypy -p rich --strict --html-report mypy_report
mypy -p rich --html-report mypy_report
.PHONY: docs
docs:
cd docs; make html
34 changes: 34 additions & 0 deletions asv.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": 1,
"project": "rich",
"project_url": "https://github.com/Textualize/rich",
"repo": ".",
"repo_subdir": "",
"install_command": [
"in-dir={env_dir} python -mpip install {wheel_file}"
],
"uninstall_command": [
"return-code=any python -mpip uninstall -y {project}"
],
"build_command": [
"pip install poetry",
"python setup.py build",
"PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}"
],
"branches": [
"master"
],
"html_dir": "./benchmarks/html",
"results_dir": "./benchmarks/results",
"env_dir": "./benchmarks/env",
"dvcs": "git",
"environment_type": "virtualenv",
"install_timeout": 180,
"show_commit_url": "http://github.com/Textualize/rich/commit/",
"pythons": [
"3.10"
],
"matrix": {
"req": {}
}
}
17 changes: 17 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Benchmarking Rich

This directory contains benchmarks, for monitoring the performance of Rich over time.

The benchmarks use a tool called [Airspeed Velocity](https://asv.readthedocs.io/en/stable) (`asv`),
and we've configured it in [asv.conf.json](../asv.conf.json).

## Running Benchmarks

We strongly recommend running `asv run --help` for a full list of options, but
here are some common actions:

* You can run the benchmarks against the `master` branch with `asv run`.
* To test the most recent commit on your branch `asv run HEAD^!`.
* To generate a static website for browsing the results, run `asv publish`. The resulting HTML can be found in `benchmarks/html`.

The asv docs have some more examples [here](https://asv.readthedocs.io/en/stable/using.html#benchmarking).
Empty file added benchmarks/__init__.py
Empty file.
193 changes: 193 additions & 0 deletions benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
from io import StringIO

from benchmarks import snippets
from rich.color import Color, ColorSystem
from rich.console import Console
from rich.pretty import Pretty
from rich.style import Style
from rich.syntax import Syntax
from rich.table import Table
from rich.text import Text


class TextSuite:
def setup(self):
self.console = Console(
file=StringIO(), color_system="truecolor", legacy_windows=False
)
self.len_lorem_ipsum = len(snippets.LOREM_IPSUM)

def time_wrapping(self):
Text(snippets.LOREM_IPSUM).wrap(self.console, 12, overflow="fold")

def time_indent_guides(self):
Text(snippets.PYTHON_SNIPPET).with_indent_guides()

def time_fit(self):
Text(snippets.LOREM_IPSUM).fit(12)

def time_split(self):
Text(snippets.LOREM_IPSUM).split()

def time_divide(self):
Text(snippets.LOREM_IPSUM).divide(range(20, 100, 4))

def time_align_center(self):
Text(snippets.LOREM_IPSUM).align("center", width=self.len_lorem_ipsum * 3)

def time_render(self):
Text(snippets.LOREM_IPSUM).render(self.console)

def time_wrapping_unicode_heavy(self):
Text(snippets.UNICODE_HEAVY_TEXT).wrap(self.console, 12, overflow="fold")

def time_fit_unicode_heavy(self):
Text(snippets.UNICODE_HEAVY_TEXT).fit(12)

def time_split_unicode_heavy(self):
Text(snippets.UNICODE_HEAVY_TEXT).split()

def time_divide_unicode_heavy(self):
Text(snippets.UNICODE_HEAVY_TEXT).divide(range(20, 100, 4))

def time_align_center_unicode_heavy(self):
Text(snippets.UNICODE_HEAVY_TEXT).align(
"center", width=self.len_lorem_ipsum * 3
)

def time_render_unicode_heavy(self):
Text(snippets.UNICODE_HEAVY_TEXT).render(self.console)


class SyntaxWrappingSuite:
def setup(self):
self.console = Console(
file=StringIO(), color_system="truecolor", legacy_windows=False
)
self.syntax = Syntax(
code=snippets.PYTHON_SNIPPET, lexer="python", word_wrap=True
)

def time_text_thin_terminal_heavy_wrapping(self):
self._print_with_width(20)

def time_text_thin_terminal_medium_wrapping(self):
self._print_with_width(60)

def time_text_wide_terminal_no_wrapping(self):
self._print_with_width(100)

def _print_with_width(self, width):
self.console.print(self.syntax, width)


class TableSuite:
def time_table_no_wrapping(self):
self._print_table(width=100)

def time_table_heavy_wrapping(self):
self._print_table(width=30)

def _print_table(self, width):
table = Table(title="Star Wars Movies")
console = Console(
file=StringIO(), color_system="truecolor", legacy_windows=False, width=width
)
table.add_column("Released", justify="right", style="cyan", no_wrap=True)
table.add_column("Title", style="magenta")
table.add_column("Box Office", justify="right", style="green")
table.add_row(
"Dec 20, 2019", "[b]Star Wars[/]: The Rise of Skywalker", "$952,110,690"
)
table.add_row(
"May 25, 2018", "Solo: A [red][b]Star Wars[/] Story[/]", "$393,151,347"
)
table.add_row(
"Dec 15, 2017",
"[b red]Star Wars[/] Ep. V111: The Last Jedi",
"$1,332,539,889",
)
table.add_row(
"Dec 16, 2016", "Rogue One: A [blue]Star Wars[/] Story", "$1,332,439,889"
)
console.print(table)


class PrettySuite:
def setup(self):
self.console = Console(
file=StringIO(), color_system="truecolor", legacy_windows=False, width=100
)

def time_pretty(self):
pretty = Pretty(snippets.PYTHON_DICT)
self.console.print(pretty)

def time_pretty_indent_guides(self):
pretty = Pretty(snippets.PYTHON_DICT, indent_guides=True)
self.console.print(pretty)

def time_pretty_justify_center(self):
pretty = Pretty(snippets.PYTHON_DICT, justify="center")
self.console.print(pretty)


class StyleSuite:
def setup(self):
self.console = Console(
file=StringIO(), color_system="truecolor", legacy_windows=False, width=100
)

def time_parse_ansi(self):
Style.parse("red on blue")

def time_parse_hex(self):
Style.parse("#f0f0f0 on #e2e28a")

def time_parse_mixed_complex_style(self):
Style.parse("dim bold reverse #00ee00 on rgb(123,12,50)")


class ColorSuite:
def setup(self):
self.console = Console(
file=StringIO(), color_system="truecolor", legacy_windows=False, width=100
)
self.color = Color.parse("#0d1da0")

def time_downgrade_to_eight_bit(self):
self.color.downgrade(ColorSystem.EIGHT_BIT)

def time_downgrade_to_standard(self):
self.color.downgrade(ColorSystem.STANDARD)

def time_downgrade_to_windows(self):
self.color.downgrade(ColorSystem.WINDOWS)


class ColorSuiteCached:
def setup(self):
self.console = Console(
file=StringIO(), color_system="truecolor", legacy_windows=False, width=100
)
self.color = Color.parse("#0d1da0")
# Warm cache
self.color.downgrade(ColorSystem.EIGHT_BIT)
self.color.downgrade(ColorSystem.STANDARD)
self.color.downgrade(ColorSystem.WINDOWS)

def time_downgrade_to_eight_bit(self):
self.color.downgrade(ColorSystem.EIGHT_BIT)

def time_downgrade_to_standard(self):
self.color.downgrade(ColorSystem.STANDARD)

def time_downgrade_to_windows(self):
self.color.downgrade(ColorSystem.WINDOWS)


class SegmentSuite:
def setup(self):
self.console = Console(
file=StringIO(), color_system="truecolor", legacy_windows=False, width=100
)

0 comments on commit 7a870e4

Please sign in to comment.