diff options
author | jaydesl <35102795+jaydesl@users.noreply.github.com> | 2021-10-16 09:00:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-16 10:00:50 +0200 |
commit | 9098c6078551e2d3028fe65537d3b0e407c85724 (patch) | |
tree | ce6faf420cf69a40ed0f7fb858add734764e9167 /tests/functional | |
parent | ab775f6f4507a1f0cd9dab0fd027c2f08be06928 (diff) | |
download | pylint-git-9098c6078551e2d3028fe65537d3b0e407c85724.tar.gz |
Consider Enums when checking for duplicate dictionary keys (#5155)
* detect duplicate-key for enum members
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/functional')
-rw-r--r-- | tests/functional/d/duplicate_dict_literal_key.py | 14 | ||||
-rw-r--r-- | tests/functional/d/duplicate_dict_literal_key.txt | 7 |
2 files changed, 18 insertions, 3 deletions
diff --git a/tests/functional/d/duplicate_dict_literal_key.py b/tests/functional/d/duplicate_dict_literal_key.py index 6d359ff0a..82e98d23e 100644 --- a/tests/functional/d/duplicate_dict_literal_key.py +++ b/tests/functional/d/duplicate_dict_literal_key.py @@ -1,11 +1,25 @@ """Check multiple key definition""" # pylint: disable=pointless-statement, redundant-u-string-prefix +from enum import Enum + + +class MyEnum(Enum): + """ Sample Enum for testing duplicate keys""" + KEY = "key" + + + correct_dict = { 'tea': 'for two', 'two': 'for tea', } +wrong_with_enum = { # [duplicate-key] + MyEnum.KEY: "value 1", + MyEnum.KEY: "value 2", +} + wrong_dict = { # [duplicate-key] 'tea': 'for two', 'two': 'for tea', diff --git a/tests/functional/d/duplicate_dict_literal_key.txt b/tests/functional/d/duplicate_dict_literal_key.txt index 756f15818..83941b988 100644 --- a/tests/functional/d/duplicate_dict_literal_key.txt +++ b/tests/functional/d/duplicate_dict_literal_key.txt @@ -1,3 +1,4 @@ -duplicate-key:9:13::Duplicate key 'tea' in dictionary -duplicate-key:16:0::Duplicate key 1 in dictionary -duplicate-key:17:0::Duplicate key 1.0 in dictionary +duplicate-key:18:18::Duplicate key 'MyEnum.KEY' in dictionary:HIGH +duplicate-key:23:13::Duplicate key 'tea' in dictionary:HIGH +duplicate-key:30:0::Duplicate key 1 in dictionary:HIGH +duplicate-key:31:0::Duplicate key 1.0 in dictionary:HIGH |