Skip to content

Commit

Permalink
Merge branch 'develop' into uv
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed Dec 6, 2024
2 parents e9e019d + 5488734 commit 59917f6
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 54 deletions.
11 changes: 6 additions & 5 deletions examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ def do_something(bar):
bar_labels = []
for i in range(BARS):
# Get a progressbar
bar_label = 'Bar #%d' % i
bar_label = f'Bar #{i:d}'
bar_labels.append(bar_label)
multibar[bar_label]
assert multibar[bar_label] is not None

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

@example
def exceeding_maximum() -> None:
with progressbar.ProgressBar(max_value=1) as progress, contextlib.suppress(
ValueError
with (
progressbar.ProgressBar(max_value=1) as progress,
contextlib.suppress(ValueError),
):
progress.update(2)

Expand Down
62 changes: 31 additions & 31 deletions progressbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,47 +45,47 @@

__date__ = str(date.today())
__all__ = [
'progressbar',
'len_color',
'streams',
'Timer',
'ETA',
'AdaptiveETA',
'AbsoluteETA',
'SmoothingETA',
'SmoothingAlgorithm',
'ExponentialMovingAverage',
'DoubleExponentialMovingAverage',
'DataSize',
'FileTransferSpeed',
'AdaptiveETA',
'AdaptiveTransferSpeed',
'AnimatedMarker',
'Counter',
'Percentage',
'FormatLabel',
'SimpleProgress',
'Bar',
'ReverseBar',
'BouncingBar',
'UnknownLength',
'ProgressBar',
'Counter',
'CurrentTime',
'DataSize',
'DataTransferBar',
'RotatingMarker',
'VariableMixin',
'MultiRangeBar',
'MultiProgressBar',
'GranularBar',
'FormatLabelBar',
'PercentageLabelBar',
'Variable',
'DoubleExponentialMovingAverage',
'DynamicMessage',
'ExponentialMovingAverage',
'FileTransferSpeed',
'FormatCustomText',
'CurrentTime',
'NullBar',
'__author__',
'__version__',
'FormatLabel',
'FormatLabelBar',
'GranularBar',
'JobStatusBar',
'LineOffsetStreamWrapper',
'MultiBar',
'MultiProgressBar',
'MultiRangeBar',
'NullBar',
'Percentage',
'PercentageLabelBar',
'ProgressBar',
'ReverseBar',
'RotatingMarker',
'SimpleProgress',
'SmoothingAlgorithm',
'SmoothingETA',
'SortKey',
'JobStatusBar',
'Timer',
'UnknownLength',
'Variable',
'VariableMixin',
'__author__',
'__version__',
'len_color',
'progressbar',
'streams',
]
2 changes: 1 addition & 1 deletion progressbar/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# float also accepts integers and longs but we don't want an explicit union
# due to type checking complexity
NumberT = float
ValueT = typing.Union[NumberT, typing.Type[base.UnknownLength], None]
ValueT = typing.Union[NumberT, type[base.UnknownLength], None]

T = types.TypeVar('T')

Expand Down
6 changes: 3 additions & 3 deletions progressbar/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class Undefined(metaclass=FalseMeta):
assert TextIO is not None

__all__ = (
'FalseMeta',
'UnknownLength',
'Undefined',
'IO',
'FalseMeta',
'TextIO',
'Undefined',
'UnknownLength',
)
2 changes: 1 addition & 1 deletion progressbar/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SortKey(str, enum.Enum):
PERCENTAGE = 'percentage'


class MultiBar(typing.Dict[str, bar.ProgressBar]):
class MultiBar(dict[str, bar.ProgressBar]):
fd: typing.TextIO
_buffer: io.StringIO

Expand Down
4 changes: 2 additions & 2 deletions progressbar/terminal/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ class SGR(CSI):
_start_code: int
_end_code: int
_code = 'm'
__slots__ = '_start_code', '_end_code'
__slots__ = '_end_code', '_start_code'

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


class SGRColor(SGR):
__slots__ = '_color', '_start_code', '_end_code'
__slots__ = '_color', '_end_code', '_start_code'

def __init__(self, color: Color, start_code: int, end_code: int) -> None:
self._color = color
Expand Down
2 changes: 1 addition & 1 deletion progressbar/terminal/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import sys
import typing
from collections.abc import Iterable, Iterator
from types import TracebackType
from typing import Iterable, Iterator

from progressbar import base

Expand Down
2 changes: 1 addition & 1 deletion progressbar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import os
import re
import sys
from collections.abc import Iterable, Iterator
from types import TracebackType
from typing import Iterable, Iterator

from python_utils import types
from python_utils.converters import scale_1024
Expand Down
15 changes: 11 additions & 4 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# We keep the ruff configuration separate so it can easily be shared across
# all projects

target-version = 'py38'
target-version = 'py39'

#src = ['progressbar']
exclude = [
'.venv',
'.tox',
# Ignore local test files/directories/old-stuff
'test.py',
'*_old.py',
]

lint.ignore = [
line-length = 79

[lint]
ignore = [
'A001', # Variable {name} is shadowing a Python builtin
'A002', # Argument {name} is shadowing a Python builtin
'A003', # Class attribute {name} is shadowing a Python builtin
Expand All @@ -28,12 +33,14 @@ lint.ignore = [
'RET506', # Unnecessary `else` after `raise` statement
'Q001', # Remove bad quotes
'Q002', # Remove bad quotes
'FA100', # Missing `from __future__ import annotations`, but uses `typing.Optional`
'COM812', # Missing trailing comma in a list
'ISC001', # String concatenation with implicit str conversion
'SIM108', # Ternary operators are not always more readable
'RUF100', # Unused noqa directives. Due to multiple Python versions, we need to keep them
]
line-length = 79
lint.select = [

select = [
'A', # flake8-builtins
'ASYNC', # flake8 async checker
'B', # flake8-bugbear
Expand Down
2 changes: 1 addition & 1 deletion tests/original_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

def example(fn):
try:
name = 'Example %d' % int(fn.__name__[7:])
name = f'Example {int(fn.__name__[7:]):d}'
except Exception:
name = fn.__name__

Expand Down
2 changes: 1 addition & 1 deletion tests/test_monitor_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_generator_example(testdir) -> None:
pprint.pprint(result.stderr.lines, width=70)

lines = [
r'[/\\|\-]\s+\|\s*#\s*\| %(i)d Elapsed Time: \d:00:%(i)02d' % dict(i=i)
fr'[/\\|\-]\s+\|\s*#\s*\| {i:d} Elapsed Time: \d:00:{i:02d}'
for i in range(9)
]
result.stderr.re_match_lines(lines)
Expand Down
7 changes: 4 additions & 3 deletions tests/test_progressbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def test_dirty() -> None:


def test_negative_maximum() -> None:
with pytest.raises(ValueError), progressbar.ProgressBar(
max_value=-1
) as progress:
with (
pytest.raises(ValueError),
progressbar.ProgressBar(max_value=-1) as progress,
):
progress.start()

0 comments on commit 59917f6

Please sign in to comment.