linters: Add flake8-bugbear for finding bugs and design problems

Also, make appropriate changes to satisfy issues flagged by
`flake8-bugbear`.
This commit is contained in:
Eric N. Vander Weele 2019-10-25 16:37:40 -04:00
parent e2c4b50a46
commit b42e758ac7
3 changed files with 7 additions and 3 deletions

View file

@ -503,7 +503,7 @@ class FileChecker(object):
runner = checker.run()
except AttributeError:
runner = checker
for (line_number, offset, text, check) in runner:
for (line_number, offset, text, _) in runner:
self.report(
error_code=None,
line_number=line_number,
@ -668,11 +668,14 @@ def _run_checks(checker):
def find_offset(offset, mapping):
# type: (int, processor._LogicalMapping) -> Tuple[int, int]
"""Find the offset tuple for a single offset."""
if isinstance(offset, tuple):
return offset
for token_offset, position in mapping:
for token in mapping:
token_offset = token[0]
if offset <= token_offset:
position = token[1]
break
return (position[0], position[1] + offset - token_offset)

View file

@ -147,7 +147,7 @@ class AfterInitFormatter(base.BaseFormatter):
def test_after_init_is_always_called():
"""Verify after_init is called."""
formatter = AfterInitFormatter(options())
assert getattr(formatter, 'post_initialized') is True
assert formatter.post_initialized is True
class FormatFormatter(base.BaseFormatter):

View file

@ -45,6 +45,7 @@ basepython = python3
skip_install = true
deps =
flake8
flake8-bugbear
flake8-colors
flake8-docstrings>=1.3.1
flake8-import-order>=0.9