Skip to content

Commit 3b2fe80

Browse files
committed
Fixed docs build and pyright issue
1 parent 76fb9b1 commit 3b2fe80

File tree

4 files changed

+70
-65
lines changed

4 files changed

+70
-65
lines changed

progressbar/bar.py

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ class DefaultFdMixin(ProgressBarMixinBase):
187187
enable_colors: progressbar.env.ColorSupport = progressbar.env.COLOR_SUPPORT
188188

189189
def __init__(
190-
self,
191-
fd: base.TextIO = sys.stderr,
192-
is_terminal: bool | None = None,
193-
line_breaks: bool | None = None,
194-
enable_colors: progressbar.env.ColorSupport | None = None,
195-
line_offset: int = 0,
196-
**kwargs,
190+
self,
191+
fd: base.TextIO = sys.stderr,
192+
is_terminal: bool | None = None,
193+
line_breaks: bool | None = None,
194+
enable_colors: progressbar.env.ColorSupport | None = None,
195+
line_offset: int = 0,
196+
**kwargs,
197197
):
198198
if fd is sys.stdout:
199199
fd = utils.streams.original_stdout
@@ -210,9 +210,9 @@ def __init__(
210210
super().__init__(**kwargs)
211211

212212
def _apply_line_offset(
213-
self,
214-
fd: base.TextIO,
215-
line_offset: int,
213+
self,
214+
fd: base.TextIO,
215+
line_offset: int,
216216
) -> base.TextIO:
217217
if line_offset:
218218
return progressbar.terminal.stream.LineOffsetStreamWrapper(
@@ -232,8 +232,8 @@ def _determine_line_breaks(self, line_breaks: bool | None) -> bool | None:
232232
return line_breaks
233233

234234
def _determine_enable_colors(
235-
self,
236-
enable_colors: progressbar.env.ColorSupport | None,
235+
self,
236+
enable_colors: progressbar.env.ColorSupport | None,
237237
) -> progressbar.env.ColorSupport:
238238
'''
239239
Determines the color support for the progress bar.
@@ -309,9 +309,9 @@ def update(self, *args: types.Any, **kwargs: types.Any) -> None:
309309
self.fd.write(types.cast(str, line.encode('ascii', 'replace')))
310310

311311
def finish(
312-
self,
313-
*args: types.Any,
314-
**kwargs: types.Any,
312+
self,
313+
*args: types.Any,
314+
**kwargs: types.Any,
315315
) -> None: # pragma: no cover
316316
if self._finished:
317317
return
@@ -341,8 +341,8 @@ def _format_widgets(self):
341341

342342
for index, widget in enumerate(self.widgets):
343343
if isinstance(
344-
widget,
345-
widgets.WidgetBase,
344+
widget,
345+
widgets.WidgetBase,
346346
) and not widget.check_size(self):
347347
continue
348348
elif isinstance(widget, widgets.AutoWidthWidgetBase):
@@ -388,9 +388,11 @@ def __init__(self, term_width: int | None = None, **kwargs):
388388
import signal
389389

390390
self._prev_handle = signal.getsignal(
391-
signal.SIGWINCH) # type: ignore
392-
signal.signal(signal.SIGWINCH, # type: ignore
393-
self._handle_resize)
391+
signal.SIGWINCH # type: ignore
392+
)
393+
signal.signal(
394+
signal.SIGWINCH, self._handle_resize # type: ignore
395+
)
394396
self.signal_set = True
395397

396398
def _handle_resize(self, signum=None, frame=None):
@@ -404,8 +406,9 @@ def finish(self): # pragma: no cover
404406
with contextlib.suppress(Exception):
405407
import signal
406408

407-
signal.signal(signal.SIGWINCH, # type: ignore
408-
self._prev_handle)
409+
signal.signal(
410+
signal.SIGWINCH, self._prev_handle # type: ignore
411+
)
409412

410413

411414
class StdRedirectMixin(DefaultFdMixin):
@@ -417,10 +420,10 @@ class StdRedirectMixin(DefaultFdMixin):
417420
_stderr: base.IO
418421

419422
def __init__(
420-
self,
421-
redirect_stderr: bool = False,
422-
redirect_stdout: bool = False,
423-
**kwargs,
423+
self,
424+
redirect_stderr: bool = False,
425+
redirect_stdout: bool = False,
426+
**kwargs,
424427
):
425428
DefaultFdMixin.__init__(self, **kwargs)
426429
self.redirect_stderr = redirect_stderr
@@ -548,23 +551,23 @@ class ProgressBar(
548551
paused: bool = False
549552

550553
def __init__(
551-
self,
552-
min_value: NumberT = 0,
553-
max_value: NumberT | types.Type[base.UnknownLength] | None = None,
554-
widgets: types.Optional[
555-
types.Sequence[widgets_module.WidgetBase | str]
556-
] = None,
557-
left_justify: bool = True,
558-
initial_value: NumberT = 0,
559-
poll_interval: types.Optional[float] = None,
560-
widget_kwargs: types.Optional[types.Dict[str, types.Any]] = None,
561-
custom_len: types.Callable[[str], int] = utils.len_color,
562-
max_error=True,
563-
prefix=None,
564-
suffix=None,
565-
variables=None,
566-
min_poll_interval=None,
567-
**kwargs,
554+
self,
555+
min_value: NumberT = 0,
556+
max_value: NumberT | types.Type[base.UnknownLength] | None = None,
557+
widgets: types.Optional[
558+
types.Sequence[widgets_module.WidgetBase | str]
559+
] = None,
560+
left_justify: bool = True,
561+
initial_value: NumberT = 0,
562+
poll_interval: types.Optional[float] = None,
563+
widget_kwargs: types.Optional[types.Dict[str, types.Any]] = None,
564+
custom_len: types.Callable[[str], int] = utils.len_color,
565+
max_error=True,
566+
prefix=None,
567+
suffix=None,
568+
variables=None,
569+
min_poll_interval=None,
570+
**kwargs,
568571
): # sourcery skip: low-code-quality
569572
'''Initializes a progress bar with sane defaults.'''
570573
StdRedirectMixin.__init__(self, **kwargs)
@@ -629,8 +632,8 @@ def __init__(
629632
default=None,
630633
)
631634
self._MINIMUM_UPDATE_INTERVAL = (
632-
utils.deltas_to_seconds(self._MINIMUM_UPDATE_INTERVAL)
633-
or self._MINIMUM_UPDATE_INTERVAL
635+
utils.deltas_to_seconds(self._MINIMUM_UPDATE_INTERVAL)
636+
or self._MINIMUM_UPDATE_INTERVAL
634637
)
635638

636639
# Note that the _MINIMUM_UPDATE_INTERVAL sets the minimum in case of
@@ -646,8 +649,8 @@ def __init__(
646649
self.variables = utils.AttributeDict(variables or {})
647650
for widget in self.widgets:
648651
if (
649-
isinstance(widget, widgets_module.VariableMixin)
650-
and widget.name not in self.variables
652+
isinstance(widget, widgets_module.VariableMixin)
653+
and widget.name not in self.variables
651654
):
652655
self.variables[widget.name] = None
653656

@@ -768,7 +771,7 @@ def data(self) -> types.Dict[str, types.Any]:
768771
total_seconds_elapsed=total_seconds_elapsed,
769772
# The seconds since the bar started modulo 60
770773
seconds_elapsed=(elapsed.seconds % 60)
771-
+ (elapsed.microseconds / 1000000.0),
774+
+ (elapsed.microseconds / 1000000.0),
772775
# The minutes since the bar started modulo 60
773776
minutes_elapsed=(elapsed.seconds / 60) % 60,
774777
# The hours since the bar started modulo 24
@@ -898,9 +901,9 @@ def update(self, value=None, force=False, **kwargs):
898901
self.start()
899902

900903
if (
901-
value is not None
902-
and value is not base.UnknownLength
903-
and isinstance(value, (int, float))
904+
value is not None
905+
and value is not base.UnknownLength
906+
and isinstance(value, (int, float))
904907
):
905908
if self.max_value is base.UnknownLength:
906909
# Can't compare against unknown lengths so just update
@@ -1023,9 +1026,9 @@ def _init_prefix(self):
10231026

10241027
def _verify_max_value(self):
10251028
if (
1026-
self.max_value is not base.UnknownLength
1027-
and self.max_value is not None
1028-
and self.max_value < 0 # type: ignore
1029+
self.max_value is not base.UnknownLength
1030+
and self.max_value is not None
1031+
and self.max_value < 0 # type: ignore
10291032
):
10301033
raise ValueError('max_value out of range, got %r' % self.max_value)
10311034

progressbar/env.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def from_env(cls):
7474
from .terminal.os_specific import windows
7575

7676
if (
77-
windows.get_console_mode()
78-
& windows.WindowsConsoleModeFlags.ENABLE_PROCESSED_OUTPUT
77+
windows.get_console_mode()
78+
& windows.WindowsConsoleModeFlags.ENABLE_PROCESSED_OUTPUT
7979
):
8080
return cls.XTERM_TRUECOLOR
8181
else:
@@ -99,8 +99,8 @@ def from_env(cls):
9999

100100

101101
def is_ansi_terminal(
102-
fd: base.IO,
103-
is_terminal: bool | None = None,
102+
fd: base.IO,
103+
is_terminal: bool | None = None,
104104
) -> bool | None: # pragma: no cover
105105
if is_terminal is None:
106106
# Jupyter Notebooks support progress bars
@@ -109,7 +109,8 @@ def is_ansi_terminal(
109109
# This works for newer versions of pycharm only. With older versions
110110
# there is no way to check.
111111
elif os.environ.get('PYCHARM_HOSTED') == '1' and not os.environ.get(
112-
'PYTEST_CURRENT_TEST'):
112+
'PYTEST_CURRENT_TEST'
113+
):
113114
is_terminal = True
114115

115116
if is_terminal is None:
@@ -165,8 +166,11 @@ def is_terminal(fd: base.IO, is_terminal: bool | None = None) -> bool | None:
165166

166167
os_specific.set_console_mode()
167168

168-
JUPYTER = bool(os.environ.get('JUPYTER_COLUMNS') or os.environ.get(
169-
'JUPYTER_LINES') or os.environ.get('JPY_PARENT_PID'))
169+
JUPYTER = bool(
170+
os.environ.get('JUPYTER_COLUMNS')
171+
or os.environ.get('JUPYTER_LINES')
172+
or os.environ.get('JPY_PARENT_PID')
173+
)
170174
COLOR_SUPPORT = ColorSupport.from_env()
171175
ANSI_TERMS = (
172176
'([xe]|bv)term',

progressbar/terminal/os_specific/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@
1111
else:
1212
from .posix import getch as _getch
1313

14-
1514
def _reset_console_mode() -> None:
1615
pass
1716

18-
1917
def _set_console_mode() -> bool:
2018
return False
2119

22-
2320
def _get_console_mode() -> int:
2421
return 0
2522

23+
2624
getch = _getch
2725
reset_console_mode = _reset_console_mode
2826
set_console_mode = _set_console_mode

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ include-package-data = true
112112
progressbar = 'progressbar.cli:main'
113113

114114
[project.optional-dependencies]
115-
docs = ['sphinx>=1.8.5', 'sphinx-autodoc-typehints>=1.6.0']
115+
docs = ['sphinx>=1.8.5', 'sphinx-autodoc-typehints>=1.6.0', 'termios']
116116
tests = [
117117
'dill>=0.3.6',
118118
'flake8>=3.7.7',

0 commit comments

Comments
 (0)