vim/ftplugin/python/pyflakes/pyflakes/messages.py @ d06b84e6f55f

sub: vim/html5
author Steve Losh <steve@stevelosh.com>
date Tue, 16 Nov 2010 17:02:06 -0500
parents d6e9fd358013
children (none)
# (c) 2005 Divmod, Inc.  See LICENSE file for details

class Message(object):
    message = ''
    message_args = ()
    def __init__(self, filename, lineno, col = None):
        self.filename = filename
        self.lineno = lineno
        self.col = col
    def __str__(self):
        if self.col is not None:
            return '%s:%s(%d): %s' % (self.filename, self.lineno, self.col, self.message % self.message_args)
        else:
            return '%s:%s: %s' % (self.filename, self.lineno, self.message % self.message_args)


class UnusedImport(Message):
    message = '%r imported but unused'
    def __init__(self, filename, lineno, name):
        Message.__init__(self, filename, lineno)
        self.message_args = (name,)


class RedefinedWhileUnused(Message):
    message = 'redefinition of unused %r from line %r'
    def __init__(self, filename, lineno, col, name, orig_lineno):
        Message.__init__(self, filename, lineno)
        self.message_args = (name, orig_lineno)


class ImportShadowedByLoopVar(Message):
    message = 'import %r from line %r shadowed by loop variable'
    def __init__(self, filename, lineno, col, name, orig_lineno):
        Message.__init__(self, filename, lineno, col)
        self.message_args = (name, orig_lineno)


class ImportStarUsed(Message):
    message = "'from %s import *' used; unable to detect undefined names"
    def __init__(self, filename, lineno, col, modname):
        Message.__init__(self, filename, lineno, col)
        self.message_args = (modname,)


class UndefinedName(Message):
    message = 'undefined name %r'
    def __init__(self, filename, lineno, col, name):
        Message.__init__(self, filename, lineno, col)
        self.message_args = (name,)


class UndefinedLocal(Message):
    message = "local variable %r (defined in enclosing scope on line %r) referenced before assignment"
    def __init__(self, filename, lineno, col, name, orig_lineno, orig_col):
        Message.__init__(self, filename, lineno)
        self.message_args = (name, orig_lineno)


class DuplicateArgument(Message):
    message = 'duplicate argument %r in function definition'
    def __init__(self, filename, lineno, col, name):
        Message.__init__(self, filename, lineno, col)
        self.message_args = (name,)


class RedefinedFunction(Message):
    message = 'redefinition of function %r from line %r'
    def __init__(self, filename, lineno, name, orig_lineno):
        Message.__init__(self, filename, lineno)
        self.message_args = (name, orig_lineno)


class LateFutureImport(Message):
    message = 'future import(s) %r after other statements'
    def __init__(self, filename, lineno, col, names):
        Message.__init__(self, filename, lineno)
        self.message_args = (names,)