@@ -1163,13 +1163,18 @@ def ambiguous_identifier(logical_line, tokens):
11631163 E741: O = 123
11641164 E741: I = 42
11651165
1166- Variables can be bound in other contexts, so identifiers appearing after
1167- the 'as' keyword are also reported:
1166+ Variables can be bound in several other contexts, including class and
1167+ function definitions, 'global' and 'nonlocal' statements, exception
1168+ handlers, and 'with' statements.
11681169
11691170 Okay: except AttributeError as o:
11701171 Okay: with lock as L:
11711172 E741: except AttributeError as O:
11721173 E741: with lock as l:
1174+ E741: global I
1175+ E741: nonlocal l
1176+ E742: class I(object):
1177+ E743: def l(x):
11731178 """
11741179 idents_to_avoid = ('l' , 'O' , 'I' )
11751180 prev_type , prev_text , prev_start , prev_end , __ = tokens [0 ]
@@ -1185,6 +1190,12 @@ def ambiguous_identifier(logical_line, tokens):
11851190 if text in idents_to_avoid :
11861191 ident = text
11871192 pos = start
1193+ if prev_text == 'class' :
1194+ if text in idents_to_avoid :
1195+ yield start , "E742 ambiguous class definition '%s'" % text
1196+ if prev_text == 'def' :
1197+ if text in idents_to_avoid :
1198+ yield start , "E743 ambiguous function definition '%s'" % text
11881199 if ident :
11891200 yield pos , "E741 ambiguous variable name '%s'" % ident
11901201 prev_type = token_type
0 commit comments