51 |
51 |
52 <h3>Methods</h3> |
52 <h3>Methods</h3> |
53 <table> |
53 <table> |
54 <tr> |
54 <tr> |
55 <td><a href="#NamingStyleChecker.__init__">NamingStyleChecker</a></td> |
55 <td><a href="#NamingStyleChecker.__init__">NamingStyleChecker</a></td> |
56 <td>Constructor (according to 'extended' pycodestyle.py API)</td> |
56 <td>Constructor</td> |
57 </tr> |
57 </tr> |
58 <tr> |
58 <tr> |
59 <td><a href="#NamingStyleChecker.__checkClassName">__checkClassName</a></td> |
59 <td><a href="#NamingStyleChecker.__checkClassName">__checkClassName</a></td> |
60 <td>Private class to check the given node for class name conventions (N801, N818).</td> |
60 <td>Private class to check the given node for class name conventions (N801, N818).</td> |
61 </tr> |
61 </tr> |
116 <td>Private method to extract the class definition.</td> |
116 <td>Private method to extract the class definition.</td> |
117 </tr> |
117 </tr> |
118 <tr> |
118 <tr> |
119 <td><a href="#NamingStyleChecker.__globalVariableCheck">__globalVariableCheck</a></td> |
119 <td><a href="#NamingStyleChecker.__globalVariableCheck">__globalVariableCheck</a></td> |
120 <td>Private method to determine the error code for a variable in global scope.</td> |
120 <td>Private method to determine the error code for a variable in global scope.</td> |
|
121 </tr> |
|
122 <tr> |
|
123 <td><a href="#NamingStyleChecker.__ignoreCode">__ignoreCode</a></td> |
|
124 <td>Private method to check if the message code should be ignored.</td> |
121 </tr> |
125 </tr> |
122 <tr> |
126 <tr> |
123 <td><a href="#NamingStyleChecker.__isMixedCase">__isMixedCase</a></td> |
127 <td><a href="#NamingStyleChecker.__isMixedCase">__isMixedCase</a></td> |
124 <td>Private method to check, if the given name is mixed case.</td> |
128 <td>Private method to check, if the given name is mixed case.</td> |
125 </tr> |
129 </tr> |
159 </table> |
163 </table> |
160 |
164 |
161 |
165 |
162 <a NAME="NamingStyleChecker.__init__" ID="NamingStyleChecker.__init__"></a> |
166 <a NAME="NamingStyleChecker.__init__" ID="NamingStyleChecker.__init__"></a> |
163 <h4>NamingStyleChecker (Constructor)</h4> |
167 <h4>NamingStyleChecker (Constructor)</h4> |
164 <b>NamingStyleChecker</b>(<i>tree, filename, options</i>) |
168 <b>NamingStyleChecker</b>(<i>source, filename, tree, select, ignore, expected, repeat, args</i>) |
165 <p> |
169 <p> |
166 Constructor (according to 'extended' pycodestyle.py API) |
170 Constructor |
167 </p> |
171 </p> |
168 |
172 |
169 <dl> |
173 <dl> |
170 |
174 |
171 <dt><i>tree</i> (ast.AST)</dt> |
175 <dt><i>source</i> (list of str)</dt> |
172 <dd> |
176 <dd> |
173 AST tree of the source file |
177 source code to be checked |
174 </dd> |
178 </dd> |
175 <dt><i>filename</i> (str)</dt> |
179 <dt><i>filename</i> (str)</dt> |
176 <dd> |
180 <dd> |
177 name of the source file |
181 name of the source file |
178 </dd> |
182 </dd> |
179 <dt><i>options</i> (optparse.Option)</dt> |
183 <dt><i>tree</i> (ast.Module)</dt> |
180 <dd> |
184 <dd> |
181 options as parsed by pycodestyle.StyleGuide |
185 AST tree of the source code |
|
186 </dd> |
|
187 <dt><i>select</i> (list of str)</dt> |
|
188 <dd> |
|
189 list of selected codes |
|
190 </dd> |
|
191 <dt><i>ignore</i> (list of str)</dt> |
|
192 <dd> |
|
193 list of codes to be ignored |
|
194 </dd> |
|
195 <dt><i>expected</i> (list of str)</dt> |
|
196 <dd> |
|
197 list of expected codes |
|
198 </dd> |
|
199 <dt><i>repeat</i> (bool)</dt> |
|
200 <dd> |
|
201 flag indicating to report each occurrence of a code |
|
202 </dd> |
|
203 <dt><i>args</i> (dict)</dt> |
|
204 <dd> |
|
205 dictionary of arguments for the various checks |
182 </dd> |
206 </dd> |
183 </dl> |
207 </dl> |
184 <a NAME="NamingStyleChecker.__checkClassName" ID="NamingStyleChecker.__checkClassName"></a> |
208 <a NAME="NamingStyleChecker.__checkClassName" ID="NamingStyleChecker.__checkClassName"></a> |
185 <h4>NamingStyleChecker.__checkClassName</h4> |
209 <h4>NamingStyleChecker.__checkClassName</h4> |
186 <b>__checkClassName</b>(<i>node, parents</i>) |
210 <b>__checkClassName</b>(<i>node, parents</i>) |
202 <dt><i>parents</i> (list of ast.AST)</dt> |
226 <dt><i>parents</i> (list of ast.AST)</dt> |
203 <dd> |
227 <dd> |
204 list of parent nodes |
228 list of parent nodes |
205 </dd> |
229 </dd> |
206 </dl> |
230 </dl> |
207 <dl> |
|
208 <dt>Yield:</dt> |
|
209 <dd> |
|
210 tuple giving line number, offset within line and error code |
|
211 </dd> |
|
212 </dl> |
|
213 <dl> |
|
214 <dt>Yield Type:</dt> |
|
215 <dd> |
|
216 tuple of (int, int, str) |
|
217 </dd> |
|
218 </dl> |
|
219 <a NAME="NamingStyleChecker.__checkFunctionArgumentNames" ID="NamingStyleChecker.__checkFunctionArgumentNames"></a> |
231 <a NAME="NamingStyleChecker.__checkFunctionArgumentNames" ID="NamingStyleChecker.__checkFunctionArgumentNames"></a> |
220 <h4>NamingStyleChecker.__checkFunctionArgumentNames</h4> |
232 <h4>NamingStyleChecker.__checkFunctionArgumentNames</h4> |
221 <b>__checkFunctionArgumentNames</b>(<i>node, _parents</i>) |
233 <b>__checkFunctionArgumentNames</b>(<i>node, _parents</i>) |
222 <p> |
234 <p> |
223 Private class to check the argument names of functions |
235 Private class to check the argument names of functions |
236 AST note to check |
248 AST note to check |
237 </dd> |
249 </dd> |
238 <dt><i>_parents</i> (list of ast.AST)</dt> |
250 <dt><i>_parents</i> (list of ast.AST)</dt> |
239 <dd> |
251 <dd> |
240 list of parent nodes (unused) |
252 list of parent nodes (unused) |
241 </dd> |
|
242 </dl> |
|
243 <dl> |
|
244 <dt>Yield:</dt> |
|
245 <dd> |
|
246 tuple giving line number, offset within line and error code |
|
247 </dd> |
|
248 </dl> |
|
249 <dl> |
|
250 <dt>Yield Type:</dt> |
|
251 <dd> |
|
252 tuple of (int, int, str) |
|
253 </dd> |
253 </dd> |
254 </dl> |
254 </dl> |
255 <a NAME="NamingStyleChecker.__checkFunctionName" ID="NamingStyleChecker.__checkFunctionName"></a> |
255 <a NAME="NamingStyleChecker.__checkFunctionName" ID="NamingStyleChecker.__checkFunctionName"></a> |
256 <h4>NamingStyleChecker.__checkFunctionName</h4> |
256 <h4>NamingStyleChecker.__checkFunctionName</h4> |
257 <b>__checkFunctionName</b>(<i>node, _parents</i>) |
257 <b>__checkFunctionName</b>(<i>node, _parents</i>) |
276 <dt><i>_parents</i> (list of ast.AST)</dt> |
276 <dt><i>_parents</i> (list of ast.AST)</dt> |
277 <dd> |
277 <dd> |
278 list of parent nodes (unused) |
278 list of parent nodes (unused) |
279 </dd> |
279 </dd> |
280 </dl> |
280 </dl> |
281 <dl> |
|
282 <dt>Yield:</dt> |
|
283 <dd> |
|
284 tuple giving line number, offset within line and error code |
|
285 </dd> |
|
286 </dl> |
|
287 <dl> |
|
288 <dt>Yield Type:</dt> |
|
289 <dd> |
|
290 tuple of (int, int, str) |
|
291 </dd> |
|
292 </dl> |
|
293 <a NAME="NamingStyleChecker.__checkImportAs" ID="NamingStyleChecker.__checkImportAs"></a> |
281 <a NAME="NamingStyleChecker.__checkImportAs" ID="NamingStyleChecker.__checkImportAs"></a> |
294 <h4>NamingStyleChecker.__checkImportAs</h4> |
282 <h4>NamingStyleChecker.__checkImportAs</h4> |
295 <b>__checkImportAs</b>(<i>node, _parents</i>) |
283 <b>__checkImportAs</b>(<i>node, _parents</i>) |
296 <p> |
284 <p> |
297 Private method to check that imports don't change the |
285 Private method to check that imports don't change the |
307 <dt><i>_parents</i> (list of ast.AST)</dt> |
295 <dt><i>_parents</i> (list of ast.AST)</dt> |
308 <dd> |
296 <dd> |
309 list of parent nodes (unused) |
297 list of parent nodes (unused) |
310 </dd> |
298 </dd> |
311 </dl> |
299 </dl> |
312 <dl> |
|
313 <dt>Yield:</dt> |
|
314 <dd> |
|
315 tuple giving line number, offset within line and error code |
|
316 </dd> |
|
317 </dl> |
|
318 <dl> |
|
319 <dt>Yield Type:</dt> |
|
320 <dd> |
|
321 tuple of (int, int, str) |
|
322 </dd> |
|
323 </dl> |
|
324 <a NAME="NamingStyleChecker.__checkModule" ID="NamingStyleChecker.__checkModule"></a> |
300 <a NAME="NamingStyleChecker.__checkModule" ID="NamingStyleChecker.__checkModule"></a> |
325 <h4>NamingStyleChecker.__checkModule</h4> |
301 <h4>NamingStyleChecker.__checkModule</h4> |
326 <b>__checkModule</b>(<i>node, _parents</i>) |
302 <b>__checkModule</b>(<i>node, _parents</i>) |
327 <p> |
303 <p> |
328 Private method to check module naming conventions (N807, N808). |
304 Private method to check module naming conventions (N807, N808). |
340 <dt><i>_parents</i> (list of ast.AST)</dt> |
316 <dt><i>_parents</i> (list of ast.AST)</dt> |
341 <dd> |
317 <dd> |
342 list of parent nodes (unused) |
318 list of parent nodes (unused) |
343 </dd> |
319 </dd> |
344 </dl> |
320 </dl> |
345 <dl> |
|
346 <dt>Yield:</dt> |
|
347 <dd> |
|
348 tuple giving line number, offset within line and error code |
|
349 </dd> |
|
350 </dl> |
|
351 <dl> |
|
352 <dt>Yield Type:</dt> |
|
353 <dd> |
|
354 tuple of (int, int, str) |
|
355 </dd> |
|
356 </dl> |
|
357 <a NAME="NamingStyleChecker.__checkNameToBeAvoided" ID="NamingStyleChecker.__checkNameToBeAvoided"></a> |
321 <a NAME="NamingStyleChecker.__checkNameToBeAvoided" ID="NamingStyleChecker.__checkNameToBeAvoided"></a> |
358 <h4>NamingStyleChecker.__checkNameToBeAvoided</h4> |
322 <h4>NamingStyleChecker.__checkNameToBeAvoided</h4> |
359 <b>__checkNameToBeAvoided</b>(<i>node, _parents</i>) |
323 <b>__checkNameToBeAvoided</b>(<i>node, _parents</i>) |
360 <p> |
324 <p> |
361 Private class to check the given node for a name to be avoided (N831). |
325 Private class to check the given node for a name to be avoided (N831). |
370 <dt><i>_parents</i> (list of ast.AST)</dt> |
334 <dt><i>_parents</i> (list of ast.AST)</dt> |
371 <dd> |
335 <dd> |
372 list of parent nodes (unused) |
336 list of parent nodes (unused) |
373 </dd> |
337 </dd> |
374 </dl> |
338 </dl> |
375 <dl> |
|
376 <dt>Yield:</dt> |
|
377 <dd> |
|
378 tuple giving line number, offset within line and error code |
|
379 </dd> |
|
380 </dl> |
|
381 <dl> |
|
382 <dt>Yield Type:</dt> |
|
383 <dd> |
|
384 tuple of (int, int, str) |
|
385 </dd> |
|
386 </dl> |
|
387 <a NAME="NamingStyleChecker.__checkVariableNames" ID="NamingStyleChecker.__checkVariableNames"></a> |
339 <a NAME="NamingStyleChecker.__checkVariableNames" ID="NamingStyleChecker.__checkVariableNames"></a> |
388 <h4>NamingStyleChecker.__checkVariableNames</h4> |
340 <h4>NamingStyleChecker.__checkVariableNames</h4> |
389 <b>__checkVariableNames</b>(<i>node, parents</i>) |
341 <b>__checkVariableNames</b>(<i>node, parents</i>) |
390 <p> |
342 <p> |
391 Private method to check variable names in function, class and global scope |
343 Private method to check variable names in function, class and global scope |
404 <dt><i>parents</i> (list of ast.AST)</dt> |
356 <dt><i>parents</i> (list of ast.AST)</dt> |
405 <dd> |
357 <dd> |
406 list of parent nodes |
358 list of parent nodes |
407 </dd> |
359 </dd> |
408 </dl> |
360 </dl> |
409 <dl> |
|
410 <dt>Yield:</dt> |
|
411 <dd> |
|
412 tuple giving line number, offset within line and error code |
|
413 </dd> |
|
414 </dl> |
|
415 <dl> |
|
416 <dt>Yield Type:</dt> |
|
417 <dd> |
|
418 tuple of (int, int, str) |
|
419 </dd> |
|
420 </dl> |
|
421 <a NAME="NamingStyleChecker.__classVariableCheck" ID="NamingStyleChecker.__classVariableCheck"></a> |
361 <a NAME="NamingStyleChecker.__classVariableCheck" ID="NamingStyleChecker.__classVariableCheck"></a> |
422 <h4>NamingStyleChecker.__classVariableCheck</h4> |
362 <h4>NamingStyleChecker.__classVariableCheck</h4> |
423 <b>__classVariableCheck</b>(<i>name</i>) |
363 <b>__classVariableCheck</b>(<i>name</i>) |
424 <p> |
364 <p> |
425 Private method to determine the error code for a variable in class scope. |
365 Private method to determine the error code for a variable in class scope. |
460 <dt><i>code</i> (str)</dt> |
400 <dt><i>code</i> (str)</dt> |
461 <dd> |
401 <dd> |
462 error code to report |
402 error code to report |
463 </dd> |
403 </dd> |
464 </dl> |
404 </dl> |
465 <dl> |
|
466 <dt>Return:</dt> |
|
467 <dd> |
|
468 tuple giving line number, offset within line and error code |
|
469 </dd> |
|
470 </dl> |
|
471 <dl> |
|
472 <dt>Return Type:</dt> |
|
473 <dd> |
|
474 tuple of (int, int, str) |
|
475 </dd> |
|
476 </dl> |
|
477 <a NAME="NamingStyleChecker.__extractNames" ID="NamingStyleChecker.__extractNames"></a> |
405 <a NAME="NamingStyleChecker.__extractNames" ID="NamingStyleChecker.__extractNames"></a> |
478 <h4>NamingStyleChecker.__extractNames</h4> |
406 <h4>NamingStyleChecker.__extractNames</h4> |
479 <b>__extractNames</b>(<i>assignmentTarget</i>) |
407 <b>__extractNames</b>(<i>assignmentTarget</i>) |
480 <p> |
408 <p> |
481 Private method to extract the names from the target node. |
409 Private method to extract the names from the target node. |
530 <dt><i>parents</i> (ast.AST)</dt> |
458 <dt><i>parents</i> (ast.AST)</dt> |
531 <dd> |
459 <dd> |
532 list of parent nodes |
460 list of parent nodes |
533 </dd> |
461 </dd> |
534 </dl> |
462 </dl> |
535 <dl> |
|
536 <dt>Yield:</dt> |
|
537 <dd> |
|
538 tuple giving line number, offset within line and error code |
|
539 </dd> |
|
540 </dl> |
|
541 <dl> |
|
542 <dt>Yield Type:</dt> |
|
543 <dd> |
|
544 tuple of (int, int, str) |
|
545 </dd> |
|
546 </dl> |
|
547 <a NAME="NamingStyleChecker.__functionVariableCheck" ID="NamingStyleChecker.__functionVariableCheck"></a> |
463 <a NAME="NamingStyleChecker.__functionVariableCheck" ID="NamingStyleChecker.__functionVariableCheck"></a> |
548 <h4>NamingStyleChecker.__functionVariableCheck</h4> |
464 <h4>NamingStyleChecker.__functionVariableCheck</h4> |
549 <b>__functionVariableCheck</b>(<i>func, varName</i>) |
465 <b>__functionVariableCheck</b>(<i>func, varName</i>) |
550 <p> |
466 <p> |
551 Private method to determine the error code for a variable in class scope. |
467 Private method to determine the error code for a variable in class scope. |
654 <dt>Return Type:</dt> |
570 <dt>Return Type:</dt> |
655 <dd> |
571 <dd> |
656 str or None |
572 str or None |
657 </dd> |
573 </dd> |
658 </dl> |
574 </dl> |
|
575 <a NAME="NamingStyleChecker.__ignoreCode" ID="NamingStyleChecker.__ignoreCode"></a> |
|
576 <h4>NamingStyleChecker.__ignoreCode</h4> |
|
577 <b>__ignoreCode</b>(<i>code</i>) |
|
578 <p> |
|
579 Private method to check if the message code should be ignored. |
|
580 </p> |
|
581 |
|
582 <dl> |
|
583 |
|
584 <dt><i>code</i> (str)</dt> |
|
585 <dd> |
|
586 message code to check for |
|
587 </dd> |
|
588 </dl> |
|
589 <dl> |
|
590 <dt>Return:</dt> |
|
591 <dd> |
|
592 flag indicating to ignore the given code |
|
593 </dd> |
|
594 </dl> |
|
595 <dl> |
|
596 <dt>Return Type:</dt> |
|
597 <dd> |
|
598 bool |
|
599 </dd> |
|
600 </dl> |
659 <a NAME="NamingStyleChecker.__isMixedCase" ID="NamingStyleChecker.__isMixedCase"></a> |
601 <a NAME="NamingStyleChecker.__isMixedCase" ID="NamingStyleChecker.__isMixedCase"></a> |
660 <h4>NamingStyleChecker.__isMixedCase</h4> |
602 <h4>NamingStyleChecker.__isMixedCase</h4> |
661 <b>__isMixedCase</b>(<i>name</i>) |
603 <b>__isMixedCase</b>(<i>name</i>) |
662 <p> |
604 <p> |
663 Private method to check, if the given name is mixed case. |
605 Private method to check, if the given name is mixed case. |
795 <dt><i>node</i> (ast.AST)</dt> |
737 <dt><i>node</i> (ast.AST)</dt> |
796 <dd> |
738 <dd> |
797 AST tree node to inspect |
739 AST tree node to inspect |
798 </dd> |
740 </dd> |
799 </dl> |
741 </dl> |
800 <dl> |
|
801 <dt>Yield:</dt> |
|
802 <dd> |
|
803 tuple giving line number, offset within line and error code |
|
804 </dd> |
|
805 </dl> |
|
806 <dl> |
|
807 <dt>Yield Type:</dt> |
|
808 <dd> |
|
809 tuple of (int, int, str) |
|
810 </dd> |
|
811 </dl> |
|
812 <a NAME="NamingStyleChecker.__visitTree" ID="NamingStyleChecker.__visitTree"></a> |
742 <a NAME="NamingStyleChecker.__visitTree" ID="NamingStyleChecker.__visitTree"></a> |
813 <h4>NamingStyleChecker.__visitTree</h4> |
743 <h4>NamingStyleChecker.__visitTree</h4> |
814 <b>__visitTree</b>(<i>node</i>) |
744 <b>__visitTree</b>(<i>node</i>) |
815 <p> |
745 <p> |
816 Private method to scan the given AST tree. |
746 Private method to scan the given AST tree. |
821 <dt><i>node</i> (ast.AST)</dt> |
751 <dt><i>node</i> (ast.AST)</dt> |
822 <dd> |
752 <dd> |
823 AST tree node to scan |
753 AST tree node to scan |
824 </dd> |
754 </dd> |
825 </dl> |
755 </dl> |
826 <dl> |
|
827 <dt>Yield:</dt> |
|
828 <dd> |
|
829 tuple giving line number, offset within line and error code |
|
830 </dd> |
|
831 </dl> |
|
832 <dl> |
|
833 <dt>Yield Type:</dt> |
|
834 <dd> |
|
835 tuple of (int, int, str) |
|
836 </dd> |
|
837 </dl> |
|
838 <a NAME="NamingStyleChecker.run" ID="NamingStyleChecker.run"></a> |
756 <a NAME="NamingStyleChecker.run" ID="NamingStyleChecker.run"></a> |
839 <h4>NamingStyleChecker.run</h4> |
757 <h4>NamingStyleChecker.run</h4> |
840 <b>run</b>(<i></i>) |
758 <b>run</b>(<i></i>) |
841 <p> |
759 <p> |
842 Public method run by the pycodestyle.py checker. |
760 Public method run by the pycodestyle.py checker. |