114 <td><a href="#BugBearVisitor.__checkForM516">__checkForM516</a></td> |
114 <td><a href="#BugBearVisitor.__checkForM516">__checkForM516</a></td> |
115 <td>Private method to check for raising a literal instead of an exception.</td> |
115 <td>Private method to check for raising a literal instead of an exception.</td> |
116 </tr> |
116 </tr> |
117 <tr> |
117 <tr> |
118 <td><a href="#BugBearVisitor.__checkForM517">__checkForM517</a></td> |
118 <td><a href="#BugBearVisitor.__checkForM517">__checkForM517</a></td> |
119 <td>Private method to check for use of the evil syntax 'with assertRaises(Exception):.</td> |
119 <td>Private method to check for use of the evil syntax 'with assertRaises(Exception): or 'with pytest.raises(Exception):'.</td> |
120 </tr> |
120 </tr> |
121 <tr> |
121 <tr> |
122 <td><a href="#BugBearVisitor.__checkForM518">__checkForM518</a></td> |
122 <td><a href="#BugBearVisitor.__checkForM518">__checkForM518</a></td> |
123 <td>Private method to check for useless expressions.</td> |
123 <td>Private method to check for useless expressions.</td> |
124 </tr> |
124 </tr> |
153 <tr> |
153 <tr> |
154 <td><a href="#BugBearVisitor.__checkForM526">__checkForM526</a></td> |
154 <td><a href="#BugBearVisitor.__checkForM526">__checkForM526</a></td> |
155 <td>Private method to check for Star-arg unpacking after keyword argument.</td> |
155 <td>Private method to check for Star-arg unpacking after keyword argument.</td> |
156 </tr> |
156 </tr> |
157 <tr> |
157 <tr> |
|
158 <td><a href="#BugBearVisitor.__checkForM528">__checkForM528</a></td> |
|
159 <td>Private method to check for warn without stacklevel.</td> |
|
160 </tr> |
|
161 <tr> |
|
162 <td><a href="#BugBearVisitor.__checkForM531">__checkForM531</a></td> |
|
163 <td>Private method to check that 'itertools.groupby' isn't iterated over more than once.</td> |
|
164 </tr> |
|
165 <tr> |
|
166 <td><a href="#BugBearVisitor.__checkForM532">__checkForM532</a></td> |
|
167 <td>Private method to check for possible unintentional typing annotation.</td> |
|
168 </tr> |
|
169 <tr> |
|
170 <td><a href="#BugBearVisitor.__checkForM533">__checkForM533</a></td> |
|
171 <td>Private method to check a set for duplicate items.</td> |
|
172 </tr> |
|
173 <tr> |
|
174 <td><a href="#BugBearVisitor.__checkRedundantExcepthandlers">__checkRedundantExcepthandlers</a></td> |
|
175 <td>Private method to check for redundant exception types in an exception handler.</td> |
|
176 </tr> |
|
177 <tr> |
158 <td><a href="#BugBearVisitor.__childrenInScope">__childrenInScope</a></td> |
178 <td><a href="#BugBearVisitor.__childrenInScope">__childrenInScope</a></td> |
159 <td>Private method to get all child nodes in the given scope.</td> |
179 <td>Private method to get all child nodes in the given scope.</td> |
160 </tr> |
180 </tr> |
161 <tr> |
181 <tr> |
162 <td><a href="#BugBearVisitor.__composeCallPath">__composeCallPath</a></td> |
182 <td><a href="#BugBearVisitor.__composeCallPath">__composeCallPath</a></td> |
163 <td>Private method get the individual elements of the call path of a node.</td> |
183 <td>Private method get the individual elements of the call path of a node.</td> |
164 </tr> |
184 </tr> |
165 <tr> |
185 <tr> |
|
186 <td><a href="#BugBearVisitor.__flattenExcepthandler">__flattenExcepthandler</a></td> |
|
187 <td>Private method to flatten the list of exceptions handled by an except handler.</td> |
|
188 </tr> |
|
189 <tr> |
166 <td><a href="#BugBearVisitor.__getAssignedNames">__getAssignedNames</a></td> |
190 <td><a href="#BugBearVisitor.__getAssignedNames">__getAssignedNames</a></td> |
167 <td>Private method to get the names of a for loop.</td> |
191 <td>Private method to get the names of a for loop.</td> |
168 </tr> |
192 </tr> |
169 <tr> |
193 <tr> |
170 <td><a href="#BugBearVisitor.__isIdentifier">__isIdentifier</a></td> |
194 <td><a href="#BugBearVisitor.__isIdentifier">__isIdentifier</a></td> |
181 <tr> |
205 <tr> |
182 <td><a href="#BugBearVisitor.__typesafeIssubclass">__typesafeIssubclass</a></td> |
206 <td><a href="#BugBearVisitor.__typesafeIssubclass">__typesafeIssubclass</a></td> |
183 <td>Private method implementing a type safe issubclass() function.</td> |
207 <td>Private method implementing a type safe issubclass() function.</td> |
184 </tr> |
208 </tr> |
185 <tr> |
209 <tr> |
|
210 <td><a href="#BugBearVisitor.__walkList">__walkList</a></td> |
|
211 <td>Private method to walk a given list of nodes.</td> |
|
212 </tr> |
|
213 <tr> |
186 <td><a href="#BugBearVisitor._loop">_loop</a></td> |
214 <td><a href="#BugBearVisitor._loop">_loop</a></td> |
187 <td></td> |
215 <td></td> |
188 </tr> |
216 </tr> |
189 <tr> |
217 <tr> |
190 <td><a href="#BugBearVisitor.emptyBody">emptyBody</a></td> |
218 <td><a href="#BugBearVisitor.emptyBody">emptyBody</a></td> |
213 <tr> |
241 <tr> |
214 <td><a href="#BugBearVisitor.visit">visit</a></td> |
242 <td><a href="#BugBearVisitor.visit">visit</a></td> |
215 <td>Public method to traverse a given AST node.</td> |
243 <td>Public method to traverse a given AST node.</td> |
216 </tr> |
244 </tr> |
217 <tr> |
245 <tr> |
|
246 <td><a href="#BugBearVisitor.visit_AnnAssign">visit_AnnAssign</a></td> |
|
247 <td>Public method to check annotated assign statements.</td> |
|
248 </tr> |
|
249 <tr> |
218 <td><a href="#BugBearVisitor.visit_Assert">visit_Assert</a></td> |
250 <td><a href="#BugBearVisitor.visit_Assert">visit_Assert</a></td> |
219 <td>Public method to handle 'assert' statements.</td> |
251 <td>Public method to handle 'assert' statements.</td> |
220 </tr> |
252 </tr> |
221 <tr> |
253 <tr> |
222 <td><a href="#BugBearVisitor.visit_Assign">visit_Assign</a></td> |
254 <td><a href="#BugBearVisitor.visit_Assign">visit_Assign</a></td> |
257 <tr> |
289 <tr> |
258 <td><a href="#BugBearVisitor.visit_GeneratorExp">visit_GeneratorExp</a></td> |
290 <td><a href="#BugBearVisitor.visit_GeneratorExp">visit_GeneratorExp</a></td> |
259 <td>Public method to handle generator expressions.</td> |
291 <td>Public method to handle generator expressions.</td> |
260 </tr> |
292 </tr> |
261 <tr> |
293 <tr> |
|
294 <td><a href="#BugBearVisitor.visit_Import">visit_Import</a></td> |
|
295 <td>Public method to check imports.</td> |
|
296 </tr> |
|
297 <tr> |
262 <td><a href="#BugBearVisitor.visit_JoinedStr">visit_JoinedStr</a></td> |
298 <td><a href="#BugBearVisitor.visit_JoinedStr">visit_JoinedStr</a></td> |
263 <td>Public method to handle f-string arguments.</td> |
299 <td>Public method to handle f-string arguments.</td> |
264 </tr> |
300 </tr> |
265 <tr> |
301 <tr> |
266 <td><a href="#BugBearVisitor.visit_ListComp">visit_ListComp</a></td> |
302 <td><a href="#BugBearVisitor.visit_ListComp">visit_ListComp</a></td> |
267 <td>Public method to handle list comprehensions.</td> |
303 <td>Public method to handle list comprehensions.</td> |
268 </tr> |
304 </tr> |
269 <tr> |
305 <tr> |
|
306 <td><a href="#BugBearVisitor.visit_Module">visit_Module</a></td> |
|
307 <td>Public method to handle a module node.</td> |
|
308 </tr> |
|
309 <tr> |
270 <td><a href="#BugBearVisitor.visit_Raise">visit_Raise</a></td> |
310 <td><a href="#BugBearVisitor.visit_Raise">visit_Raise</a></td> |
271 <td>Public method to handle 'raise' statements.</td> |
311 <td>Public method to handle 'raise' statements.</td> |
|
312 </tr> |
|
313 <tr> |
|
314 <td><a href="#BugBearVisitor.visit_Set">visit_Set</a></td> |
|
315 <td>Public method to check a set.</td> |
272 </tr> |
316 </tr> |
273 <tr> |
317 <tr> |
274 <td><a href="#BugBearVisitor.visit_SetComp">visit_SetComp</a></td> |
318 <td><a href="#BugBearVisitor.visit_SetComp">visit_SetComp</a></td> |
275 <td>Public method to handle set comprehensions.</td> |
319 <td>Public method to handle set comprehensions.</td> |
276 </tr> |
320 </tr> |
516 <dt><i>node</i> (ast.Call)</dt> |
560 <dt><i>node</i> (ast.Call)</dt> |
517 <dd> |
561 <dd> |
518 reference to the node to be processed |
562 reference to the node to be processed |
519 </dd> |
563 </dd> |
520 </dl> |
564 </dl> |
|
565 <a NAME="BugBearVisitor.__checkForM528" ID="BugBearVisitor.__checkForM528"></a> |
|
566 <h4>BugBearVisitor.__checkForM528</h4> |
|
567 <b>__checkForM528</b>(<i>node</i>) |
|
568 |
|
569 <p> |
|
570 Private method to check for warn without stacklevel. |
|
571 </p> |
|
572 <dl> |
|
573 |
|
574 <dt><i>node</i> (ast.Call)</dt> |
|
575 <dd> |
|
576 reference to the node to be processed |
|
577 </dd> |
|
578 </dl> |
|
579 <a NAME="BugBearVisitor.__checkForM531" ID="BugBearVisitor.__checkForM531"></a> |
|
580 <h4>BugBearVisitor.__checkForM531</h4> |
|
581 <b>__checkForM531</b>(<i>loopNode</i>) |
|
582 |
|
583 <p> |
|
584 Private method to check that 'itertools.groupby' isn't iterated over more than |
|
585 once. |
|
586 </p> |
|
587 <p> |
|
588 A warning is emitted when the generator returned by 'groupby()' is used |
|
589 more than once inside a loop body or when it's used in a nested loop. |
|
590 </p> |
|
591 <dl> |
|
592 |
|
593 <dt><i>loopNode</i> (ast.For or ast.AsyncFor)</dt> |
|
594 <dd> |
|
595 reference to the node to be processed |
|
596 </dd> |
|
597 </dl> |
|
598 <a NAME="BugBearVisitor.__checkForM532" ID="BugBearVisitor.__checkForM532"></a> |
|
599 <h4>BugBearVisitor.__checkForM532</h4> |
|
600 <b>__checkForM532</b>(<i>node</i>) |
|
601 |
|
602 <p> |
|
603 Private method to check for possible unintentional typing annotation. |
|
604 </p> |
|
605 <dl> |
|
606 |
|
607 <dt><i>node</i> (ast.AnnAssign)</dt> |
|
608 <dd> |
|
609 reference to the node to be processed |
|
610 </dd> |
|
611 </dl> |
|
612 <a NAME="BugBearVisitor.__checkForM533" ID="BugBearVisitor.__checkForM533"></a> |
|
613 <h4>BugBearVisitor.__checkForM533</h4> |
|
614 <b>__checkForM533</b>(<i>node</i>) |
|
615 |
|
616 <p> |
|
617 Private method to check a set for duplicate items. |
|
618 </p> |
|
619 <dl> |
|
620 |
|
621 <dt><i>node</i> (ast.Set)</dt> |
|
622 <dd> |
|
623 reference to the node to be processed |
|
624 </dd> |
|
625 </dl> |
|
626 <a NAME="BugBearVisitor.__checkRedundantExcepthandlers" ID="BugBearVisitor.__checkRedundantExcepthandlers"></a> |
|
627 <h4>BugBearVisitor.__checkRedundantExcepthandlers</h4> |
|
628 <b>__checkRedundantExcepthandlers</b>(<i>names, node</i>) |
|
629 |
|
630 <p> |
|
631 Private method to check for redundant exception types in an exception handler. |
|
632 </p> |
|
633 <dl> |
|
634 |
|
635 <dt><i>names</i> (list of ast.Name)</dt> |
|
636 <dd> |
|
637 list of exception types to be checked |
|
638 </dd> |
|
639 <dt><i>node</i> (ast.ExceptionHandler)</dt> |
|
640 <dd> |
|
641 reference to the exception handler node |
|
642 </dd> |
|
643 </dl> |
|
644 <dl> |
|
645 <dt>Return:</dt> |
|
646 <dd> |
|
647 tuple containing the error data |
|
648 </dd> |
|
649 </dl> |
|
650 <dl> |
|
651 <dt>Return Type:</dt> |
|
652 <dd> |
|
653 tuple of (ast.Node, str, str, str, str) |
|
654 </dd> |
|
655 </dl> |
521 <a NAME="BugBearVisitor.__childrenInScope" ID="BugBearVisitor.__childrenInScope"></a> |
656 <a NAME="BugBearVisitor.__childrenInScope" ID="BugBearVisitor.__childrenInScope"></a> |
522 <h4>BugBearVisitor.__childrenInScope</h4> |
657 <h4>BugBearVisitor.__childrenInScope</h4> |
523 <b>__childrenInScope</b>(<i>node</i>) |
658 <b>__childrenInScope</b>(<i>node</i>) |
524 |
659 |
525 <p> |
660 <p> |
568 <dt>Yield Type:</dt> |
703 <dt>Yield Type:</dt> |
569 <dd> |
704 <dd> |
570 ast.Node |
705 ast.Node |
571 </dd> |
706 </dd> |
572 </dl> |
707 </dl> |
|
708 <a NAME="BugBearVisitor.__flattenExcepthandler" ID="BugBearVisitor.__flattenExcepthandler"></a> |
|
709 <h4>BugBearVisitor.__flattenExcepthandler</h4> |
|
710 <b>__flattenExcepthandler</b>(<i>node</i>) |
|
711 |
|
712 <p> |
|
713 Private method to flatten the list of exceptions handled by an except handler. |
|
714 </p> |
|
715 <dl> |
|
716 |
|
717 <dt><i>node</i> (ast.Node)</dt> |
|
718 <dd> |
|
719 reference to the node to be processed |
|
720 </dd> |
|
721 </dl> |
|
722 <dl> |
|
723 <dt>Yield:</dt> |
|
724 <dd> |
|
725 reference to the exception type node |
|
726 </dd> |
|
727 </dl> |
|
728 <dl> |
|
729 <dt>Yield Type:</dt> |
|
730 <dd> |
|
731 ast.Node |
|
732 </dd> |
|
733 </dl> |
573 <a NAME="BugBearVisitor.__getAssignedNames" ID="BugBearVisitor.__getAssignedNames"></a> |
734 <a NAME="BugBearVisitor.__getAssignedNames" ID="BugBearVisitor.__getAssignedNames"></a> |
574 <h4>BugBearVisitor.__getAssignedNames</h4> |
735 <h4>BugBearVisitor.__getAssignedNames</h4> |
575 <b>__getAssignedNames</b>(<i>loopNode</i>) |
736 <b>__getAssignedNames</b>(<i>loopNode</i>) |
576 |
737 |
577 <p> |
738 <p> |
709 <dt>Return Type:</dt> |
870 <dt>Return Type:</dt> |
710 <dd> |
871 <dd> |
711 bool |
872 bool |
712 </dd> |
873 </dd> |
713 </dl> |
874 </dl> |
|
875 <a NAME="BugBearVisitor.__walkList" ID="BugBearVisitor.__walkList"></a> |
|
876 <h4>BugBearVisitor.__walkList</h4> |
|
877 <b>__walkList</b>(<i>nodes</i>) |
|
878 |
|
879 <p> |
|
880 Private method to walk a given list of nodes. |
|
881 </p> |
|
882 <dl> |
|
883 |
|
884 <dt><i>nodes</i> (list of ast.Node)</dt> |
|
885 <dd> |
|
886 list of nodes to walk |
|
887 </dd> |
|
888 </dl> |
|
889 <dl> |
|
890 <dt>Yield:</dt> |
|
891 <dd> |
|
892 node references as determined by the ast.walk() function |
|
893 </dd> |
|
894 </dl> |
|
895 <dl> |
|
896 <dt>Yield Type:</dt> |
|
897 <dd> |
|
898 ast.Node |
|
899 </dd> |
|
900 </dl> |
714 <a NAME="BugBearVisitor._loop" ID="BugBearVisitor._loop"></a> |
901 <a NAME="BugBearVisitor._loop" ID="BugBearVisitor._loop"></a> |
715 <h4>BugBearVisitor._loop</h4> |
902 <h4>BugBearVisitor._loop</h4> |
716 <b>_loop</b>(<i>badNodeTypes</i>) |
903 <b>_loop</b>(<i>badNodeTypes</i>) |
717 |
904 |
718 <a NAME="BugBearVisitor.emptyBody" ID="BugBearVisitor.emptyBody"></a> |
905 <a NAME="BugBearVisitor.emptyBody" ID="BugBearVisitor.emptyBody"></a> |
766 <dt><i>node</i> (ast.Node)</dt> |
953 <dt><i>node</i> (ast.Node)</dt> |
767 <dd> |
954 <dd> |
768 AST node to be traversed |
955 AST node to be traversed |
769 </dd> |
956 </dd> |
770 </dl> |
957 </dl> |
|
958 <a NAME="BugBearVisitor.visit_AnnAssign" ID="BugBearVisitor.visit_AnnAssign"></a> |
|
959 <h4>BugBearVisitor.visit_AnnAssign</h4> |
|
960 <b>visit_AnnAssign</b>(<i>node</i>) |
|
961 |
|
962 <p> |
|
963 Public method to check annotated assign statements. |
|
964 </p> |
|
965 <dl> |
|
966 |
|
967 <dt><i>node</i> (ast.AnnAssign)</dt> |
|
968 <dd> |
|
969 reference to the node to be processed |
|
970 </dd> |
|
971 </dl> |
771 <a NAME="BugBearVisitor.visit_Assert" ID="BugBearVisitor.visit_Assert"></a> |
972 <a NAME="BugBearVisitor.visit_Assert" ID="BugBearVisitor.visit_Assert"></a> |
772 <h4>BugBearVisitor.visit_Assert</h4> |
973 <h4>BugBearVisitor.visit_Assert</h4> |
773 <b>visit_Assert</b>(<i>node</i>) |
974 <b>visit_Assert</b>(<i>node</i>) |
774 |
975 |
775 <p> |
976 <p> |
920 <dt><i>node</i> (ast.GeneratorExp)</dt> |
1121 <dt><i>node</i> (ast.GeneratorExp)</dt> |
921 <dd> |
1122 <dd> |
922 reference to the node to be processed |
1123 reference to the node to be processed |
923 </dd> |
1124 </dd> |
924 </dl> |
1125 </dl> |
|
1126 <a NAME="BugBearVisitor.visit_Import" ID="BugBearVisitor.visit_Import"></a> |
|
1127 <h4>BugBearVisitor.visit_Import</h4> |
|
1128 <b>visit_Import</b>(<i>node</i>) |
|
1129 |
|
1130 <p> |
|
1131 Public method to check imports. |
|
1132 </p> |
|
1133 <dl> |
|
1134 |
|
1135 <dt><i>node</i> (ast.Import)</dt> |
|
1136 <dd> |
|
1137 reference to the node to be processed |
|
1138 </dd> |
|
1139 </dl> |
925 <a NAME="BugBearVisitor.visit_JoinedStr" ID="BugBearVisitor.visit_JoinedStr"></a> |
1140 <a NAME="BugBearVisitor.visit_JoinedStr" ID="BugBearVisitor.visit_JoinedStr"></a> |
926 <h4>BugBearVisitor.visit_JoinedStr</h4> |
1141 <h4>BugBearVisitor.visit_JoinedStr</h4> |
927 <b>visit_JoinedStr</b>(<i>node</i>) |
1142 <b>visit_JoinedStr</b>(<i>node</i>) |
928 |
1143 |
929 <p> |
1144 <p> |
948 <dt><i>node</i> (ast.ListComp)</dt> |
1163 <dt><i>node</i> (ast.ListComp)</dt> |
949 <dd> |
1164 <dd> |
950 reference to the node to be processed |
1165 reference to the node to be processed |
951 </dd> |
1166 </dd> |
952 </dl> |
1167 </dl> |
|
1168 <a NAME="BugBearVisitor.visit_Module" ID="BugBearVisitor.visit_Module"></a> |
|
1169 <h4>BugBearVisitor.visit_Module</h4> |
|
1170 <b>visit_Module</b>(<i>node</i>) |
|
1171 |
|
1172 <p> |
|
1173 Public method to handle a module node. |
|
1174 </p> |
|
1175 <dl> |
|
1176 |
|
1177 <dt><i>node</i> (ast.Module)</dt> |
|
1178 <dd> |
|
1179 reference to the node to be processed |
|
1180 </dd> |
|
1181 </dl> |
953 <a NAME="BugBearVisitor.visit_Raise" ID="BugBearVisitor.visit_Raise"></a> |
1182 <a NAME="BugBearVisitor.visit_Raise" ID="BugBearVisitor.visit_Raise"></a> |
954 <h4>BugBearVisitor.visit_Raise</h4> |
1183 <h4>BugBearVisitor.visit_Raise</h4> |
955 <b>visit_Raise</b>(<i>node</i>) |
1184 <b>visit_Raise</b>(<i>node</i>) |
956 |
1185 |
957 <p> |
1186 <p> |
958 Public method to handle 'raise' statements. |
1187 Public method to handle 'raise' statements. |
959 </p> |
1188 </p> |
960 <dl> |
1189 <dl> |
961 |
1190 |
962 <dt><i>node</i> (ast.Raise)</dt> |
1191 <dt><i>node</i> (ast.Raise)</dt> |
|
1192 <dd> |
|
1193 reference to the node to be processed |
|
1194 </dd> |
|
1195 </dl> |
|
1196 <a NAME="BugBearVisitor.visit_Set" ID="BugBearVisitor.visit_Set"></a> |
|
1197 <h4>BugBearVisitor.visit_Set</h4> |
|
1198 <b>visit_Set</b>(<i>node</i>) |
|
1199 |
|
1200 <p> |
|
1201 Public method to check a set. |
|
1202 </p> |
|
1203 <dl> |
|
1204 |
|
1205 <dt><i>node</i> (ast.Set)</dt> |
963 <dd> |
1206 <dd> |
964 reference to the node to be processed |
1207 reference to the node to be processed |
965 </dd> |
1208 </dd> |
966 </dl> |
1209 </dl> |
967 <a NAME="BugBearVisitor.visit_SetComp" ID="BugBearVisitor.visit_SetComp"></a> |
1210 <a NAME="BugBearVisitor.visit_SetComp" ID="BugBearVisitor.visit_SetComp"></a> |