How to use the pylint.checkers.initialize function in pylint

To help you get started, we’ve selected a few pylint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Shopify / shopify_python / tests / test_functional.py View on Github external
def __init__(self, test_file):
        test_reporter = FunctionalTestReporter()
        self._linter = lint.PyLinter()

        google_styleguide.register_checkers(self._linter)
        shopify_styleguide.register_checkers(self._linter)

        self._linter.set_reporter(test_reporter)
        self._linter.config.persistent = 0
        checkers.initialize(self._linter)
        self._linter.disable('I')
        try:
            self._linter.read_config_file(test_file.option_file)
            self._linter.load_config_file()
        except NoFileError:
            pass
        self._test_file = test_file
github nelfin / pylint-protobuf / tests / test_integration.py View on Github external
def linter(register, enable, disable):
        _linter = PyLinter()
        _linter.set_reporter(MinimalTestReporter())
        checkers.initialize(_linter)
        if register:
            register(_linter)
        if disable:
            for msg in disable:
                _linter.disable(msg)
        if enable:
            for msg in enable:
                _linter.enable(msg)
        return _linter
    return linter
github PyCQA / pylint / pylint / testutils.py View on Github external
def __init__(self, test_file):
        _test_reporter = FunctionalTestReporter()
        self._linter = PyLinter()
        self._linter.set_reporter(_test_reporter)
        self._linter.config.persistent = 0
        checkers.initialize(self._linter)
        self._linter.disable("I")
        try:
            self._linter.read_config_file(test_file.option_file)
            self._linter.load_config_file()
        except NoFileError:
            pass
        self._test_file = test_file
github PyCQA / pylint / testutils.py View on Github external
'\n'.join(repr(m) for m in got)))
        self.assertEqual(list(messages), got, msg)

    def walk(self, node):
        """recursive walk on the given node"""
        walker = PyLintASTWalker(linter)
        walker.add_checker(self.checker)
        walker.walk(node)


# Init
test_reporter = TestReporter()
linter = PyLinter()
linter.set_reporter(test_reporter)
linter.config.persistent = 0
checkers.initialize(linter)
linter.global_set_option('required-attributes', ('__revision__',))

if linesep != '\n':
    LINE_RGX = re.compile(linesep)
    def ulines(string):
        return LINE_RGX.sub('\n', string)
else:
    def ulines(string):
        return string

INFO_TEST_RGX = re.compile(r'^func_i\d\d\d\d$')

def exception_str(self, ex):
    """function used to replace default __str__ method of exception instances"""
    return 'in %s\n:: %s' % (ex.file, ', '.join(ex.args))
github douglas / sublimetext2_configs / sublimelint / modules / sublime_pylint.py View on Github external
def run_pylint(code):
    '''runs pylint on the code using a temporary file for storage'''
    linter = lint.PyLinter()
    checkers.initialize(linter)
    # Disable some errors.
    linter.load_command_line_configuration([
        '--module-rgx=.*',  # don't check the module name
        '--reports=n',      # remove tables
        '--persistent=n',   # don't save the old score (no sense for temp)
    ])

    temp = tempfile.NamedTemporaryFile(suffix='.py')
    temp.write(code)
    temp.flush()

    output_buffer = StringIO()
    linter.reporter.set_output(output_buffer)
    linter.check(temp.name)
    _report = output_buffer.getvalue().replace(temp.name, 'line ')
github lad1337 / XDM / rootLibs / pylint / lint.py View on Github external
def load_default_plugins(self):
        from pylint import checkers
        checkers.initialize(self)
github pylava / pylava_pylint / pylama_pylint / pylint / lint.py View on Github external
def load_default_plugins(self):
        checkers_initialize(self)
        reporters_initialize(self)
        # Make sure to load the default reporter, because
        # the option has been set before the plugins had been loaded.
        if not self.reporter:
            self._load_reporter()
github PyCQA / pylint / pylint / lint.py View on Github external
def load_default_plugins(self):
        checkers.initialize(self)
        reporters.initialize(self)
        # Make sure to load the default reporter, because
        # the option has been set before the plugins had been loaded.
        if not self.reporter:
            self._load_reporter()
github bendangelo / dotfiles / sublime / packages / SublimeLinter / sublimelinter / modules / sublime_pylint.py View on Github external
def built_in_check(self, view, code, filename):
        linter = lint.PyLinter()
        checkers.initialize(linter)

        # Disable some errors.
        linter.load_command_line_configuration([
            '--module-rgx=.*',  # don't check the module name
            '--reports=n',      # remove tables
            '--persistent=n',   # don't save the old score (no sense for temp)
        ])

        temp = tempfile.NamedTemporaryFile(suffix='.py')
        temp.write(code)
        temp.flush()

        output_buffer = StringIO()
        linter.reporter.set_output(output_buffer)
        linter.check(temp.name)
        report = output_buffer.getvalue().replace(temp.name, 'line ')
github lamby / django-lint / DjangoLint / script.py View on Github external
"Django application" % target
                )

    try:
        import django
    except ImportError:
        print >>sys.stderr, "E: Cannot import `django' module, exiting.."
        return 1

    linter = lint.PyLinter()
    linter.set_reporter(text_reporter.TextReporter())
    linter.set_option('reports', options.report)
    linter.set_option('output-format', options.outputformat)

    if options.pylint:
        checkers.initialize(linter)
        for msg in ('C0111', 'C0301'):
            linter.disable(msg)

    AstCheckers.register(linter)

    if options.errors:
        linter.set_option('disable-msg-cat', 'WCRI')
        linter.set_option('reports', False)
        linter.set_option('persistent', False)

    linter.check(targets)

    return linter.msg_status