summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2021-06-01 20:54:10 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-06-10 12:49:20 +0200
commit5cd19d2f8fab98f707d666f8dabb89c9c8b94f11 (patch)
treeb323ea18a9a5780c1c3ba7158e558c68f680a2e5
parentb4afe920e3a0fc45025120ca9dd91d7363a0750b (diff)
downloadpylint-git-5cd19d2f8fab98f707d666f8dabb89c9c8b94f11.tar.gz
Fix existing code
-rw-r--r--pylint/checkers/classes.py4
-rw-r--r--pylint/checkers/format.py2
-rw-r--r--pylint/checkers/python3.py4
-rw-r--r--pylint/checkers/refactoring/len_checker.py2
-rw-r--r--pylint/checkers/refactoring/refactoring_checker.py6
-rw-r--r--pylint/extensions/_check_docs_utils.py4
-rw-r--r--tests/checkers/unittest_strings.py4
-rw-r--r--tests/extensions/test_check_raise_docs.py6
-rw-r--r--tests/lint/unittest_lint.py8
-rw-r--r--tests/test_import_graph.py2
-rw-r--r--tests/test_self.py2
-rw-r--r--tests/unittest_pyreverse_diadefs.py4
12 files changed, 24 insertions, 24 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py
index a8b94977a..ab918c265 100644
--- a/pylint/checkers/classes.py
+++ b/pylint/checkers/classes.py
@@ -2291,10 +2291,10 @@ class SpecialMethodsChecker(BaseChecker):
if len(inferred.elts) != 2:
found_error = True
else:
- for arg, check in [
+ for arg, check in (
(inferred.elts[0], self._is_tuple),
(inferred.elts[1], self._is_dict),
- ]:
+ ):
if isinstance(arg, astroid.Call):
arg = safe_infer(arg)
diff --git a/pylint/checkers/format.py b/pylint/checkers/format.py
index 9a4662607..07e61f831 100644
--- a/pylint/checkers/format.py
+++ b/pylint/checkers/format.py
@@ -443,7 +443,7 @@ class FormatChecker(BaseTokenChecker):
def _prepare_token_dispatcher(self):
dispatch = {}
- for tokens, handler in [(_KEYWORD_TOKENS, self._check_keyword_parentheses)]:
+ for tokens, handler in ((_KEYWORD_TOKENS, self._check_keyword_parentheses),):
for token in tokens:
dispatch[token] = handler
return dispatch
diff --git a/pylint/checkers/python3.py b/pylint/checkers/python3.py
index f61efa135..2762458c5 100644
--- a/pylint/checkers/python3.py
+++ b/pylint/checkers/python3.py
@@ -908,13 +908,13 @@ class Python3Checker(checkers.BaseChecker):
_python_2_tests = frozenset(
astroid.extract_node(x).repr_tree()
- for x in [
+ for x in (
"sys.version_info[0] == 2",
"sys.version_info[0] < 3",
"sys.version_info == (2, 7)",
"sys.version_info <= (2, 7)",
"sys.version_info < (3, 0)",
- ]
+ )
)
def __init__(self, *args, **kwargs):
diff --git a/pylint/checkers/refactoring/len_checker.py b/pylint/checkers/refactoring/len_checker.py
index 9ee7760be..1132a63a9 100644
--- a/pylint/checkers/refactoring/len_checker.py
+++ b/pylint/checkers/refactoring/len_checker.py
@@ -84,7 +84,7 @@ class LenChecker(checkers.BaseChecker):
return
mother_classes = self.base_classes_of_node(instance)
affected_by_pep8 = any(
- t in mother_classes for t in ["str", "tuple", "list", "set"]
+ t in mother_classes for t in ("str", "tuple", "list", "set")
)
if "range" in mother_classes or (
affected_by_pep8 and not self.instance_has_bool(instance)
diff --git a/pylint/checkers/refactoring/refactoring_checker.py b/pylint/checkers/refactoring/refactoring_checker.py
index 65b7932f4..8eda6c5a3 100644
--- a/pylint/checkers/refactoring/refactoring_checker.py
+++ b/pylint/checkers/refactoring/refactoring_checker.py
@@ -617,10 +617,10 @@ class RefactoringChecker(checkers.BaseTokenChecker):
@staticmethod
def _type_and_name_are_equal(node_a, node_b):
- for _type in [astroid.Name, astroid.AssignName]:
- if all(isinstance(_node, _type) for _node in [node_a, node_b]):
+ for _type in (astroid.Name, astroid.AssignName):
+ if all(isinstance(_node, _type) for _node in (node_a, node_b)):
return node_a.name == node_b.name
- if all(isinstance(_node, astroid.Const) for _node in [node_a, node_b]):
+ if all(isinstance(_node, astroid.Const) for _node in (node_a, node_b)):
return node_a.value == node_b.value
return False
diff --git a/pylint/extensions/_check_docs_utils.py b/pylint/extensions/_check_docs_utils.py
index 0a6f230df..cabd5128f 100644
--- a/pylint/extensions/_check_docs_utils.py
+++ b/pylint/extensions/_check_docs_utils.py
@@ -168,12 +168,12 @@ def possible_exc_types(node):
def docstringify(docstring, default_type="default"):
- for docstring_type in [
+ for docstring_type in (
SphinxDocstring,
EpytextDocstring,
GoogleDocstring,
NumpyDocstring,
- ]:
+ ):
instance = docstring_type(docstring)
if instance.is_valid():
return instance
diff --git a/tests/checkers/unittest_strings.py b/tests/checkers/unittest_strings.py
index c8e860dcf..d5d0244b5 100644
--- a/tests/checkers/unittest_strings.py
+++ b/tests/checkers/unittest_strings.py
@@ -69,14 +69,14 @@ class TestStringChecker(CheckerTestCase):
node = astroid.extract_node(code)
self.checker.visit_binop(node)
- for code, arg_type, format_type in [
+ for code, arg_type, format_type in (
("'%d' % '1'", "builtins.str", "d"),
("'%(key)d' % {'key' : '1'}", "builtins.str", "d"),
("'%x' % 1.1", "builtins.float", "x"),
("'%(key)x' % {'key' : 1.1}", "builtins.float", "x"),
("'%d' % []", "builtins.list", "d"),
("'%(key)d' % {'key' : []}", "builtins.list", "d"),
- ]:
+ ):
node = astroid.extract_node(code)
with self.assertAddsMessages(
Message(
diff --git a/tests/extensions/test_check_raise_docs.py b/tests/extensions/test_check_raise_docs.py
index 7ed7c405c..80384e192 100644
--- a/tests/extensions/test_check_raise_docs.py
+++ b/tests/extensions/test_check_raise_docs.py
@@ -202,7 +202,7 @@ class TestDocstringCheckerRaise(CheckerTestCase):
import re
raise re.error('hi') #@
'''
- for prefix in ["~", "!"]:
+ for prefix in ("~", "!"):
raise_node = astroid.extract_node(code_snippet.format(prefix=prefix))
with self.assertNoMessages():
self.checker.visit_raise(raise_node)
@@ -643,7 +643,7 @@ class TestDocstringCheckerRaise(CheckerTestCase):
import re
raise re.error('hi') #@
'''
- for prefix in ["~", "!"]:
+ for prefix in ("~", "!"):
raise_node = astroid.extract_node(code_snippet.format(prefix=prefix))
with self.assertNoMessages():
self.checker.visit_raise(raise_node)
@@ -763,7 +763,7 @@ class TestDocstringCheckerRaise(CheckerTestCase):
import re
raise re.error('hi') #@
'''
- for prefix in ["~", "!"]:
+ for prefix in ("~", "!"):
raise_node = astroid.extract_node(code_snippet.format(prefix=prefix))
with self.assertNoMessages():
self.checker.visit_raise(raise_node)
diff --git a/tests/lint/unittest_lint.py b/tests/lint/unittest_lint.py
index 22c93cf24..21748a507 100644
--- a/tests/lint/unittest_lint.py
+++ b/tests/lint/unittest_lint.py
@@ -220,7 +220,7 @@ def test_more_args(fake_path, case):
create_files(["a/b/c/__init__.py", "a/d/__init__.py", "a/e/f.py"])
expected = [
join(chroot, suffix)
- for suffix in [sep.join(("a", "b")), "a", sep.join(("a", "e"))]
+ for suffix in (sep.join(("a", "b")), "a", sep.join(("a", "e")))
] + fake_path
assert sys.path == fake_path
@@ -583,7 +583,7 @@ def test_full_documentation(linter):
linter.print_full_documentation(out)
output = out.getvalue()
# A few spot checks only
- for re_str in [
+ for re_str in (
# autogenerated text
"^Pylint global options and switches$",
"Verbatim name of the checker is ``python3``",
@@ -591,7 +591,7 @@ def test_full_documentation(linter):
"^:old-octal-literal \\(E1608\\):",
# options
"^:dummy-variables-rgx:",
- ]:
+ ):
regexp = re.compile(re_str, re.MULTILINE)
assert re.search(regexp, output)
@@ -756,7 +756,7 @@ def test_custom_should_analyze_file():
package_dir = os.path.join(REGRTEST_DATA_DIR, "bad_package")
wrong_file = os.path.join(package_dir, "wrong.py")
- for jobs in [1, 2]:
+ for jobs in (1, 2):
reporter = testutils.GenericTestReporter()
linter = _CustomPyLinter()
linter.config.jobs = jobs
diff --git a/tests/test_import_graph.py b/tests/test_import_graph.py
index 816e78a0f..9a4071220 100644
--- a/tests/test_import_graph.py
+++ b/tests/test_import_graph.py
@@ -66,7 +66,7 @@ URL="." node[shape="box"]
@pytest.mark.parametrize("filename", ["graph.png", "graph"])
@pytest.mark.skipif(
- any(shutil.which(x) for x in ["dot", "gv"]), reason="dot or gv is installed"
+ any(shutil.which(x) for x in ("dot", "gv")), reason="dot or gv is installed"
)
def test_missing_graphviz(filename):
"""Raises if graphviz is not installed, and defaults to png if no extension given"""
diff --git a/tests/test_self.py b/tests/test_self.py
index c5653457a..d8da706a7 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -400,7 +400,7 @@ class TestRunTC:
assert key in message
assert message[key] == value
msg = message["message"].lower()
- assert any(x in msg for x in ["expected ':'", "invalid syntax"])
+ assert any(x in msg for x in ("expected ':'", "invalid syntax"))
assert "<unknown>" in msg
assert "line 1" in msg
diff --git a/tests/unittest_pyreverse_diadefs.py b/tests/unittest_pyreverse_diadefs.py
index 8eb333fad..25a8fc363 100644
--- a/tests/unittest_pyreverse_diadefs.py
+++ b/tests/unittest_pyreverse_diadefs.py
@@ -67,7 +67,7 @@ def test_option_values(HANDLER, PROJECT):
assert not df_h.module_names
assert cl_h._get_levels() == (-1, -1)
assert cl_h.module_names
- for hndl in [df_h, cl_h]:
+ for hndl in (df_h, cl_h):
hndl.config.all_ancestors = True
hndl.config.all_associated = True
hndl.config.module_names = True
@@ -79,7 +79,7 @@ def test_option_values(HANDLER, PROJECT):
cl_config = Config()
cl_config.classes = ["Specialization"]
cl_h = DiaDefGenerator(Linker(PROJECT), DiadefsHandler(cl_config))
- for hndl in [df_h, cl_h]:
+ for hndl in (df_h, cl_h):
hndl.config.show_ancestors = 2
hndl.config.show_associated = 1
hndl.config.module_names = False