How to use the pylint.lint.Run 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 PyCQA / pylint / test / unittest_lint.py View on Github external
def test_init_hooks_called_before_load_plugins(self):
        self.assertRaises(RuntimeError,
                          Run, ['--load-plugins', 'unexistant', '--init-hook', 'raise RuntimeError'])
        self.assertRaises(RuntimeError,
                          Run, ['--init-hook', 'raise RuntimeError', '--load-plugins', 'unexistant'])
github leo-editor / leo-editor / pylint-leo.py View on Github external
def report_version():
    try:
        from pylint import lint
    except ImportError:
        g.trace('can not import pylint')
    table = (
        os.path.abspath(os.path.expanduser('~/.leo/pylint-leo-rc.txt')),
        os.path.abspath(os.path.join('leo', 'test', 'pylint-leo-rc.txt')),
    )
    for rc_fn in table:
        try:
            rc_fn = rc_fn.replace('\\', '/')
            lint.Run(["--rcfile=%s" % (rc_fn), '--version',])
        except OSError:
            pass
    g.trace('no rc file found in')
    g.printList(table)
github SNSystems / dexter / dex / utils / Linting.py View on Github external
from pylint.lint import Run
    except ImportError as e:
        _warn(context, 'could not run pylint ({})\n'.format(e))
        return True

    exit_code = 1

    with PreserveAutoColors(context.o):
        context.o.auto_reds.extend(['^[EF]:', r'^\*+'])
        context.o.auto_yellows.extend(['^Your code', '^[CRW]:'])

        with _PreserveStreams():
            try:
                sys.stdout = StringIO()
                sys.stderr = StringIO()
                Run(args=[context.root_directory])
            except SystemExit as e:
                exit_code = e.code
            finally:
                if exit_code:
                    context.o.green('\npylint output:\n')
                    context.o.auto(sys.stdout.getvalue())
                    context.o.auto(sys.stderr.getvalue())

    return exit_code is 0
github openstack / os-brick / tools / lintstack.py View on Github external
def run_pylint():
    buff = StringIO()
    reporter = text.ParseableTextReporter(output=buff)
    args = ["--include-ids=y", "-E", "os_brick"]
    lint.Run(args, reporter=reporter, exit=False)
    val = buff.getvalue()
    buff.close()
    return val
github linux-system-roles / network / .travis / custom_pylint.py View on Github external
args, include_pattern, exclude_pattern = probe_args()
    if "-h" in args or "--help" in args:
        print_line(__doc__)
        return 0
    if os.getenv("RUN_PYLINT_DISABLED", "") != "":
        return 0
    files = probe_dir(
        os.getcwd(), re.compile(include_pattern), re.compile(exclude_pattern)
    )
    if not files:
        return 0
    show_files(files)
    args.extend(files)
    sys.argv[0] = "pylint"
    return Run(args, None, False).linter.msg_status
github ethz-asl / linter / linter.py View on Github external
# for errors in the code.
    pylint_errors = []
    for changed_file in staged_files:
        if not os.path.isfile(changed_file):
            continue
        if re.search(r'\.py$', changed_file):

            print("Running pylint on \'{}\'".format(repo_root + "/" +
                                                    changed_file))
            pylint_output = TextReporterBuffer()
            pylint_args = [
                "--rcfile=" + pylint_file, "-rn",
                repo_root + "/" + changed_file
            ]
            from pylint.reporters.text import TextReporter
            pylint.lint.Run(pylint_args,
                            reporter=TextReporter(pylint_output),
                            exit=False)

            for output_line in pylint_output.read():
                if re.search(r'^(E|C|W):', output_line):
                    print(changed_file + ": " + output_line)
                    pylint_errors.append(output_line)

    if pylint_errors:
        print("=" * 80)
        print("Found {} pylint errors".format(len(pylint_errors)))
        print("=" * 80)
        return False
    else:
        return True
github fossasia / knittingpattern / setup.py View on Github external
def run_tests(self):
        from pylint.lint import Run
        Run(self.TEST_ARGS)
github avocado-framework / avocado-vt / tools / run_pylint.py View on Github external
def check_file(file_path):
    if not file_path.endswith('.py'):
        return 0
    for blacklist_pattern in blacklist:
        if fnmatch.fnmatch(os.path.abspath(file_path),
                           '*' + blacklist_pattern):
            return 0
    pylint_opts = get_pylint_opts()
    if pylint_version >= 0.21:
        runner = pylint.lint.Run(pylint_opts + [file_path], exit=False)
    else:
        runner = pylint.lint.Run(pylint_opts + [file_path])

    return runner.linter.msg_status
github a2i2 / surround / surround / linter.py View on Github external
if extra_args:
            args.extend(extra_args)

        disable_msgs = [
            'missing-class-docstring',
            'missing-function-docstring',
            'abstract-method',
            'attribute-defined-outside-init'
        ]

        args.append("--load-plugins=surround.checkers.surround_checker")

        for msg in disable_msgs:
            args.append('--disable=%s' % msg)

        result = Run(args, do_exit=False)
        return result.linter.msg_status == 0