How to use the pylint.lint 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 autotest / autotest-client-tests / 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 BradenM / micropy-cli / tests / test_template.py View on Github external
def test_pylint_load():
        try:
            lint_args = ["--rcfile", str(expected_path.absolute())]
            pylint.lint.Run(lint_args)
        except SyntaxError:
            pytest.fail(str(SyntaxError))  # noqa
        except:  # noqa
            pass
    stubs, paths, ctx_paths = stub_context
github NativeScript / nativescript-cli-tests / nosexunit / audit / __init__.py View on Github external
def create_reporter(output):
    '''Create a reporter for the provided output'''
    # Check if default reporter selected
    if output == nconst.AUDIT_DEFAULT_REPORTER: return AuditReporter()
    # Get PyLint reporter
    else: return pylint.lint.REPORTER_OPT_MAP[output]()     
github ExtensiveAutomation / extensiveautomation-server / svr-core / Scripts / pychecker.py View on Github external
fName, fMsg = val
        if fName == os.path.basename(filename):
            if not len(fMsg):
                exceptDetected = True
                break
            ARGS_RUN.append(fMsg)

    if exceptDetected:
        nbExceptions += 1
        continue

    print(ARGS_RUN)

    # execute pylint to analyze the code
    pylint_output = WritableObject()
    lint.Run([filename]+ARGS_RUN, reporter=TextReporter(pylint_output), exit=False)

    if GenerateRepport:
        # extract the note
        note = 0
        for line in pylint_output.read():
            if line.startswith("Your code has been rated at"):
                note = line.split("Your code has been rated at ")[1].split('/10')[0]
                notes.append( float(note) )
                break
    else:
        nbTotError = 0
        nbTotFatal = 0
        nbTotWarning = 0
        nbTotRefactor = 0
        nbTotConvention = 0
        nbTot = 0
github openstack / ceilometer / tools / lintstack.py View on Github external
def run_pylint():
    buff = StringIO()
    args = ["--msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}",
            "-E",
            "ceilometer"]
    lint.Run(args, exit=False)
    val = buff.getvalue()
    buff.close()
    return val
github openstack / sahara / tools / lintstack.py View on Github external
def run_pylint():
    buff = StringIO()
    reporter = text.ParseableTextReporter(output=buff)
    args = ["--include-ids=y", "-E", "sahara"]
    lint.Run(args, reporter=reporter, exit=False)
    val = buff.getvalue()
    buff.close()
    return val
github geerk / django_linter / django_linter / main.py View on Github external
def main():
    arg_parser = ArgumentParser(
        description='Simple extension for pylint to check django projects for '
                    'common mistakes.')
    arg_parser.add_argument('targets', metavar='TARGET', nargs='+',
                            help='python package or module')

    args = arg_parser.parse_args()

    linter = lint.PyLinter()
    reporters.initialize(linter)
    linter._load_reporter()
    register(linter)

    with lint.fix_import_path(args.targets):
        linter.check(args.targets)

    return linter.msg_status
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 leo-editor / leo-editor / leo / commands / checkerCommands.py View on Github external
def import_lint(self):
        """Make sure lint can be imported."""
        try:
            from pylint import lint
            g.placate_pyflakes(lint)
            return True
        except ImportError:
            g.es_print('pylint is not installed')
            return False
    #@+node:ekr.20150514125218.10: *3* 3. pylint.get_rc_file