Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black formatting #3035

Merged
merged 4 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion examples/dynamic_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def run_steps(name, step_times, app_steps_task_id):
# 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))
Expand Down
1 change: 0 additions & 1 deletion examples/top_lite_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion rich/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ def iter_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:


if __name__ == "__main__": # pragma: no cover

console = Console(
file=io.StringIO(),
force_terminal=True,
Expand Down
1 change: 0 additions & 1 deletion rich/_ratio.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def ratio_distribute(

@dataclass
class E:

size: Optional[int] = None
ratio: int = 1
minimum_size: int = 1
Expand Down
1 change: 0 additions & 1 deletion rich/_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class WindowsConsoleFeatures:
)

except (AttributeError, ImportError, ValueError):

# Fallback if we can't load the Windows DLL
def get_windows_console_features() -> WindowsConsoleFeatures:
features = WindowsConsoleFeatures()
Expand Down
1 change: 0 additions & 1 deletion rich/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __repr__(self) -> str:
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,
Expand Down
1 change: 0 additions & 1 deletion rich/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ def get_bottom(self, widths: Iterable[int]) -> str:


if __name__ == "__main__": # pragma: no cover

from rich.columns import Columns
from rich.panel import Panel

Expand Down
1 change: 0 additions & 1 deletion rich/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion rich/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion rich/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def __rich__(self) -> Text:


if __name__ == "__main__":

import argparse
import sys

Expand Down
3 changes: 1 addition & 2 deletions rich/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ def tree(self) -> "Tree":
from rich.tree import Tree

def summary(layout: "Layout") -> Table:

icon = layout.splitter.get_tree_icon()

table = Table.grid(padding=(0, 1, 0, 0))
Expand Down Expand Up @@ -403,7 +402,7 @@ def __rich_console__(
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
Expand Down
2 changes: 1 addition & 1 deletion rich/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def process_renderables(
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,
Expand Down
1 change: 0 additions & 1 deletion rich/live_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def restore_cursor(self) -> Control:
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)
Expand Down
1 change: 0 additions & 1 deletion rich/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def _render_pulse(
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
Expand Down
1 change: 0 additions & 1 deletion rich/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ def process_response(self, value: str) -> bool:


if __name__ == "__main__": # pragma: no cover

from rich import print

if Confirm.ask("Run [i]prompt[/i] tests?", default=True):
Expand Down
1 change: 0 additions & 1 deletion rich/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def is_control(self) -> bool:
@classmethod
@lru_cache(1024 * 16)
def _split_cells(cls, segment: "Segment", cut: int) -> Tuple["Segment", "Segment"]:

text, style, control = segment
_Segment = Segment

Expand Down
1 change: 0 additions & 1 deletion rich/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def __exit__(


if __name__ == "__main__": # pragma: no cover

from time import sleep

from .console import Console
Expand Down
4 changes: 1 addition & 3 deletions rich/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ def __init__(
caption_justify: "JustifyMethod" = "center",
highlight: bool = False,
) -> None:

self.columns: List[Column] = []
self.rows: List[Row] = []
self.title = title
Expand Down Expand Up @@ -471,7 +470,6 @@ def add_section(self) -> None:
def __rich_console__(
self, console: "Console", options: "ConsoleOptions"
) -> "RenderResult":

if not self.columns:
yield Segment("\n")
return
Expand Down Expand Up @@ -685,7 +683,7 @@ def get_padding(first_row: bool, last_row: bool) -> Tuple[int, int, int, int]:
getattr(renderable, "vertical", None) or column.vertical,
)
else:
for (style, renderable) in raw_cells:
for style, renderable in raw_cells:
yield _Cell(
style,
renderable,
Expand Down
3 changes: 0 additions & 3 deletions rich/traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,6 @@ def render_locals(frame: Frame) -> Iterable[ConsoleRenderable]:

excluded = False
for frame_index, frame in enumerate(stack.frames):

if exclude_frames and frame_index in exclude_frames:
excluded = True
continue
Expand Down Expand Up @@ -720,7 +719,6 @@ def render_locals(frame: Frame) -> Iterable[ConsoleRenderable]:


if __name__ == "__main__": # pragma: no cover

from .console import Console

console = Console()
Expand All @@ -744,7 +742,6 @@ def foo(a: Any) -> None:
bar(a)

def error() -> None:

try:
try:
foo(0)
Expand Down
2 changes: 0 additions & 2 deletions rich/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def add(
def __rich_console__(
self, console: "Console", options: "ConsoleOptions"
) -> "RenderResult":

stack: List[Iterator[Tuple[bool, Tree]]] = []
pop = stack.pop
push = stack.append
Expand Down Expand Up @@ -195,7 +194,6 @@ def __rich_measure__(


if __name__ == "__main__": # pragma: no cover

from rich.console import Group
from rich.markdown import Markdown
from rich.panel import Panel
Expand Down
1 change: 0 additions & 1 deletion tests/test_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


def test_bad_align_legal():

# Legal
Align("foo", "left")
Align("foo", "center")
Expand Down
1 change: 0 additions & 1 deletion tests/test_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
1 change: 0 additions & 1 deletion tests/test_file_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def test_flush():


def test_new_lines():

file = io.StringIO()
console = Console(file=file)
file_proxy = FileProxy(console, file)
Expand Down
1 change: 0 additions & 1 deletion tests/test_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def create_capture_console(


def test_live_state() -> None:

with Live("") as live:
assert live._started
live.start()
Expand Down
4 changes: 0 additions & 4 deletions tests/test_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ def get_time():


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))
Expand All @@ -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))
Expand Down Expand Up @@ -280,7 +278,6 @@ def test_render() -> None:


def test_track() -> None:

console = Console(
file=io.StringIO(),
force_terminal=True,
Expand Down Expand Up @@ -339,7 +336,6 @@ def test_progress_track() -> None:


def test_columns() -> None:

console = Console(
file=io.StringIO(),
force_terminal=True,
Expand Down
1 change: 0 additions & 1 deletion tests/test_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


def test_stack():

stack = Stack()
stack.push("foo")
stack.push("bar")
Expand Down
1 change: 0 additions & 1 deletion tests/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


def test_status():

console = Console(
color_system=None, width=80, legacy_windows=False, get_time=lambda: 0.0
)
Expand Down
1 change: 0 additions & 1 deletion tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/test_traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ def level3():


if __name__ == "__main__": # pragma: no cover

expected = render(get_exception())

with open("_exception_render.py", "wt") as fh:
Expand Down
1 change: 0 additions & 1 deletion tools/make_terminal_widths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down