summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-09-29 16:10:45 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2018-09-29 16:10:45 +0200
commit9ba4196c5e1083c4d058ca01c77bc0679605a1a7 (patch)
tree28e502f6bdfb9f54095a1ee8e2d4df40386090fb
parentdaef49a9f5623a324f65f5227f2e4a2f7cfeeff0 (diff)
downloadpylint-git-9ba4196c5e1083c4d058ca01c77bc0679605a1a7.tar.gz
Fix formatting errors
-rw-r--r--pylint/checkers/similar.py16
-rw-r--r--pylint/test/unittest_checker_similar.py29
2 files changed, 29 insertions, 16 deletions
diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py
index da2ab5b9d..2e45ce9c6 100644
--- a/pylint/checkers/similar.py
+++ b/pylint/checkers/similar.py
@@ -157,14 +157,17 @@ def stripped_lines(lines, ignore_comments, ignore_docstrings, ignore_imports):
features removed
"""
if ignore_imports:
- tree = astroid.parse(''.join(lines))
+ tree = astroid.parse("".join(lines))
node_is_import_by_lineno = (
(node.lineno, isinstance(node, (astroid.Import, astroid.ImportFrom)))
- for node in tree.body)
+ for node in tree.body
+ )
line_begins_import = {
lineno: all(is_import for _, is_import in node_is_import_group)
- for lineno, node_is_import_group
- in groupby(node_is_import_by_lineno, key=lambda x: x[0])}
+ for lineno, node_is_import_group in groupby(
+ node_is_import_by_lineno, key=lambda x: x[0]
+ )
+ }
current_line_is_import = False
strippedlines = []
@@ -181,9 +184,10 @@ def stripped_lines(lines, ignore_comments, ignore_docstrings, ignore_imports):
line = ""
if ignore_imports:
current_line_is_import = line_begins_import.get(
- lineno, current_line_is_import)
+ lineno, current_line_is_import
+ )
if current_line_is_import:
- line = ''
+ line = ""
if ignore_comments:
# XXX should use regex in checkers/format to avoid cutting
# at a "#" in a string
diff --git a/pylint/test/unittest_checker_similar.py b/pylint/test/unittest_checker_similar.py
index 4151419eb..f2cd901a8 100644
--- a/pylint/test/unittest_checker_similar.py
+++ b/pylint/test/unittest_checker_similar.py
@@ -18,12 +18,12 @@ import pytest
from pylint.checkers import similar
-SIMILAR1 = join(dirname(abspath(__file__)), 'input', 'similar1')
-SIMILAR2 = join(dirname(abspath(__file__)), 'input', 'similar2')
-MULTILINE = join(dirname(abspath(__file__)), 'input', 'multiline-import')
+SIMILAR1 = join(dirname(abspath(__file__)), "input", "similar1")
+SIMILAR2 = join(dirname(abspath(__file__)), "input", "similar2")
+MULTILINE = join(dirname(abspath(__file__)), "input", "multiline-import")
HIDE_CODE_WITH_IMPORTS = join(
- dirname(abspath(__file__)), 'input', 'hide_code_with_imports.py')
-
+ dirname(abspath(__file__)), "input", "hide_code_with_imports.py"
+)
def test_ignore_comments():
@@ -109,7 +109,10 @@ def test_multiline_imports():
with redirect_stdout(output), pytest.raises(SystemExit) as ex:
similar.Run([MULTILINE, MULTILINE])
assert ex.value.code == 0
- assert output.getvalue().strip() == ("""
+ assert (
+ output.getvalue().strip()
+ == (
+ """
8 similar lines in 2 files
==%s:0
==%s:0
@@ -122,23 +125,29 @@ def test_multiline_imports():
quuuuux,
)
TOTAL lines=16 duplicates=8 percent=50.00
-""" % (MULTILINE, MULTILINE)).strip()
+"""
+ % (MULTILINE, MULTILINE)
+ ).strip()
+ )
def test_ignore_multiline_imports():
output = StringIO()
with redirect_stdout(output), pytest.raises(SystemExit) as ex:
- similar.Run(['--ignore-imports', MULTILINE, MULTILINE])
+ similar.Run(["--ignore-imports", MULTILINE, MULTILINE])
assert ex.value.code == 0
- assert output.getvalue().strip() == """
+ assert (
+ output.getvalue().strip()
+ == """
TOTAL lines=16 duplicates=0 percent=0.00
""".strip()
+ )
def test_no_hide_code_with_imports():
output = StringIO()
with redirect_stdout(output), pytest.raises(SystemExit) as ex:
- similar.Run(['--ignore-imports'] + 2 * [HIDE_CODE_WITH_IMPORTS])
+ similar.Run(["--ignore-imports"] + 2 * [HIDE_CODE_WITH_IMPORTS])
assert ex.value.code == 0
assert "TOTAL lines=32 duplicates=16 percent=50.00" in output.getvalue()