Skip to content

Commit 5488734

Browse files
committed
more ruff fixes
1 parent 039a239 commit 5488734

7 files changed

Lines changed: 48 additions & 46 deletions

File tree

examples.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def do_something(bar):
7373
bar_labels = []
7474
for i in range(BARS):
7575
# Get a progressbar
76-
bar_label = 'Bar #%d' % i
76+
bar_label = f'Bar #{i:d}'
7777
bar_labels.append(bar_label)
78-
multibar[bar_label]
78+
assert multibar[bar_label] is not None
7979

8080
for _ in range(N * BARS):
8181
time.sleep(0.005)
@@ -148,7 +148,7 @@ def with_example_stdout_redirection() -> None:
148148
with progressbar.ProgressBar(max_value=10, redirect_stdout=True) as p:
149149
for i in range(10):
150150
if i % 3 == 0:
151-
print('Some print statement %i' % i)
151+
print(f'Some print statement {i:d}')
152152
# do something
153153
p.update(i)
154154
time.sleep(0.1)
@@ -544,8 +544,9 @@ def with_right_justify() -> None:
544544

545545
@example
546546
def exceeding_maximum() -> None:
547-
with progressbar.ProgressBar(max_value=1) as progress, contextlib.suppress(
548-
ValueError
547+
with (
548+
progressbar.ProgressBar(max_value=1) as progress,
549+
contextlib.suppress(ValueError),
549550
):
550551
progress.update(2)
551552

progressbar/__init__.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,47 +45,47 @@
4545

4646
__date__ = str(date.today())
4747
__all__ = [
48-
'progressbar',
49-
'len_color',
50-
'streams',
51-
'Timer',
5248
'ETA',
53-
'AdaptiveETA',
5449
'AbsoluteETA',
55-
'SmoothingETA',
56-
'SmoothingAlgorithm',
57-
'ExponentialMovingAverage',
58-
'DoubleExponentialMovingAverage',
59-
'DataSize',
60-
'FileTransferSpeed',
50+
'AdaptiveETA',
6151
'AdaptiveTransferSpeed',
6252
'AnimatedMarker',
63-
'Counter',
64-
'Percentage',
65-
'FormatLabel',
66-
'SimpleProgress',
6753
'Bar',
68-
'ReverseBar',
6954
'BouncingBar',
70-
'UnknownLength',
71-
'ProgressBar',
55+
'Counter',
56+
'CurrentTime',
57+
'DataSize',
7258
'DataTransferBar',
73-
'RotatingMarker',
74-
'VariableMixin',
75-
'MultiRangeBar',
76-
'MultiProgressBar',
77-
'GranularBar',
78-
'FormatLabelBar',
79-
'PercentageLabelBar',
80-
'Variable',
59+
'DoubleExponentialMovingAverage',
8160
'DynamicMessage',
61+
'ExponentialMovingAverage',
62+
'FileTransferSpeed',
8263
'FormatCustomText',
83-
'CurrentTime',
84-
'NullBar',
85-
'__author__',
86-
'__version__',
64+
'FormatLabel',
65+
'FormatLabelBar',
66+
'GranularBar',
67+
'JobStatusBar',
8768
'LineOffsetStreamWrapper',
8869
'MultiBar',
70+
'MultiProgressBar',
71+
'MultiRangeBar',
72+
'NullBar',
73+
'Percentage',
74+
'PercentageLabelBar',
75+
'ProgressBar',
76+
'ReverseBar',
77+
'RotatingMarker',
78+
'SimpleProgress',
79+
'SmoothingAlgorithm',
80+
'SmoothingETA',
8981
'SortKey',
90-
'JobStatusBar',
82+
'Timer',
83+
'UnknownLength',
84+
'Variable',
85+
'VariableMixin',
86+
'__author__',
87+
'__version__',
88+
'len_color',
89+
'progressbar',
90+
'streams',
9191
]

progressbar/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class Undefined(metaclass=FalseMeta):
2828
assert TextIO is not None
2929

3030
__all__ = (
31-
'FalseMeta',
32-
'UnknownLength',
33-
'Undefined',
3431
'IO',
32+
'FalseMeta',
3533
'TextIO',
34+
'Undefined',
35+
'UnknownLength',
3636
)

progressbar/terminal/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ class SGR(CSI):
601601
_start_code: int
602602
_end_code: int
603603
_code = 'm'
604-
__slots__ = '_start_code', '_end_code'
604+
__slots__ = '_end_code', '_start_code'
605605

606606
def __init__(self, start_code: int, end_code: int) -> None:
607607
self._start_code = start_code
@@ -624,7 +624,7 @@ def __call__( # pyright: ignore[reportIncompatibleMethodOverride]
624624

625625

626626
class SGRColor(SGR):
627-
__slots__ = '_color', '_start_code', '_end_code'
627+
__slots__ = '_color', '_end_code', '_start_code'
628628

629629
def __init__(self, color: Color, start_code: int, end_code: int) -> None:
630630
self._color = color

tests/original_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
def example(fn):
2828
try:
29-
name = 'Example %d' % int(fn.__name__[7:])
29+
name = f'Example {int(fn.__name__[7:]):d}'
3030
except Exception:
3131
name = fn.__name__
3232

tests/test_monitor_progress.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_generator_example(testdir) -> None:
114114
pprint.pprint(result.stderr.lines, width=70)
115115

116116
lines = [
117-
r'[/\\|\-]\s+\|\s*#\s*\| %(i)d Elapsed Time: \d:00:%(i)02d' % dict(i=i)
117+
fr'[/\\|\-]\s+\|\s*#\s*\| {i:d} Elapsed Time: \d:00:{i:02d}'
118118
for i in range(9)
119119
]
120120
result.stderr.re_match_lines(lines)

tests/test_progressbar.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ def test_dirty() -> None:
7272

7373

7474
def test_negative_maximum() -> None:
75-
with pytest.raises(ValueError), progressbar.ProgressBar(
76-
max_value=-1
77-
) as progress:
75+
with (
76+
pytest.raises(ValueError),
77+
progressbar.ProgressBar(max_value=-1) as progress,
78+
):
7879
progress.start()

0 commit comments

Comments
 (0)