From aab29c823975252fdb7e5da86c167cfcad01ae2d Mon Sep 17 00:00:00 2001 From: Ilito Torquato Date: Sun, 3 Oct 2021 20:47:28 -0300 Subject: [PATCH 01/10] correct misspelled words, grammatical errors, translates sentences and removes duplications --- README.pt-br.md | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/README.pt-br.md b/README.pt-br.md index 504052efa..1e0451822 100644 --- a/README.pt-br.md +++ b/README.pt-br.md @@ -18,19 +18,19 @@ • [हिन्दी readme](https://github.com/willmcgugan/rich/blob/master/README.hi.md) • [Português brasileiro readme](https://github.com/willmcgugan/rich/blob/master/README.pt-br.md) -Rich é uma biblioteca Python para _rich_ text e formatação de estilos no termial. +Rich é uma biblioteca Python para _rich_ text e formatação de estilos no terminal. -A [API do Rich](https://rich.readthedocs.io/en/latest/) permite adicionar cores e estilos no output do termial de forma fácil. Rich também permite formataçao de tabelas, barra de progresso, markdown, highlight de sintaxe de código fonte, rastreio de erros (traceback), e muito mais. +A [API do Rich](https://rich.readthedocs.io/en/latest/) permite adicionar cores e estilos no output do terminal de forma fácil. Rich também permite formataçao de tabelas, barra de progresso, markdown, highlight de sintaxe de código fonte, rastreio de erros (traceback) e muito mais. ![Funcões](https://github.com/willmcgugan/rich/raw/master/imgs/features.png) -Para mais detalhes, veja um vídeo de introdução so Rick em [calmcode.io](https://calmcode.io/rich/introduction.html) por [@fishnets88](https://twitter.com/fishnets88). +Para mais detalhes, veja um vídeo de introdução so Rich em [calmcode.io](https://calmcode.io/rich/introduction.html) por [@fishnets88](https://twitter.com/fishnets88). Veja aqui [o que estão falando sobre o Rich](https://www.willmcgugan.com/blog/pages/post/rich-tweets/). ## Compatibilidade -Rich funciona no Linux, OSX e Windows. True color / emoji funciona no novo Terminal do Windows, o terminal classico é limitado a 16 cores. Rich requer Python 3.6.1 or later. +Rich funciona no Linux, OSX e Windows. True color / emoji funciona no novo Terminal do Windows, o terminal classico é limitado a 16 cores. Rich requer Python 3.6.1 ou superior. Rich funciona com [Jupyter notebooks](https://jupyter.org/) sem a necessidade de configurações adicionais. @@ -111,7 +111,7 @@ Voce pode usar o objeto do Console para gerar facilmente uma saída para o termi ## Inspect do Rich -O Rich tem uma função [inspect](https://rich.readthedocs.io/en/latest/reference/init.html?highlight=inspect#rich.inspect) que gera um relatório de qualquer objeto no Python, como classes, instancias ou funções nativas. +O Rich tem uma função [inspect](https://rich.readthedocs.io/en/latest/reference/init.html?highlight=inspect#rich.inspect) que gera um relatório de qualquer objeto no Python, como classes, instâncias ou funções nativas. ```python >>> my_list = ["foo", "bar"] @@ -185,18 +185,18 @@ Para imprimir um emoji no console, coloque o nome do emoji entre dois ":" (dois 😃 🧛 💩 👍 🦝 ``` -Please use this feature wisely. +Por favor use esse recurso com sabedoria.
Tabelas -O Rich pode imprimir [tables](https://rich.readthedocs.io/en/latest/tables.html) flexiveis usando caracteres unicode como bordas. Existem várias opções de formatação de bordas, estilos, alinhamento das celulas etc. +O Rich pode imprimir [tables](https://rich.readthedocs.io/en/latest/tables.html) flexíveis usando caracteres unicode como bordas. Existem várias opções de formatação de bordas, estilos, alinhamento das celulas, etc. ![table movie](https://github.com/willmcgugan/rich/raw/master/imgs/table_movie.gif) -A animação acima foi gerada com o arquivo [table_movie.py](https://github.com/willmcgugan/rich/blob/master/examples/table_movie.py) da pasta de exeplos. +A animação acima foi gerada com o arquivo [table_movie.py](https://github.com/willmcgugan/rich/blob/master/examples/table_movie.py) da pasta de exemplos. Veja um exemplo mais simple: @@ -236,7 +236,7 @@ Que gera o seguinte resultado: Observe que o markup é renderizado da mesma for que em `print()` e `log()`. De fato, tudo que é renderizável pelo Rich pode ser incluído nos cabeçalhos ou linhas (até mesmo outras tabelas). -A class `Table` é inteligente o suficiente para ajustar o tamanho das colunas para caber na largura do terminal, quebrando o texto em novas linhas como necessário. Veja a seguir o mesmo exemplo, só que desta vez com um terminal menor do que o tamanho original da tabela: +A classe `Table` é inteligente o suficiente para ajustar o tamanho das colunas para caber na largura do terminal, quebrando o texto em novas linhas quando necessário. Veja a seguir o mesmo exemplo, só que desta vez com um terminal menor do que o tamanho original da tabela: ![table2](https://github.com/willmcgugan/rich/raw/master/imgs/table2.png) @@ -256,7 +256,6 @@ for step in track(range(100)): do_step(step) ``` -It's not much harder to add multiple progress bars. Here's an example taken from the docs: Adicionar multiplas barras de progresso também é simples. Veja outro exemplo que existe na documentação: ![progress](https://github.com/willmcgugan/rich/raw/master/imgs/progress.gif) @@ -265,7 +264,7 @@ As colunas podem ser configuradas pra mostrar qualquer detalho necessário. As c ![progress](https://github.com/willmcgugan/rich/raw/master/imgs/downloader.gif) -Para testar isso no seu terminal, use o arquivo [examples/downloader.py](https://github.com/willmcgugan/rich/blob/master/examples/downloader.py) para fazer o download de multiplas URLs simultaneamente, exibindo o progress de cada download. +Para testar isso no seu terminal, use o arquivo [examples/downloader.py](https://github.com/willmcgugan/rich/blob/master/examples/downloader.py) para fazer o download de multiplas URLs simultaneamente, exibindo o progresso de cada download.
@@ -319,7 +318,6 @@ Isso gera o seguinte resultado: ![markdown](https://github.com/willmcgugan/rich/raw/master/imgs/tree.png) -Veja o exemplo em [tree.py](https://github.com/willmcgugan/rich/blob/master/examples/tree.py) de um script that displays a tree view of any directory, similar to the linux `tree` command. Veja o exemplo em [tree.py](https://github.com/willmcgugan/rich/blob/master/examples/tree.py) de um código que gera uma árvore de exibição de um dicionário, semelhante ao comando `tree` do linux. @@ -340,7 +338,6 @@ directory = os.listdir(sys.argv[1]) print(Columns(directory)) ``` -The following screenshot is the output from the [columns example](https://github.com/willmcgugan/rich/blob/master/examples/columns.py) which displays data pulled from an API in columns: O screenshot a seguir é do resultado do [exemplo de colunas](https://github.com/willmcgugan/rich/blob/master/examples/columns.py) formatando em colunas os dados extraidos de uma API: ![columns](https://github.com/willmcgugan/rich/raw/master/imgs/columns.png) @@ -444,14 +441,14 @@ Aqui estão alguns projetos que usam o Rich: - [cansarigol/pdbr](https://github.com/cansarigol/pdbr) pdb + Rich para auxiliar no debug - [plant99/felicette](https://github.com/plant99/felicette) - Imagem de satélites para tolos. + Imagem de satélites para iniciantes. - [seleniumbase/SeleniumBase](https://github.com/seleniumbase/SeleniumBase) Automatize & teste 10x mais rápido com Selenium & pytest. Baterias inclusas. - [smacke/ffsubsync](https://github.com/smacke/ffsubsync) Automagicamente sincronize legendas com vídeos. - [tryolabs/norfair](https://github.com/tryolabs/norfair) Biblioteca Python para adicionar rastreio em tempo real de objetos 2D em qualquer detector. -- [ansible/ansible-lint](https://github.com/ansible/ansible-lint) Ansible-lint verifica boas praticas e comportamento que podem ser melhorados. +- [ansible/ansible-lint](https://github.com/ansible/ansible-lint) Ansible-lint verifica boas práticas e comportamento que podem ser melhorados. - [ansible-community/molecule](https://github.com/ansible-community/molecule) Framework de test para Ansible Molecule - +[Muitos outros](https://github.com/willmcgugan/rich/network/dependents)! From ca8a509d08c6e25b2a5ab029d0b2783673cef7f0 Mon Sep 17 00:00:00 2001 From: 0xflotus <0xflotus@gmail.com> Date: Tue, 5 Oct 2021 23:56:54 +0200 Subject: [PATCH 02/10] fix: small error in docs --- docs/source/console.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/console.rst b/docs/source/console.rst index c5de7b5e3..6ea6e0926 100644 --- a/docs/source/console.rst +++ b/docs/source/console.rst @@ -384,7 +384,7 @@ Interactive mode Rich will remove animations such as progress bars and status indicators when not writing to a terminal as you probably don't want to write these out to a text file (for example). You can override this behavior by setting the ``force_interactive`` argument on the constructor. Set it to True to enable animations or False to disable them. .. note:: - Some CI systems support ANSI color and style but not anything that moves the cursor or selectively refreshes parts of the terminal. For these you might want to set ``force_terminal`` to ``True`` and ``force_interactve`` to ``False``. + Some CI systems support ANSI color and style but not anything that moves the cursor or selectively refreshes parts of the terminal. For these you might want to set ``force_terminal`` to ``True`` and ``force_interactive`` to ``False``. Environment variables --------------------- From 3f192d3f58181653673891bb085be07ab6b1d94a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Oct 2021 13:07:02 +0000 Subject: [PATCH 03/10] Bump pytest-cov from 2.12.1 to 3.0.0 Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.12.1 to 3.0.0. - [Release notes](https://github.com/pytest-dev/pytest-cov/releases) - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.12.1...v3.0.0) --- updated-dependencies: - dependency-name: pytest-cov dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- poetry.lock | 36 +++++++++++++++++++++++++++++------- pyproject.toml | 2 +- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/poetry.lock b/poetry.lock index 9bd5f60d4..3374de9de 100644 --- a/poetry.lock +++ b/poetry.lock @@ -152,6 +152,9 @@ category = "dev" optional = false python-versions = ">=3.6" +[package.dependencies] +tomli = {version = "*", optional = true, markers = "extra == \"toml\""} + [package.extras] toml = ["tomli"] @@ -713,16 +716,15 @@ testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xm [[package]] name = "pytest-cov" -version = "2.12.1" +version = "3.0.0" description = "Pytest plugin for measuring coverage." category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +python-versions = ">=3.6" [package.dependencies] -coverage = ">=5.2.1" +coverage = {version = ">=5.2.1", extras = ["toml"]} pytest = ">=4.6" -toml = "*" [package.extras] testing = ["fields", "hunter", "process-tests", "six", "pytest-xdist", "virtualenv"] @@ -931,7 +933,7 @@ jupyter = ["ipywidgets"] [metadata] lock-version = "1.1" python-versions = "^3.6.2" -content-hash = "97432dbcf77dd3aaa24f0cd35a7e70df03b64fe3b0397618bcb566507dcc40c3" +content-hash = "0215d2db0f3d908a013cd733e8019891e208c9b6b733a05658d49e96a8be3108" [metadata.files] appnope = [ @@ -1140,12 +1142,22 @@ jupyterlab-widgets = [ {file = "jupyterlab_widgets-1.0.2.tar.gz", hash = "sha256:7885092b2b96bf189c3a705cc3c412a4472ec5e8382d0b47219a66cccae73cfa"}, ] markupsafe = [ + {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-win32.whl", hash = "sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:0955295dd5eec6cb6cc2fe1698f4c6d84af2e92de33fbcac4111913cd100a6ff"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:0446679737af14f45767963a1a9ef7620189912317d095f2d9ffa183a4d25d2b"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:f826e31d18b516f653fe296d967d700fddad5901ae07c622bb3705955e1faa94"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:fa130dd50c57d53368c9d59395cb5526eda596d3ffe36666cd81a44d56e48872"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:905fec760bd2fa1388bb5b489ee8ee5f7291d692638ea5f67982d968366bef9f"}, + {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c"}, + {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724"}, + {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-win32.whl", hash = "sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567"}, @@ -1154,14 +1166,21 @@ markupsafe = [ {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:d7f9850398e85aba693bb640262d3611788b1f29a79f0c93c565694658f4071f"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:6a7fae0dd14cf60ad5ff42baa2e95727c3d81ded453457771d02b7d2b3f9c0c2"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:b7f2d075102dc8c794cbde1947378051c4e5180d52d276987b8d28a3bd58c17d"}, + {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85"}, + {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6"}, + {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-win32.whl", hash = "sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914"}, + {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9"}, {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:be98f628055368795d818ebf93da628541e10b75b41c559fdf36d104c5787066"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:1d609f577dc6e1aa17d746f8bd3c31aa4d258f4070d61b2aa5c4166c1539de35"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7d91275b0245b1da4d4cfa07e0faedd5b0812efc15b702576d103293e252af1b"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:47ab1e7b91c098ab893b828deafa1203de86d0bc6ab587b160f78fe6c4011f75"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:97383d78eb34da7e1fa37dd273c20ad4320929af65d156e35a5e2d89566d9dfb"}, + {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b"}, + {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a"}, + {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6"}, {file = "MarkupSafe-2.0.1-cp38-cp38-win32.whl", hash = "sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64"}, {file = "MarkupSafe-2.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833"}, {file = "MarkupSafe-2.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26"}, @@ -1171,6 +1190,9 @@ markupsafe = [ {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:4efca8f86c54b22348a5467704e3fec767b2db12fc39c6d963168ab1d3fc9135"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:ab3ef638ace319fa26553db0624c4699e31a28bb2a835c5faca8f8acf6a5a902"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:f8ba0e8349a38d3001fae7eadded3f6606f0da5d748ee53cc1dab1d6527b9509"}, + {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1"}, + {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac"}, + {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6"}, {file = "MarkupSafe-2.0.1-cp39-cp39-win32.whl", hash = "sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74"}, {file = "MarkupSafe-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8"}, {file = "MarkupSafe-2.0.1.tar.gz", hash = "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a"}, @@ -1316,8 +1338,8 @@ pytest = [ {file = "pytest-6.2.5.tar.gz", hash = "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89"}, ] pytest-cov = [ - {file = "pytest-cov-2.12.1.tar.gz", hash = "sha256:261ceeb8c227b726249b376b8526b600f38667ee314f910353fa318caa01f4d7"}, - {file = "pytest_cov-2.12.1-py2.py3-none-any.whl", hash = "sha256:261bb9e47e65bd099c89c3edf92972865210c36813f80ede5277dceb77a4a62a"}, + {file = "pytest-cov-3.0.0.tar.gz", hash = "sha256:e7f0f5b1617d2210a2cabc266dfe2f4c75a8d32fb89eafb7ad9d06f6d076d470"}, + {file = "pytest_cov-3.0.0-py3-none-any.whl", hash = "sha256:578d5d15ac4a25e5f961c938b85a05b09fdaae9deef3bb6de9a6e766622ca7a6"}, ] python-dateutil = [ {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, diff --git a/pyproject.toml b/pyproject.toml index a0b8600c8..6d1d265b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ jupyter = ["ipywidgets"] pytest = "^6.2.5" black = "^21.9b0" mypy = "^0.910" -pytest-cov = "^2.12.1" +pytest-cov = "^3.0.0" attrs = "^21.2.0" types-dataclasses = "^0.1.7" From 510cec7116dcd64ae6f3da2ae72cada7f36c9e78 Mon Sep 17 00:00:00 2001 From: Troy Williams Date: Sat, 9 Oct 2021 09:37:08 -0400 Subject: [PATCH 04/10] Added section `Automatic Traceback Handler` to traceback.rst. It describes a method to automatically install the rich.traceback without having to include the code in your modules. --- docs/source/traceback.rst | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/source/traceback.rst b/docs/source/traceback.rst index 6b1a6f9ce..120ca0ceb 100644 --- a/docs/source/traceback.rst +++ b/docs/source/traceback.rst @@ -26,7 +26,7 @@ The ``show_locals=True`` parameter causes Rich to display the value of local var See `exception.py `_ for a larger example. -Traceback handler +Traceback Handler ----------------- Rich can be installed as the default traceback handler so that all uncaught exceptions will be rendered with highlighting. Here's how:: @@ -36,6 +36,27 @@ Rich can be installed as the default traceback handler so that all uncaught exce There are a few options to configure the traceback handler, see :func:`~rich.traceback.install` for details. +Automatic Traceback Handler +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In some cases you may want to have the traceback handler installed automatically without having to worry about importing the code in your module. You can do that by modifying the `sitecustomize.py` in your virtual environment. Typically it would be located in your virtual environment path, underneath the `site-packages` folder, something like this:: + + ./.venv/lib/python3.9/site-packages/sitecustomize.py + +In most cases this file will not exist. If it doesn't exist, you can create it by:: + + $ touch .venv/lib/python3.9/site-packages/sitecustomize.py + +Add the following code to the file:: + + from rich.traceback import install + install(show_locals=True) + +At this point, the traceback will be installed for any code that is run within the virtual environment. + +.. note:: + If you plan on sharing your code, it is probably best to include the traceback install in your main entry point module. + Suppressing Frames ------------------ @@ -73,4 +94,5 @@ Here's an example of printing an recursive error:: try: foo(1) except Exception: - console.print_exception(max_frames=20) \ No newline at end of file + console.print_exception(max_frames=20) + From 76a7b89cd8c935dec87ac89ec36b174c9a0636c4 Mon Sep 17 00:00:00 2001 From: GBeauregard Date: Tue, 12 Oct 2021 16:11:24 -0700 Subject: [PATCH 05/10] change lambda with broken typing to def This function is annotated with a Callable[] syntax that works only because of a bug with attribute methods in the current mypy. In a future release of mypy this is fixed and this will start throwing an error. If a lambda is needed the only way to type it correctly would be defining a protocol and using __call__, but I've opted to replace the lambda with a def instead since it's much simpler. --- rich/pager.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rich/pager.py b/rich/pager.py index 4290021f2..ea9bdf08f 100644 --- a/rich/pager.py +++ b/rich/pager.py @@ -17,9 +17,8 @@ def show(self, content: str) -> None: class SystemPager(Pager): """Uses the pager installed on the system.""" - _pager: Callable[[Any, str], Any] = lambda self, content: __import__("pydoc").pager( - content - ) + def _pager(self, content: str) -> Any: + return __import__("pydoc").pager(content) def show(self, content: str) -> None: """Use the same pager used by pydoc.""" From 19961c1a6a7448295377bb52479ac937e2bfdf9b Mon Sep 17 00:00:00 2001 From: GBeauregard Date: Tue, 12 Oct 2021 16:13:16 -0700 Subject: [PATCH 06/10] Fix annotation for callable that needed optional This is annotated with Callable[], but it's being assigned a getattr that could be None. Add Optional to fix the typing. This mistake wasn't caught by mypy on current release, but it will start causing errors in the future. --- rich/measure.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rich/measure.py b/rich/measure.py index 4382184f6..b57aa9c85 100644 --- a/rich/measure.py +++ b/rich/measure.py @@ -100,8 +100,8 @@ def get( if hasattr(renderable, "__rich__"): renderable = renderable.__rich__() # type: ignore if is_renderable(renderable): - get_console_width: Callable[ - ["Console", "ConsoleOptions"], "Measurement" + get_console_width: Optional[ + Callable[["Console", "ConsoleOptions"], "Measurement"] ] = getattr(renderable, "__rich_measure__", None) if get_console_width is not None: render_width = ( From 67ef9a86c041b5b4d5f87a730d047aa3ea944633 Mon Sep 17 00:00:00 2001 From: GBeauregard Date: Tue, 12 Oct 2021 16:16:33 -0700 Subject: [PATCH 07/10] update CONTRIBUTORS.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9b5f9b6c7..2f5959783 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -4,6 +4,7 @@ The following people have contributed to the development of Rich: +- [Gregory Beauregard](https://github.com/GBeauregard/pyffstream) - [Pete Davison](https://github.com/pd93) - [Oleksis Fraga](https://github.com/oleksis) - [Finn Hughes](https://github.com/finnhughes) From 6f5ced7db567f49075ff9d1ddc769beb17f538a5 Mon Sep 17 00:00:00 2001 From: GBeauregard Date: Wed, 13 Oct 2021 12:48:34 -0700 Subject: [PATCH 08/10] Fixed incorrect justify default Changed incorrect DEFAULT_OVERFLOW to DEFAULT_JUSTIFY. This wasn't caught by mypy because self.justify was incorrectly cast to a JustifyMethod instead of Optional[JustifyMethod] which made mypy think the remaining or values could never be evaluated. The cast is unneeded for mypy so removed it entirely. --- rich/text.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rich/text.py b/rich/text.py index cce93274e..eee446d12 100644 --- a/rich/text.py +++ b/rich/text.py @@ -555,9 +555,7 @@ def __rich_console__( self, console: "Console", options: "ConsoleOptions" ) -> Iterable[Segment]: tab_size: int = console.tab_size or self.tab_size or 8 - justify = ( - cast("JustifyMethod", self.justify) or options.justify or DEFAULT_OVERFLOW - ) + justify = self.justify or options.justify or DEFAULT_JUSTIFY overflow = ( cast("OverflowMethod", self.overflow) From 69f197c65fdef9e437c76347123f5e0e535b6ddc Mon Sep 17 00:00:00 2001 From: GBeauregard Date: Wed, 13 Oct 2021 12:58:30 -0700 Subject: [PATCH 09/10] Remove wrong casts a la previous commit There were no new runtime bugs to find here, but they could conceal bugs in the future. Some type checkers will widen literals when assigning in an init, so we clarify we keep the self.justify/overflow as the string literals in order to keep type checking as strict as possible everywhere. --- rich/text.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/rich/text.py b/rich/text.py index eee446d12..0ecdeae4b 100644 --- a/rich/text.py +++ b/rich/text.py @@ -14,7 +14,6 @@ Optional, Tuple, Union, - cast, ) from ._loop import loop_last @@ -144,8 +143,8 @@ def __init__( ) -> None: self._text = [strip_control_codes(text)] self.style = style - self.justify = justify - self.overflow = overflow + self.justify: Optional["JustifyMethod"] = justify + self.overflow: Optional["OverflowMethod"] = overflow self.no_wrap = no_wrap self.end = end self.tab_size = tab_size @@ -557,11 +556,7 @@ def __rich_console__( tab_size: int = console.tab_size or self.tab_size or 8 justify = self.justify or options.justify or DEFAULT_JUSTIFY - overflow = ( - cast("OverflowMethod", self.overflow) - or options.overflow - or DEFAULT_OVERFLOW - ) + overflow = self.overflow or options.overflow or DEFAULT_OVERFLOW lines = self.wrap( console, @@ -1063,10 +1058,8 @@ def wrap( Returns: Lines: Number of lines. """ - wrap_justify = cast("JustifyMethod", justify or self.justify) or DEFAULT_JUSTIFY - wrap_overflow = ( - cast("OverflowMethod", overflow or self.overflow) or DEFAULT_OVERFLOW - ) + wrap_justify = justify or self.justify or DEFAULT_JUSTIFY + wrap_overflow = overflow or self.overflow or DEFAULT_OVERFLOW no_wrap = pick_bool(no_wrap, self.no_wrap, False) or overflow == "ignore" From 8cfd988cae6af85d2210ceb4d83ba770111a7cc4 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Fri, 15 Oct 2021 09:54:20 +0100 Subject: [PATCH 10/10] Added link to Italian Readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ae8cd1026..dabe67a4b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ • [Schwizerdütsch readme](https://github.com/willmcgugan/rich/blob/master/README.de-ch.md) • [हिन्दी readme](https://github.com/willmcgugan/rich/blob/master/README.hi.md) • [Português brasileiro readme](https://github.com/willmcgugan/rich/blob/master/README.pt-br.md) + • [Italian readme](https://github.com/willmcgugan/rich/blob/master/README.it.md) Rich is a Python library for _rich_ text and beautiful formatting in the terminal.