Documentation/Source/Pep8NamingCheckerPy2.html

branch
BgService
changeset 3209
c5432abceb25
parent 3177
5af61402d74d
child 3228
f489068e51e8
equal deleted inserted replaced
3177:5af61402d74d 3209:c5432abceb25
1 <!DOCTYPE html>
2 <html><head>
3 <title>Pep8NamingCheckerPy2</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><a NAME="top" ID="top"></a>
22 <h1>Pep8NamingCheckerPy2</h1>
23 <p>
24 Module implementing a checker for PEP-8 naming conventions for Python2.
25 </p>
26 <h3>Global Attributes</h3>
27 <table>
28 <tr><td>None</td></tr>
29 </table>
30 <h3>Classes</h3>
31 <table>
32 <tr>
33 <td><a href="#Pep8NamingChecker">Pep8NamingChecker</a></td>
34 <td>Class implementing a checker for PEP-8 naming conventions for Python2.</td>
35 </tr>
36 </table>
37 <h3>Functions</h3>
38 <table>
39 <tr><td>None</td></tr>
40 </table>
41 <hr /><hr />
42 <a NAME="Pep8NamingChecker" ID="Pep8NamingChecker"></a>
43 <h2>Pep8NamingChecker</h2>
44 <p>
45 Class implementing a checker for PEP-8 naming conventions for Python2.
46 </p>
47 <h3>Derived from</h3>
48 object
49 <h3>Class Attributes</h3>
50 <table>
51 <tr><td>CamelcaseRegexp</td></tr><tr><td>Codes</td></tr><tr><td>LowercaseRegex</td></tr><tr><td>MixedcaseRegexp</td></tr><tr><td>UppercaseRegexp</td></tr>
52 </table>
53 <h3>Class Methods</h3>
54 <table>
55 <tr><td>None</td></tr>
56 </table>
57 <h3>Methods</h3>
58 <table>
59 <tr>
60 <td><a href="#Pep8NamingChecker.__init__">Pep8NamingChecker</a></td>
61 <td>Constructor (according to 'extended' pep8.py API)</td>
62 </tr><tr>
63 <td><a href="#Pep8NamingChecker.__checkClassName">__checkClassName</a></td>
64 <td>Private class to check the given node for class name conventions (N801).</td>
65 </tr><tr>
66 <td><a href="#Pep8NamingChecker.__checkFunctionArgumentNames">__checkFunctionArgumentNames</a></td>
67 <td>Private class to check the argument names of functions (N803, N804, N805, N806).</td>
68 </tr><tr>
69 <td><a href="#Pep8NamingChecker.__checkFuntionName">__checkFuntionName</a></td>
70 <td>Private class to check the given node for function name conventions (N802).</td>
71 </tr><tr>
72 <td><a href="#Pep8NamingChecker.__checkImportAs">__checkImportAs</a></td>
73 <td>Private method to check that imports don't change the naming convention (N811, N812, N813, N814).</td>
74 </tr><tr>
75 <td><a href="#Pep8NamingChecker.__checkModule">__checkModule</a></td>
76 <td>Private method to check module naming conventions (N807, N808).</td>
77 </tr><tr>
78 <td><a href="#Pep8NamingChecker.__checkNameToBeAvoided">__checkNameToBeAvoided</a></td>
79 <td>Private class to check the given node for a name to be avoided (N831).</td>
80 </tr><tr>
81 <td><a href="#Pep8NamingChecker.__checkVariablesInFunction">__checkVariablesInFunction</a></td>
82 <td>Private method to check local variables in functions (N821).</td>
83 </tr><tr>
84 <td><a href="#Pep8NamingChecker.__error">__error</a></td>
85 <td>Private method to build the error information</td>
86 </tr><tr>
87 <td><a href="#Pep8NamingChecker.__findGlobalDefs">__findGlobalDefs</a></td>
88 <td>Private method amend a node with global definitions information.</td>
89 </tr><tr>
90 <td><a href="#Pep8NamingChecker.__getArgNames">__getArgNames</a></td>
91 <td>Private method to get the argument names of a function node.</td>
92 </tr><tr>
93 <td><a href="#Pep8NamingChecker.__isNameToBeAvoided">__isNameToBeAvoided</a></td>
94 <td>Private method to check, if the given name should be avoided.</td>
95 </tr><tr>
96 <td><a href="#Pep8NamingChecker.__tagClassFunctions">__tagClassFunctions</a></td>
97 <td>Private method to tag functions if they are methods, class methods or static methods.</td>
98 </tr><tr>
99 <td><a href="#Pep8NamingChecker.__visitNode">__visitNode</a></td>
100 <td>Private method to inspect the given AST node.</td>
101 </tr><tr>
102 <td><a href="#Pep8NamingChecker.__visitTree">__visitTree</a></td>
103 <td>Private method to scan the given AST tree.</td>
104 </tr><tr>
105 <td><a href="#Pep8NamingChecker.run">run</a></td>
106 <td>Public method run by the pep8.py checker.</td>
107 </tr><tr>
108 <td><a href="#Pep8NamingChecker.unpackArgs">unpackArgs</a></td>
109 <td>Local helper function to unpack function argument names.</td>
110 </tr>
111 </table>
112 <h3>Static Methods</h3>
113 <table>
114 <tr><td>None</td></tr>
115 </table>
116 <a NAME="Pep8NamingChecker.__init__" ID="Pep8NamingChecker.__init__"></a>
117 <h4>Pep8NamingChecker (Constructor)</h4>
118 <b>Pep8NamingChecker</b>(<i>tree, filename, options</i>)
119 <p>
120 Constructor (according to 'extended' pep8.py API)
121 </p><dl>
122 <dt><i>tree</i></dt>
123 <dd>
124 AST tree of the source file
125 </dd><dt><i>filename</i></dt>
126 <dd>
127 name of the source file (string)
128 </dd><dt><i>options</i></dt>
129 <dd>
130 options as parsed by pep8.StyleGuide
131 </dd>
132 </dl><a NAME="Pep8NamingChecker.__checkClassName" ID="Pep8NamingChecker.__checkClassName"></a>
133 <h4>Pep8NamingChecker.__checkClassName</h4>
134 <b>__checkClassName</b>(<i>node, parents</i>)
135 <p>
136 Private class to check the given node for class name
137 conventions (N801).
138 </p><p>
139 Almost without exception, class names use the CapWords convention.
140 Classes for internal use have a leading underscore in addition.
141 </p><dl>
142 <dt><i>node</i></dt>
143 <dd>
144 AST note to check
145 </dd>
146 </dl><dl>
147 <dt>Returns:</dt>
148 <dd>
149 tuple giving line number, offset within line and error code
150 (integer, integer, string)
151 </dd>
152 </dl><a NAME="Pep8NamingChecker.__checkFunctionArgumentNames" ID="Pep8NamingChecker.__checkFunctionArgumentNames"></a>
153 <h4>Pep8NamingChecker.__checkFunctionArgumentNames</h4>
154 <b>__checkFunctionArgumentNames</b>(<i>node, parents</i>)
155 <p>
156 Private class to check the argument names of functions
157 (N803, N804, N805, N806).
158 </p><p>
159 The argument names of a function should be lowercase, with words
160 separated by underscores. A class method should have 'cls' as the
161 first argument. A method should have 'self' as the first argument.
162 </p><dl>
163 <dt><i>node</i></dt>
164 <dd>
165 AST note to check
166 </dd>
167 </dl><dl>
168 <dt>Returns:</dt>
169 <dd>
170 tuple giving line number, offset within line and error code
171 (integer, integer, string)
172 </dd>
173 </dl><a NAME="Pep8NamingChecker.__checkFuntionName" ID="Pep8NamingChecker.__checkFuntionName"></a>
174 <h4>Pep8NamingChecker.__checkFuntionName</h4>
175 <b>__checkFuntionName</b>(<i>node, parents</i>)
176 <p>
177 Private class to check the given node for function name
178 conventions (N802).
179 </p><p>
180 Function names should be lowercase, with words separated by underscores
181 as necessary to improve readability. Functions <b>not</b> being
182 methods '__' in front and back are not allowed. Mixed case is allowed
183 only in contexts where that's already the prevailing style
184 (e.g. threading.py), to retain backwards compatibility.
185 </p><dl>
186 <dt><i>node</i></dt>
187 <dd>
188 AST note to check
189 </dd>
190 </dl><dl>
191 <dt>Returns:</dt>
192 <dd>
193 tuple giving line number, offset within line and error code
194 (integer, integer, string)
195 </dd>
196 </dl><a NAME="Pep8NamingChecker.__checkImportAs" ID="Pep8NamingChecker.__checkImportAs"></a>
197 <h4>Pep8NamingChecker.__checkImportAs</h4>
198 <b>__checkImportAs</b>(<i>node, parents</i>)
199 <p>
200 Private method to check that imports don't change the
201 naming convention (N811, N812, N813, N814).
202 </p><dl>
203 <dt><i>node</i></dt>
204 <dd>
205 AST note to check
206 </dd>
207 </dl><dl>
208 <dt>Returns:</dt>
209 <dd>
210 tuple giving line number, offset within line and error code
211 (integer, integer, string)
212 </dd>
213 </dl><a NAME="Pep8NamingChecker.__checkModule" ID="Pep8NamingChecker.__checkModule"></a>
214 <h4>Pep8NamingChecker.__checkModule</h4>
215 <b>__checkModule</b>(<i>node, parents</i>)
216 <p>
217 Private method to check module naming conventions (N807, N808).
218 </p><p>
219 Module and package names should be lowercase.
220 </p><dl>
221 <dt><i>node</i></dt>
222 <dd>
223 AST note to check
224 </dd>
225 </dl><dl>
226 <dt>Returns:</dt>
227 <dd>
228 tuple giving line number, offset within line and error code
229 (integer, integer, string)
230 </dd>
231 </dl><a NAME="Pep8NamingChecker.__checkNameToBeAvoided" ID="Pep8NamingChecker.__checkNameToBeAvoided"></a>
232 <h4>Pep8NamingChecker.__checkNameToBeAvoided</h4>
233 <b>__checkNameToBeAvoided</b>(<i>node, parents</i>)
234 <p>
235 Private class to check the given node for a name to be avoided (N831).
236 </p><dl>
237 <dt><i>node</i></dt>
238 <dd>
239 AST note to check
240 </dd>
241 </dl><dl>
242 <dt>Returns:</dt>
243 <dd>
244 tuple giving line number, offset within line and error code
245 (integer, integer, string)
246 </dd>
247 </dl><a NAME="Pep8NamingChecker.__checkVariablesInFunction" ID="Pep8NamingChecker.__checkVariablesInFunction"></a>
248 <h4>Pep8NamingChecker.__checkVariablesInFunction</h4>
249 <b>__checkVariablesInFunction</b>(<i>node, parents</i>)
250 <p>
251 Private method to check local variables in functions (N821).
252 </p><p>
253 Local variables in functions should be lowercase.
254 </p><dl>
255 <dt><i>node</i></dt>
256 <dd>
257 AST note to check
258 </dd>
259 </dl><dl>
260 <dt>Returns:</dt>
261 <dd>
262 tuple giving line number, offset within line and error code
263 (integer, integer, string)
264 </dd>
265 </dl><a NAME="Pep8NamingChecker.__error" ID="Pep8NamingChecker.__error"></a>
266 <h4>Pep8NamingChecker.__error</h4>
267 <b>__error</b>(<i>node, code</i>)
268 <p>
269 Private method to build the error information
270 </p><dl>
271 <dt><i>node</i></dt>
272 <dd>
273 AST node to report an error for
274 </dd><dt><i>code</i></dt>
275 <dd>
276 error code to report (string)
277 </dd>
278 </dl><dl>
279 <dt>Returns:</dt>
280 <dd>
281 tuple giving line number, offset within line and error code
282 (integer, integer, string)
283 </dd>
284 </dl><a NAME="Pep8NamingChecker.__findGlobalDefs" ID="Pep8NamingChecker.__findGlobalDefs"></a>
285 <h4>Pep8NamingChecker.__findGlobalDefs</h4>
286 <b>__findGlobalDefs</b>(<i>functionNode</i>)
287 <p>
288 Private method amend a node with global definitions information.
289 </p><dl>
290 <dt><i>functionNode</i></dt>
291 <dd>
292 AST tree node to amend
293 </dd>
294 </dl><a NAME="Pep8NamingChecker.__getArgNames" ID="Pep8NamingChecker.__getArgNames"></a>
295 <h4>Pep8NamingChecker.__getArgNames</h4>
296 <b>__getArgNames</b>(<i>node</i>)
297 <p>
298 Private method to get the argument names of a function node.
299 </p><dl>
300 <dt><i>node</i></dt>
301 <dd>
302 AST node to extract arguments names from
303 </dd>
304 </dl><dl>
305 <dt>Returns:</dt>
306 <dd>
307 list of argument names (list of string)
308 </dd>
309 </dl><a NAME="Pep8NamingChecker.__isNameToBeAvoided" ID="Pep8NamingChecker.__isNameToBeAvoided"></a>
310 <h4>Pep8NamingChecker.__isNameToBeAvoided</h4>
311 <b>__isNameToBeAvoided</b>(<i>name</i>)
312 <p>
313 Private method to check, if the given name should be avoided.
314 </p><dl>
315 <dt><i>name</i></dt>
316 <dd>
317 name to be checked (string)
318 </dd>
319 </dl><dl>
320 <dt>Returns:</dt>
321 <dd>
322 flag indicating to avoid it (boolen)
323 </dd>
324 </dl><a NAME="Pep8NamingChecker.__tagClassFunctions" ID="Pep8NamingChecker.__tagClassFunctions"></a>
325 <h4>Pep8NamingChecker.__tagClassFunctions</h4>
326 <b>__tagClassFunctions</b>(<i>classNode</i>)
327 <p>
328 Private method to tag functions if they are methods, class methods or
329 static methods.
330 </p><dl>
331 <dt><i>classNode</i></dt>
332 <dd>
333 AST tree node to tag
334 </dd>
335 </dl><a NAME="Pep8NamingChecker.__visitNode" ID="Pep8NamingChecker.__visitNode"></a>
336 <h4>Pep8NamingChecker.__visitNode</h4>
337 <b>__visitNode</b>(<i>node</i>)
338 <p>
339 Private method to inspect the given AST node.
340 </p><dl>
341 <dt><i>node</i></dt>
342 <dd>
343 AST tree node to inspect
344 </dd>
345 </dl><dl>
346 <dt>Returns:</dt>
347 <dd>
348 tuple giving line number, offset within line, code and
349 checker function
350 </dd>
351 </dl><a NAME="Pep8NamingChecker.__visitTree" ID="Pep8NamingChecker.__visitTree"></a>
352 <h4>Pep8NamingChecker.__visitTree</h4>
353 <b>__visitTree</b>(<i>node</i>)
354 <p>
355 Private method to scan the given AST tree.
356 </p><dl>
357 <dt><i>node</i></dt>
358 <dd>
359 AST tree node to scan
360 </dd>
361 </dl><dl>
362 <dt>Returns:</dt>
363 <dd>
364 tuple giving line number, offset within line, code and
365 checker function
366 </dd>
367 </dl><a NAME="Pep8NamingChecker.run" ID="Pep8NamingChecker.run"></a>
368 <h4>Pep8NamingChecker.run</h4>
369 <b>run</b>(<i></i>)
370 <p>
371 Public method run by the pep8.py checker.
372 </p><dl>
373 <dt>Returns:</dt>
374 <dd>
375 tuple giving line number, offset within line, code and
376 checker function
377 </dd>
378 </dl><a NAME="Pep8NamingChecker.unpackArgs" ID="Pep8NamingChecker.unpackArgs"></a>
379 <h4>Pep8NamingChecker.unpackArgs</h4>
380 <b>unpackArgs</b>(<i></i>)
381 <p>
382 Local helper function to unpack function argument names.
383 </p><dl>
384 <dt><i>args</i></dt>
385 <dd>
386 list of AST node arguments
387 </dd>
388 </dl><dl>
389 <dt>Returns:</dt>
390 <dd>
391 list of argument names (list of string)
392 </dd>
393 </dl>
394 <div align="right"><a href="#top">Up</a></div>
395 <hr />
396 </body></html>

eric ide

mercurial