|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsFutureVisitor</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsFutureVisitor</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing a node visitor for function type annotations. |
|
13 </p> |
|
14 <h3>Global Attributes</h3> |
|
15 |
|
16 <table> |
|
17 <tr><td>None</td></tr> |
|
18 </table> |
|
19 <h3>Classes</h3> |
|
20 |
|
21 <table> |
|
22 |
|
23 <tr> |
|
24 <td><a href="#AnnotationsFutureVisitor">AnnotationsFutureVisitor</a></td> |
|
25 <td>Class implementing a node visitor to check __future__ imports.</td> |
|
26 </tr> |
|
27 </table> |
|
28 <h3>Functions</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <hr /> |
|
34 <hr /> |
|
35 <a NAME="AnnotationsFutureVisitor" ID="AnnotationsFutureVisitor"></a> |
|
36 <h2>AnnotationsFutureVisitor</h2> |
|
37 |
|
38 <p> |
|
39 Class implementing a node visitor to check __future__ imports. |
|
40 </p> |
|
41 <h3>Derived from</h3> |
|
42 ast.NodeVisitor |
|
43 <h3>Class Attributes</h3> |
|
44 |
|
45 <table> |
|
46 <tr><td>SimplifyableTypes</td></tr> |
|
47 </table> |
|
48 <h3>Class Methods</h3> |
|
49 |
|
50 <table> |
|
51 <tr><td>None</td></tr> |
|
52 </table> |
|
53 <h3>Methods</h3> |
|
54 |
|
55 <table> |
|
56 |
|
57 <tr> |
|
58 <td><a href="#AnnotationsFutureVisitor.__init__">AnnotationsFutureVisitor</a></td> |
|
59 <td>Constructor</td> |
|
60 </tr> |
|
61 <tr> |
|
62 <td><a href="#AnnotationsFutureVisitor.getTypingImports">getTypingImports</a></td> |
|
63 <td>Public method to get the list of typing imports.</td> |
|
64 </tr> |
|
65 <tr> |
|
66 <td><a href="#AnnotationsFutureVisitor.hasTypingImports">hasTypingImports</a></td> |
|
67 <td>Public method to check, if the analyzed code includes typing imports.</td> |
|
68 </tr> |
|
69 <tr> |
|
70 <td><a href="#AnnotationsFutureVisitor.importsFutureAnnotations">importsFutureAnnotations</a></td> |
|
71 <td>Public method to check, if the analyzed code uses future annotation.</td> |
|
72 </tr> |
|
73 <tr> |
|
74 <td><a href="#AnnotationsFutureVisitor.visit_Attribute">visit_Attribute</a></td> |
|
75 <td>Public method to record simplifiable names.</td> |
|
76 </tr> |
|
77 <tr> |
|
78 <td><a href="#AnnotationsFutureVisitor.visit_Import">visit_Import</a></td> |
|
79 <td>Public method to check imports for typing related stuff.</td> |
|
80 </tr> |
|
81 <tr> |
|
82 <td><a href="#AnnotationsFutureVisitor.visit_ImportFrom">visit_ImportFrom</a></td> |
|
83 <td>Public method to detect the 'from __future__ import annotations' import if present.</td> |
|
84 </tr> |
|
85 </table> |
|
86 <h3>Static Methods</h3> |
|
87 |
|
88 <table> |
|
89 <tr><td>None</td></tr> |
|
90 </table> |
|
91 |
|
92 <a NAME="AnnotationsFutureVisitor.__init__" ID="AnnotationsFutureVisitor.__init__"></a> |
|
93 <h4>AnnotationsFutureVisitor (Constructor)</h4> |
|
94 <b>AnnotationsFutureVisitor</b>(<i></i>) |
|
95 |
|
96 <p> |
|
97 Constructor |
|
98 </p> |
|
99 <a NAME="AnnotationsFutureVisitor.getTypingImports" ID="AnnotationsFutureVisitor.getTypingImports"></a> |
|
100 <h4>AnnotationsFutureVisitor.getTypingImports</h4> |
|
101 <b>getTypingImports</b>(<i></i>) |
|
102 |
|
103 <p> |
|
104 Public method to get the list of typing imports. |
|
105 </p> |
|
106 <dl> |
|
107 <dt>Return:</dt> |
|
108 <dd> |
|
109 list of typing imports |
|
110 </dd> |
|
111 </dl> |
|
112 <dl> |
|
113 <dt>Return Type:</dt> |
|
114 <dd> |
|
115 list of str |
|
116 </dd> |
|
117 </dl> |
|
118 <a NAME="AnnotationsFutureVisitor.hasTypingImports" ID="AnnotationsFutureVisitor.hasTypingImports"></a> |
|
119 <h4>AnnotationsFutureVisitor.hasTypingImports</h4> |
|
120 <b>hasTypingImports</b>(<i></i>) |
|
121 |
|
122 <p> |
|
123 Public method to check, if the analyzed code includes typing imports. |
|
124 </p> |
|
125 <dl> |
|
126 <dt>Return:</dt> |
|
127 <dd> |
|
128 flag indicating the use of typing imports |
|
129 </dd> |
|
130 </dl> |
|
131 <dl> |
|
132 <dt>Return Type:</dt> |
|
133 <dd> |
|
134 bool |
|
135 </dd> |
|
136 </dl> |
|
137 <a NAME="AnnotationsFutureVisitor.importsFutureAnnotations" ID="AnnotationsFutureVisitor.importsFutureAnnotations"></a> |
|
138 <h4>AnnotationsFutureVisitor.importsFutureAnnotations</h4> |
|
139 <b>importsFutureAnnotations</b>(<i></i>) |
|
140 |
|
141 <p> |
|
142 Public method to check, if the analyzed code uses future annotation. |
|
143 </p> |
|
144 <dl> |
|
145 <dt>Return:</dt> |
|
146 <dd> |
|
147 flag indicatung the use of future annotation |
|
148 </dd> |
|
149 </dl> |
|
150 <dl> |
|
151 <dt>Return Type:</dt> |
|
152 <dd> |
|
153 bool |
|
154 </dd> |
|
155 </dl> |
|
156 <a NAME="AnnotationsFutureVisitor.visit_Attribute" ID="AnnotationsFutureVisitor.visit_Attribute"></a> |
|
157 <h4>AnnotationsFutureVisitor.visit_Attribute</h4> |
|
158 <b>visit_Attribute</b>(<i>node</i>) |
|
159 |
|
160 <p> |
|
161 Public method to record simplifiable names. |
|
162 </p> |
|
163 <p> |
|
164 If 'import typing' or 'import typing as t' is used, add simplifiable |
|
165 names that were used later on in the code. |
|
166 </p> |
|
167 <dl> |
|
168 |
|
169 <dt><i>node</i> (ast.Attribute)</dt> |
|
170 <dd> |
|
171 reference to the AST Attribute node |
|
172 </dd> |
|
173 </dl> |
|
174 <a NAME="AnnotationsFutureVisitor.visit_Import" ID="AnnotationsFutureVisitor.visit_Import"></a> |
|
175 <h4>AnnotationsFutureVisitor.visit_Import</h4> |
|
176 <b>visit_Import</b>(<i>node</i>) |
|
177 |
|
178 <p> |
|
179 Public method to check imports for typing related stuff. |
|
180 </p> |
|
181 <p> |
|
182 This looks like: |
|
183 import typing |
|
184 or |
|
185 import typing as t |
|
186 </p> |
|
187 <p> |
|
188 typing or t will be added to the list of typing aliases. |
|
189 </p> |
|
190 <dl> |
|
191 |
|
192 <dt><i>node</i> (ast.Import)</dt> |
|
193 <dd> |
|
194 reference to the AST Import node |
|
195 </dd> |
|
196 </dl> |
|
197 <a NAME="AnnotationsFutureVisitor.visit_ImportFrom" ID="AnnotationsFutureVisitor.visit_ImportFrom"></a> |
|
198 <h4>AnnotationsFutureVisitor.visit_ImportFrom</h4> |
|
199 <b>visit_ImportFrom</b>(<i>node</i>) |
|
200 |
|
201 <p> |
|
202 Public method to detect the 'from __future__ import annotations' |
|
203 import if present. |
|
204 </p> |
|
205 <p> |
|
206 If 'from typing import ...' is used, add simplifiable names that were |
|
207 imported. |
|
208 </p> |
|
209 <dl> |
|
210 |
|
211 <dt><i>node</i> (ast.ImportFrom)</dt> |
|
212 <dd> |
|
213 reference to the AST ImportFrom node |
|
214 </dd> |
|
215 </dl> |
|
216 <div align="right"><a href="#top">Up</a></div> |
|
217 <hr /> |
|
218 </body></html> |