5 <link rel="stylesheet" href="styles.css"> |
5 <link rel="stylesheet" href="styles.css"> |
6 </head> |
6 </head> |
7 <body> |
7 <body> |
8 <a NAME="top" ID="top"></a> |
8 <a NAME="top" ID="top"></a> |
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsFunctionVisitor</h1> |
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsFunctionVisitor</h1> |
10 |
|
11 <p> |
10 <p> |
12 Module implementing a node visitor for function type annotations. |
11 Module implementing a node visitor for function type annotations. |
13 </p> |
12 </p> |
|
13 |
14 <h3>Global Attributes</h3> |
14 <h3>Global Attributes</h3> |
15 |
|
16 <table> |
15 <table> |
17 <tr><td>AST_ARG_TYPES</td></tr> |
16 <tr><td>AST_ARG_TYPES</td></tr> |
18 </table> |
17 </table> |
|
18 |
19 <h3>Classes</h3> |
19 <h3>Classes</h3> |
20 |
20 <table> |
21 <table> |
|
22 |
|
23 <tr> |
21 <tr> |
24 <td><a href="#Argument">Argument</a></td> |
22 <td><a href="#Argument">Argument</a></td> |
25 <td>Class representing a function argument.</td> |
23 <td>Class representing a function argument.</td> |
26 </tr> |
24 </tr> |
27 <tr> |
25 <tr> |
35 <tr> |
33 <tr> |
36 <td><a href="#ReturnVisitor">ReturnVisitor</a></td> |
34 <td><a href="#ReturnVisitor">ReturnVisitor</a></td> |
37 <td>Class implementing a node visitor to check the return statements of a function node.</td> |
35 <td>Class implementing a node visitor to check the return statements of a function node.</td> |
38 </tr> |
36 </tr> |
39 </table> |
37 </table> |
|
38 |
40 <h3>Functions</h3> |
39 <h3>Functions</h3> |
41 |
|
42 <table> |
40 <table> |
43 <tr><td>None</td></tr> |
41 <tr><td>None</td></tr> |
44 </table> |
42 </table> |
|
43 |
45 <hr /> |
44 <hr /> |
46 <hr /> |
45 <hr /> |
47 <a NAME="Argument" ID="Argument"></a> |
46 <a NAME="Argument" ID="Argument"></a> |
48 <h2>Argument</h2> |
47 <h2>Argument</h2> |
49 |
|
50 <p> |
48 <p> |
51 Class representing a function argument. |
49 Class representing a function argument. |
52 </p> |
50 </p> |
|
51 |
53 <h3>Derived from</h3> |
52 <h3>Derived from</h3> |
54 None |
53 None |
55 <h3>Class Attributes</h3> |
54 <h3>Class Attributes</h3> |
56 |
|
57 <table> |
55 <table> |
58 <tr><td>None</td></tr> |
56 <tr><td>None</td></tr> |
59 </table> |
57 </table> |
|
58 |
60 <h3>Class Methods</h3> |
59 <h3>Class Methods</h3> |
61 |
60 <table> |
62 <table> |
|
63 |
|
64 <tr> |
61 <tr> |
65 <td><a href="#Argument.fromNode">fromNode</a></td> |
62 <td><a href="#Argument.fromNode">fromNode</a></td> |
66 <td>Class method to create an Argument object based on the given node.</td> |
63 <td>Class method to create an Argument object based on the given node.</td> |
67 </tr> |
64 </tr> |
68 </table> |
65 </table> |
|
66 |
69 <h3>Methods</h3> |
67 <h3>Methods</h3> |
70 |
68 <table> |
71 <table> |
|
72 |
|
73 <tr> |
69 <tr> |
74 <td><a href="#Argument.__init__">Argument</a></td> |
70 <td><a href="#Argument.__init__">Argument</a></td> |
75 <td>Constructor</td> |
71 <td>Constructor</td> |
76 </tr> |
72 </tr> |
77 </table> |
73 </table> |
|
74 |
78 <h3>Static Methods</h3> |
75 <h3>Static Methods</h3> |
79 |
76 <table> |
80 <table> |
|
81 |
|
82 <tr> |
77 <tr> |
83 <td><a href="#Argument._isAnnotatedAny">_isAnnotatedAny</a></td> |
78 <td><a href="#Argument._isAnnotatedAny">_isAnnotatedAny</a></td> |
84 <td>Static method to check if the provided expression node is annotated with 'typing.Any'.</td> |
79 <td>Static method to check if the provided expression node is annotated with 'typing.Any'.</td> |
85 </tr> |
80 </tr> |
86 </table> |
81 </table> |
|
82 |
87 |
83 |
88 <a NAME="Argument.fromNode" ID="Argument.fromNode"></a> |
84 <a NAME="Argument.fromNode" ID="Argument.fromNode"></a> |
89 <h4>Argument.fromNode (class method)</h4> |
85 <h4>Argument.fromNode (class method)</h4> |
90 <b>fromNode</b>(<i>node, annotationTypeName</i>) |
86 <b>fromNode</b>(<i>node, annotationTypeName</i>) |
91 |
|
92 <p> |
87 <p> |
93 Class method to create an Argument object based on the given node. |
88 Class method to create an Argument object based on the given node. |
94 </p> |
89 </p> |
|
90 |
95 <dl> |
91 <dl> |
96 |
92 |
97 <dt><i>node</i> (ast.arguments)</dt> |
93 <dt><i>node</i> (ast.arguments)</dt> |
98 <dd> |
94 <dd> |
99 reference to the node to be converted |
95 reference to the node to be converted |
116 </dd> |
112 </dd> |
117 </dl> |
113 </dl> |
118 <a NAME="Argument.__init__" ID="Argument.__init__"></a> |
114 <a NAME="Argument.__init__" ID="Argument.__init__"></a> |
119 <h4>Argument (Constructor)</h4> |
115 <h4>Argument (Constructor)</h4> |
120 <b>Argument</b>(<i>argname, lineno, col_offset, annotationType, hasTypeAnnotation=False, hasTypeComment=False, isDynamicallyTyped=False, </i>) |
116 <b>Argument</b>(<i>argname, lineno, col_offset, annotationType, hasTypeAnnotation=False, hasTypeComment=False, isDynamicallyTyped=False, </i>) |
121 |
|
122 <p> |
117 <p> |
123 Constructor |
118 Constructor |
124 </p> |
119 </p> |
|
120 |
125 <dl> |
121 <dl> |
126 |
122 |
127 <dt><i>argname</i> (str)</dt> |
123 <dt><i>argname</i> (str)</dt> |
128 <dd> |
124 <dd> |
129 name of the argument |
125 name of the argument |
156 </dd> |
152 </dd> |
157 </dl> |
153 </dl> |
158 <a NAME="Argument._isAnnotatedAny" ID="Argument._isAnnotatedAny"></a> |
154 <a NAME="Argument._isAnnotatedAny" ID="Argument._isAnnotatedAny"></a> |
159 <h4>Argument._isAnnotatedAny (static)</h4> |
155 <h4>Argument._isAnnotatedAny (static)</h4> |
160 <b>_isAnnotatedAny</b>(<i></i>) |
156 <b>_isAnnotatedAny</b>(<i></i>) |
161 |
|
162 <p> |
157 <p> |
163 Static method to check if the provided expression node is annotated with |
158 Static method to check if the provided expression node is annotated with |
164 'typing.Any'. |
159 'typing.Any'. |
165 </p> |
160 </p> |
166 <p> |
161 <p> |
167 Support is provided for the following patterns: |
162 Support is provided for the following patterns: |
168 * 'from typing import Any; foo: Any' |
163 * 'from typing import Any; foo: Any' |
169 * 'import typing; foo: typing.Any' |
164 * 'import typing; foo: typing.Any' |
170 * 'import typing as <alias>; foo: <alias>.Any' |
165 * 'import typing as <alias>; foo: <alias>.Any' |
171 </p> |
166 </p> |
|
167 |
172 <dl> |
168 <dl> |
173 |
169 |
174 <dt><i>argExpr</i> (ast.expr or str)</dt> |
170 <dt><i>argExpr</i> (ast.expr or str)</dt> |
175 <dd> |
171 <dd> |
176 DESCRIPTION |
172 DESCRIPTION |
191 <div align="right"><a href="#top">Up</a></div> |
187 <div align="right"><a href="#top">Up</a></div> |
192 <hr /> |
188 <hr /> |
193 <hr /> |
189 <hr /> |
194 <a NAME="Function" ID="Function"></a> |
190 <a NAME="Function" ID="Function"></a> |
195 <h2>Function</h2> |
191 <h2>Function</h2> |
196 |
|
197 <p> |
192 <p> |
198 Class representing a function. |
193 Class representing a function. |
199 </p> |
194 </p> |
|
195 |
200 <h3>Derived from</h3> |
196 <h3>Derived from</h3> |
201 None |
197 None |
202 <h3>Class Attributes</h3> |
198 <h3>Class Attributes</h3> |
203 |
|
204 <table> |
199 <table> |
205 <tr><td>None</td></tr> |
200 <tr><td>None</td></tr> |
206 </table> |
201 </table> |
|
202 |
207 <h3>Class Methods</h3> |
203 <h3>Class Methods</h3> |
208 |
204 <table> |
209 <table> |
|
210 |
|
211 <tr> |
205 <tr> |
212 <td><a href="#Function.fromNode">fromNode</a></td> |
206 <td><a href="#Function.fromNode">fromNode</a></td> |
213 <td>Class method to create a Function object from ast.FunctionDef or ast.AsyncFunctionDef nodes.</td> |
207 <td>Class method to create a Function object from ast.FunctionDef or ast.AsyncFunctionDef nodes.</td> |
214 </tr> |
208 </tr> |
215 </table> |
209 </table> |
|
210 |
216 <h3>Methods</h3> |
211 <h3>Methods</h3> |
217 |
212 <table> |
218 <table> |
|
219 |
|
220 <tr> |
213 <tr> |
221 <td><a href="#Function.__init__">Function</a></td> |
214 <td><a href="#Function.__init__">Function</a></td> |
222 <td>Constructor</td> |
215 <td>Constructor</td> |
223 </tr> |
216 </tr> |
224 <tr> |
217 <tr> |
265 <tr> |
257 <tr> |
266 <td><a href="#Function.getFunctionType">getFunctionType</a></td> |
258 <td><a href="#Function.getFunctionType">getFunctionType</a></td> |
267 <td>Static method to determine the function's FunctionType from its name.</td> |
259 <td>Static method to determine the function's FunctionType from its name.</td> |
268 </tr> |
260 </tr> |
269 </table> |
261 </table> |
|
262 |
270 |
263 |
271 <a NAME="Function.fromNode" ID="Function.fromNode"></a> |
264 <a NAME="Function.fromNode" ID="Function.fromNode"></a> |
272 <h4>Function.fromNode (class method)</h4> |
265 <h4>Function.fromNode (class method)</h4> |
273 <b>fromNode</b>(<i>node, lines, **kwargs</i>) |
266 <b>fromNode</b>(<i>node, lines, **kwargs</i>) |
274 |
|
275 <p> |
267 <p> |
276 Class method to create a Function object from ast.FunctionDef or |
268 Class method to create a Function object from ast.FunctionDef or |
277 ast.AsyncFunctionDef nodes. |
269 ast.AsyncFunctionDef nodes. |
278 </p> |
270 </p> |
279 <p> |
271 <p> |
315 </dd> |
308 </dd> |
316 </dl> |
309 </dl> |
317 <a NAME="Function.__init__" ID="Function.__init__"></a> |
310 <a NAME="Function.__init__" ID="Function.__init__"></a> |
318 <h4>Function (Constructor)</h4> |
311 <h4>Function (Constructor)</h4> |
319 <b>Function</b>(<i>name, lineno, col_offset, functionType=FunctionType.PUBLIC, isClassMethod=False, classDecoratorType=None, isReturnAnnotated=False, hasTypeComment=False, hasOnlyNoneReturns=True, isNested=False, decoratorList=None, args=None, </i>) |
312 <b>Function</b>(<i>name, lineno, col_offset, functionType=FunctionType.PUBLIC, isClassMethod=False, classDecoratorType=None, isReturnAnnotated=False, hasTypeComment=False, hasOnlyNoneReturns=True, isNested=False, decoratorList=None, args=None, </i>) |
320 |
|
321 <p> |
313 <p> |
322 Constructor |
314 Constructor |
323 </p> |
315 </p> |
|
316 |
324 <dl> |
317 <dl> |
325 |
318 |
326 <dt><i>name</i> (str)</dt> |
319 <dt><i>name</i> (str)</dt> |
327 <dd> |
320 <dd> |
328 name of the function |
321 name of the function |
494 </dd> |
487 </dd> |
495 </dl> |
488 </dl> |
496 <a NAME="Function.isDynamicallyTyped" ID="Function.isDynamicallyTyped"></a> |
489 <a NAME="Function.isDynamicallyTyped" ID="Function.isDynamicallyTyped"></a> |
497 <h4>Function.isDynamicallyTyped</h4> |
490 <h4>Function.isDynamicallyTyped</h4> |
498 <b>isDynamicallyTyped</b>(<i></i>) |
491 <b>isDynamicallyTyped</b>(<i></i>) |
499 |
|
500 <p> |
492 <p> |
501 Public method to check, if a function definition is dynamically typed |
493 Public method to check, if a function definition is dynamically typed |
502 (i.e. completely lacking hints). |
494 (i.e. completely lacking hints). |
503 </p> |
495 </p> |
|
496 |
504 <dl> |
497 <dl> |
505 <dt>Return:</dt> |
498 <dt>Return:</dt> |
506 <dd> |
499 <dd> |
507 flag indicating a dynamically typed function definition |
500 flag indicating a dynamically typed function definition |
508 </dd> |
501 </dd> |
514 </dd> |
507 </dd> |
515 </dl> |
508 </dl> |
516 <a NAME="Function.isFullyAnnotated" ID="Function.isFullyAnnotated"></a> |
509 <a NAME="Function.isFullyAnnotated" ID="Function.isFullyAnnotated"></a> |
517 <h4>Function.isFullyAnnotated</h4> |
510 <h4>Function.isFullyAnnotated</h4> |
518 <b>isFullyAnnotated</b>(<i></i>) |
511 <b>isFullyAnnotated</b>(<i></i>) |
519 |
|
520 <p> |
512 <p> |
521 Public method to check, if the function definition is fully type |
513 Public method to check, if the function definition is fully type |
522 annotated. |
514 annotated. |
523 </p> |
515 </p> |
524 <p> |
516 <p> |
525 Note: self.args will always include an Argument object for return. |
517 Note: self.args will always include an Argument object for return. |
526 </p> |
518 </p> |
|
519 |
527 <dl> |
520 <dl> |
528 <dt>Return:</dt> |
521 <dt>Return:</dt> |
529 <dd> |
522 <dd> |
530 flag indicating a fully annotated function definition |
523 flag indicating a fully annotated function definition |
531 </dd> |
524 </dd> |
537 </dd> |
530 </dd> |
538 </dl> |
531 </dl> |
539 <a NAME="Function._singleLineColonSeeker" ID="Function._singleLineColonSeeker"></a> |
532 <a NAME="Function._singleLineColonSeeker" ID="Function._singleLineColonSeeker"></a> |
540 <h4>Function._singleLineColonSeeker (static)</h4> |
533 <h4>Function._singleLineColonSeeker (static)</h4> |
541 <b>_singleLineColonSeeker</b>(<i>line</i>) |
534 <b>_singleLineColonSeeker</b>(<i>line</i>) |
542 |
|
543 <p> |
535 <p> |
544 Static method to find the line & column indices of a single line |
536 Static method to find the line & column indices of a single line |
545 function definition. |
537 function definition. |
546 </p> |
538 </p> |
|
539 |
547 <dl> |
540 <dl> |
548 |
541 |
549 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt> |
542 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt> |
550 <dd> |
543 <dd> |
551 reference to the function definition node |
544 reference to the function definition node |
568 </dd> |
561 </dd> |
569 </dl> |
562 </dl> |
570 <a NAME="Function.colonSeeker" ID="Function.colonSeeker"></a> |
563 <a NAME="Function.colonSeeker" ID="Function.colonSeeker"></a> |
571 <h4>Function.colonSeeker (static)</h4> |
564 <h4>Function.colonSeeker (static)</h4> |
572 <b>colonSeeker</b>(<i>lines</i>) |
565 <b>colonSeeker</b>(<i>lines</i>) |
573 |
|
574 <p> |
566 <p> |
575 Static method to find the line & column indices of the function |
567 Static method to find the line & column indices of the function |
576 definition's closing colon. |
568 definition's closing colon. |
577 </p> |
569 </p> |
|
570 |
578 <dl> |
571 <dl> |
579 |
572 |
580 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt> |
573 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt> |
581 <dd> |
574 <dd> |
582 reference to the function definition node |
575 reference to the function definition node |
634 </dd> |
627 </dd> |
635 </dl> |
628 </dl> |
636 <a NAME="Function.getFunctionType" ID="Function.getFunctionType"></a> |
629 <a NAME="Function.getFunctionType" ID="Function.getFunctionType"></a> |
637 <h4>Function.getFunctionType (static)</h4> |
630 <h4>Function.getFunctionType (static)</h4> |
638 <b>getFunctionType</b>(<i></i>) |
631 <b>getFunctionType</b>(<i></i>) |
639 |
|
640 <p> |
632 <p> |
641 Static method to determine the function's FunctionType from its name. |
633 Static method to determine the function's FunctionType from its name. |
642 </p> |
634 </p> |
643 <p> |
635 <p> |
644 MethodType is determined by the following priority: |
636 MethodType is determined by the following priority: |
645 1. Special: function name prefixed & suffixed by "__" |
637 1. Special: function name prefixed & suffixed by "__" |
646 2. Private: function name prefixed by "__" |
638 2. Private: function name prefixed by "__" |
647 3. Protected: function name prefixed by "_" |
639 3. Protected: function name prefixed by "_" |
648 4. Public: everything else |
640 4. Public: everything else |
649 </p> |
641 </p> |
|
642 |
650 <dl> |
643 <dl> |
651 |
644 |
652 <dt><i>functionName</i> (str)</dt> |
645 <dt><i>functionName</i> (str)</dt> |
653 <dd> |
646 <dd> |
654 function name to be checked |
647 function name to be checked |
669 <div align="right"><a href="#top">Up</a></div> |
662 <div align="right"><a href="#top">Up</a></div> |
670 <hr /> |
663 <hr /> |
671 <hr /> |
664 <hr /> |
672 <a NAME="FunctionVisitor" ID="FunctionVisitor"></a> |
665 <a NAME="FunctionVisitor" ID="FunctionVisitor"></a> |
673 <h2>FunctionVisitor</h2> |
666 <h2>FunctionVisitor</h2> |
674 |
|
675 <p> |
667 <p> |
676 Class implementing a node visitor to check function annotations. |
668 Class implementing a node visitor to check function annotations. |
677 </p> |
669 </p> |
|
670 |
678 <h3>Derived from</h3> |
671 <h3>Derived from</h3> |
679 ast.NodeVisitor |
672 ast.NodeVisitor |
680 <h3>Class Attributes</h3> |
673 <h3>Class Attributes</h3> |
681 |
674 <table> |
682 <table> |
675 <tr><td>AstFuncTypes</td></tr> |
683 <tr><td>AstFuncTypes</td></tr><tr><td>visit_AsyncFunctionDef</td></tr><tr><td>visit_ClassDef</td></tr><tr><td>visit_FunctionDef</td></tr> |
676 <tr><td>visit_AsyncFunctionDef</td></tr> |
684 </table> |
677 <tr><td>visit_ClassDef</td></tr> |
|
678 <tr><td>visit_FunctionDef</td></tr> |
|
679 </table> |
|
680 |
685 <h3>Class Methods</h3> |
681 <h3>Class Methods</h3> |
686 |
|
687 <table> |
682 <table> |
688 <tr><td>None</td></tr> |
683 <tr><td>None</td></tr> |
689 </table> |
684 </table> |
|
685 |
690 <h3>Methods</h3> |
686 <h3>Methods</h3> |
691 |
687 <table> |
692 <table> |
|
693 |
|
694 <tr> |
688 <tr> |
695 <td><a href="#FunctionVisitor.__init__">FunctionVisitor</a></td> |
689 <td><a href="#FunctionVisitor.__init__">FunctionVisitor</a></td> |
696 <td>Constructor</td> |
690 <td>Constructor</td> |
697 </tr> |
691 </tr> |
698 <tr> |
692 <tr> |
699 <td><a href="#FunctionVisitor.switchContext">switchContext</a></td> |
693 <td><a href="#FunctionVisitor.switchContext">switchContext</a></td> |
700 <td>Public method implementing a context switcher as a generic function visitor in order to track function context.</td> |
694 <td>Public method implementing a context switcher as a generic function visitor in order to track function context.</td> |
701 </tr> |
695 </tr> |
702 </table> |
696 </table> |
|
697 |
703 <h3>Static Methods</h3> |
698 <h3>Static Methods</h3> |
704 |
|
705 <table> |
699 <table> |
706 <tr><td>None</td></tr> |
700 <tr><td>None</td></tr> |
707 </table> |
701 </table> |
|
702 |
708 |
703 |
709 <a NAME="FunctionVisitor.__init__" ID="FunctionVisitor.__init__"></a> |
704 <a NAME="FunctionVisitor.__init__" ID="FunctionVisitor.__init__"></a> |
710 <h4>FunctionVisitor (Constructor)</h4> |
705 <h4>FunctionVisitor (Constructor)</h4> |
711 <b>FunctionVisitor</b>(<i>lines</i>) |
706 <b>FunctionVisitor</b>(<i>lines</i>) |
712 |
|
713 <p> |
707 <p> |
714 Constructor |
708 Constructor |
715 </p> |
709 </p> |
|
710 |
716 <dl> |
711 <dl> |
717 |
712 |
718 <dt><i>lines</i> (list of str)</dt> |
713 <dt><i>lines</i> (list of str)</dt> |
719 <dd> |
714 <dd> |
720 source code lines of the function |
715 source code lines of the function |
721 </dd> |
716 </dd> |
722 </dl> |
717 </dl> |
723 <a NAME="FunctionVisitor.switchContext" ID="FunctionVisitor.switchContext"></a> |
718 <a NAME="FunctionVisitor.switchContext" ID="FunctionVisitor.switchContext"></a> |
724 <h4>FunctionVisitor.switchContext</h4> |
719 <h4>FunctionVisitor.switchContext</h4> |
725 <b>switchContext</b>(<i>node</i>) |
720 <b>switchContext</b>(<i>node</i>) |
726 |
|
727 <p> |
721 <p> |
728 Public method implementing a context switcher as a generic function |
722 Public method implementing a context switcher as a generic function |
729 visitor in order to track function context. |
723 visitor in order to track function context. |
730 </p> |
724 </p> |
731 <p> |
725 <p> |
732 Without keeping track of context, it's challenging to reliably |
726 Without keeping track of context, it's challenging to reliably |
733 differentiate class methods from "regular" functions, especially in the |
727 differentiate class methods from "regular" functions, especially in the |
734 case of nested classes. |
728 case of nested classes. |
735 </p> |
729 </p> |
|
730 |
736 <dl> |
731 <dl> |
737 |
732 |
738 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt> |
733 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt> |
739 <dd> |
734 <dd> |
740 reference to the function definition node to be analyzed |
735 reference to the function definition node to be analyzed |
764 Due to the generic visiting being done, we need to keep track of the |
758 Due to the generic visiting being done, we need to keep track of the |
765 context in which a non-`None` return node is found. These functions are |
759 context in which a non-`None` return node is found. These functions are |
766 added to a set that is checked to see whether nor not the parent node is |
760 added to a set that is checked to see whether nor not the parent node is |
767 present. |
761 present. |
768 </p> |
762 </p> |
|
763 |
769 <h3>Derived from</h3> |
764 <h3>Derived from</h3> |
770 ast.NodeVisitor |
765 ast.NodeVisitor |
771 <h3>Class Attributes</h3> |
766 <h3>Class Attributes</h3> |
772 |
767 <table> |
773 <table> |
768 <tr><td>visit_AsyncFunctionDef</td></tr> |
774 <tr><td>visit_AsyncFunctionDef</td></tr><tr><td>visit_FunctionDef</td></tr> |
769 <tr><td>visit_FunctionDef</td></tr> |
775 </table> |
770 </table> |
|
771 |
776 <h3>Class Methods</h3> |
772 <h3>Class Methods</h3> |
777 |
|
778 <table> |
773 <table> |
779 <tr><td>None</td></tr> |
774 <tr><td>None</td></tr> |
780 </table> |
775 </table> |
|
776 |
781 <h3>Methods</h3> |
777 <h3>Methods</h3> |
782 |
778 <table> |
783 <table> |
|
784 |
|
785 <tr> |
779 <tr> |
786 <td><a href="#ReturnVisitor.__init__">ReturnVisitor</a></td> |
780 <td><a href="#ReturnVisitor.__init__">ReturnVisitor</a></td> |
787 <td>Constructor</td> |
781 <td>Constructor</td> |
788 </tr> |
782 </tr> |
789 <tr> |
783 <tr> |
797 <tr> |
791 <tr> |
798 <td><a href="#ReturnVisitor.visit_Return">visit_Return</a></td> |
792 <td><a href="#ReturnVisitor.visit_Return">visit_Return</a></td> |
799 <td>Public method to check each Return node to see if it returns anything other than `None`.</td> |
793 <td>Public method to check each Return node to see if it returns anything other than `None`.</td> |
800 </tr> |
794 </tr> |
801 </table> |
795 </table> |
|
796 |
802 <h3>Static Methods</h3> |
797 <h3>Static Methods</h3> |
803 |
|
804 <table> |
798 <table> |
805 <tr><td>None</td></tr> |
799 <tr><td>None</td></tr> |
806 </table> |
800 </table> |
|
801 |
807 |
802 |
808 <a NAME="ReturnVisitor.__init__" ID="ReturnVisitor.__init__"></a> |
803 <a NAME="ReturnVisitor.__init__" ID="ReturnVisitor.__init__"></a> |
809 <h4>ReturnVisitor (Constructor)</h4> |
804 <h4>ReturnVisitor (Constructor)</h4> |
810 <b>ReturnVisitor</b>(<i>parentNode</i>) |
805 <b>ReturnVisitor</b>(<i>parentNode</i>) |
811 |
|
812 <p> |
806 <p> |
813 Constructor |
807 Constructor |
814 </p> |
808 </p> |
|
809 |
815 <dl> |
810 <dl> |
816 |
811 |
817 <dt><i>parentNode</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt> |
812 <dt><i>parentNode</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt> |
818 <dd> |
813 <dd> |
819 reference to the function definition node to be |
814 reference to the function definition node to be |
821 </dd> |
816 </dd> |
822 </dl> |
817 </dl> |
823 <a NAME="ReturnVisitor.hasOnlyNoneReturns" ID="ReturnVisitor.hasOnlyNoneReturns"></a> |
818 <a NAME="ReturnVisitor.hasOnlyNoneReturns" ID="ReturnVisitor.hasOnlyNoneReturns"></a> |
824 <h4>ReturnVisitor.hasOnlyNoneReturns</h4> |
819 <h4>ReturnVisitor.hasOnlyNoneReturns</h4> |
825 <b>hasOnlyNoneReturns</b>(<i></i>) |
820 <b>hasOnlyNoneReturns</b>(<i></i>) |
826 |
|
827 <p> |
821 <p> |
828 Public method indicating, that the parent node isn't in the visited |
822 Public method indicating, that the parent node isn't in the visited |
829 nodes that don't return `None`. |
823 nodes that don't return `None`. |
830 </p> |
824 </p> |
|
825 |
831 <dl> |
826 <dl> |
832 <dt>Return:</dt> |
827 <dt>Return:</dt> |
833 <dd> |
828 <dd> |
834 flag indicating, that the parent node isn't in the visited |
829 flag indicating, that the parent node isn't in the visited |
835 nodes that don't return `None` |
830 nodes that don't return `None` |
842 </dd> |
837 </dd> |
843 </dl> |
838 </dl> |
844 <a NAME="ReturnVisitor.switchContext" ID="ReturnVisitor.switchContext"></a> |
839 <a NAME="ReturnVisitor.switchContext" ID="ReturnVisitor.switchContext"></a> |
845 <h4>ReturnVisitor.switchContext</h4> |
840 <h4>ReturnVisitor.switchContext</h4> |
846 <b>switchContext</b>(<i>node</i>) |
841 <b>switchContext</b>(<i>node</i>) |
847 |
|
848 <p> |
842 <p> |
849 Public method implementing a context switcher as a generic function |
843 Public method implementing a context switcher as a generic function |
850 visitor in order to track function context. |
844 visitor in order to track function context. |
851 </p> |
845 </p> |
852 <p> |
846 <p> |
853 Without keeping track of context, it's challenging to reliably |
847 Without keeping track of context, it's challenging to reliably |
854 differentiate class methods from "regular" functions, especially in the |
848 differentiate class methods from "regular" functions, especially in the |
855 case of nested classes. |
849 case of nested classes. |
856 </p> |
850 </p> |
|
851 |
857 <dl> |
852 <dl> |
858 |
853 |
859 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt> |
854 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt> |
860 <dd> |
855 <dd> |
861 reference to the function definition node to be analyzed |
856 reference to the function definition node to be analyzed |
862 </dd> |
857 </dd> |
863 </dl> |
858 </dl> |
864 <a NAME="ReturnVisitor.visit_Return" ID="ReturnVisitor.visit_Return"></a> |
859 <a NAME="ReturnVisitor.visit_Return" ID="ReturnVisitor.visit_Return"></a> |
865 <h4>ReturnVisitor.visit_Return</h4> |
860 <h4>ReturnVisitor.visit_Return</h4> |
866 <b>visit_Return</b>(<i>node</i>) |
861 <b>visit_Return</b>(<i>node</i>) |
867 |
|
868 <p> |
862 <p> |
869 Public method to check each Return node to see if it returns anything |
863 Public method to check each Return node to see if it returns anything |
870 other than `None`. |
864 other than `None`. |
871 </p> |
865 </p> |
872 <p> |
866 <p> |
873 If the node being visited returns anything other than `None`, its |
867 If the node being visited returns anything other than `None`, its |
874 parent context is added to the set of non-returning child nodes of |
868 parent context is added to the set of non-returning child nodes of |
875 the parent node. |
869 the parent node. |
876 </p> |
870 </p> |
|
871 |
877 <dl> |
872 <dl> |
878 |
873 |
879 <dt><i>node</i> (ast.Return)</dt> |
874 <dt><i>node</i> (ast.Return)</dt> |
880 <dd> |
875 <dd> |
881 reference to the AST Return node |
876 reference to the AST Return node |