|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Pydantic.PydanticVisitor</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.Pydantic.PydanticVisitor</h1> |
|
10 <p> |
|
11 Module implementing a node visitor to check for pydantic related issues. |
|
12 </p> |
|
13 |
|
14 <h3>Global Attributes</h3> |
|
15 <table> |
|
16 <tr><td>None</td></tr> |
|
17 </table> |
|
18 |
|
19 <h3>Classes</h3> |
|
20 <table> |
|
21 <tr> |
|
22 <td><a href="#PydanticVisitor">PydanticVisitor</a></td> |
|
23 <td>Class implementing a node visitor to check for pydantic related issues.</td> |
|
24 </tr> |
|
25 </table> |
|
26 |
|
27 <h3>Functions</h3> |
|
28 <table> |
|
29 <tr><td>None</td></tr> |
|
30 </table> |
|
31 |
|
32 <hr /> |
|
33 <hr /> |
|
34 <a NAME="PydanticVisitor" ID="PydanticVisitor"></a> |
|
35 <h2>PydanticVisitor</h2> |
|
36 <p> |
|
37 Class implementing a node visitor to check for pydantic related issues. |
|
38 </p> |
|
39 |
|
40 <h3>Derived from</h3> |
|
41 ast.NodeVisitor |
|
42 <h3>Class Attributes</h3> |
|
43 <table> |
|
44 <tr><td>None</td></tr> |
|
45 </table> |
|
46 |
|
47 <h3>Class Methods</h3> |
|
48 <table> |
|
49 <tr><td>None</td></tr> |
|
50 </table> |
|
51 |
|
52 <h3>Methods</h3> |
|
53 <table> |
|
54 <tr> |
|
55 <td><a href="#PydanticVisitor.__init__">PydanticVisitor</a></td> |
|
56 <td>Constructor</td> |
|
57 </tr> |
|
58 <tr> |
|
59 <td><a href="#PydanticVisitor.__checkForPyd001">__checkForPyd001</a></td> |
|
60 <td>Private method to check positional argument for Field default argument.</td> |
|
61 </tr> |
|
62 <tr> |
|
63 <td><a href="#PydanticVisitor.__checkForPyd002">__checkForPyd002</a></td> |
|
64 <td>Private method to check non-annotated attribute inside Pydantic model.</td> |
|
65 </tr> |
|
66 <tr> |
|
67 <td><a href="#PydanticVisitor.__checkForPyd003">__checkForPyd003</a></td> |
|
68 <td>Private method to check unecessary Field call to specify a default value.</td> |
|
69 </tr> |
|
70 <tr> |
|
71 <td><a href="#PydanticVisitor.__checkForPyd004">__checkForPyd004</a></td> |
|
72 <td>Private method to check for a default argument specified in annotated.</td> |
|
73 </tr> |
|
74 <tr> |
|
75 <td><a href="#PydanticVisitor.__checkForPyd005">__checkForPyd005</a></td> |
|
76 <td>Private method to check for a field name overriding the annotation.</td> |
|
77 </tr> |
|
78 <tr> |
|
79 <td><a href="#PydanticVisitor.__checkForPyd006">__checkForPyd006</a></td> |
|
80 <td>Private method to check for duplicate field names.</td> |
|
81 </tr> |
|
82 <tr> |
|
83 <td><a href="#PydanticVisitor.__checkForPyd010">__checkForPyd010</a></td> |
|
84 <td>Private method to check for the use of `__pydantic_config__`.</td> |
|
85 </tr> |
|
86 <tr> |
|
87 <td><a href="#PydanticVisitor.__currentClass">__currentClass</a></td> |
|
88 <td>Private method returning the current class type as recorded by the __enterClass method.</td> |
|
89 </tr> |
|
90 <tr> |
|
91 <td><a href="#PydanticVisitor.__enterClass">__enterClass</a></td> |
|
92 <td>Private method to record class type when entering a class definition.</td> |
|
93 </tr> |
|
94 <tr> |
|
95 <td><a href="#PydanticVisitor.__leaveClass">__leaveClass</a></td> |
|
96 <td>Private method to remove the data recorded by the __enterClass method.</td> |
|
97 </tr> |
|
98 <tr> |
|
99 <td><a href="#PydanticVisitor.visit_AnnAssign">visit_AnnAssign</a></td> |
|
100 <td>Public method to process annotated assignment.</td> |
|
101 </tr> |
|
102 <tr> |
|
103 <td><a href="#PydanticVisitor.visit_ClassDef">visit_ClassDef</a></td> |
|
104 <td>Public method to process class definitions.</td> |
|
105 </tr> |
|
106 </table> |
|
107 |
|
108 <h3>Static Methods</h3> |
|
109 <table> |
|
110 <tr><td>None</td></tr> |
|
111 </table> |
|
112 |
|
113 |
|
114 <a NAME="PydanticVisitor.__init__" ID="PydanticVisitor.__init__"></a> |
|
115 <h4>PydanticVisitor (Constructor)</h4> |
|
116 <b>PydanticVisitor</b>(<i>errorCallback</i>) |
|
117 <p> |
|
118 Constructor |
|
119 </p> |
|
120 |
|
121 <dl> |
|
122 |
|
123 <dt><i>errorCallback</i> (func)</dt> |
|
124 <dd> |
|
125 callback function to register an error |
|
126 </dd> |
|
127 </dl> |
|
128 <a NAME="PydanticVisitor.__checkForPyd001" ID="PydanticVisitor.__checkForPyd001"></a> |
|
129 <h4>PydanticVisitor.__checkForPyd001</h4> |
|
130 <b>__checkForPyd001</b>(<i>node: ast.AnnAssign</i>) |
|
131 <p> |
|
132 Private method to check positional argument for Field default argument. |
|
133 </p> |
|
134 |
|
135 <dl> |
|
136 |
|
137 <dt><i>node</i> (ast.AnnAssign)</dt> |
|
138 <dd> |
|
139 reference to the node to be processed |
|
140 </dd> |
|
141 </dl> |
|
142 <a NAME="PydanticVisitor.__checkForPyd002" ID="PydanticVisitor.__checkForPyd002"></a> |
|
143 <h4>PydanticVisitor.__checkForPyd002</h4> |
|
144 <b>__checkForPyd002</b>(<i>node</i>) |
|
145 <p> |
|
146 Private method to check non-annotated attribute inside Pydantic model. |
|
147 </p> |
|
148 |
|
149 <dl> |
|
150 |
|
151 <dt><i>node</i> (ast.ClassDef)</dt> |
|
152 <dd> |
|
153 reference to the node to be processed |
|
154 </dd> |
|
155 </dl> |
|
156 <a NAME="PydanticVisitor.__checkForPyd003" ID="PydanticVisitor.__checkForPyd003"></a> |
|
157 <h4>PydanticVisitor.__checkForPyd003</h4> |
|
158 <b>__checkForPyd003</b>(<i>node</i>) |
|
159 <p> |
|
160 Private method to check unecessary Field call to specify a default value. |
|
161 </p> |
|
162 |
|
163 <dl> |
|
164 |
|
165 <dt><i>node</i> (ast.AnnAssign)</dt> |
|
166 <dd> |
|
167 reference to the node to be processed |
|
168 </dd> |
|
169 </dl> |
|
170 <a NAME="PydanticVisitor.__checkForPyd004" ID="PydanticVisitor.__checkForPyd004"></a> |
|
171 <h4>PydanticVisitor.__checkForPyd004</h4> |
|
172 <b>__checkForPyd004</b>(<i>node</i>) |
|
173 <p> |
|
174 Private method to check for a default argument specified in annotated. |
|
175 </p> |
|
176 |
|
177 <dl> |
|
178 |
|
179 <dt><i>node</i> (ast.AnnAssign)</dt> |
|
180 <dd> |
|
181 reference to the node to be processed |
|
182 </dd> |
|
183 </dl> |
|
184 <a NAME="PydanticVisitor.__checkForPyd005" ID="PydanticVisitor.__checkForPyd005"></a> |
|
185 <h4>PydanticVisitor.__checkForPyd005</h4> |
|
186 <b>__checkForPyd005</b>(<i>node</i>) |
|
187 <p> |
|
188 Private method to check for a field name overriding the annotation. |
|
189 </p> |
|
190 |
|
191 <dl> |
|
192 |
|
193 <dt><i>node</i> (ast.ClassDef)</dt> |
|
194 <dd> |
|
195 reference to the node to be processed |
|
196 </dd> |
|
197 </dl> |
|
198 <a NAME="PydanticVisitor.__checkForPyd006" ID="PydanticVisitor.__checkForPyd006"></a> |
|
199 <h4>PydanticVisitor.__checkForPyd006</h4> |
|
200 <b>__checkForPyd006</b>(<i>node</i>) |
|
201 <p> |
|
202 Private method to check for duplicate field names. |
|
203 </p> |
|
204 |
|
205 <dl> |
|
206 |
|
207 <dt><i>node</i> (ast.ClassDef)</dt> |
|
208 <dd> |
|
209 reference to the node to be processed |
|
210 </dd> |
|
211 </dl> |
|
212 <a NAME="PydanticVisitor.__checkForPyd010" ID="PydanticVisitor.__checkForPyd010"></a> |
|
213 <h4>PydanticVisitor.__checkForPyd010</h4> |
|
214 <b>__checkForPyd010</b>(<i>node: ast.ClassDef</i>) |
|
215 <p> |
|
216 Private method to check for the use of `__pydantic_config__`. |
|
217 </p> |
|
218 |
|
219 <dl> |
|
220 |
|
221 <dt><i>node</i> (ast.ClassDef)</dt> |
|
222 <dd> |
|
223 reference to the node to be processed |
|
224 </dd> |
|
225 </dl> |
|
226 <a NAME="PydanticVisitor.__currentClass" ID="PydanticVisitor.__currentClass"></a> |
|
227 <h4>PydanticVisitor.__currentClass</h4> |
|
228 <b>__currentClass</b>(<i></i>) |
|
229 <p> |
|
230 Private method returning the current class type as recorded by the __enterClass |
|
231 method. |
|
232 </p> |
|
233 |
|
234 <dl> |
|
235 <dt>Return:</dt> |
|
236 <dd> |
|
237 current class type (one of 'pydantic_model', 'dataclass' or |
|
238 'other_class') |
|
239 </dd> |
|
240 </dl> |
|
241 <dl> |
|
242 <dt>Return Type:</dt> |
|
243 <dd> |
|
244 str |
|
245 </dd> |
|
246 </dl> |
|
247 <a NAME="PydanticVisitor.__enterClass" ID="PydanticVisitor.__enterClass"></a> |
|
248 <h4>PydanticVisitor.__enterClass</h4> |
|
249 <b>__enterClass</b>(<i>node</i>) |
|
250 <p> |
|
251 Private method to record class type when entering a class definition. |
|
252 </p> |
|
253 |
|
254 <dl> |
|
255 |
|
256 <dt><i>node</i> (ast.ClassDef)</dt> |
|
257 <dd> |
|
258 reference to the node to be processed |
|
259 </dd> |
|
260 </dl> |
|
261 <a NAME="PydanticVisitor.__leaveClass" ID="PydanticVisitor.__leaveClass"></a> |
|
262 <h4>PydanticVisitor.__leaveClass</h4> |
|
263 <b>__leaveClass</b>(<i></i>) |
|
264 <p> |
|
265 Private method to remove the data recorded by the __enterClass method. |
|
266 </p> |
|
267 |
|
268 <a NAME="PydanticVisitor.visit_AnnAssign" ID="PydanticVisitor.visit_AnnAssign"></a> |
|
269 <h4>PydanticVisitor.visit_AnnAssign</h4> |
|
270 <b>visit_AnnAssign</b>(<i>node: ast.AnnAssign</i>) |
|
271 <p> |
|
272 Public method to process annotated assignment. |
|
273 </p> |
|
274 |
|
275 <dl> |
|
276 |
|
277 <dt><i>node</i> (ast.AnnAssign)</dt> |
|
278 <dd> |
|
279 reference to the node to be processed. |
|
280 </dd> |
|
281 </dl> |
|
282 <a NAME="PydanticVisitor.visit_ClassDef" ID="PydanticVisitor.visit_ClassDef"></a> |
|
283 <h4>PydanticVisitor.visit_ClassDef</h4> |
|
284 <b>visit_ClassDef</b>(<i>node: ast.ClassDef</i>) |
|
285 <p> |
|
286 Public method to process class definitions. |
|
287 </p> |
|
288 |
|
289 <dl> |
|
290 |
|
291 <dt><i>node</i> (ast.ClassDef)</dt> |
|
292 <dd> |
|
293 reference to the node to be processed. |
|
294 </dd> |
|
295 </dl> |
|
296 <div align="right"><a href="#top">Up</a></div> |
|
297 <hr /> |
|
298 </body></html> |