Skip to content

Commit 59917f6

Browse files
committed
Merge branch 'develop' into uv
2 parents e9e019d + 5488734 commit 59917f6

File tree

12 files changed

+63
-54
lines changed

12 files changed

+63
-54
lines changed

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/bar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# float also accepts integers and longs but we don't want an explicit union
3535
# due to type checking complexity
3636
NumberT = float
37-
ValueT = typing.Union[NumberT, typing.Type[base.UnknownLength], None]
37+
ValueT = typing.Union[NumberT, type[base.UnknownLength], None]
3838

3939
T = types.TypeVar('T')
4040

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/multi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class SortKey(str, enum.Enum):
4343
PERCENTAGE = 'percentage'
4444

4545

46-
class MultiBar(typing.Dict[str, bar.ProgressBar]):
46+
class MultiBar(dict[str, bar.ProgressBar]):
4747
fd: typing.TextIO
4848
_buffer: io.StringIO
4949

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

progressbar/terminal/stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import sys
44
import typing
5+
from collections.abc import Iterable, Iterator
56
from types import TracebackType
6-
from typing import Iterable, Iterator
77

88
from progressbar import base
99

progressbar/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import os
99
import re
1010
import sys
11+
from collections.abc import Iterable, Iterator
1112
from types import TracebackType
12-
from typing import Iterable, Iterator
1313

1414
from python_utils import types
1515
from python_utils.converters import scale_1024

ruff.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
# We keep the ruff configuration separate so it can easily be shared across
22
# all projects
33

4-
target-version = 'py38'
4+
target-version = 'py39'
55

66
#src = ['progressbar']
77
exclude = [
88
'.venv',
99
'.tox',
10+
# Ignore local test files/directories/old-stuff
1011
'test.py',
12+
'*_old.py',
1113
]
1214

13-
lint.ignore = [
15+
line-length = 79
16+
17+
[lint]
18+
ignore = [
1419
'A001', # Variable {name} is shadowing a Python builtin
1520
'A002', # Argument {name} is shadowing a Python builtin
1621
'A003', # Class attribute {name} is shadowing a Python builtin
@@ -28,12 +33,14 @@ lint.ignore = [
2833
'RET506', # Unnecessary `else` after `raise` statement
2934
'Q001', # Remove bad quotes
3035
'Q002', # Remove bad quotes
36+
'FA100', # Missing `from __future__ import annotations`, but uses `typing.Optional`
3137
'COM812', # Missing trailing comma in a list
3238
'ISC001', # String concatenation with implicit str conversion
3339
'SIM108', # Ternary operators are not always more readable
40+
'RUF100', # Unused noqa directives. Due to multiple Python versions, we need to keep them
3441
]
35-
line-length = 79
36-
lint.select = [
42+
43+
select = [
3744
'A', # flake8-builtins
3845
'ASYNC', # flake8 async checker
3946
'B', # flake8-bugbear

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

0 commit comments

Comments
 (0)