Skip to content

Commit 975eb8f

Browse files
committed
Merge branch 'release/v3.39.0'
2 parents 5df7e08 + 2a2c410 commit 975eb8f

File tree

13 files changed

+287
-64
lines changed

13 files changed

+287
-64
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ python:
99
install:
1010
- pip install .
1111
- pip install -r tests/requirements.txt
12-
before_script: flake8 --ignore=W391 progressbar tests
12+
before_script: flake8 progressbar tests
1313
script:
1414
- python setup.py test
1515
- python examples.py

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Due to limitations in both the IDLE shell and the Jetbrains (Pycharm) shells thi
7373

7474
- The IDLE editor doesn't support these types of progress bars at all: https://bugs.python.org/issue23220
7575
- The Jetbrains (Pycharm) editors partially work but break with fast output. As a workaround make sure you only write to either `sys.stdout` (regular print) or `sys.stderr` at the same time. If you do plan to use both, make sure you wait about ~200 milliseconds for the next output or it will break regularly. Linked issue: https://github.com/WoLpH/python-progressbar/issues/115
76+
- Jupyter notebooks buffer `sys.stdout` which can cause mixed output. This issue can be resolved easily using: `import sys; sys.stdout.flush()`. Linked issue: https://github.com/WoLpH/python-progressbar/issues/173
7677

7778
******************************************************************************
7879
Links

progressbar/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
long running operations.
2020
'''.strip().split())
2121
__email__ = '[email protected]'
22-
__version__ = '3.38.0'
22+
__version__ = '3.39.0'
2323
__license__ = 'BSD'
2424
__copyright__ = 'Copyright 2015 Rick van Hattem (Wolph)'
2525
__url__ = 'https://github.com/WoLpH/python-progressbar'

progressbar/bar.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,13 @@ def default_widgets(self):
434434

435435
def __call__(self, iterable, max_value=None):
436436
'Use a ProgressBar to iterate through an iterable'
437-
if max_value is None:
437+
if max_value is not None:
438+
self.max_value = max_value
439+
elif self.max_value is None:
438440
try:
439441
self.max_value = len(iterable)
440442
except TypeError: # pragma: no cover
441-
if self.max_value is None:
442-
self.max_value = base.UnknownLength
443-
else:
444-
self.max_value = max_value
443+
self.max_value = base.UnknownLength
445444

446445
self._iterable = iter(iterable)
447446
return self
@@ -529,6 +528,7 @@ def _needs_update(self):
529528
delta = timeit.default_timer() - self._last_update_timer
530529
poll_status = delta > self.poll_interval.total_seconds()
531530
else:
531+
delta = 0
532532
poll_status = False
533533

534534
# Do not update if value increment is not large enough to
@@ -542,7 +542,7 @@ def _needs_update(self):
542542
# ignore any division errors
543543
pass
544544

545-
return self.value > self.next_update or poll_status or self.end_time
545+
return poll_status or self.end_time
546546

547547
def update(self, value=None, force=False, **kwargs):
548548
'Updates the ProgressBar to a new value.'
@@ -554,7 +554,7 @@ def update(self, value=None, force=False, **kwargs):
554554
if self.max_value is base.UnknownLength:
555555
# Can't compare against unknown lengths so just update
556556
pass
557-
elif self.min_value <= value <= self.max_value:
557+
elif self.min_value <= value <= self.max_value: # pragma: no cover
558558
# Correct value, let's accept
559559
pass
560560
elif self.max_error:
@@ -647,7 +647,6 @@ def start(self, max_value=None, init=True):
647647
)
648648

649649
self.num_intervals = max(100, self.term_width)
650-
self.next_update = 0
651650

652651
if self.max_value is not base.UnknownLength and self.max_value < 0:
653652
raise ValueError('Value out of range')

progressbar/widgets.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,20 @@ class SamplesMixin(TimeSensitiveWidgetBase):
240240
>>> samples(progress, None, True)
241241
(None, None)
242242
>>> progress.last_update_time += datetime.timedelta(seconds=1)
243-
>>> samples(progress, None, True)
244-
(datetime.timedelta(0, 1), 0)
243+
>>> samples(progress, None, True) == (datetime.timedelta(seconds=1), 0)
244+
True
245+
245246
>>> progress.last_update_time += datetime.timedelta(seconds=1)
246-
>>> samples(progress, None, True)
247-
(datetime.timedelta(0, 1), 0)
247+
>>> samples(progress, None, True) == (datetime.timedelta(seconds=1), 0)
248+
True
248249
249250
>>> samples = SamplesMixin(samples=datetime.timedelta(seconds=1))
250251
>>> _, value = samples(progress, None)
251252
>>> value
252253
[1, 1]
253254
254-
>>> samples(progress, None, True)
255-
(datetime.timedelta(0, 1), 0)
255+
>>> samples(progress, None, True) == (datetime.timedelta(seconds=1), 0)
256+
True
256257
'''
257258

