summaryrefslogtreecommitdiff
path: root/tests/functional/ext/code_style
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2021-06-09 23:20:47 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-06-10 12:49:20 +0200
commit8ff4d5d6bdb9590677d6a59c070e436ea283a8c6 (patch)
treebbaabaef51e80fc56c611226455097bb3bb59e65 /tests/functional/ext/code_style
parentfd8daeef884fe036ff9041339a3876ed38b99668 (diff)
downloadpylint-git-8ff4d5d6bdb9590677d6a59c070e436ea283a8c6.tar.gz
Move to new extension CodeStyleChecker
Diffstat (limited to 'tests/functional/ext/code_style')
-rw-r--r--tests/functional/ext/code_style/consider_using_tuple.py29
-rw-r--r--tests/functional/ext/code_style/consider_using_tuple.rc2
-rw-r--r--tests/functional/ext/code_style/consider_using_tuple.txt4
3 files changed, 35 insertions, 0 deletions
diff --git a/tests/functional/ext/code_style/consider_using_tuple.py b/tests/functional/ext/code_style/consider_using_tuple.py
new file mode 100644
index 000000000..679ef77d2
--- /dev/null
+++ b/tests/functional/ext/code_style/consider_using_tuple.py
@@ -0,0 +1,29 @@
+# pylint: disable=invalid-name,missing-docstring,pointless-statement,unnecessary-comprehension
+
+var = (1, 2, 3)
+
+for x in var:
+ pass
+for x in (1, 2, 3):
+ pass
+for x in [1, 2, 3]: # [consider-using-tuple]
+ pass
+
+(x for x in var)
+(x for x in (1, 2, 3))
+(x for x in [1, 2, 3]) # [consider-using-tuple]
+(x for x in {1, 2, 3}) # [consider-using-tuple]
+
+[x for x in var]
+[x for x in (1, 2, 3)]
+[x for x in [1, 2, 3]] # [consider-using-tuple]
+
+
+# list/set can't be replaced if tuple unpacking is used
+for x in [*var]:
+ pass
+for x in [2, *var]:
+ pass
+
+[x for x in [*var, 2]]
+[x for x in {*var, 2}]
diff --git a/tests/functional/ext/code_style/consider_using_tuple.rc b/tests/functional/ext/code_style/consider_using_tuple.rc
new file mode 100644
index 000000000..47767a206
--- /dev/null
+++ b/tests/functional/ext/code_style/consider_using_tuple.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.code_style
diff --git a/tests/functional/ext/code_style/consider_using_tuple.txt b/tests/functional/ext/code_style/consider_using_tuple.txt
new file mode 100644
index 000000000..df796b683
--- /dev/null
+++ b/tests/functional/ext/code_style/consider_using_tuple.txt
@@ -0,0 +1,4 @@
+consider-using-tuple:9:9::Consider using an in-place tuple instead of list
+consider-using-tuple:14:12::Consider using an in-place tuple instead of list
+consider-using-tuple:15:12::Consider using an in-place tuple instead of set
+consider-using-tuple:19:12::Consider using an in-place tuple instead of list