Skip to content

Commit

Permalink
Merge branch 'release/4.4.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed Aug 23, 2024
2 parents 64f43b6 + 604342d commit 90bfd06
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 67 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/stale@v8
with:
days-before-stale: 30
days-before-issue-stale: 30
exempt-issue-labels: in-progress,help-wanted,pinned,security,enhancement
exempt-all-pr-assignees: true
exempt-all-assignees: true

8 changes: 0 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,6 @@ of widgets:
The progressbar module is very easy to use, yet very powerful. It will also
automatically enable features like auto-resizing when the system supports it.

******************************************************************************
Security contact information
******************************************************************************

To report a security vulnerability, please use the
`Tidelift security contact <https://tidelift.com/security>`_.
Tidelift will coordinate the fix and disclosure.

******************************************************************************
Known issues
******************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def example(fn):
@functools.wraps(fn)
def wrapped(*args, **kwargs):
try:
sys.stdout.write('Running: %s\n' % fn.__name__)
sys.stdout.write(f'Running: {fn.__name__}\n')
fn(*args, **kwargs)
sys.stdout.write('\n')
except KeyboardInterrupt:
Expand Down
2 changes: 1 addition & 1 deletion progressbar/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'''.strip().split(),
)
__email__ = 'wolph@wol.ph'
__version__ = '4.4.2'
__version__ = '4.4.3'
__license__ = 'BSD'
__copyright__ = 'Copyright 2015 Rick van Hattem (Wolph)'
__url__ = 'https://github.com/WoLpH/python-progressbar'
100 changes: 50 additions & 50 deletions progressbar/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ class DefaultFdMixin(ProgressBarMixinBase):
enable_colors: progressbar.env.ColorSupport = progressbar.env.COLOR_SUPPORT

def __init__(
self,
fd: base.TextIO = sys.stderr,
is_terminal: bool | None = None,
line_breaks: bool | None = None,
enable_colors: progressbar.env.ColorSupport | None = None,
line_offset: int = 0,
**kwargs,
self,
fd: base.TextIO = sys.stderr,
is_terminal: bool | None = None,
line_breaks: bool | None = None,
enable_colors: progressbar.env.ColorSupport | None = None,
line_offset: int = 0,
**kwargs,
):
if fd is sys.stdout:
fd = utils.streams.original_stdout
Expand All @@ -211,9 +211,9 @@ def __init__(
super().__init__(**kwargs)

def _apply_line_offset(
self,
fd: base.TextIO,
line_offset: int,
self,
fd: base.TextIO,
line_offset: int,
) -> base.TextIO:
if line_offset:
return progressbar.terminal.stream.LineOffsetStreamWrapper(
Expand All @@ -233,8 +233,8 @@ def _determine_line_breaks(self, line_breaks: bool | None) -> bool | None:
return line_breaks

def _determine_enable_colors(
self,
enable_colors: progressbar.env.ColorSupport | None,
self,
enable_colors: progressbar.env.ColorSupport | None,
) -> progressbar.env.ColorSupport:
'''
Determines the color support for the progress bar.
Expand Down Expand Up @@ -314,9 +314,9 @@ def update(self, *args: types.Any, **kwargs: types.Any) -> None:
self.fd.write(types.cast(str, line.encode('ascii', 'replace')))

def finish(
self,
*args: types.Any,
**kwargs: types.Any,
self,
*args: types.Any,
**kwargs: types.Any,
) -> None: # pragma: no cover
os_specific.reset_console_mode()

Expand Down Expand Up @@ -348,8 +348,8 @@ def _format_widgets(self):

for index, widget in enumerate(self.widgets):
if isinstance(
widget,
widgets.WidgetBase,
widget,
widgets.WidgetBase,
) and not widget.check_size(self):
continue
elif isinstance(widget, widgets.AutoWidthWidgetBase):
Expand Down Expand Up @@ -427,10 +427,10 @@ class StdRedirectMixin(DefaultFdMixin):
_stderr: base.IO

