Skip to content

Commit 30334f4

Browse files
committed
Fix documentation CI dependencies and lint checks
1 parent aefce6f commit 30334f4

9 files changed

Lines changed: 55 additions & 35 deletions

File tree

docs/examples/_registry.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ def svg_path(self) -> pathlib.Path:
5959
DEMOS: tuple[Demo, ...] = (
6060
Demo('howto/colors', 'Fixed and gradient bar colors'),
6161
Demo('howto/custom-widget', 'The current job phase', term_width=60),
62-
Demo('howto/dynamic-messages', 'Errors found while scanning logs', term_width=60),
62+
Demo(
63+
'howto/dynamic-messages',
64+
'Errors found while scanning logs',
65+
term_width=60,
66+
),
6367
Demo(
6468
'howto/file-transfer',
6569
'DataSize, FileTransferSpeed, AdaptiveTransferSpeed',

docs/examples/howto/prefix_suffix.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88

99
import progressbar
1010

11-
FILES: list[str] = ['users.csv', 'sales.csv', 'stock.csv', 'costs.csv', 'audit.csv']
11+
FILES: list[str] = [
12+
'users.csv',
13+
'sales.csv',
14+
'stock.csv',
15+
'costs.csv',
16+
'audit.csv',
17+
]
1218
BLOCKS_PER_FILE: int = 20
1319

1420

@@ -17,7 +23,7 @@ def main() -> None:
1723
bar: progressbar.ProgressBar
1824
file_number: int
1925
filename: str
20-
block: int
26+
_block: int
2127
with progressbar.ProgressBar(
2228
max_value=len(FILES) * BLOCKS_PER_FILE,
2329
prefix='{variables.filename} {variables.file_number}/5 ',
@@ -26,7 +32,7 @@ def main() -> None:
2632
widgets=[progressbar.Percentage(), ' ', progressbar.Bar()],
2733
) as bar:
2834
for file_number, filename in enumerate(FILES, start=1):
29-
for block in range(BLOCKS_PER_FILE):
35+
for _block in range(BLOCKS_PER_FILE):
3036
time.sleep(0.02)
3137
completed += 1
3238
bar.update(

progressbar/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ def deltas_to_seconds(
128128

129129

130130
def no_color(value: StringT) -> StringT:
131-
"""Return the `value` without ANSI escape codes.
131+
r"""Return the `value` without ANSI escape codes.
132132
133-
>>> no_color(b'\\x1b[1234]abc')
133+
>>> no_color(b'\x1b[1234]abc')
134134
b'abc'
135-
>>> str(no_color('\\x1b[1234]abc'))
135+
>>> str(no_color('\x1b[1234]abc'))
136136
'abc'
137-
>>> str(no_color('\\x1b[1234]abc'))
137+
>>> str(no_color('\x1b[1234]abc'))
138138
'abc'
139139
>>> no_color(123)
140140
Traceback (most recent call last):
@@ -158,13 +158,13 @@ def no_color(value: StringT) -> StringT:
158158

159159

160160
def len_color(value: types.StringTypes) -> int:
161-
"""Return the length of `value` without ANSI escape codes.
161+
r"""Return the length of `value` without ANSI escape codes.
162162
163-
>>> len_color(b'\\x1b[1234]abc')
163+
>>> len_color(b'\x1b[1234]abc')
164164
3
165-
>>> len_color('\\x1b[1234]abc')
165+
>>> len_color('\x1b[1234]abc')
166166
3
167-
>>> len_color('\\x1b[1234]abc')
167+
>>> len_color('\x1b[1234]abc')
168168
3
169169
"""
170170
return len(no_color(value))

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ docs-tests = [
149149
'playwright>=1.48.0',
150150
'pytest-cov>=2.6.1',
151151
'pytest>=4.6.9',
152+
'sphinx>=1.8.5',
152153
]
153154

154155
[dependency-groups]

scripts/render_demos.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ def _parse_history_frames(
379379
for part in raw_line.split('\r'):
380380
line: str = normalize_terminal_line(part.strip())
381381
if line:
382-
frames.append((history + [line])[-history_lines:])
382+
frames.append([*history, line][-history_lines:])
383383
last_line = line
384384
if last_line:
385-
history = (history + [last_line])[-history_lines:]
385+
history = [*history, last_line][-history_lines:]
386386
return frames
387387

388388

tests/console/test_console.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
* ``test_multibar_demos_have_no_run_button`` -- ``MultiBar``'s ``with``
3030
form starts a real OS thread, which Pyodide cannot provide
3131
(``Thread.start()`` raises there). Both ``howto/multibar`` and
32-
``howto/parallel-execution`` need threads (``readme/multibar`` is registered for
33-
SVG rendering only -- ``README.md`` embeds it as a static image for
32+
``howto/parallel-execution`` need threads. ``readme/multibar`` is only
33+
registered for SVG rendering -- ``README.md`` embeds a static image for
3434
PyPI/GitHub, never through the ``.. demo::`` directive, so it never
35-
produces a ``.demo-run`` element to test). The Run button must never
35+
produces a ``.demo-run`` element to test. The Run button must never
3636
be offered there, and the contrast case
3737
(``howto/multibar-line-offset``, which does not use the threaded
3838
form) must still get one -- otherwise this test would pass whether or
@@ -268,7 +268,9 @@ def test_run_button_streams_progress_to_completion(
268268
assert not errors, f'console errors during a normal run: {errors}'
269269

270270

271-
@pytest.mark.parametrize('demo_name', ['howto/multibar', 'howto/parallel-execution'])
271+
@pytest.mark.parametrize(
272+
'demo_name', ['howto/multibar', 'howto/parallel-execution']
273+
)
272274
def test_multibar_demos_have_no_run_button(
273275
server: str,
274276
page: tuple[Page, list[str]],

tests/console/test_homepage.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,16 @@ def test_showcase_keyboard_updates_recording_title_and_guide(
6666
tabs.first.focus()
6767
browser_page.keyboard.press('ArrowRight')
6868
playwright_api.expect(tabs.nth(1)).to_be_focused()
69-
playwright_api.expect(tabs.nth(1)).to_have_attribute('aria-selected', 'true')
69+
playwright_api.expect(tabs.nth(1)).to_have_attribute(
70+
'aria-selected', 'true'
71+
)
7072
playwright_api.expect(recording).to_have_attribute(
7173
'data', '_static/demos/readme-multibar.svg'
7274
)
7375
playwright_api.expect(title).to_have_text('Several jobs in one terminal')
74-
playwright_api.expect(guide).to_have_attribute('href', 'howto/multibar.html')
76+
playwright_api.expect(guide).to_have_attribute(
77+
'href', 'howto/multibar.html'
78+
)
7579
browser_page.keyboard.press('End')
7680
playwright_api.expect(tabs.last).to_be_focused()
7781
playwright_api.expect(guide).to_have_attribute(
@@ -186,7 +190,9 @@ def test_showcase_reduced_motion_and_failed_recording_keep_guides(
186190
browser_page.route('**/readme-multibar.svg', _missing)
187191
browser_page.get_by_role('tab', name='Multiple jobs').click()
188192
guide: Locator = browser_page.locator('#showcase-guide')
189-
playwright_api.expect(guide).to_have_attribute('href', 'howto/multibar.html')
193+
playwright_api.expect(guide).to_have_attribute(
194+
'href', 'howto/multibar.html'
195+
)
190196
playwright_api.expect(guide).to_be_visible()
191197
playwright_api.expect(
192198
browser_page.locator('#showcase-pause')

tests/console/test_showcase_assets.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""The homepage's raw HTML recordings fail the build when an asset is absent."""
1+
"""Reject missing homepage recording assets during the build."""
22

33
from __future__ import annotations
44

@@ -14,7 +14,9 @@
1414
ROOT: pathlib.Path = pathlib.Path(__file__).resolve().parents[2]
1515

1616

17-
@pytest.mark.parametrize('name', ['readme/colors', 'readme/multibar', 'readme/hero'])
17+
@pytest.mark.parametrize(
18+
'name', ['readme/colors', 'readme/multibar', 'readme/hero']
19+
)
1820
def test_missing_showcase_recording_is_a_build_error(
1921
name: str,
2022
tmp_path: pathlib.Path,

tests/test_readme_demos.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import itertools
34
import os
45
import re
56
import sys
@@ -414,9 +415,7 @@ def test_parse_frames_groups_repeated_manual_line_offsets() -> None:
414415

415416
def test_multibar_clear_removes_only_the_retired_row() -> None:
416417
output: str = (
417-
'\x1b[2Fbuild 100%\x1b[2E'
418-
'\x1b[1Ftest 50%\x1b[1E'
419-
'\x1b[2F\x1b[2K\x1b[2E'
418+
'\x1b[2Fbuild 100%\x1b[2E\x1b[1Ftest 50%\x1b[1E\x1b[2F\x1b[2K\x1b[2E'
420419
)
421420
assert demos.parse_frames(output)[-1] == ['test 50%']
422421

@@ -431,8 +430,7 @@ def test_manual_line_offset_capture_shows_four_actual_rows() -> None:
431430
)
432431
assert len(frames[-1]) == 4
433432
assert all(
434-
'(20 of 20)' in demos.ANSI_SGR_RE.sub('', line)
435-
for line in frames[-1]
433+
'(20 of 20)' in demos.ANSI_SGR_RE.sub('', line) for line in frames[-1]
436434
)
437435
assert min(_bar_widths(frames)) >= 20
438436

@@ -450,7 +448,7 @@ def test_parallel_execution_capture_shows_three_active_workers() -> None:
450448
plain_line: str = demos.ANSI_SGR_RE.sub('', line)
451449
match: re.Match[str] | None = demos.PERCENT_RE.search(plain_line)
452450
if match and 0 < int(match.group()[:-1]) < 100:
453-
active_workers.add(plain_line[:match.start()].strip())
451+
active_workers.add(plain_line[: match.start()].strip())
454452
if len(active_workers) >= 3:
455453
break
456454
else:
@@ -504,16 +502,17 @@ def test_non_tty_capture_keeps_increasing_updates_in_history() -> None:
504502
[
505503
int(match.group()[:-1])
506504
for line in frame
507-
if (match := demos.PERCENT_RE.search(
508-
demos.ANSI_SGR_RE.sub('', line)
509-
))
505+
if (
506+
match := demos.PERCENT_RE.search(
507+
demos.ANSI_SGR_RE.sub('', line)
508+
)
509+
)
510510
]
511511
for frame in frames
512512
]
513513
assert max(map(len, frames)) == 4
514514
assert any(
515-
len(values) == 4
516-
and all(a < b for a, b in zip(values, values[1:]))
515+
len(values) == 4 and all(a < b for a, b in itertools.pairwise(values))
517516
for values in percentages
518517
)
519518
assert percentages[-1][-1] == 100
@@ -582,7 +581,7 @@ def test_tutorial_recording_preserves_intermediate_progress() -> None:
582581
assert percentages[0] == 0
583582
assert percentages[-1] == 100
584583
assert len(set(percentages)) >= 80
585-
assert max(b - a for a, b in zip(percentages, percentages[1:])) <= 2
584+
assert max(b - a for a, b in itertools.pairwise(percentages)) <= 2
586585

587586

588587
# Demos whose entire purpose is a time-derived reading (an elapsed duration,

0 commit comments

Comments
 (0)