diff options
author | Marc Mueller <30130371+cdce8p@users.noreply.github.com> | 2021-06-09 23:20:47 +0200 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-06-10 12:49:20 +0200 |
commit | 8ff4d5d6bdb9590677d6a59c070e436ea283a8c6 (patch) | |
tree | bbaabaef51e80fc56c611226455097bb3bb59e65 /tests/functional/ext/code_style | |
parent | fd8daeef884fe036ff9041339a3876ed38b99668 (diff) | |
download | pylint-git-8ff4d5d6bdb9590677d6a59c070e436ea283a8c6.tar.gz |
Move to new extension CodeStyleChecker
Diffstat (limited to 'tests/functional/ext/code_style')
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 |