src/eric7/Documentation/Source/eric7.Plugins.CheckerPlugins.CodeStyleChecker.Imports.ImportsChecker.html

branch
eric7
changeset 10046
35b27af462ef
parent 9503
ae9232bf4854
child 10479
856476537696
equal deleted inserted replaced
10045:f5c57f8d17a4 10046:35b27af462ef
57 <tr> 57 <tr>
58 <td><a href="#ImportsChecker.__init__">ImportsChecker</a></td> 58 <td><a href="#ImportsChecker.__init__">ImportsChecker</a></td>
59 <td>Constructor</td> 59 <td>Constructor</td>
60 </tr> 60 </tr>
61 <tr> 61 <tr>
62 <td><a href="#ImportsChecker.__atoi">__atoi</a></td>
63 <td>Private method to convert the given text to an integer number.</td>
64 </tr>
65 <tr>
66 <td><a href="#ImportsChecker.__checkBannedImport">__checkBannedImport</a></td> 62 <td><a href="#ImportsChecker.__checkBannedImport">__checkBannedImport</a></td>
67 <td>Private method to check import of banned modules.</td> 63 <td>Private method to check import of banned modules.</td>
68 </tr> 64 </tr>
69 <tr> 65 <tr>
70 <td><a href="#ImportsChecker.__checkBannedRelativeImports">__checkBannedRelativeImports</a></td> 66 <td><a href="#ImportsChecker.__checkBannedRelativeImports">__checkBannedRelativeImports</a></td>
71 <td>Private method to check if relative imports are banned.</td> 67 <td>Private method to check if relative imports are banned.</td>
72 </tr> 68 </tr>
73 <tr> 69 <tr>
74 <td><a href="#ImportsChecker.__checkImportOrder">__checkImportOrder</a></td>
75 <td>Private method to check the order of import statements.</td>
76 </tr>
77 <tr>
78 <td><a href="#ImportsChecker.__checkLocalImports">__checkLocalImports</a></td> 70 <td><a href="#ImportsChecker.__checkLocalImports">__checkLocalImports</a></td>
79 <td>Private method to check local imports.</td> 71 <td>Private method to check local imports.</td>
80 </tr> 72 </tr>
81 <tr> 73 <tr>
82 <td><a href="#ImportsChecker.__checkUnnecessaryAlias">__checkUnnecessaryAlias</a></td> 74 <td><a href="#ImportsChecker.__checkUnnecessaryAlias">__checkUnnecessaryAlias</a></td>
89 <tr> 81 <tr>
90 <td><a href="#ImportsChecker.__error">__error</a></td> 82 <td><a href="#ImportsChecker.__error">__error</a></td>
91 <td>Private method to record an issue.</td> 83 <td>Private method to record an issue.</td>
92 </tr> 84 </tr>
93 <tr> 85 <tr>
94 <td><a href="#ImportsChecker.__findErrorInAll">__findErrorInAll</a></td>
95 <td>Private method to check the '__all__' node for errors.</td>
96 </tr>
97 <tr>
98 <td><a href="#ImportsChecker.__findNodes">__findNodes</a></td>
99 <td>Private method to find all import and import from nodes of the given tree.</td>
100 </tr>
101 <tr>
102 <td><a href="#ImportsChecker.__ignoreCode">__ignoreCode</a></td> 86 <td><a href="#ImportsChecker.__ignoreCode">__ignoreCode</a></td>
103 <td>Private method to check if the message code should be ignored.</td> 87 <td>Private method to check if the message code should be ignored.</td>
104 </tr> 88 </tr>
105 <tr> 89 <tr>
106 <td><a href="#ImportsChecker.__isModuleBanned">__isModuleBanned</a></td> 90 <td><a href="#ImportsChecker.__isModuleBanned">__isModuleBanned</a></td>
107 <td>Private method to check, if the given module name banned.</td> 91 <td>Private method to check, if the given module name banned.</td>
108 </tr> 92 </tr>
109 <tr> 93 <tr>
110 <td><a href="#ImportsChecker.__naturalKeys">__naturalKeys</a></td>
111 <td>Private method to generate keys for natural sorting.</td>
112 </tr>
113 <tr>
114 <td><a href="#ImportsChecker.__naturally">__naturally</a></td>
115 <td>Private method to sort the given list of names naturally.</td>
116 </tr>
117 <tr>
118 <td><a href="#ImportsChecker.__tidyImports">__tidyImports</a></td> 94 <td><a href="#ImportsChecker.__tidyImports">__tidyImports</a></td>
119 <td>Private method to check various other import related topics.</td> 95 <td>Private method to check various other import related topics.</td>
120 </tr> 96 </tr>
121 <tr> 97 <tr>
122 <td><a href="#ImportsChecker.getStandardModules">getStandardModules</a></td>
123 <td>Public method to get a list of modules of the standard library.</td>
124 </tr>
125 <tr>
126 <td><a href="#ImportsChecker.keyCallback">keyCallback</a></td>
127 <td></td>
128 </tr>
129 <tr>
130 <td><a href="#ImportsChecker.moduleKey">moduleKey</a></td>
131 <td>Public method to generate a key for the given module name.</td>
132 </tr>
133 <tr>
134 <td><a href="#ImportsChecker.run">run</a></td> 98 <td><a href="#ImportsChecker.run">run</a></td>
135 <td>Public method to check the given source against miscellaneous conditions.</td> 99 <td>Public method to check the given source against miscellaneous conditions.</td>
136 </tr>
137 <tr>
138 <td><a href="#ImportsChecker.sorted">sorted</a></td>
139 <td>Public method to sort the given list of names.</td>
140 </tr> 100 </tr>
141 </table> 101 </table>
142 <h3>Static Methods</h3> 102 <h3>Static Methods</h3>
143 103
144 <table> 104 <table>
185 <dt><i>args</i> (dict)</dt> 145 <dt><i>args</i> (dict)</dt>
186 <dd> 146 <dd>
187 dictionary of arguments for the various checks 147 dictionary of arguments for the various checks
188 </dd> 148 </dd>
189 </dl> 149 </dl>
190 <a NAME="ImportsChecker.__atoi" ID="ImportsChecker.__atoi"></a>
191 <h4>ImportsChecker.__atoi</h4>
192 <b>__atoi</b>(<i>text</i>)
193
194 <p>
195 Private method to convert the given text to an integer number.
196 </p>
197 <dl>
198
199 <dt><i>text</i> (str)</dt>
200 <dd>
201 text to be converted
202 </dd>
203 </dl>
204 <dl>
205 <dt>Return:</dt>
206 <dd>
207 integer number
208 </dd>
209 </dl>
210 <dl>
211 <dt>Return Type:</dt>
212 <dd>
213 int
214 </dd>
215 </dl>
216 <a NAME="ImportsChecker.__checkBannedImport" ID="ImportsChecker.__checkBannedImport"></a> 150 <a NAME="ImportsChecker.__checkBannedImport" ID="ImportsChecker.__checkBannedImport"></a>
217 <h4>ImportsChecker.__checkBannedImport</h4> 151 <h4>ImportsChecker.__checkBannedImport</h4>
218 <b>__checkBannedImport</b>(<i>node</i>) 152 <b>__checkBannedImport</b>(<i>node</i>)
219 153
220 <p> 154 <p>
239 <dt><i>node</i> (ast.AST)</dt> 173 <dt><i>node</i> (ast.AST)</dt>
240 <dd> 174 <dd>
241 reference to the node to be checked 175 reference to the node to be checked
242 </dd> 176 </dd>
243 </dl> 177 </dl>
244 <a NAME="ImportsChecker.__checkImportOrder" ID="ImportsChecker.__checkImportOrder"></a>
245 <h4>ImportsChecker.__checkImportOrder</h4>
246 <b>__checkImportOrder</b>(<i></i>)
247
248 <p>
249 Private method to check the order of import statements.
250 </p>
251 <a NAME="ImportsChecker.__checkLocalImports" ID="ImportsChecker.__checkLocalImports"></a> 178 <a NAME="ImportsChecker.__checkLocalImports" ID="ImportsChecker.__checkLocalImports"></a>
252 <h4>ImportsChecker.__checkLocalImports</h4> 179 <h4>ImportsChecker.__checkLocalImports</h4>
253 <b>__checkLocalImports</b>(<i></i>) 180 <b>__checkLocalImports</b>(<i></i>)
254 181
255 <p> 182 <p>
320 <dt><i>args</i> (list)</dt> 247 <dt><i>args</i> (list)</dt>
321 <dd> 248 <dd>
322 arguments for the message 249 arguments for the message
323 </dd> 250 </dd>
324 </dl> 251 </dl>
325 <a NAME="ImportsChecker.__findErrorInAll" ID="ImportsChecker.__findErrorInAll"></a>
326 <h4>ImportsChecker.__findErrorInAll</h4>
327 <b>__findErrorInAll</b>(<i>node</i>)
328
329 <p>
330 Private method to check the '__all__' node for errors.
331 </p>
332 <dl>
333
334 <dt><i>node</i> (ast.List or ast.Tuple)</dt>
335 <dd>
336 reference to the '__all__' node
337 </dd>
338 </dl>
339 <dl>
340 <dt>Return:</dt>
341 <dd>
342 tuple containing a reference to the node and an error code
343 </dd>
344 </dl>
345 <dl>
346 <dt>Return Type:</dt>
347 <dd>
348 rtype tuple of (ast.List | ast.Tuple, str)
349 </dd>
350 </dl>
351 <a NAME="ImportsChecker.__findNodes" ID="ImportsChecker.__findNodes"></a>
352 <h4>ImportsChecker.__findNodes</h4>
353 <b>__findNodes</b>(<i>tree</i>)
354
355 <p>
356 Private method to find all import and import from nodes of the given
357 tree.
358 </p>
359 <dl>
360
361 <dt><i>tree</i> (ast.AST)</dt>
362 <dd>
363 reference to the ast node tree to be parsed
364 </dd>
365 </dl>
366 <dl>
367 <dt>Return:</dt>
368 <dd>
369 tuple containing a list of import nodes and the '__all__' node
370 </dd>
371 </dl>
372 <dl>
373 <dt>Return Type:</dt>
374 <dd>
375 tuple of (ast.Import | ast.ImportFrom, ast.List | ast.Tuple)
376 </dd>
377 </dl>
378 <a NAME="ImportsChecker.__ignoreCode" ID="ImportsChecker.__ignoreCode"></a> 252 <a NAME="ImportsChecker.__ignoreCode" ID="ImportsChecker.__ignoreCode"></a>
379 <h4>ImportsChecker.__ignoreCode</h4> 253 <h4>ImportsChecker.__ignoreCode</h4>
380 <b>__ignoreCode</b>(<i>code</i>) 254 <b>__ignoreCode</b>(<i>code</i>)
381 255
382 <p> 256 <p>
425 <dt>Return Type:</dt> 299 <dt>Return Type:</dt>
426 <dd> 300 <dd>
427 bool 301 bool
428 </dd> 302 </dd>
429 </dl> 303 </dl>
430 <a NAME="ImportsChecker.__naturalKeys" ID="ImportsChecker.__naturalKeys"></a>
431 <h4>ImportsChecker.__naturalKeys</h4>
432 <b>__naturalKeys</b>(<i>text</i>)
433
434 <p>
435 Private method to generate keys for natural sorting.
436 </p>
437 <dl>
438
439 <dt><i>text</i> (str)</dt>
440 <dd>
441 text to generate a key for
442 </dd>
443 </dl>
444 <dl>
445 <dt>Return:</dt>
446 <dd>
447 key for natural sorting
448 </dd>
449 </dl>
450 <dl>
451 <dt>Return Type:</dt>
452 <dd>
453 list of str or int
454 </dd>
455 </dl>
456 <a NAME="ImportsChecker.__naturally" ID="ImportsChecker.__naturally"></a>
457 <h4>ImportsChecker.__naturally</h4>
458 <b>__naturally</b>(<i>toSort, key=None, reverse=False</i>)
459
460 <p>
461 Private method to sort the given list of names naturally.
462 </p>
463 <p>
464 Note: Natural sorting maintains the sort order of numbers (i.e.
465 [Q1, Q10, Q2] is sorted as [Q1, Q2, Q10] while the Python
466 standard sort would yield [Q1, Q10, Q2].
467 </p>
468 <dl>
469
470 <dt><i>toSort</i> (list of str)</dt>
471 <dd>
472 list of names to be sorted
473 </dd>
474 <dt><i>key</i> (function (optional))</dt>
475 <dd>
476 function to generate keys (defaults to None)
477 </dd>
478 <dt><i>reverse</i> (bool (optional))</dt>
479 <dd>
480 flag indicating a reverse sort (defaults to False)
481 </dd>
482 </dl>
483 <dl>
484 <dt>Return:</dt>
485 <dd>
486 sorted list of names
487 </dd>
488 </dl>
489 <dl>
490 <dt>Return Type:</dt>
491 <dd>
492 list of str
493 </dd>
494 </dl>
495 <a NAME="ImportsChecker.__tidyImports" ID="ImportsChecker.__tidyImports"></a> 304 <a NAME="ImportsChecker.__tidyImports" ID="ImportsChecker.__tidyImports"></a>
496 <h4>ImportsChecker.__tidyImports</h4> 305 <h4>ImportsChecker.__tidyImports</h4>
497 <b>__tidyImports</b>(<i></i>) 306 <b>__tidyImports</b>(<i></i>)
498 307
499 <p> 308 <p>
500 Private method to check various other import related topics. 309 Private method to check various other import related topics.
501 </p> 310 </p>
502 <a NAME="ImportsChecker.getStandardModules" ID="ImportsChecker.getStandardModules"></a>
503 <h4>ImportsChecker.getStandardModules</h4>
504 <b>getStandardModules</b>(<i></i>)
505
506 <p>
507 Public method to get a list of modules of the standard library.
508 </p>
509 <dl>
510 <dt>Return:</dt>
511 <dd>
512 set of builtin modules
513 </dd>
514 </dl>
515 <dl>
516 <dt>Return Type:</dt>
517 <dd>
518 set of str
519 </dd>
520 </dl>
521 <a NAME="ImportsChecker.keyCallback" ID="ImportsChecker.keyCallback"></a>
522 <h4>ImportsChecker.keyCallback</h4>
523 <b>keyCallback</b>(<i></i>)
524
525 <a NAME="ImportsChecker.moduleKey" ID="ImportsChecker.moduleKey"></a>
526 <h4>ImportsChecker.moduleKey</h4>
527 <b>moduleKey</b>(<i>moduleName, subImports=False</i>)
528
529 <p>
530 Public method to generate a key for the given module name.
531 </p>
532 <dl>
533
534 <dt><i>moduleName</i> (str)</dt>
535 <dd>
536 module name
537 </dd>
538 <dt><i>subImports</i> (bool (optional))</dt>
539 <dd>
540 flag indicating a sub import like in
541 'from foo import bar, baz' (defaults to False)
542 </dd>
543 </dl>
544 <dl>
545 <dt>Return:</dt>
546 <dd>
547 generated key
548 </dd>
549 </dl>
550 <dl>
551 <dt>Return Type:</dt>
552 <dd>
553 str
554 </dd>
555 </dl>
556 <a NAME="ImportsChecker.run" ID="ImportsChecker.run"></a> 311 <a NAME="ImportsChecker.run" ID="ImportsChecker.run"></a>
557 <h4>ImportsChecker.run</h4> 312 <h4>ImportsChecker.run</h4>
558 <b>run</b>(<i></i>) 313 <b>run</b>(<i></i>)
559 314
560 <p> 315 <p>
561 Public method to check the given source against miscellaneous 316 Public method to check the given source against miscellaneous
562 conditions. 317 conditions.
563 </p> 318 </p>
564 <a NAME="ImportsChecker.sorted" ID="ImportsChecker.sorted"></a>
565 <h4>ImportsChecker.sorted</h4>
566 <b>sorted</b>(<i>toSort, key=None, reverse=False</i>)
567
568 <p>
569 Public method to sort the given list of names.
570 </p>
571 <dl>
572
573 <dt><i>toSort</i> (list of str)</dt>
574 <dd>
575 list of names to be sorted
576 </dd>
577 <dt><i>key</i> (function (optional))</dt>
578 <dd>
579 function to generate keys (defaults to None)
580 </dd>
581 <dt><i>reverse</i> (bool (optional))</dt>
582 <dd>
583 flag indicating a reverse sort (defaults to False)
584 </dd>
585 </dl>
586 <dl>
587 <dt>Return:</dt>
588 <dd>
589 sorted list of names
590 </dd>
591 </dl>
592 <dl>
593 <dt>Return Type:</dt>
594 <dd>
595 list of str
596 </dd>
597 </dl>
598 <div align="right"><a href="#top">Up</a></div> 319 <div align="right"><a href="#top">Up</a></div>
599 <hr /> 320 <hr />
600 </body></html> 321 </body></html>

eric ide

mercurial