mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 21:16:54 +00:00
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:
parent
e2c4b50a46
commit
b42e758ac7
3 changed files with 7 additions and 3 deletions
|
|
@ -503,7 +503,7 @@ class FileChecker(object):
|
||||||
runner = checker.run()
|
runner = checker.run()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
runner = checker
|
runner = checker
|
||||||
for (line_number, offset, text, check) in runner:
|
for (line_number, offset, text, _) in runner:
|
||||||
self.report(
|
self.report(
|
||||||
error_code=None,
|
error_code=None,
|
||||||
line_number=line_number,
|
line_number=line_number,
|
||||||
|
|
@ -668,11 +668,14 @@ def _run_checks(checker):
|
||||||
|
|
||||||
|
|
||||||
def find_offset(offset, mapping):
|
def find_offset(offset, mapping):
|
||||||
|
# type: (int, processor._LogicalMapping) -> Tuple[int, int]
|
||||||
"""Find the offset tuple for a single offset."""
|
"""Find the offset tuple for a single offset."""
|
||||||
if isinstance(offset, tuple):
|
if isinstance(offset, tuple):
|
||||||
return offset
|
return offset
|
||||||
|
|
||||||
for token_offset, position in mapping:
|
for token in mapping:
|
||||||
|
token_offset = token[0]
|
||||||
if offset <= token_offset:
|
if offset <= token_offset:
|
||||||
|
position = token[1]
|
||||||
break
|
break
|
||||||
return (position[0], position[1] + offset - token_offset)
|
return (position[0], position[1] + offset - token_offset)
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ class AfterInitFormatter(base.BaseFormatter):
|
||||||
def test_after_init_is_always_called():
|
def test_after_init_is_always_called():
|
||||||
"""Verify after_init is called."""
|
"""Verify after_init is called."""
|
||||||
formatter = AfterInitFormatter(options())
|
formatter = AfterInitFormatter(options())
|
||||||
assert getattr(formatter, 'post_initialized') is True
|
assert formatter.post_initialized is True
|
||||||
|
|
||||||
|
|
||||||
class FormatFormatter(base.BaseFormatter):
|
class FormatFormatter(base.BaseFormatter):
|
||||||
|
|
|
||||||
1
tox.ini
1
tox.ini
|
|
@ -45,6 +45,7 @@ basepython = python3
|
||||||
skip_install = true
|
skip_install = true
|
||||||
deps =
|
deps =
|
||||||
flake8
|
flake8
|
||||||
|
flake8-bugbear
|
||||||
flake8-colors
|
flake8-colors
|
||||||
flake8-docstrings>=1.3.1
|
flake8-docstrings>=1.3.1
|
||||||
flake8-import-order>=0.9
|
flake8-import-order>=0.9
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue