9220:e9e7eca7efee | 9221:bf71ee032bb4 |
---|---|
10 """ | 10 """ |
11 Module providing the class Message and its subclasses. | 11 Module providing the class Message and its subclasses. |
12 """ | 12 """ |
13 | 13 |
14 | 14 |
15 class Message(): | 15 class Message: |
16 """ | 16 """ |
17 Class defining the base for all specific message classes. | 17 Class defining the base for all specific message classes. |
18 """ | 18 """ |
19 message_id = 'F00' | 19 |
20 message = '' | 20 message_id = "F00" |
21 message = "" | |
21 message_args = () | 22 message_args = () |
22 | 23 |
23 def __init__(self, filename, loc): | 24 def __init__(self, filename, loc): |
24 """ | 25 """ |
25 Constructor | 26 Constructor |
26 | 27 |
27 @param filename name of the file | 28 @param filename name of the file |
28 @type str | 29 @type str |
29 @param loc location of the issue | 30 @param loc location of the issue |
30 """ | 31 """ |
31 self.filename = filename | 32 self.filename = filename |
32 self.lineno = loc.lineno | 33 self.lineno = loc.lineno |
33 self.col = getattr(loc, 'col_offset', 0) | 34 self.col = getattr(loc, "col_offset", 0) |
34 | 35 |
35 def __str__(self): | 36 def __str__(self): |
36 """ | 37 """ |
37 Special method return a string representation of the instance object. | 38 Special method return a string representation of the instance object. |
38 | 39 |
39 @return string representation of the object | 40 @return string representation of the object |
40 @rtype str | 41 @rtype str |
41 """ | 42 """ |
42 return '{0}:{1}:{2} {3}'.format( | 43 return "{0}:{1}:{2} {3}".format( |
43 self.filename, self.lineno, self.col + 1, | 44 self.filename, self.lineno, self.col + 1, self.message % self.message_args |
44 self.message % self.message_args) | 45 ) |
45 | 46 |
46 def getMessageData(self): | 47 def getMessageData(self): |
47 """ | 48 """ |
48 Public method to get the individual message data elements. | 49 Public method to get the individual message data elements. |
49 | 50 |
50 @return tuple containing file name, line number, column, message ID | 51 @return tuple containing file name, line number, column, message ID |
51 and message arguments | 52 and message arguments |
52 @rtype tuple of (str, int, int, str, list) | 53 @rtype tuple of (str, int, int, str, list) |
53 """ | 54 """ |
54 return (self.filename, self.lineno, self.col, self.message_id, | 55 return ( |
55 self.message_args) | 56 self.filename, |
57 self.lineno, | |
58 self.col, | |
59 self.message_id, | |
60 self.message_args, | |
61 ) | |
56 | 62 |
57 | 63 |
58 class UnusedImport(Message): | 64 class UnusedImport(Message): |
59 """ | 65 """ |
60 Class defining the "Unused Import" message. | 66 Class defining the "Unused Import" message. |
61 """ | 67 """ |
62 message_id = 'F01' | 68 |
63 message = '%r imported but unused' | 69 message_id = "F01" |
70 message = "%r imported but unused" | |
64 | 71 |
65 def __init__(self, filename, loc, name): | 72 def __init__(self, filename, loc, name): |
66 """ | 73 """ |
67 Constructor | 74 Constructor |
68 | 75 |
69 @param filename name of the file (string) | 76 @param filename name of the file (string) |
70 @param loc location of the issue | 77 @param loc location of the issue |
71 @param name name of the unused import (string) | 78 @param name name of the unused import (string) |
72 """ | 79 """ |
73 Message.__init__(self, filename, loc) | 80 Message.__init__(self, filename, loc) |
76 | 83 |
77 class RedefinedWhileUnused(Message): | 84 class RedefinedWhileUnused(Message): |
78 """ | 85 """ |
79 Class defining the "Redefined While Unused" message. | 86 Class defining the "Redefined While Unused" message. |
80 """ | 87 """ |
81 message_id = 'F02' | 88 |
82 message = 'redefinition of unused %r from line %r' | 89 message_id = "F02" |
90 message = "redefinition of unused %r from line %r" | |
83 | 91 |
84 def __init__(self, filename, loc, name, orig_loc): | 92 def __init__(self, filename, loc, name, orig_loc): |
85 """ | 93 """ |
86 Constructor | 94 Constructor |
87 | 95 |
88 @param filename name of the file (string) | 96 @param filename name of the file (string) |
89 @param loc location of the issue | 97 @param loc location of the issue |
90 @param name name of the redefined object (string) | 98 @param name name of the redefined object (string) |
91 @param orig_loc location of the original definition | 99 @param orig_loc location of the original definition |
92 """ | 100 """ |
96 | 104 |
97 class RedefinedInListComp(Message): | 105 class RedefinedInListComp(Message): |
98 """ | 106 """ |
99 Class defining the "Redefined In List Comprehension" message. | 107 Class defining the "Redefined In List Comprehension" message. |
100 """ | 108 """ |
101 message_id = 'F12' | 109 |
102 message = 'list comprehension redefines %r from line %r' | 110 message_id = "F12" |
111 message = "list comprehension redefines %r from line %r" | |
103 | 112 |
104 def __init__(self, filename, loc, name, orig_loc): | 113 def __init__(self, filename, loc, name, orig_loc): |
105 """ | 114 """ |
106 Constructor | 115 Constructor |
107 | 116 |
108 @param filename name of the file (string) | 117 @param filename name of the file (string) |
109 @param loc location of the issue | 118 @param loc location of the issue |
110 @param name name of the redefined object (string) | 119 @param name name of the redefined object (string) |
111 @param orig_loc location of the original definition | 120 @param orig_loc location of the original definition |
112 """ | 121 """ |
116 | 125 |
117 class ImportShadowedByLoopVar(Message): | 126 class ImportShadowedByLoopVar(Message): |
118 """ | 127 """ |
119 Class defining the "Import Shadowed By Loop Var" message. | 128 Class defining the "Import Shadowed By Loop Var" message. |
120 """ | 129 """ |
121 message_id = 'F03' | 130 |
122 message = 'import %r from line %r shadowed by loop variable' | 131 message_id = "F03" |
132 message = "import %r from line %r shadowed by loop variable" | |
123 | 133 |
124 def __init__(self, filename, loc, name, orig_loc): | 134 def __init__(self, filename, loc, name, orig_loc): |
125 """ | 135 """ |
126 Constructor | 136 Constructor |
127 | 137 |
128 @param filename name of the file (string) | 138 @param filename name of the file (string) |
129 @param loc location of the issue | 139 @param loc location of the issue |
130 @param name name of the shadowed import (string) | 140 @param name name of the shadowed import (string) |
131 @param orig_loc location of the import | 141 @param orig_loc location of the import |
132 """ | 142 """ |
136 | 146 |
137 class ImportStarNotPermitted(Message): | 147 class ImportStarNotPermitted(Message): |
138 """ | 148 """ |
139 Class defining the "Import * not permitted" message. | 149 Class defining the "Import * not permitted" message. |
140 """ | 150 """ |
141 message_id = 'F16' | 151 |
152 message_id = "F16" | |
142 message = "'from %s import *' only allowed at module level" | 153 message = "'from %s import *' only allowed at module level" |
143 | 154 |
144 def __init__(self, filename, loc, modname): | 155 def __init__(self, filename, loc, modname): |
145 """ | 156 """ |
146 Constructor | 157 Constructor |
147 | 158 |
148 @param filename name of the file (string) | 159 @param filename name of the file (string) |
149 @param loc location of the issue | 160 @param loc location of the issue |
150 @param modname name of the module (string) | 161 @param modname name of the module (string) |
151 """ | 162 """ |
152 Message.__init__(self, filename, loc) | 163 Message.__init__(self, filename, loc) |
155 | 166 |
156 class ImportStarUsed(Message): | 167 class ImportStarUsed(Message): |
157 """ | 168 """ |
158 Class defining the "Import Star Used" message. | 169 Class defining the "Import Star Used" message. |
159 """ | 170 """ |
160 message_id = 'F04' | 171 |
172 message_id = "F04" | |
161 message = "'from %s import *' used; unable to detect undefined names" | 173 message = "'from %s import *' used; unable to detect undefined names" |
162 | 174 |
163 def __init__(self, filename, loc, modname): | 175 def __init__(self, filename, loc, modname): |
164 """ | 176 """ |
165 Constructor | 177 Constructor |
166 | 178 |
167 @param filename name of the file (string) | 179 @param filename name of the file (string) |
168 @param loc location of the issue | 180 @param loc location of the issue |
169 @param modname name of the module imported using star import (string) | 181 @param modname name of the module imported using star import (string) |
170 """ | 182 """ |
171 Message.__init__(self, filename, loc) | 183 Message.__init__(self, filename, loc) |
174 | 186 |
175 class ImportStarUsage(Message): | 187 class ImportStarUsage(Message): |
176 """ | 188 """ |
177 Class defining the "Import Star Usage" message. | 189 Class defining the "Import Star Usage" message. |
178 """ | 190 """ |
179 message_id = 'F17' | 191 |
192 message_id = "F17" | |
180 message = "%r may be undefined, or defined from star imports: %s" | 193 message = "%r may be undefined, or defined from star imports: %s" |
181 | 194 |
182 def __init__(self, filename, loc, name, from_list): | 195 def __init__(self, filename, loc, name, from_list): |
183 """ | 196 """ |
184 Constructor | 197 Constructor |
185 | 198 |
186 @param filename name of the file (string) | 199 @param filename name of the file (string) |
187 @param loc location of the issue | 200 @param loc location of the issue |
188 @param name name of the variable (string) | 201 @param name name of the variable (string) |
189 @param from_list list of modules imported from with * (string) | 202 @param from_list list of modules imported from with * (string) |
190 """ | 203 """ |
194 | 207 |
195 class UndefinedName(Message): | 208 class UndefinedName(Message): |
196 """ | 209 """ |
197 Class defining the "Undefined Name" message. | 210 Class defining the "Undefined Name" message. |
198 """ | 211 """ |
199 message_id = 'F05' | 212 |
200 message = 'undefined name %r' | 213 message_id = "F05" |
214 message = "undefined name %r" | |
201 | 215 |
202 def __init__(self, filename, loc, name): | 216 def __init__(self, filename, loc, name): |
203 """ | 217 """ |
204 Constructor | 218 Constructor |
205 | 219 |
206 @param filename name of the file (string) | 220 @param filename name of the file (string) |
207 @param loc location of the issue | 221 @param loc location of the issue |
208 @param name undefined name (string) | 222 @param name undefined name (string) |
209 """ | 223 """ |
210 Message.__init__(self, filename, loc) | 224 Message.__init__(self, filename, loc) |
213 | 227 |
214 class DoctestSyntaxError(Message): | 228 class DoctestSyntaxError(Message): |
215 """ | 229 """ |
216 Class defining the "Doctest syntax Error" message. | 230 Class defining the "Doctest syntax Error" message. |
217 """ | 231 """ |
218 message_id = 'F13' | 232 |
219 message = 'syntax error in doctest' | 233 message_id = "F13" |
234 message = "syntax error in doctest" | |
220 | 235 |
221 def __init__(self, filename, loc, position=None): | 236 def __init__(self, filename, loc, position=None): |
222 """ | 237 """ |
223 Constructor | 238 Constructor |
224 | 239 |
225 @param filename name of the file (string) | 240 @param filename name of the file (string) |
226 @param loc location of the issue | 241 @param loc location of the issue |
227 @param position position of the syntax error | 242 @param position position of the syntax error |
228 """ | 243 """ |
229 Message.__init__(self, filename, loc) | 244 Message.__init__(self, filename, loc) |
234 | 249 |
235 class UndefinedExport(Message): | 250 class UndefinedExport(Message): |
236 """ | 251 """ |
237 Class defining the "Undefined Export" message. | 252 Class defining the "Undefined Export" message. |
238 """ | 253 """ |
239 message_id = 'F06' | 254 |
240 message = 'undefined name %r in __all__' | 255 message_id = "F06" |
256 message = "undefined name %r in __all__" | |
241 | 257 |
242 def __init__(self, filename, loc, name): | 258 def __init__(self, filename, loc, name): |
243 """ | 259 """ |
244 Constructor | 260 Constructor |
245 | 261 |
246 @param filename name of the file (string) | 262 @param filename name of the file (string) |
247 @param loc location of the issue | 263 @param loc location of the issue |
248 @param name undefined exported name (string) | 264 @param name undefined exported name (string) |
249 """ | 265 """ |
250 Message.__init__(self, filename, loc) | 266 Message.__init__(self, filename, loc) |
253 | 269 |
254 class UndefinedLocal(Message): | 270 class UndefinedLocal(Message): |
255 """ | 271 """ |
256 Class defining the "Undefined Local Variable" message. | 272 Class defining the "Undefined Local Variable" message. |
257 """ | 273 """ |
258 message_id = 'F07' | 274 |
259 message = 'local variable %r {0} referenced before assignment' | 275 message_id = "F07" |
260 | 276 message = "local variable %r {0} referenced before assignment" |
261 default = 'defined in enclosing scope on line %r' | 277 |
262 builtin = 'defined as a builtin' | 278 default = "defined in enclosing scope on line %r" |
279 builtin = "defined as a builtin" | |
263 | 280 |
264 def __init__(self, filename, loc, name, orig_loc): | 281 def __init__(self, filename, loc, name, orig_loc): |
265 """ | 282 """ |
266 Constructor | 283 Constructor |
267 | 284 |
268 @param filename name of the file (string) | 285 @param filename name of the file (string) |
269 @param loc location of the issue | 286 @param loc location of the issue |
270 @param name name of the prematurely referenced variable (string) | 287 @param name name of the prematurely referenced variable (string) |
271 @param orig_loc location of the variable definition | 288 @param orig_loc location of the variable definition |
272 """ | 289 """ |
273 Message.__init__(self, filename, loc) | 290 Message.__init__(self, filename, loc) |
274 if orig_loc is None: | 291 if orig_loc is None: |
275 self.message = self.message.format(self.builtin) | 292 self.message = self.message.format(self.builtin) |
276 self.message_args = (name,) | 293 self.message_args = (name,) |
277 self.message_id = 'F07B' | 294 self.message_id = "F07B" |
278 else: | 295 else: |
279 self.message = self.message.format(self.default) | 296 self.message = self.message.format(self.default) |
280 self.message_args = (name, orig_loc.lineno) | 297 self.message_args = (name, orig_loc.lineno) |
281 self.message_id = 'F07A' | 298 self.message_id = "F07A" |
282 | 299 |
283 | 300 |
284 class DuplicateArgument(Message): | 301 class DuplicateArgument(Message): |
285 """ | 302 """ |
286 Class defining the "Duplicate Argument" message. | 303 Class defining the "Duplicate Argument" message. |
287 """ | 304 """ |
288 message_id = 'F08' | 305 |
289 message = 'duplicate argument %r in function definition' | 306 message_id = "F08" |
307 message = "duplicate argument %r in function definition" | |
290 | 308 |
291 def __init__(self, filename, loc, name): | 309 def __init__(self, filename, loc, name): |
292 """ | 310 """ |
293 Constructor | 311 Constructor |
294 | 312 |
295 @param filename name of the file (string) | 313 @param filename name of the file (string) |
296 @param loc location of the issue | 314 @param loc location of the issue |
297 @param name name of the duplicate argument (string) | 315 @param name name of the duplicate argument (string) |
298 """ | 316 """ |
299 Message.__init__(self, filename, loc) | 317 Message.__init__(self, filename, loc) |
302 | 320 |
303 class MultiValueRepeatedKeyLiteral(Message): | 321 class MultiValueRepeatedKeyLiteral(Message): |
304 """ | 322 """ |
305 Class defining the multiple used dictionary key message. | 323 Class defining the multiple used dictionary key message. |
306 """ | 324 """ |
307 message_id = 'F18' | 325 |
308 message = 'dictionary key %r repeated with different values' | 326 message_id = "F18" |
327 message = "dictionary key %r repeated with different values" | |
309 | 328 |
310 def __init__(self, filename, loc, key): | 329 def __init__(self, filename, loc, key): |
311 """ | 330 """ |
312 Constructor | 331 Constructor |
313 | 332 |
314 @param filename name of the file (string) | 333 @param filename name of the file (string) |
315 @param loc location of the issue | 334 @param loc location of the issue |
316 @param key dictionary key (string) | 335 @param key dictionary key (string) |
317 """ | 336 """ |
318 Message.__init__(self, filename, loc) | 337 Message.__init__(self, filename, loc) |
321 | 340 |
322 class MultiValueRepeatedKeyVariable(Message): | 341 class MultiValueRepeatedKeyVariable(Message): |
323 """ | 342 """ |
324 Class defining the multiple used dictionary key variable message. | 343 Class defining the multiple used dictionary key variable message. |
325 """ | 344 """ |
326 message_id = 'F19' | 345 |
327 message = 'dictionary key variable %s repeated with different values' | 346 message_id = "F19" |
347 message = "dictionary key variable %s repeated with different values" | |
328 | 348 |
329 def __init__(self, filename, loc, key): | 349 def __init__(self, filename, loc, key): |
330 """ | 350 """ |
331 Constructor | 351 Constructor |
332 | 352 |
333 @param filename name of the file (string) | 353 @param filename name of the file (string) |
334 @param loc location of the issue | 354 @param loc location of the issue |
335 @param key dictionary key variable (string) | 355 @param key dictionary key variable (string) |
336 """ | 356 """ |
337 Message.__init__(self, filename, loc) | 357 Message.__init__(self, filename, loc) |
340 | 360 |
341 class LateFutureImport(Message): | 361 class LateFutureImport(Message): |
342 """ | 362 """ |
343 Class defining the "Late Future Import" message. | 363 Class defining the "Late Future Import" message. |
344 """ | 364 """ |
345 message_id = 'F10' | 365 |
346 message = 'from __future__ imports must occur at the beginning of the file' | 366 message_id = "F10" |
367 message = "from __future__ imports must occur at the beginning of the file" | |
347 | 368 |
348 def __init__(self, filename, loc, names): | 369 def __init__(self, filename, loc, names): |
349 """ | 370 """ |
350 Constructor | 371 Constructor |
351 | 372 |
352 @param filename name of the file (string) | 373 @param filename name of the file (string) |
353 @param loc location of the issue | 374 @param loc location of the issue |
354 @param names names of the imported futures (string) | 375 @param names names of the imported futures (string) |
355 """ | 376 """ |
356 Message.__init__(self, filename, loc) | 377 Message.__init__(self, filename, loc) |
359 | 380 |
360 class FutureFeatureNotDefined(Message): | 381 class FutureFeatureNotDefined(Message): |
361 """ | 382 """ |
362 Class defining the undefined __future__ feature message. | 383 Class defining the undefined __future__ feature message. |
363 """ | 384 """ |
364 message_id = 'F20' | 385 |
365 message = 'future feature %s is not defined' | 386 message_id = "F20" |
387 message = "future feature %s is not defined" | |
366 | 388 |
367 def __init__(self, filename, loc, name): | 389 def __init__(self, filename, loc, name): |
368 """ | 390 """ |
369 Constructor | 391 Constructor |
370 | 392 |
371 @param filename name of the file (string) | 393 @param filename name of the file (string) |
372 @param loc location of the issue | 394 @param loc location of the issue |
373 @param name name of the imported undefined future feature (string) | 395 @param name name of the imported undefined future feature (string) |
374 """ | 396 """ |
375 Message.__init__(self, filename, loc) | 397 Message.__init__(self, filename, loc) |
377 | 399 |
378 | 400 |
379 class UnusedVariable(Message): | 401 class UnusedVariable(Message): |
380 """ | 402 """ |
381 Class defining the "Unused Variable" message. | 403 Class defining the "Unused Variable" message. |
382 | 404 |
383 Indicates that a variable has been explicitly assigned to but not actually | 405 Indicates that a variable has been explicitly assigned to but not actually |
384 used. | 406 used. |
385 """ | 407 """ |
386 message_id = 'F11' | 408 |
387 message = 'local variable %r is assigned to but never used' | 409 message_id = "F11" |
410 message = "local variable %r is assigned to but never used" | |
388 | 411 |
389 def __init__(self, filename, loc, names): | 412 def __init__(self, filename, loc, names): |
390 """ | 413 """ |
391 Constructor | 414 Constructor |
392 | 415 |
393 @param filename name of the file (string) | 416 @param filename name of the file (string) |
394 @param loc location of the issue | 417 @param loc location of the issue |
395 @param names names of unused variable (string) | 418 @param names names of unused variable (string) |
396 """ | 419 """ |
397 Message.__init__(self, filename, loc) | 420 Message.__init__(self, filename, loc) |
399 | 422 |
400 | 423 |
401 class ReturnWithArgsInsideGenerator(Message): | 424 class ReturnWithArgsInsideGenerator(Message): |
402 """ | 425 """ |
403 Class defining the "Return values in generator" message. | 426 Class defining the "Return values in generator" message. |
404 | 427 |
405 Indicates a return statement with arguments inside a generator. | 428 Indicates a return statement with arguments inside a generator. |
406 """ | 429 """ |
407 message_id = 'F14' | 430 |
408 message = '\'return\' with argument inside generator' | 431 message_id = "F14" |
432 message = "'return' with argument inside generator" | |
409 | 433 |
410 | 434 |
411 class ReturnOutsideFunction(Message): | 435 class ReturnOutsideFunction(Message): |
412 """ | 436 """ |
413 Class defining the "Return outside function" message. | 437 Class defining the "Return outside function" message. |
414 | 438 |
415 Indicates a return statement outside of a function/method. | 439 Indicates a return statement outside of a function/method. |
416 """ | 440 """ |
417 message_id = 'F15' | 441 |
418 message = '\'return\' outside function' | 442 message_id = "F15" |
443 message = "'return' outside function" | |
419 | 444 |
420 | 445 |
421 class YieldOutsideFunction(Message): | 446 class YieldOutsideFunction(Message): |
422 """ | 447 """ |
423 Class defining the "Yield outside function" message. | 448 Class defining the "Yield outside function" message. |
424 | 449 |
425 Indicates a yield or yield from statement outside of a function/method. | 450 Indicates a yield or yield from statement outside of a function/method. |
426 """ | 451 """ |
427 message_id = 'F21' | 452 |
428 message = '\'yield\' outside function' | 453 message_id = "F21" |
454 message = "'yield' outside function" | |
429 | 455 |
430 | 456 |
431 # For whatever reason, Python gives different error messages for these two. We | 457 # For whatever reason, Python gives different error messages for these two. We |
432 # match the Python error message exactly. | 458 # match the Python error message exactly. |
433 class ContinueOutsideLoop(Message): | 459 class ContinueOutsideLoop(Message): |
434 """ | 460 """ |
435 Class defining the "Continue outside loop" message. | 461 Class defining the "Continue outside loop" message. |
436 | 462 |
437 Indicates a continue statement outside of a while or for loop. | 463 Indicates a continue statement outside of a while or for loop. |
438 """ | 464 """ |
439 message_id = 'F22' | 465 |
440 message = '\'continue\' not properly in loop' | 466 message_id = "F22" |
467 message = "'continue' not properly in loop" | |
441 | 468 |
442 | 469 |
443 class BreakOutsideLoop(Message): | 470 class BreakOutsideLoop(Message): |
444 """ | 471 """ |
445 Class defining the "Break outside loop" message. | 472 Class defining the "Break outside loop" message. |
446 | 473 |
447 Indicates a break statement outside of a while or for loop. | 474 Indicates a break statement outside of a while or for loop. |
448 """ | 475 """ |
449 message_id = 'F23' | 476 |
450 message = '\'break\' outside loop' | 477 message_id = "F23" |
478 message = "'break' outside loop" | |
451 | 479 |
452 | 480 |
453 class ContinueInFinally(Message): | 481 class ContinueInFinally(Message): |
454 """ | 482 """ |
455 Class defining the "Continue in finally block" message. | 483 Class defining the "Continue in finally block" message. |
456 | 484 |
457 Indicates a continue statement in a finally block in a while or for loop. | 485 Indicates a continue statement in a finally block in a while or for loop. |
458 """ | 486 """ |
459 message_id = 'F24' | 487 |
460 message = '\'continue\' not supported inside \'finally\' clause' | 488 message_id = "F24" |
489 message = "'continue' not supported inside 'finally' clause" | |
461 | 490 |
462 | 491 |
463 class DefaultExceptNotLast(Message): | 492 class DefaultExceptNotLast(Message): |
464 """ | 493 """ |
465 Class defining the "Default except not being the last" message. | 494 Class defining the "Default except not being the last" message. |
466 | 495 |
467 Indicates an except: block as not the last exception handler. | 496 Indicates an except: block as not the last exception handler. |
468 """ | 497 """ |
469 message_id = 'F25' | 498 |
470 message = 'default \'except:\' must be last' | 499 message_id = "F25" |
500 message = "default 'except:' must be last" | |
471 | 501 |
472 | 502 |
473 class TwoStarredExpressions(Message): | 503 class TwoStarredExpressions(Message): |
474 """ | 504 """ |
475 Class defining the "multiple starred expressions" message. | 505 Class defining the "multiple starred expressions" message. |
476 | 506 |
477 Two or more starred expressions in an assignment (a, *b, *c = d). | 507 Two or more starred expressions in an assignment (a, *b, *c = d). |
478 """ | 508 """ |
479 message_id = 'F26' | 509 |
480 message = 'two starred expressions in assignment' | 510 message_id = "F26" |
511 message = "two starred expressions in assignment" | |
481 | 512 |
482 | 513 |
483 class TooManyExpressionsInStarredAssignment(Message): | 514 class TooManyExpressionsInStarredAssignment(Message): |
484 """ | 515 """ |
485 Class defining the "too many starred expressions" message. | 516 Class defining the "too many starred expressions" message. |
486 | 517 |
487 Too many expressions in an assignment with star-unpacking | 518 Too many expressions in an assignment with star-unpacking |
488 """ | 519 """ |
489 message_id = 'F27' | 520 |
490 message = 'too many expressions in star-unpacking assignment' | 521 message_id = "F27" |
522 message = "too many expressions in star-unpacking assignment" | |
491 | 523 |
492 | 524 |
493 class IfTuple(Message): | 525 class IfTuple(Message): |
494 """ | 526 """ |
495 Class defining the "non-empty tuple literal" message. | 527 Class defining the "non-empty tuple literal" message. |
496 | 528 |
497 Conditional test is a non-empty tuple literal, which are always True. | 529 Conditional test is a non-empty tuple literal, which are always True. |
498 """ | 530 """ |
499 message_id = 'F49' | 531 |
500 message = ( | 532 message_id = "F49" |
501 '\'if tuple literal\' is always true, perhaps remove accidental comma?' | 533 message = "'if tuple literal' is always true, perhaps remove accidental comma?" |
502 ) | |
503 | 534 |
504 | 535 |
505 class AssertTuple(Message): | 536 class AssertTuple(Message): |
506 """ | 537 """ |
507 Class defining the "tuple assertion" message. | 538 Class defining the "tuple assertion" message. |
508 | 539 |
509 Assertion test is a tuple, which are always True. | 540 Assertion test is a tuple, which are always True. |
510 """ | 541 """ |
511 message_id = 'F28' | 542 |
512 message = 'assertion is always true, perhaps remove parentheses?' | 543 message_id = "F28" |
544 message = "assertion is always true, perhaps remove parentheses?" | |
513 | 545 |
514 | 546 |
515 class ForwardAnnotationSyntaxError(Message): | 547 class ForwardAnnotationSyntaxError(Message): |
516 """ | 548 """ |
517 Class defining the "forward annotation syntax error" message. | 549 Class defining the "forward annotation syntax error" message. |
518 | 550 |
519 Found a syntax error in forward annotation. | 551 Found a syntax error in forward annotation. |
520 """ | 552 """ |
521 message_id = 'F29' | 553 |
522 message = 'syntax error in forward annotation %r' | 554 message_id = "F29" |
555 message = "syntax error in forward annotation %r" | |
523 | 556 |
524 def __init__(self, filename, loc, annotation): | 557 def __init__(self, filename, loc, annotation): |
525 """ | 558 """ |
526 Constructor | 559 Constructor |
527 | 560 |
528 @param filename name of the file (string) | 561 @param filename name of the file (string) |
529 @param loc location of the issue | 562 @param loc location of the issue |
530 @param annotation erroneous forward annotation (string) | 563 @param annotation erroneous forward annotation (string) |
531 """ | 564 """ |
532 Message.__init__(self, filename, loc) | 565 Message.__init__(self, filename, loc) |
534 | 567 |
535 | 568 |
536 class CommentAnnotationSyntaxError(Message): | 569 class CommentAnnotationSyntaxError(Message): |
537 """ | 570 """ |
538 Class defining the "Comment Annotation Syntax Error" message. | 571 Class defining the "Comment Annotation Syntax Error" message. |
539 | 572 |
540 Indicates a syntax error in a type comment. | 573 Indicates a syntax error in a type comment. |
541 """ | 574 """ |
542 message_id = 'F31' | 575 |
543 message = 'syntax error in type comment %r' | 576 message_id = "F31" |
577 message = "syntax error in type comment %r" | |
544 | 578 |
545 def __init__(self, filename, loc, annotation): | 579 def __init__(self, filename, loc, annotation): |
546 """ | 580 """ |
547 Constructor | 581 Constructor |
548 | 582 |
549 @param filename name of the file (string) | 583 @param filename name of the file (string) |
550 @param loc location of the issue | 584 @param loc location of the issue |
551 @param annotation erroneous forward annotation (string) | 585 @param annotation erroneous forward annotation (string) |
552 """ | 586 """ |
553 Message.__init__(self, filename, loc) | 587 Message.__init__(self, filename, loc) |
555 | 589 |
556 | 590 |
557 class RaiseNotImplemented(Message): | 591 class RaiseNotImplemented(Message): |
558 """ | 592 """ |
559 Class defining the "raise not implemented" message. | 593 Class defining the "raise not implemented" message. |
560 | 594 |
561 Use NotImplementedError instead of NotImplemented. | 595 Use NotImplementedError instead of NotImplemented. |
562 """ | 596 """ |
563 message_id = 'F30' | 597 |
598 message_id = "F30" | |
564 message = "'raise NotImplemented' should be 'raise NotImplementedError'" | 599 message = "'raise NotImplemented' should be 'raise NotImplementedError'" |
565 | 600 |
566 | 601 |
567 class InvalidPrintSyntax(Message): | 602 class InvalidPrintSyntax(Message): |
568 """ | 603 """ |
569 Class defining the "Invalid Print Syntax" message. | 604 Class defining the "Invalid Print Syntax" message. |
570 | 605 |
571 Indicates the use of >> with a print function. | 606 Indicates the use of >> with a print function. |
572 """ | 607 """ |
573 message_id = 'F32' | 608 |
574 message = 'use of >> is invalid with print function' | 609 message_id = "F32" |
610 message = "use of >> is invalid with print function" | |
575 | 611 |
576 | 612 |
577 class IsLiteral(Message): | 613 class IsLiteral(Message): |
578 """ | 614 """ |
579 Class defining the "Is Literal" message. | 615 Class defining the "Is Literal" message. |
580 | 616 |
581 Indicates the use of "is" or "is not" against str, int and bytes. | 617 Indicates the use of "is" or "is not" against str, int and bytes. |
582 """ | 618 """ |
583 message_id = 'F33' | 619 |
584 message = 'use ==/!= to compare str, bytes, and int literals' | 620 message_id = "F33" |
621 message = "use ==/!= to compare str, bytes, and int literals" | |
585 | 622 |
586 | 623 |
587 class FStringMissingPlaceholders(Message): | 624 class FStringMissingPlaceholders(Message): |
588 """ | 625 """ |
589 Class defining the "Missing Placeholder" message. | 626 Class defining the "Missing Placeholder" message. |
590 | 627 |
591 Indicates that an f-string is missing some placeholders. | 628 Indicates that an f-string is missing some placeholders. |
592 """ | 629 """ |
593 message_id = 'F34' | 630 |
594 message = 'f-string is missing placeholders' | 631 message_id = "F34" |
632 message = "f-string is missing placeholders" | |
595 | 633 |
596 | 634 |
597 class StringDotFormatExtraPositionalArguments(Message): | 635 class StringDotFormatExtraPositionalArguments(Message): |
598 """ | 636 """ |
599 Class defining the "Unused Arguments" message. | 637 Class defining the "Unused Arguments" message. |
600 | 638 |
601 Indicates that an f-string has unused arguments. | 639 Indicates that an f-string has unused arguments. |
602 """ | 640 """ |
603 message_id = 'F35' | 641 |
642 message_id = "F35" | |
604 message = "'...'.format(...) has unused arguments at position(s): %s" | 643 message = "'...'.format(...) has unused arguments at position(s): %s" |
605 | 644 |
606 def __init__(self, filename, loc, extra_positions): | 645 def __init__(self, filename, loc, extra_positions): |
607 """ | 646 """ |
608 Constructor | 647 Constructor |
609 | 648 |
610 @param filename name of the file (string) | 649 @param filename name of the file (string) |
611 @param loc location of the issue | 650 @param loc location of the issue |
612 @param extra_positions indexes of unused arguments | 651 @param extra_positions indexes of unused arguments |
613 """ | 652 """ |
614 Message.__init__(self, filename, loc) | 653 Message.__init__(self, filename, loc) |
616 | 655 |
617 | 656 |
618 class StringDotFormatExtraNamedArguments(Message): | 657 class StringDotFormatExtraNamedArguments(Message): |
619 """ | 658 """ |
620 Class defining the "Unused Named Arguments" message. | 659 Class defining the "Unused Named Arguments" message. |
621 | 660 |
622 Indicates that an f-string has unused named arguments. | 661 Indicates that an f-string has unused named arguments. |
623 """ | 662 """ |
624 message_id = 'F36' | 663 |
664 message_id = "F36" | |
625 message = "'...'.format(...) has unused named argument(s): %s" | 665 message = "'...'.format(...) has unused named argument(s): %s" |
626 | 666 |
627 def __init__(self, filename, loc, extra_keywords): | 667 def __init__(self, filename, loc, extra_keywords): |
628 """ | 668 """ |
629 Constructor | 669 Constructor |
630 | 670 |
631 @param filename name of the file (string) | 671 @param filename name of the file (string) |
632 @param loc location of the issue | 672 @param loc location of the issue |
633 @param extra_keywords index of unused named arguments | 673 @param extra_keywords index of unused named arguments |
634 """ | 674 """ |
635 Message.__init__(self, filename, loc) | 675 Message.__init__(self, filename, loc) |
637 | 677 |
638 | 678 |
639 class StringDotFormatMissingArgument(Message): | 679 class StringDotFormatMissingArgument(Message): |
640 """ | 680 """ |
641 Class defining the "Missing Arguments" message. | 681 Class defining the "Missing Arguments" message. |
642 | 682 |
643 Indicates that an f-string is missing some arguments. | 683 Indicates that an f-string is missing some arguments. |
644 """ | 684 """ |
645 message_id = 'F37' | 685 |
686 message_id = "F37" | |
646 message = "'...'.format(...) is missing argument(s) for placeholder(s): %s" | 687 message = "'...'.format(...) is missing argument(s) for placeholder(s): %s" |
647 | 688 |
648 def __init__(self, filename, loc, missing_arguments): | 689 def __init__(self, filename, loc, missing_arguments): |
649 """ | 690 """ |
650 Constructor | 691 Constructor |
651 | 692 |
652 @param filename name of the file (string) | 693 @param filename name of the file (string) |
653 @param loc location of the issue | 694 @param loc location of the issue |
654 @param missing_arguments missing arguments | 695 @param missing_arguments missing arguments |
655 """ | 696 """ |
656 Message.__init__(self, filename, loc) | 697 Message.__init__(self, filename, loc) |
658 | 699 |
659 | 700 |
660 class StringDotFormatMixingAutomatic(Message): | 701 class StringDotFormatMixingAutomatic(Message): |
661 """ | 702 """ |
662 Class defining the "Mixing Automatic and Manual" message. | 703 Class defining the "Mixing Automatic and Manual" message. |
663 | 704 |
664 Indicates that an f-string mixes automatic and manual numbering. | 705 Indicates that an f-string mixes automatic and manual numbering. |
665 """ | 706 """ |
666 message_id = 'F38' | 707 |
708 message_id = "F38" | |
667 message = "'...'.format(...) mixes automatic and manual numbering" | 709 message = "'...'.format(...) mixes automatic and manual numbering" |
668 | 710 |
669 | 711 |
670 class StringDotFormatInvalidFormat(Message): | 712 class StringDotFormatInvalidFormat(Message): |
671 """ | 713 """ |
672 Class defining the "Invalid Format String" message. | 714 Class defining the "Invalid Format String" message. |
673 | 715 |
674 Indicates that an f-string contains an invalid format string. | 716 Indicates that an f-string contains an invalid format string. |
675 """ | 717 """ |
676 message_id = 'F39' | 718 |
719 message_id = "F39" | |
677 message = "'...'.format(...) has invalid format string: %s" | 720 message = "'...'.format(...) has invalid format string: %s" |
678 | 721 |
679 def __init__(self, filename, loc, error): | 722 def __init__(self, filename, loc, error): |
680 """ | 723 """ |
681 Constructor | 724 Constructor |
682 | 725 |
683 @param filename name of the file (string) | 726 @param filename name of the file (string) |
684 @param loc location of the issue | 727 @param loc location of the issue |
685 @param error error details | 728 @param error error details |
686 """ | 729 """ |
687 Message.__init__(self, filename, loc) | 730 Message.__init__(self, filename, loc) |
691 | 734 |
692 | 735 |
693 class PercentFormatInvalidFormat(Message): | 736 class PercentFormatInvalidFormat(Message): |
694 """ | 737 """ |
695 Class defining the "Invalid Percent Format String" message. | 738 Class defining the "Invalid Percent Format String" message. |
696 | 739 |
697 Indicates that a percent format has an invalid format string. | 740 Indicates that a percent format has an invalid format string. |
698 """ | 741 """ |
699 message_id = 'F40' | 742 |
743 message_id = "F40" | |
700 message = "'...' %% ... has invalid format string: %s" | 744 message = "'...' %% ... has invalid format string: %s" |
701 | 745 |
702 def __init__(self, filename, loc, error): | 746 def __init__(self, filename, loc, error): |
703 """ | 747 """ |
704 Constructor | 748 Constructor |
705 | 749 |
706 @param filename name of the file (string) | 750 @param filename name of the file (string) |
707 @param loc location of the issue | 751 @param loc location of the issue |
708 @param error error details | 752 @param error error details |
709 """ | 753 """ |
710 Message.__init__(self, filename, loc) | 754 Message.__init__(self, filename, loc) |
712 | 756 |
713 | 757 |
714 class PercentFormatMixedPositionalAndNamed(Message): | 758 class PercentFormatMixedPositionalAndNamed(Message): |
715 """ | 759 """ |
716 Class defining the "Mixed Positional and Named" message. | 760 Class defining the "Mixed Positional and Named" message. |
717 | 761 |
718 Indicates that a percent format has mixed positional and named | 762 Indicates that a percent format has mixed positional and named |
719 placeholders. | 763 placeholders. |
720 """ | 764 """ |
721 message_id = 'F41' | 765 |
766 message_id = "F41" | |
722 message = "'...' %% ... has mixed positional and named placeholders" | 767 message = "'...' %% ... has mixed positional and named placeholders" |
723 | 768 |
724 | 769 |
725 class PercentFormatUnsupportedFormatCharacter(Message): | 770 class PercentFormatUnsupportedFormatCharacter(Message): |
726 """ | 771 """ |
727 Class defining the "Unsupported Format Character" message. | 772 Class defining the "Unsupported Format Character" message. |
728 | 773 |
729 Indicates that a percent format has an unsupported format character. | 774 Indicates that a percent format has an unsupported format character. |
730 """ | 775 """ |
731 message_id = 'F42' | 776 |
777 message_id = "F42" | |
732 message = "'...' %% ... has unsupported format character %r" | 778 message = "'...' %% ... has unsupported format character %r" |
733 | 779 |
734 def __init__(self, filename, loc, c): | 780 def __init__(self, filename, loc, c): |
735 """ | 781 """ |
736 Constructor | 782 Constructor |
737 | 783 |
738 @param filename name of the file (string) | 784 @param filename name of the file (string) |
739 @param loc location of the issue | 785 @param loc location of the issue |
740 @param c unsupported format character | 786 @param c unsupported format character |
741 """ | 787 """ |
742 Message.__init__(self, filename, loc) | 788 Message.__init__(self, filename, loc) |
744 | 790 |
745 | 791 |
746 class PercentFormatPositionalCountMismatch(Message): | 792 class PercentFormatPositionalCountMismatch(Message): |
747 """ | 793 """ |
748 Class defining the "Placeholder Substitution Mismatch" message. | 794 Class defining the "Placeholder Substitution Mismatch" message. |
749 | 795 |
750 Indicates that a percent format has a mismatching number of placeholders | 796 Indicates that a percent format has a mismatching number of placeholders |
751 and substitutions. | 797 and substitutions. |
752 """ | 798 """ |
753 message_id = 'F43' | 799 |
800 message_id = "F43" | |
754 message = "'...' %% ... has %d placeholder(s) but %d substitution(s)" | 801 message = "'...' %% ... has %d placeholder(s) but %d substitution(s)" |
755 | 802 |
756 def __init__(self, filename, loc, n_placeholders, n_substitutions): | 803 def __init__(self, filename, loc, n_placeholders, n_substitutions): |
757 """ | 804 """ |
758 Constructor | 805 Constructor |
759 | 806 |
760 @param filename name of the file (string) | 807 @param filename name of the file (string) |
761 @param loc location of the issue | 808 @param loc location of the issue |
762 @param n_placeholders number of placeholders (integer) | 809 @param n_placeholders number of placeholders (integer) |
763 @param n_substitutions number of substitutions (integer) | 810 @param n_substitutions number of substitutions (integer) |
764 """ | 811 """ |
767 | 814 |
768 | 815 |
769 class PercentFormatExtraNamedArguments(Message): | 816 class PercentFormatExtraNamedArguments(Message): |
770 """ | 817 """ |
771 Class defining the "Unused Named Arguments" message. | 818 Class defining the "Unused Named Arguments" message. |
772 | 819 |
773 Indicates that a percent format has unused named arguments. | 820 Indicates that a percent format has unused named arguments. |
774 """ | 821 """ |
775 message_id = 'F44' | 822 |
823 message_id = "F44" | |
776 message = "'...' %% ... has unused named argument(s): %s" | 824 message = "'...' %% ... has unused named argument(s): %s" |
777 | 825 |
778 def __init__(self, filename, loc, extra_keywords): | 826 def __init__(self, filename, loc, extra_keywords): |
779 """ | 827 """ |
780 Constructor | 828 Constructor |
781 | 829 |
782 @param filename name of the file (string) | 830 @param filename name of the file (string) |
783 @param loc location of the issue | 831 @param loc location of the issue |
784 @param extra_keywords index of unused named arguments | 832 @param extra_keywords index of unused named arguments |
785 """ | 833 """ |
786 Message.__init__(self, filename, loc) | 834 Message.__init__(self, filename, loc) |
788 | 836 |
789 | 837 |
790 class PercentFormatMissingArgument(Message): | 838 class PercentFormatMissingArgument(Message): |
791 """ | 839 """ |
792 Class defining the "Missing Arguments" message. | 840 Class defining the "Missing Arguments" message. |
793 | 841 |
794 Indicates that a percent format is missing arguments for some placeholders. | 842 Indicates that a percent format is missing arguments for some placeholders. |
795 """ | 843 """ |
796 message_id = 'F45' | 844 |
845 message_id = "F45" | |
797 message = "'...' %% ... is missing argument(s) for placeholder(s): %s" | 846 message = "'...' %% ... is missing argument(s) for placeholder(s): %s" |
798 | 847 |
799 def __init__(self, filename, loc, missing_arguments): | 848 def __init__(self, filename, loc, missing_arguments): |
800 """ | 849 """ |
801 Constructor | 850 Constructor |
802 | 851 |
803 @param filename name of the file (string) | 852 @param filename name of the file (string) |
804 @param loc location of the issue | 853 @param loc location of the issue |
805 @param missing_arguments missing arguments | 854 @param missing_arguments missing arguments |
806 """ | 855 """ |
807 Message.__init__(self, filename, loc) | 856 Message.__init__(self, filename, loc) |
809 | 858 |
810 | 859 |
811 class PercentFormatExpectedMapping(Message): | 860 class PercentFormatExpectedMapping(Message): |
812 """ | 861 """ |
813 Class defining the "Sequence instead of Mapping" message. | 862 Class defining the "Sequence instead of Mapping" message. |
814 | 863 |
815 Indicates that a percent format expected a mapping but got a sequence. | 864 Indicates that a percent format expected a mapping but got a sequence. |
816 """ | 865 """ |
817 message_id = 'F46' | 866 |
867 message_id = "F46" | |
818 message = "'...' %% ... expected mapping but got sequence" | 868 message = "'...' %% ... expected mapping but got sequence" |
819 | 869 |
820 | 870 |
821 class PercentFormatExpectedSequence(Message): | 871 class PercentFormatExpectedSequence(Message): |
822 """ | 872 """ |
823 Class defining the "Mapping instead of Sequence" message. | 873 Class defining the "Mapping instead of Sequence" message. |
824 | 874 |
825 Indicates that a percent format expected a sequence but got a mapping. | 875 Indicates that a percent format expected a sequence but got a mapping. |
826 """ | 876 """ |
827 message_id = 'F47' | 877 |
878 message_id = "F47" | |
828 message = "'...' %% ... expected sequence but got mapping" | 879 message = "'...' %% ... expected sequence but got mapping" |
829 | 880 |
830 | 881 |
831 class PercentFormatStarRequiresSequence(Message): | 882 class PercentFormatStarRequiresSequence(Message): |
832 """ | 883 """ |
833 Class defining the "'*' Requires Sequence" message. | 884 Class defining the "'*' Requires Sequence" message. |
834 | 885 |
835 Indicates that a percent format expected a sequence. | 886 Indicates that a percent format expected a sequence. |
836 """ | 887 """ |
837 message_id = 'F48' | 888 |
889 message_id = "F48" | |
838 message = "'...' %% ... `*` specifier requires sequence" | 890 message = "'...' %% ... `*` specifier requires sequence" |