Skip to content

Commit

Permalink
Linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
avylove committed Aug 21, 2020
1 parent 244338a commit 9485432
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions enlighten/_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import time

from enlighten._basecounter import BaseCounter, PrintableCounter
from enlighten._util import EnlightenWarning, format_time, warn_best_level
from enlighten._util import EnlightenWarning, format_time, raise_from_none, warn_best_level

COUNTER_FMT = u'{desc}{desc_pad}{count:d} {unit}{unit_pad}' + \
u'[{elapsed}, {rate:.2f}{unit_pad}{unit}/s]{fill}'
Expand Down Expand Up @@ -578,7 +578,7 @@ def format(self, width=None, elapsed=None):
try:
rtn = self.bar_format.format(**fields)
except KeyError as e:
raise ValueError('%r specified in format, but not provided' % e.args[0])
raise_from_none(ValueError('%r specified in format, but not provided' % e.args[0]))

# Format the bar
if self.offset is None:
Expand Down Expand Up @@ -618,7 +618,7 @@ def format(self, width=None, elapsed=None):
try:
rtn = self.counter_format.format(**fields)
except KeyError as e:
raise ValueError('%r specified in format, but not provided' % e.args[0])
raise_from_none(ValueError('%r specified in format, but not provided' % e.args[0]))

return self._fill_text(rtn, width, offset=self.offset)

Expand Down
4 changes: 2 additions & 2 deletions enlighten/_statusbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import time

from enlighten._basecounter import PrintableCounter
from enlighten._util import EnlightenWarning, format_time, Justify, warn_best_level
from enlighten._util import EnlightenWarning, format_time, Justify, raise_from_none, warn_best_level


STATUS_FIELDS = {'elapsed', 'fill'}
Expand Down Expand Up @@ -205,7 +205,7 @@ def format(self, width=None, elapsed=None):
try:
rtn = self.status_format.format(**fields)
except KeyError as e:
raise ValueError('%r specified in format, but not provided' % e.args[0])
raise_from_none(ValueError('%r specified in format, but not provided' % e.args[0]))

rtn = self._fill_text(rtn, width)

Expand Down
12 changes: 12 additions & 0 deletions enlighten/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import inspect
import os
import sys
import warnings

try:
Expand Down Expand Up @@ -69,6 +70,17 @@ def format_time(seconds):
return rtn


def raise_from_none(exc): # pragma: no cover
"""
Convenience function to raise from None in a Python 2/3 compatible manner
"""
raise exc


if sys.version_info[0] >= 3: # pragma: no branch
exec('def raise_from_none(exc):\n raise exc from None') # pylint: disable=exec-used


class Justify(object):
"""
Enumerated type for justification options
Expand Down
1 change: 1 addition & 0 deletions examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import enlighten

# pylint: disable=wrong-import-order
from multicolored import run_tests, load
from multiple_logging import process_files, win_time_granularity

Expand Down
3 changes: 2 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ good-names=e,_

[MESSAGES CONTROL]
disable=
super-with-arguments, # Python 2
too-few-public-methods,
useless-object-inheritance
useless-object-inheritance, # Python 2

[SIMILARITIES]
# Minimum lines number of a similarity.
Expand Down

0 comments on commit 9485432

Please sign in to comment.