Black formatting (#3035)

* fix: minor black formatting

* style: update CONTRIBUTORS.md

* fix: more black formatting

Default black with no arguments provided

---------

Co-authored-by: Darren Burns <darrenburns@users.noreply.github.com>
This commit is contained in:
Henry Mai 2023-11-08 04:27:21 +10:30 committed by GitHub
parent 7a168a27c5
commit 0177b03700
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 4 additions and 39 deletions

View file

@ -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)

View file

@ -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))

View file

@ -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,

View file

@ -207,7 +207,6 @@ Supports much of the *markdown* __syntax__!
if __name__ == "__main__": # pragma: no cover
console = Console(
file=io.StringIO(),
force_terminal=True,

View file

@ -151,7 +151,6 @@ if __name__ == "__main__":
@dataclass
class E:
size: Optional[int] = None
ratio: int = 1
minimum_size: int = 1

View file

@ -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()

View file

@ -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,

View file

@ -464,7 +464,6 @@ PLAIN_HEADED_SUBSTITUTIONS = {
if __name__ == "__main__": # pragma: no cover
from rich.columns import Columns
from rich.panel import Panel

View file

@ -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)

View file

@ -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

View file

@ -103,7 +103,6 @@ class JSON:
if __name__ == "__main__":
import argparse
import sys

View file

@ -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

View file

@ -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,

View file

@ -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)

View file

@ -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

View file

@ -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):

View file

@ -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

View file

@ -107,7 +107,6 @@ class Status(JupyterMixin):
if __name__ == "__main__": # pragma: no cover
from time import sleep
from .console import Console

View file

@ -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,

View file

@ -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)

View file

@ -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

View file

@ -8,7 +8,6 @@ from rich.measure import Measurement
def test_bad_align_legal():
# Legal
Align("foo", "left")
Align("foo", "center")

View file

@ -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
)

View file

@ -28,7 +28,6 @@ def test_flush():
def test_new_lines():
file = io.StringIO()
console = Console(file=file)
file_proxy = FileProxy(console, file)

View file

@ -22,7 +22,6 @@ def create_capture_console(
def test_live_state() -> None:
with Live("") as live:
assert live._started
live.start()

View file

@ -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,

View file

@ -2,7 +2,6 @@ from rich._stack import Stack
def test_stack():
stack = Stack()
stack.push("foo")
stack.push("bar")

View file

@ -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
)

View file

@ -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

View file

@ -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:

View file

@ -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