250 class UndefinedLocal(Message): |
250 class UndefinedLocal(Message): |
251 """ |
251 """ |
252 Class defining the "Undefined Local Variable" message. |
252 Class defining the "Undefined Local Variable" message. |
253 """ |
253 """ |
254 message_id = 'F07' |
254 message_id = 'F07' |
255 message = ('local variable %r (defined in enclosing scope on line %r) ' |
255 message = 'local variable %r {0} referenced before assignment' |
256 'referenced before assignment') |
256 |
|
257 default = 'defined in enclosing scope on line %r' |
|
258 builtin = 'defined as a builtin' |
257 |
259 |
258 def __init__(self, filename, loc, name, orig_loc): |
260 def __init__(self, filename, loc, name, orig_loc): |
259 """ |
261 """ |
260 Constructor |
262 Constructor |
261 |
263 |
263 @param loc location of the issue |
265 @param loc location of the issue |
264 @param name name of the prematurely referenced variable (string) |
266 @param name name of the prematurely referenced variable (string) |
265 @param orig_loc location of the variable definition |
267 @param orig_loc location of the variable definition |
266 """ |
268 """ |
267 Message.__init__(self, filename, loc) |
269 Message.__init__(self, filename, loc) |
268 self.message_args = (name, orig_loc.lineno) |
270 if orig_loc is None: |
|
271 self.message = self.message.format(self.builtin) |
|
272 self.message_args = (name,) |
|
273 self.message_id = 'F07B' |
|
274 else: |
|
275 self.message = self.message.format(self.default) |
|
276 self.message_args = (name, orig_loc.lineno) |
|
277 self.message_id = 'F07A' |
269 |
278 |
270 |
279 |
271 class DuplicateArgument(Message): |
280 class DuplicateArgument(Message): |
272 """ |
281 """ |
273 Class defining the "Duplicate Argument" message. |
282 Class defining the "Duplicate Argument" message. |
506 """ |
515 """ |
507 Message.__init__(self, filename, loc) |
516 Message.__init__(self, filename, loc) |
508 self.message_args = (annotation,) |
517 self.message_args = (annotation,) |
509 |
518 |
510 |
519 |
|
520 class CommentAnnotationSyntaxError(Message): |
|
521 """ |
|
522 Class defining the "Comment Annotation Syntax Error" message. |
|
523 |
|
524 Indicates a syntax error in a type comment. |
|
525 """ |
|
526 message_id = 'F31' |
|
527 message = 'syntax error in type comment %r' |
|
528 |
|
529 def __init__(self, filename, loc, annotation): |
|
530 Message.__init__(self, filename, loc) |
|
531 self.message_args = (annotation,) |
|
532 |
|
533 |
511 class RaiseNotImplemented(Message): |
534 class RaiseNotImplemented(Message): |
512 """ |
535 """ |
513 Class defining the "raise not implemented" message. |
536 Class defining the "raise not implemented" message. |
514 |
537 |
515 Use NotImplementedError instead of NotImplemented. |
538 Use NotImplementedError instead of NotImplemented. |
516 """ |
539 """ |
517 message_id = 'F30' |
540 message_id = 'F30' |
518 message = "'raise NotImplemented' should be 'raise NotImplementedError'" |
541 message = "'raise NotImplemented' should be 'raise NotImplementedError'" |
519 |
542 |
|
543 |
|
544 class InvalidPrintSyntax(Message): |
|
545 """ |
|
546 Class defining the "Invalid Print Syntax" message. |
|
547 |
|
548 Indicates the use of >> with a print function. |
|
549 """ |
|
550 message_id = 'F32' |
|
551 message = 'use of >> is invalid with print function' |
|
552 |
|
553 |
|
554 class IsLiteral(Message): |
|
555 """ |
|
556 Class defining the "Is Literal" message. |
|
557 |
|
558 Indicates the use of "is" or "is not" against str, int and bytes. |
|
559 """ |
|
560 message_id = 'F33' |
|
561 message = 'use ==/!= to compare str, bytes, and int literals' |
|
562 |
520 # |
563 # |
521 # eflag: noqa = M702 |
564 # eflag: noqa = M702 |