def __init__(
self,
redirect_stderr: bool = False,
redirect_stdout: bool = False,
**kwargs,
self,
redirect_stderr: bool = False,
redirect_stdout: bool = False,
**kwargs,
):
DefaultFdMixin.__init__(self, **kwargs)
self.redirect_stderr = redirect_stderr
Expand Down Expand Up @@ -558,23 +558,23 @@ class ProgressBar(
paused: bool = False

def __init__(
self,
min_value: NumberT = 0,
max_value: NumberT | types.Type[base.UnknownLength] | None = None,
widgets: types.Optional[
types.Sequence[widgets_module.WidgetBase | str]
] = None,
left_justify: bool = True,
initial_value: NumberT = 0,
poll_interval: types.Optional[float] = None,
widget_kwargs: types.Optional[types.Dict[str, types.Any]] = None,
custom_len: types.Callable[[str], int] = utils.len_color,
max_error=True,
prefix=None,
suffix=None,
variables=None,
min_poll_interval=None,
**kwargs,
self,
min_value: NumberT = 0,
max_value: NumberT | types.Type[base.UnknownLength] | None = None,
widgets: types.Optional[
types.Sequence[widgets_module.WidgetBase | str]
] = None,
left_justify: bool = True,
initial_value: NumberT = 0,
poll_interval: types.Optional[float] = None,
widget_kwargs: types.Optional[types.Dict[str, types.Any]] = None,
custom_len: types.Callable[[str], int] = utils.len_color,
max_error=True,
prefix=None,
suffix=None,
variables=None,
min_poll_interval=None,
**kwargs,
): # sourcery skip: low-code-quality
'''Initializes a progress bar with sane defaults.'''
StdRedirectMixin.__init__(self, **kwargs)
Expand Down Expand Up @@ -639,8 +639,8 @@ def __init__(
default=None,
)
self._MINIMUM_UPDATE_INTERVAL = (
utils.deltas_to_seconds(self._MINIMUM_UPDATE_INTERVAL)
or self._MINIMUM_UPDATE_INTERVAL
utils.deltas_to_seconds(self._MINIMUM_UPDATE_INTERVAL)
or self._MINIMUM_UPDATE_INTERVAL
)

# Note that the _MINIMUM_UPDATE_INTERVAL sets the minimum in case of
Expand All @@ -656,8 +656,8 @@ def __init__(
self.variables = utils.AttributeDict(variables or {})
for widget in self.widgets:
if (
isinstance(widget, widgets_module.VariableMixin)
and widget.name not in self.variables
isinstance(widget, widgets_module.VariableMixin)
and widget.name not in self.variables
):
self.variables[widget.name] = None

Expand Down Expand Up @@ -778,7 +778,7 @@ def data(self) -> types.Dict[str, types.Any]:
total_seconds_elapsed=total_seconds_elapsed,
# The seconds since the bar started modulo 60
seconds_elapsed=(elapsed.seconds % 60)
+ (elapsed.microseconds / 1000000.0),
+ (elapsed.microseconds / 1000000.0),
# The minutes since the bar started modulo 60
minutes_elapsed=(elapsed.seconds / 60) % 60,
# The hours since the bar started modulo 24
Expand Down Expand Up @@ -908,9 +908,9 @@ def update(self, value=None, force=False, **kwargs):
self.start()

if (
value is not None
and value is not base.UnknownLength
and isinstance(value, (int, float))
value is not None
and value is not base.UnknownLength
and isinstance(value, (int, float))
):
if self.max_value is base.UnknownLength:
# Can't compare against unknown lengths so just update
Expand Down Expand Up @@ -1033,11 +1033,11 @@ def _init_prefix(self):

def _verify_max_value(self):
if (
self.max_value is not base.UnknownLength
and self.max_value is not None
and self.max_value < 0 # type: ignore
self.max_value is not base.UnknownLength
and self.max_value is not None
and self.max_value < 0 # type: ignore
):
raise ValueError('max_value out of range, got %r' % self.max_value)
raise ValueError(f'max_value out of range, got {self.max_value!r}')

def _calculate_poll_interval(self) -> None:
self.num_intervals = max(100, self.term_width)
Expand Down
2 changes: 1 addition & 1 deletion progressbar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def no_color(value: StringT) -> StringT:
elif isinstance(value, str):
return re.sub('\x1b\\[.*?[@-~]', '', value) # type: ignore
else:
raise TypeError('`value` must be a string or bytes, got %r' % value)
raise TypeError(f'`value` must be a string or bytes, got {value!r}')


def len_color(value: types.StringTypes) -> int:
Expand Down
4 changes: 2 additions & 2 deletions progressbar/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def __call__(

data['eta'] = None
if data['eta_seconds']:
with contextlib.suppress(ValueError, OverflowError):
with contextlib.suppress(ValueError, OverflowError, OSError):
data['eta'] = utils.format_time(data['eta_seconds'])

if data['value'] == progress.min_value:
Expand All @@ -560,7 +560,7 @@ def __call__(
fmt = self.format_NA
else:
fmt = self.format_zero

:
return Timer.__call__(self, progress, data, format=fmt)


Expand Down
2 changes: 1 addition & 1 deletion tests/original_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def example(fn):

def wrapped():
try:
sys.stdout.write('Running: %s\n' % name)
sys.stdout.write(f'Running: {name}\n')
fn()
sys.stdout.write('\n')
except KeyboardInterrupt:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
('t', True),
('yes', True),
('true', True),
('True', True),
('0', False),
('n', False),
('f', False),
('no', False),
('false', False),
('False', False),
],
)
def test_env_flag(value, expected, monkeypatch):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_widgets_large_values(max_value):

def test_format_widget():
widgets = [
progressbar.FormatLabel('%%(%s)r' % mapping)
progressbar.FormatLabel(f'%({mapping})r')
for mapping in progressbar.FormatLabel.mapping
]
p = progressbar.ProgressBar(widgets=widgets)
Expand Down

0 comments on commit 90bfd06

Please sign in to comment.