diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-07-10 23:39:03 +0200 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-07-10 23:44:25 +0200 |
commit | 2376f5e14b3d43bdd579f327ee75c16ccb778d7c (patch) | |
tree | cd9400b7bf4e77ab4df7c827485b8b201b74de3f | |
parent | 7d0ba6f8a5858d7db06c4f3cff5f249f39720fa2 (diff) | |
download | astroid-git-2376f5e14b3d43bdd579f327ee75c16ccb778d7c.tar.gz |
Fix 'Consider using an in-place tuple instead of list'
-rw-r--r-- | astroid/as_string.py | 2 | ||||
-rw-r--r-- | astroid/interpreter/_import/spec.py | 2 | ||||
-rw-r--r-- | astroid/rebuilder.py | 1 | ||||
-rw-r--r-- | astroid/scoped_nodes.py | 2 | ||||
-rw-r--r-- | pylintrc | 2 | ||||
-rw-r--r-- | tests/unittest_brain.py | 10 | ||||
-rw-r--r-- | tests/unittest_scoped_nodes.py | 2 |
7 files changed, 11 insertions, 10 deletions
diff --git a/astroid/as_string.py b/astroid/as_string.py index 9665a1b2..d081e725 100644 --- a/astroid/as_string.py +++ b/astroid/as_string.py @@ -317,7 +317,7 @@ class AsStringVisitor: # Try to find surrounding quotes that don't appear at all in the string. # Because the formatted values inside {} can't contain backslash (\) # using a triple quote is sometimes necessary - for quote in ["'", '"', '"""', "'''"]: + for quote in ("'", '"', '"""', "'''"): if quote not in string: break diff --git a/astroid/interpreter/_import/spec.py b/astroid/interpreter/_import/spec.py index 9d2bb593..6fa9074b 100644 --- a/astroid/interpreter/_import/spec.py +++ b/astroid/interpreter/_import/spec.py @@ -129,7 +129,7 @@ class ImportlibFinder(Finder): for entry in submodule_path: package_directory = os.path.join(entry, modname) - for suffix in [".py", importlib.machinery.BYTECODE_SUFFIXES[0]]: + for suffix in (".py", importlib.machinery.BYTECODE_SUFFIXES[0]): package_file_name = "__init__" + suffix file_path = os.path.join(package_directory, package_file_name) if os.path.isfile(file_path): diff --git a/astroid/rebuilder.py b/astroid/rebuilder.py index 3cd2a1fb..59ceac77 100644 --- a/astroid/rebuilder.py +++ b/astroid/rebuilder.py @@ -85,7 +85,6 @@ T_With = TypeVar("T_With", nodes.With, nodes.AsyncWith) # noinspection PyMethodMayBeStatic class TreeRebuilder: - # pylint: disable=no-self-use """Rebuilds the _ast tree to become an Astroid tree""" def __init__( diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py index de3d0270..09ed3910 100644 --- a/astroid/scoped_nodes.py +++ b/astroid/scoped_nodes.py @@ -2516,7 +2516,7 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG, node_classes.Statement implicit_meta = self.implicit_metaclass() context = contextmod.copy_context(context) metaclass = self.metaclass(context=context) - for cls in {implicit_meta, metaclass}: + for cls in (implicit_meta, metaclass): if cls and cls != self and isinstance(cls, ClassDef): cls_attributes = self._get_attribute_from_metaclass(cls, name, context) attrs.update(set(cls_attributes)) @@ -21,6 +21,8 @@ persistent=yes # usually to register additional checkers. load-plugins= pylint.extensions.check_elif, + pylint.extensions.bad_builtin, + pylint.extensions.code_style, # Use multiple processes to speed up Pylint. jobs=1 diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py index edba817a..834720fb 100644 --- a/tests/unittest_brain.py +++ b/tests/unittest_brain.py @@ -105,16 +105,16 @@ class HashlibTest(unittest.TestCase): def test_hashlib(self): """Tests that brain extensions for hashlib work.""" hashlib_module = MANAGER.ast_from_module_name("hashlib") - for class_name in ["md5", "sha1"]: + for class_name in ("md5", "sha1"): class_obj = hashlib_module[class_name] self._assert_hashlib_class(class_obj) def test_hashlib_py36(self): hashlib_module = MANAGER.ast_from_module_name("hashlib") - for class_name in ["sha3_224", "sha3_512", "shake_128"]: + for class_name in ("sha3_224", "sha3_512", "shake_128"): class_obj = hashlib_module[class_name] self._assert_hashlib_class(class_obj) - for class_name in ["blake2b", "blake2s"]: + for class_name in ("blake2b", "blake2s"): class_obj = hashlib_module[class_name] self.assertEqual(len(class_obj["__init__"].args.args), 2) @@ -743,7 +743,7 @@ class ThreadingBrainTest(unittest.TestCase): def assert_is_valid_lock(self, inferred): self.assertIsInstance(inferred, astroid.Instance) self.assertEqual(inferred.root().name, "threading") - for method in {"acquire", "release", "__enter__", "__exit__"}: + for method in ("acquire", "release", "__enter__", "__exit__"): self.assertIsInstance(next(inferred.igetattr(method)), astroid.BoundMethod) @@ -1112,7 +1112,7 @@ class IOBrainTest(unittest.TestCase): "use pytest -s for this test to work", ) def test_sys_streams(self): - for name in {"stdout", "stderr", "stdin"}: + for name in ("stdout", "stderr", "stdin"): node = astroid.extract_node( f""" import sys diff --git a/tests/unittest_scoped_nodes.py b/tests/unittest_scoped_nodes.py index d23db46a..bd7092b1 100644 --- a/tests/unittest_scoped_nodes.py +++ b/tests/unittest_scoped_nodes.py @@ -511,7 +511,7 @@ class FunctionNodeTest(ModuleLoader, unittest.TestCase): afoo, abar, cfoo, cbar = builder.extract_node(code) assert next(afoo.infer()) is util.Uninferable - for node, value in [(abar, None), (cfoo, 123), (cbar, None)]: + for node, value in ((abar, None), (cfoo, 123), (cbar, None)): inferred = next(node.infer()) assert isinstance(inferred, nodes.Const) assert inferred.value == value |