eric7/Documentation/Source/eric7.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsChecker.html

branch
eric7
changeset 8372
e0227a7c850e
child 8596
d64760b2da50
equal deleted inserted replaced
8371:d6062691d424 8372:e0227a7c850e
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsChecker</title>
4 <meta charset="UTF-8">
5 <style>
6 body {
7 background: #EDECE6;
8 margin: 0em 1em 10em 1em;
9 color: black;
10 }
11
12 h1 { color: white; background: #85774A; }
13 h2 { color: white; background: #85774A; }
14 h3 { color: white; background: #9D936E; }
15 h4 { color: white; background: #9D936E; }
16
17 a { color: #BA6D36; }
18
19 </style>
20 </head>
21 <body>
22 <a NAME="top" ID="top"></a>
23 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsChecker</h1>
24
25 <p>
26 Module implementing a checker for function type annotations.
27 </p>
28 <h3>Global Attributes</h3>
29
30 <table>
31 <tr><td>None</td></tr>
32 </table>
33 <h3>Classes</h3>
34
35 <table>
36
37 <tr>
38 <td><a href="#AnnotationsChecker">AnnotationsChecker</a></td>
39 <td>Class implementing a checker for function type annotations.</td>
40 </tr>
41 </table>
42 <h3>Functions</h3>
43
44 <table>
45 <tr><td>None</td></tr>
46 </table>
47 <hr />
48 <hr />
49 <a NAME="AnnotationsChecker" ID="AnnotationsChecker"></a>
50 <h2>AnnotationsChecker</h2>
51
52 <p>
53 Class implementing a checker for function type annotations.
54 </p>
55 <h3>Derived from</h3>
56 None
57 <h3>Class Attributes</h3>
58
59 <table>
60 <tr><td>Codes</td></tr>
61 </table>
62 <h3>Class Methods</h3>
63
64 <table>
65 <tr><td>None</td></tr>
66 </table>
67 <h3>Methods</h3>
68
69 <table>
70
71 <tr>
72 <td><a href="#AnnotationsChecker.__init__">AnnotationsChecker</a></td>
73 <td>Constructor</td>
74 </tr>
75 <tr>
76 <td><a href="#AnnotationsChecker.__argumentErrorClassifier">__argumentErrorClassifier</a></td>
77 <td>Private method to classify an argument type annotation issue.</td>
78 </tr>
79 <tr>
80 <td><a href="#AnnotationsChecker.__checkAnnotationComplexity">__checkAnnotationComplexity</a></td>
81 <td>Private method to check the type annotation complexity.</td>
82 </tr>
83 <tr>
84 <td><a href="#AnnotationsChecker.__checkAnnotationsCoverage">__checkAnnotationsCoverage</a></td>
85 <td>Private method to check for function annotation coverage.</td>
86 </tr>
87 <tr>
88 <td><a href="#AnnotationsChecker.__checkFunctionAnnotations">__checkFunctionAnnotations</a></td>
89 <td>Private method to check for function annotation issues.</td>
90 </tr>
91 <tr>
92 <td><a href="#AnnotationsChecker.__classifyError">__classifyError</a></td>
93 <td>Private method to classify the missing type annotation based on the Function & Argument metadata.</td>
94 </tr>
95 <tr>
96 <td><a href="#AnnotationsChecker.__error">__error</a></td>
97 <td>Private method to record an issue.</td>
98 </tr>
99 <tr>
100 <td><a href="#AnnotationsChecker.__getAnnotationComplexity">__getAnnotationComplexity</a></td>
101 <td>Private method to determine the annotation complexity.</td>
102 </tr>
103 <tr>
104 <td><a href="#AnnotationsChecker.__getAnnotationLength">__getAnnotationLength</a></td>
105 <td>Private method to determine the annotation length.</td>
106 </tr>
107 <tr>
108 <td><a href="#AnnotationsChecker.__hasTypeAnnotations">__hasTypeAnnotations</a></td>
109 <td>Private method to check for type annotations.</td>
110 </tr>
111 <tr>
112 <td><a href="#AnnotationsChecker.__ignoreCode">__ignoreCode</a></td>
113 <td>Private method to check if the message code should be ignored.</td>
114 </tr>
115 <tr>
116 <td><a href="#AnnotationsChecker.__returnErrorClassifier">__returnErrorClassifier</a></td>
117 <td>Private method to classify a return type annotation issue.</td>
118 </tr>
119 <tr>
120 <td><a href="#AnnotationsChecker.run">run</a></td>
121 <td>Public method to check the given source against annotation issues.</td>
122 </tr>
123 </table>
124 <h3>Static Methods</h3>
125
126 <table>
127 <tr><td>None</td></tr>
128 </table>
129
130 <a NAME="AnnotationsChecker.__init__" ID="AnnotationsChecker.__init__"></a>
131 <h4>AnnotationsChecker (Constructor)</h4>
132 <b>AnnotationsChecker</b>(<i>source, filename, tree, select, ignore, expected, repeat, args</i>)
133
134 <p>
135 Constructor
136 </p>
137 <dl>
138
139 <dt><i>source</i> (list of str)</dt>
140 <dd>
141 source code to be checked
142 </dd>
143 <dt><i>filename</i> (str)</dt>
144 <dd>
145 name of the source file
146 </dd>
147 <dt><i>tree</i> (ast.Module)</dt>
148 <dd>
149 AST tree of the source code
150 </dd>
151 <dt><i>select</i> (list of str)</dt>
152 <dd>
153 list of selected codes
154 </dd>
155 <dt><i>ignore</i> (list of str)</dt>
156 <dd>
157 list of codes to be ignored
158 </dd>
159 <dt><i>expected</i> (list of str)</dt>
160 <dd>
161 list of expected codes
162 </dd>
163 <dt><i>repeat</i> (bool)</dt>
164 <dd>
165 flag indicating to report each occurrence of a code
166 </dd>
167 <dt><i>args</i> (dict)</dt>
168 <dd>
169 dictionary of arguments for the annotation checks
170 </dd>
171 </dl>
172 <a NAME="AnnotationsChecker.__argumentErrorClassifier" ID="AnnotationsChecker.__argumentErrorClassifier"></a>
173 <h4>AnnotationsChecker.__argumentErrorClassifier</h4>
174 <b>__argumentErrorClassifier</b>(<i>isClassMethod, isFirstArg, classDecoratorType, annotationType</i>)
175
176 <p>
177 Private method to classify an argument type annotation issue.
178 </p>
179 <dl>
180
181 <dt><i>isClassMethod</i> (bool)</dt>
182 <dd>
183 flag indicating a classmethod type function
184 </dd>
185 <dt><i>isFirstArg</i> (bool)</dt>
186 <dd>
187 flag indicating the first argument
188 </dd>
189 <dt><i>classDecoratorType</i> (enums.ClassDecoratorType)</dt>
190 <dd>
191 type of class decorator
192 </dd>
193 <dt><i>annotationType</i> (AnnotationType)</dt>
194 <dd>
195 type of annotation
196 </dd>
197 </dl>
198 <dl>
199 <dt>Return:</dt>
200 <dd>
201 error code
202 </dd>
203 </dl>
204 <dl>
205 <dt>Return Type:</dt>
206 <dd>
207 str
208 </dd>
209 </dl>
210 <a NAME="AnnotationsChecker.__checkAnnotationComplexity" ID="AnnotationsChecker.__checkAnnotationComplexity"></a>
211 <h4>AnnotationsChecker.__checkAnnotationComplexity</h4>
212 <b>__checkAnnotationComplexity</b>(<i></i>)
213
214 <p>
215 Private method to check the type annotation complexity.
216 </p>
217 <a NAME="AnnotationsChecker.__checkAnnotationsCoverage" ID="AnnotationsChecker.__checkAnnotationsCoverage"></a>
218 <h4>AnnotationsChecker.__checkAnnotationsCoverage</h4>
219 <b>__checkAnnotationsCoverage</b>(<i></i>)
220
221 <p>
222 Private method to check for function annotation coverage.
223 </p>
224 <a NAME="AnnotationsChecker.__checkFunctionAnnotations" ID="AnnotationsChecker.__checkFunctionAnnotations"></a>
225 <h4>AnnotationsChecker.__checkFunctionAnnotations</h4>
226 <b>__checkFunctionAnnotations</b>(<i></i>)
227
228 <p>
229 Private method to check for function annotation issues.
230 </p>
231 <a NAME="AnnotationsChecker.__classifyError" ID="AnnotationsChecker.__classifyError"></a>
232 <h4>AnnotationsChecker.__classifyError</h4>
233 <b>__classifyError</b>(<i>function, arg</i>)
234
235 <p>
236 Private method to classify the missing type annotation based on the
237 Function & Argument metadata.
238 </p>
239 <p>
240 For the currently defined rules & program flow, the assumption can be
241 made that an argument passed to this method will match a linting error,
242 and will only match a single linting error
243 </p>
244 <p>
245 This function provides an initial classificaton, then passes relevant
246 attributes to cached helper function(s).
247 </p>
248 <dl>
249
250 <dt><i>function</i> (Function)</dt>
251 <dd>
252 reference to the Function object
253 </dd>
254 <dt><i>arg</i> (Argument)</dt>
255 <dd>
256 reference to the Argument object
257 </dd>
258 </dl>
259 <a NAME="AnnotationsChecker.__error" ID="AnnotationsChecker.__error"></a>
260 <h4>AnnotationsChecker.__error</h4>
261 <b>__error</b>(<i>lineNumber, offset, code, *args</i>)
262
263 <p>
264 Private method to record an issue.
265 </p>
266 <dl>
267
268 <dt><i>lineNumber</i> (int)</dt>
269 <dd>
270 line number of the issue
271 </dd>
272 <dt><i>offset</i> (int)</dt>
273 <dd>
274 position within line of the issue
275 </dd>
276 <dt><i>code</i> (str)</dt>
277 <dd>
278 message code
279 </dd>
280 <dt><i>args</i> (list)</dt>
281 <dd>
282 arguments for the message
283 </dd>
284 </dl>
285 <a NAME="AnnotationsChecker.__getAnnotationComplexity" ID="AnnotationsChecker.__getAnnotationComplexity"></a>
286 <h4>AnnotationsChecker.__getAnnotationComplexity</h4>
287 <b>__getAnnotationComplexity</b>(<i>annotationNode, defaultComplexity=1</i>)
288
289 <p>
290 Private method to determine the annotation complexity.
291 </p>
292 <dl>
293
294 <dt><i>annotationNode</i> (ast.AST)</dt>
295 <dd>
296 reference to the node to determine the annotation
297 complexity for
298 </dd>
299 <dt><i>defaultComplexity</i> (int)</dt>
300 <dd>
301 default complexity value
302 </dd>
303 </dl>
304 <dl>
305 <dt>Return:</dt>
306 <dd>
307 annotation complexity
308 </dd>
309 </dl>
310 <dl>
311 <dt>Return Type:</dt>
312 <dd>
313 = int
314 </dd>
315 </dl>
316 <a NAME="AnnotationsChecker.__getAnnotationLength" ID="AnnotationsChecker.__getAnnotationLength"></a>
317 <h4>AnnotationsChecker.__getAnnotationLength</h4>
318 <b>__getAnnotationLength</b>(<i>annotationNode</i>)
319
320 <p>
321 Private method to determine the annotation length.
322 </p>
323 <dl>
324
325 <dt><i>annotationNode</i> (ast.AST)</dt>
326 <dd>
327 reference to the node to determine the annotation
328 length for
329 </dd>
330 </dl>
331 <dl>
332 <dt>Return:</dt>
333 <dd>
334 annotation length
335 </dd>
336 </dl>
337 <dl>
338 <dt>Return Type:</dt>
339 <dd>
340 = int
341 </dd>
342 </dl>
343 <a NAME="AnnotationsChecker.__hasTypeAnnotations" ID="AnnotationsChecker.__hasTypeAnnotations"></a>
344 <h4>AnnotationsChecker.__hasTypeAnnotations</h4>
345 <b>__hasTypeAnnotations</b>(<i>funcNode</i>)
346
347 <p>
348 Private method to check for type annotations.
349 </p>
350 <dl>
351
352 <dt><i>funcNode</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt>
353 <dd>
354 reference to the function definition node to be checked
355 </dd>
356 </dl>
357 <dl>
358 <dt>Return:</dt>
359 <dd>
360 flag indicating the presence of type annotations
361 </dd>
362 </dl>
363 <dl>
364 <dt>Return Type:</dt>
365 <dd>
366 bool
367 </dd>
368 </dl>
369 <a NAME="AnnotationsChecker.__ignoreCode" ID="AnnotationsChecker.__ignoreCode"></a>
370 <h4>AnnotationsChecker.__ignoreCode</h4>
371 <b>__ignoreCode</b>(<i>code</i>)
372
373 <p>
374 Private method to check if the message code should be ignored.
375 </p>
376 <dl>
377
378 <dt><i>code</i> (str)</dt>
379 <dd>
380 message code to check for
381 </dd>
382 </dl>
383 <dl>
384 <dt>Return:</dt>
385 <dd>
386 flag indicating to ignore the given code
387 </dd>
388 </dl>
389 <dl>
390 <dt>Return Type:</dt>
391 <dd>
392 bool
393 </dd>
394 </dl>
395 <a NAME="AnnotationsChecker.__returnErrorClassifier" ID="AnnotationsChecker.__returnErrorClassifier"></a>
396 <h4>AnnotationsChecker.__returnErrorClassifier</h4>
397 <b>__returnErrorClassifier</b>(<i>isClassMethod, classDecoratorType, functionType</i>)
398
399 <p>
400 Private method to classify a return type annotation issue.
401 </p>
402 <dl>
403
404 <dt><i>isClassMethod</i> (bool)</dt>
405 <dd>
406 flag indicating a classmethod type function
407 </dd>
408 <dt><i>classDecoratorType</i> (ClassDecoratorType)</dt>
409 <dd>
410 type of class decorator
411 </dd>
412 <dt><i>functionType</i> (FunctionType)</dt>
413 <dd>
414 type of function
415 </dd>
416 </dl>
417 <dl>
418 <dt>Return:</dt>
419 <dd>
420 error code
421 </dd>
422 </dl>
423 <dl>
424 <dt>Return Type:</dt>
425 <dd>
426 str
427 </dd>
428 </dl>
429 <a NAME="AnnotationsChecker.run" ID="AnnotationsChecker.run"></a>
430 <h4>AnnotationsChecker.run</h4>
431 <b>run</b>(<i></i>)
432
433 <p>
434 Public method to check the given source against annotation issues.
435 </p>
436 <div align="right"><a href="#top">Up</a></div>
437 <hr />
438 </body></html>

eric ide

mercurial