From cb58cfd5c8dc26a9cb56c86ab0c88b14fdb1550e Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sun, 12 Apr 2020 13:08:47 +0100 Subject: [PATCH 1/2] pull request template --- CHANGELOG.md | 2 +- pull_request_template.md | 18 ++++++++++++++++++ pyproject.toml | 2 +- rich/console.py | 2 +- rich/table.py | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 pull_request_template.md diff --git a/CHANGELOG.md b/CHANGELOG.md index e00f46012..085b2e105 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Added force_terminal option to Console.**init** +- Added force_terminal option to `Console.__init__` ### Added diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 000000000..98b952123 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,18 @@ +## Type of changes + +- [ ] Bug fix +- [ ] New feature +- [ ] Documentation / docstrings +- [ ] Tests +- [ ] Other + +## Checklist + +- [ ] I've run the latest [black](https://github.com/ambv/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 + +Please describe your changes here. If this fixes a bug, please link to the issue, if possible. diff --git a/pyproject.toml b/pyproject.toml index d6ef9a7f2..1f1999a72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "rich" homepage = "https://github.com/willmcgugan/rich" documentation = "https://rich.readthedocs.io/en/latest/" -version = "0.8.8" +version = "0.8.9" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" authors = ["Will McGugan "] license = "MIT" diff --git a/rich/console.py b/rich/console.py index cbe3c335d..e8697af19 100644 --- a/rich/console.py +++ b/rich/console.py @@ -639,7 +639,7 @@ def get_style( return self.get_style(default) if " " in name: raise - raise errors.MissingStyle(f"No style named {name!r}; {error}") + raise errors.MissingStyle(f"Failed to get style; {error}") def _collect_renderables( self, diff --git a/rich/table.py b/rich/table.py index 1b16df044..c6919ee46 100644 --- a/rich/table.py +++ b/rich/table.py @@ -517,7 +517,7 @@ def _render( from .console import Console c = Console() - table = Table(row_styles=["red", "yellow"], expand=True) + table = Table(row_styles=["grey44", "white"], expand=True) table.add_column(no_wrap=True) table.add_column() table.add_row( From 507f54995a2fb330440cb4fc9d7c6335350bd6a2 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sun, 12 Apr 2020 15:33:12 +0100 Subject: [PATCH 2/2] fix row_style applying to header --- CHANGELOG.md | 6 ++++++ pyproject.toml | 2 +- rich/table.py | 11 ++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 085b2e105..ba2fc8c69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.8.10] - 2020-04-12 + +### Fixed + +- Fix row_styles applying to header + ## [0.8.9] - 2020-04-12 ### Changed diff --git a/pyproject.toml b/pyproject.toml index 1f1999a72..75c92f190 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "rich" homepage = "https://github.com/willmcgugan/rich" documentation = "https://rich.readthedocs.io/en/latest/" -version = "0.8.9" +version = "0.8.10" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" authors = ["Will McGugan "] license = "MIT" diff --git a/rich/table.py b/rich/table.py index c6919ee46..bb1728dfb 100644 --- a/rich/table.py +++ b/rich/table.py @@ -453,7 +453,12 @@ def _render( for index, (first, last, row) in enumerate(loop_first_last(rows)): max_height = 1 cells: List[List[List[Segment]]] = [] - row_style = get_style(get_row_style(index)) + if show_header and first: + row_style = Style() + else: + row_style = get_style( + get_row_style(index - 1 if show_header else index) + ) for width, cell, column in zip(widths, row, columns): render_options = options.update(width=width, justify=column.justify) cell_style = table_style + row_style + get_style(cell.style) @@ -517,8 +522,8 @@ def _render( from .console import Console c = Console() - table = Table(row_styles=["grey44", "white"], expand=True) - table.add_column(no_wrap=True) + table = Table(row_styles=["red", "green"], expand=True) + table.add_column("foo", no_wrap=True) table.add_column() table.add_row( "Magnet",