diff --git a/CHANGELOG.md b/CHANGELOG.md index 7907e5903..f2d7ce991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Enabled supported box chars for legacy Windows, and introduce `safe_box` flag - Disable hyperlinks on legacy Windows - Constructors for Rule and Panel now have keyword only arguments (reason for major version bump) +- Table.add_colum added keyword only arguments ### Fixed diff --git a/rich/panel.py b/rich/panel.py index 9b5b410d9..b108acaf8 100644 --- a/rich/panel.py +++ b/rich/panel.py @@ -47,11 +47,11 @@ def __init__( ) -> None: self.renderable = renderable self.box = box + self.safe_box = safe_box self.expand = expand self.style = style self.width = width self.padding = padding - self.safe_box = safe_box def __rich_console__( self, console: Console, options: ConsoleOptions diff --git a/rich/table.py b/rich/table.py index 43e4b6c90..b8a7c729d 100644 --- a/rich/table.py +++ b/rich/table.py @@ -150,6 +150,7 @@ def __init__( self.caption = caption self.width = width self.box = box + self.safe_box = safe_box self._padding = Padding.unpack(padding) self.pad_edge = pad_edge self.expand = expand @@ -164,7 +165,6 @@ def __init__( self.border_style = border_style self.title_style = title_style self.caption_style = title_style - self.safe_box = safe_box self._row_count = 0 self.row_styles = list(row_styles or []) @@ -227,14 +227,12 @@ def __rich_measure__(self, console: "Console", max_width: int) -> Measurement: extra_width = self._extra_width _measure_column = self._measure_column - minimum_width = sum( - _measure_column(console, column, max_width).minimum - for column in self.columns - ) - maximum_width = sum( - _measure_column(console, column, max_width).maximum - for column in self.columns - ) + + measurements = [ + _measure_column(console, column, max_width) for column in self.columns + ] + minimum_width = sum(measurement.minimum for measurement in measurements) + maximum_width = sum(measurement.maximum for measurement in measurements) return Measurement(minimum_width + extra_width, maximum_width + extra_width) @property @@ -252,6 +250,7 @@ def add_column( self, header: "RenderableType" = "", footer: "RenderableType" = "", + *, header_style: StyleType = None, footer_style: StyleType = None, style: StyleType = None,