@@ -527,6 +527,10 @@ def visit_Import(self, node):
527527 self .check_for_b005 (node )
528528 self .generic_visit (node )
529529
530+ def visit_Set (self , node ):
531+ self .check_for_b033 (node )
532+ self .generic_visit (node )
533+
530534 def check_for_b005 (self , node ):
531535 if isinstance (node , ast .Import ):
532536 for name in node .names :
@@ -1346,6 +1350,14 @@ def check_for_b032(self, node):
13461350 ):
13471351 self .errors .append (B032 (node .lineno , node .col_offset ))
13481352
1353+ def check_for_b033 (self , node ):
1354+ constants = [
1355+ item .value
1356+ for item in filter (lambda x : isinstance (x , ast .Constant ), node .elts )
1357+ ]
1358+ if len (constants ) != len (set (constants )):
1359+ self .errors .append (B033 (node .lineno , node .col_offset ))
1360+
13491361
13501362def compose_call_path (node ):
13511363 if isinstance (node , ast .Attribute ):
@@ -1743,6 +1755,13 @@ def visit_Lambda(self, node):
17431755 )
17441756)
17451757
1758+ B033 = Error (
1759+ message = (
1760+ "B033 Sets should not contain duplicate items. Duplicate items will be replaced"
1761+ " with a single item at runtime."
1762+ )
1763+ )
1764+
17461765# Warnings disabled by default.
17471766B901 = Error (
17481767 message = (
0 commit comments