Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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]()
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
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
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
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
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
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