258259
def __init__(self, samples=datetime.timedelta(seconds=2), key_prefix=None,
@@ -352,10 +353,12 @@ def __call__(self, progress, data, value=None, elapsed=None):
352353
data['eta_seconds'] = None
353354
ETA_NA = True
354355

356+
data['eta'] = None
355357
if data['eta_seconds']:
356-
data['eta'] = utils.format_time(data['eta_seconds'])
357-
else:
358-
data['eta'] = None
358+
try:
359+
data['eta'] = utils.format_time(data['eta_seconds'])
360+
except (ValueError, OverflowError): # pragma: no cover
361+
pass
359362

360363
if data['value'] == progress.min_value:
361364
format = self.format_not_started

pytest.ini

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@ addopts =
99
--cov-report html
1010
--no-cov-on-fail
1111
--doctest-modules
12-
--pep8
13-
--flakes
14-
15-
pep8ignore =
16-
*.py W391
17-
docs/*.py ALL
18-
progressbar/six.py ALL
19-
ptr.py W191 W503
20-
21-
flakes-ignore =
22-
docs/*.py ALL
23-
progressbar/six.py ALL
2412

2513
norecursedirs =
2614
.svn
@@ -31,3 +19,6 @@ norecursedirs =
3119
dist
3220
.ropeproject
3321
.tox
22+
23+
filterwarnings =
24+
ignore::DeprecationWarning

setup.cfg

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,6 @@ test=pytest
44
[metadata]
55
description-file = README.rst
66

7-
[nosetests]
8-
verbosity=3
9-
detailed-errors=1
10-
debug=nose.loader
11-
12-
with-doctest=1
13-
14-
with-coverage=1
15-
cover-package=progressbar
16-
cover-branches=1
17-
cover-min-percentage=100
18-
19-
#pdb=1
20-
pdb-failures=1
21-
22-
with-tissue=1
23-
tissue-ignore=W391
24-
tissue-package=progressbar
25-
26-
[build_sphinx]
27-
source-dir = docs/
28-
build-dir = docs/_build
29-
all_files = 1
30-
31-
[upload_sphinx]
32-
upload-dir = docs/_build/html
33-
34-
[flake8]
35-
ignore = W391
36-
377
[bdist_wheel]
388
universal = 1
399

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626

2727
install_reqs = []
28+
needs_pytest = set(['ptr', 'pytest', 'test']).intersection(sys.argv)
29+
pytest_runner = ['pytest-runner>=2.8'] if needs_pytest else []
2830
tests_reqs = []
2931

3032
if sys.version_info < (2, 7):
@@ -62,7 +64,7 @@
6264
'six',
6365
],
6466
tests_require=tests_reqs,
65-
setup_requires=['setuptools', 'pytest-runner>=2.8'],
67+
setup_requires=['setuptools'] + pytest_runner,
6668
zip_safe=False,
6769
extras_require={
6870
'docs': [

tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import time
2+
import timeit
23
import pytest
34
import logging
45
import freezegun
@@ -23,6 +24,7 @@ def small_interval(monkeypatch):
2324
# Remove the update limit for tests by default
2425
monkeypatch.setattr(
2526
progressbar.ProgressBar, '_MINIMUM_UPDATE_INTERVAL', 1e-6)
27+
monkeypatch.setattr(timeit, 'default_timer', time.time)
2628

2729

2830
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)