diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index ba8759ea..5e2d3c49 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -31,6 +31,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) +- [Henry Mai](https://github.com/tanducmai) - [Luka Mamukashvili](https://github.com/UltraStudioLTD) - [Alexander Mancevice](https://github.com/amancevice) - [Will McGugan](https://github.com/willmcgugan) diff --git a/examples/dynamic_progress.py b/examples/dynamic_progress.py index c38da2eb..1165b4f6 100644 --- a/examples/dynamic_progress.py +++ b/examples/dynamic_progress.py @@ -89,7 +89,6 @@ overall_task_id = overall_progress.add_task("", total=len(apps)) # which allows for running multiple different progress bars in parallel, # and dynamically showing/hiding them with Live(progress_group): - for idx, (name, step_times) in enumerate(apps): # update message on overall progress bar top_descr = "[bold #AAAAAA](%d out of %d apps installed)" % (idx, len(apps)) diff --git a/examples/top_lite_simulator.py b/examples/top_lite_simulator.py index 4fecaaa8..147cbb0f 100644 --- a/examples/top_lite_simulator.py +++ b/examples/top_lite_simulator.py @@ -53,7 +53,6 @@ def generate_process(pid: int) -> Process: def create_process_table(height: int) -> Table: - processes = sorted( [generate_process(pid) for pid in range(height)], key=lambda p: p.cpu_percent, diff --git a/rich/__main__.py b/rich/__main__.py index bc55aede..8b55130f 100644 --- a/rich/__main__.py +++ b/rich/__main__.py @@ -207,7 +207,6 @@ Supports much of the *markdown* __syntax__! if __name__ == "__main__": # pragma: no cover - console = Console( file=io.StringIO(), force_terminal=True, diff --git a/rich/_ratio.py b/rich/_ratio.py index f7dbe927..e12397af 100644 --- a/rich/_ratio.py +++ b/rich/_ratio.py @@ -151,7 +151,6 @@ if __name__ == "__main__": @dataclass class E: - size: Optional[int] = None ratio: int = 1 minimum_size: int = 1 diff --git a/rich/_windows.py b/rich/_windows.py index 98c70086..e17c5c0f 100644 --- a/rich/_windows.py +++ b/rich/_windows.py @@ -30,7 +30,6 @@ try: ) except (AttributeError, ImportError, ValueError): - # Fallback if we can't load the Windows DLL def get_windows_console_features() -> WindowsConsoleFeatures: features = WindowsConsoleFeatures() diff --git a/rich/bar.py b/rich/bar.py index ed86a552..022284b5 100644 --- a/rich/bar.py +++ b/rich/bar.py @@ -48,7 +48,6 @@ class Bar(JupyterMixin): def __rich_console__( self, console: Console, options: ConsoleOptions ) -> RenderResult: - width = min( self.width if self.width is not None else options.max_width, options.max_width, diff --git a/rich/box.py b/rich/box.py index c2655002..968f1529 100644 --- a/rich/box.py +++ b/rich/box.py @@ -464,7 +464,6 @@ PLAIN_HEADED_SUBSTITUTIONS = { if __name__ == "__main__": # pragma: no cover - from rich.columns import Columns from rich.panel import Panel diff --git a/rich/cells.py b/rich/cells.py index 9354f9e3..31d0c4cb 100644 --- a/rich/cells.py +++ b/rich/cells.py @@ -145,7 +145,6 @@ def chop_cells(text: str, max_size: int, position: int = 0) -> List[str]: if __name__ == "__main__": # pragma: no cover - print(get_character_cell_size("😽")) for line in chop_cells("""这是对亚洲语言支持的测试。面对模棱两可的想法,拒绝猜测的诱惑。""", 8): print(line) diff --git a/rich/color.py b/rich/color.py index dfe45593..4270a278 100644 --- a/rich/color.py +++ b/rich/color.py @@ -592,7 +592,6 @@ def blend_rgb( if __name__ == "__main__": # pragma: no cover - from .console import Console from .table import Table from .text import Text diff --git a/rich/json.py b/rich/json.py index 24dc5e60..f048902d 100644 --- a/rich/json.py +++ b/rich/json.py @@ -103,7 +103,6 @@ class JSON: if __name__ == "__main__": - import argparse import sys diff --git a/rich/layout.py b/rich/layout.py index 50ebd188..7fa2852e 100644 --- a/rich/layout.py +++ b/rich/layout.py @@ -227,7 +227,6 @@ class Layout: from rich.tree import Tree def summary(layout: "Layout") -> Table: - icon = layout.splitter.get_tree_icon() table = Table.grid(padding=(0, 1, 0, 0)) @@ -403,7 +402,7 @@ class Layout: self._render_map = render_map layout_lines: List[List[Segment]] = [[] for _ in range(height)] _islice = islice - for (region, lines) in render_map.values(): + for region, lines in render_map.values(): _x, y, _layout_width, layout_height = region for row, line in zip( _islice(layout_lines, y, y + layout_height), lines diff --git a/rich/live.py b/rich/live.py index 3ebbbc4c..f0529a78 100644 --- a/rich/live.py +++ b/rich/live.py @@ -362,7 +362,7 @@ if __name__ == "__main__": # pragma: no cover table.add_column("Destination Currency") table.add_column("Exchange Rate") - for ((source, dest), exchange_rate) in exchange_rate_dict.items(): + for (source, dest), exchange_rate in exchange_rate_dict.items(): table.add_row( source, dest, diff --git a/rich/live_render.py b/rich/live_render.py index f6fa7b2d..4284cccc 100644 --- a/rich/live_render.py +++ b/rich/live_render.py @@ -82,7 +82,6 @@ class LiveRender: def __rich_console__( self, console: Console, options: ConsoleOptions ) -> RenderResult: - renderable = self.renderable style = console.get_style(self.style) lines = console.render_lines(renderable, options, style=style, pad=False) diff --git a/rich/progress_bar.py b/rich/progress_bar.py index 67361df2..a2bf3261 100644 --- a/rich/progress_bar.py +++ b/rich/progress_bar.py @@ -156,7 +156,6 @@ class ProgressBar(JupyterMixin): def __rich_console__( self, console: Console, options: ConsoleOptions ) -> RenderResult: - width = min(self.width or options.max_width, options.max_width) ascii = options.legacy_windows or options.ascii_only should_pulse = self.pulse or self.total is None diff --git a/rich/prompt.py b/rich/prompt.py index 064c959b..36e0bba6 100644 --- a/rich/prompt.py +++ b/rich/prompt.py @@ -346,7 +346,6 @@ class Confirm(PromptBase[bool]): if __name__ == "__main__": # pragma: no cover - from rich import print if Confirm.ask("Run [i]prompt[/i] tests?", default=True): diff --git a/rich/segment.py b/rich/segment.py index 9bcfc7c5..603d5097 100644 --- a/rich/segment.py +++ b/rich/segment.py @@ -109,7 +109,6 @@ class Segment(NamedTuple): @classmethod @lru_cache(1024 * 16) def _split_cells(cls, segment: "Segment", cut: int) -> Tuple["Segment", "Segment"]: - text, style, control = segment _Segment = Segment diff --git a/rich/status.py b/rich/status.py index 09eff405..65744838 100644 --- a/rich/status.py +++ b/rich/status.py @@ -107,7 +107,6 @@ class Status(JupyterMixin): if __name__ == "__main__": # pragma: no cover - from time import sleep from .console import Console diff --git a/rich/table.py b/rich/table.py index 578d3d63..5fc5ace0 100644 --- a/rich/table.py +++ b/rich/table.py @@ -212,7 +212,6 @@ class Table(JupyterMixin): caption_justify: "JustifyMethod" = "center", highlight: bool = False, ) -> None: - self.columns: List[Column] = [] self.rows: List[Row] = [] self.title = title @@ -471,7 +470,6 @@ class Table(JupyterMixin): def __rich_console__( self, console: "Console", options: "ConsoleOptions" ) -> "RenderResult": - if not self.columns: yield Segment("\n") return @@ -685,7 +683,7 @@ class Table(JupyterMixin): getattr(renderable, "vertical", None) or column.vertical, ) else: - for (style, renderable) in raw_cells: + for style, renderable in raw_cells: yield _Cell( style, renderable, diff --git a/rich/traceback.py b/rich/traceback.py index 341f7f41..821c7501 100644 --- a/rich/traceback.py +++ b/rich/traceback.py @@ -636,7 +636,6 @@ class Traceback: excluded = False for frame_index, frame in enumerate(stack.frames): - if exclude_frames and frame_index in exclude_frames: excluded = True continue @@ -720,7 +719,6 @@ class Traceback: if __name__ == "__main__": # pragma: no cover - from .console import Console console = Console() @@ -744,7 +742,6 @@ if __name__ == "__main__": # pragma: no cover bar(a) def error() -> None: - try: try: foo(0) diff --git a/rich/tree.py b/rich/tree.py index b9b7bbe5..8c5e7181 100644 --- a/rich/tree.py +++ b/rich/tree.py @@ -72,7 +72,6 @@ class Tree(JupyterMixin): def __rich_console__( self, console: "Console", options: "ConsoleOptions" ) -> "RenderResult": - stack: List[Iterator[Tuple[bool, Tree]]] = [] pop = stack.pop push = stack.append @@ -195,7 +194,6 @@ class Tree(JupyterMixin): if __name__ == "__main__": # pragma: no cover - from rich.console import Group from rich.markdown import Markdown from rich.panel import Panel diff --git a/tests/test_align.py b/tests/test_align.py index 5f67dcbc..9abf3e2d 100644 --- a/tests/test_align.py +++ b/tests/test_align.py @@ -8,7 +8,6 @@ from rich.measure import Measurement def test_bad_align_legal(): - # Legal Align("foo", "left") Align("foo", "center") diff --git a/tests/test_color.py b/tests/test_color.py index 796f0198..010d7974 100644 --- a/tests/test_color.py +++ b/tests/test_color.py @@ -124,7 +124,6 @@ def test_get_ansi_codes() -> None: def test_downgrade() -> None: - assert Color.parse("color(9)").downgrade(0) == Color( "color(9)", ColorType.STANDARD, 9, None ) diff --git a/tests/test_file_proxy.py b/tests/test_file_proxy.py index 51c530aa..2ec4d789 100644 --- a/tests/test_file_proxy.py +++ b/tests/test_file_proxy.py @@ -28,7 +28,6 @@ def test_flush(): def test_new_lines(): - file = io.StringIO() console = Console(file=file) file_proxy = FileProxy(console, file) diff --git a/tests/test_live.py b/tests/test_live.py index 8e3d5892..f037e4b8 100644 --- a/tests/test_live.py +++ b/tests/test_live.py @@ -22,7 +22,6 @@ def create_capture_console( def test_live_state() -> None: - with Live("") as live: assert live._started live.start() diff --git a/tests/test_progress.py b/tests/test_progress.py index 6a336d34..72497a0c 100644 --- a/tests/test_progress.py +++ b/tests/test_progress.py @@ -150,7 +150,6 @@ def test_spinner_column(): def test_download_progress_uses_decimal_units() -> None: - column = DownloadColumn() test_task = Task(1, "test", 1000, 500, _get_time=lambda: 1.0) rendered_progress = str(column.render(test_task)) @@ -159,7 +158,6 @@ def test_download_progress_uses_decimal_units() -> None: def test_download_progress_uses_binary_units() -> None: - column = DownloadColumn(binary_units=True) test_task = Task(1, "test", 1024, 512, _get_time=lambda: 1.0) rendered_progress = str(column.render(test_task)) @@ -280,7 +278,6 @@ def test_render() -> None: def test_track() -> None: - console = Console( file=io.StringIO(), force_terminal=True, @@ -339,7 +336,6 @@ def test_progress_track() -> None: def test_columns() -> None: - console = Console( file=io.StringIO(), force_terminal=True, diff --git a/tests/test_stack.py b/tests/test_stack.py index 5bbb885d..e961ddd8 100644 --- a/tests/test_stack.py +++ b/tests/test_stack.py @@ -2,7 +2,6 @@ from rich._stack import Stack def test_stack(): - stack = Stack() stack.push("foo") stack.push("bar") diff --git a/tests/test_status.py b/tests/test_status.py index 43ef94e0..c2aec504 100644 --- a/tests/test_status.py +++ b/tests/test_status.py @@ -6,7 +6,6 @@ from rich.status import Status def test_status(): - console = Console( color_system=None, width=80, legacy_windows=False, get_time=lambda: 0.0 ) diff --git a/tests/test_table.py b/tests/test_table.py index 4faf9d53..2eea1897 100644 --- a/tests/test_table.py +++ b/tests/test_table.py @@ -114,7 +114,6 @@ def test_init_append_column(): def test_rich_measure(): - console = Console() assert Table("test_header", width=-1).__rich_measure__( console, console.options diff --git a/tests/test_traceback.py b/tests/test_traceback.py index 11b623dd..cf24b0cc 100644 --- a/tests/test_traceback.py +++ b/tests/test_traceback.py @@ -345,7 +345,6 @@ def test_rich_traceback_omit_optional_local_flag( if __name__ == "__main__": # pragma: no cover - expected = render(get_exception()) with open("_exception_render.py", "wt") as fh: diff --git a/tools/make_terminal_widths.py b/tools/make_terminal_widths.py index 850f67a9..1e556834 100644 --- a/tools/make_terminal_widths.py +++ b/tools/make_terminal_widths.py @@ -40,7 +40,6 @@ def make_widths_table() -> List[Tuple[int, int, int]]: def get_cell_size(table: List[Tuple[int, int, int]], character: str) -> int: - codepoint = ord(character) lower_bound = 0 upper_bound = len(table) - 1