本文整理汇总了Python中pylint.lint.PyLinter类的典型用法代码示例。如果您正苦于以下问题:Python PyLinter类的具体用法?Python PyLinter怎么用?Python PyLinter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PyLinter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
linter = PyLinter()
# linter.msgs = get_msg_ids(error_level)
ns = parse_arguments()
for mod in ns.module:
print("module = %s" % mod)
print(linter.check(mod))
示例2: linter
def linter():
linter = PyLinter()
linter.disable('I')
linter.config.persistent = 0
# register checkers
checkers.initialize(linter)
linter.set_reporter(testutils.TestReporter())
return linter
示例3: linter
def linter():
linter = PyLinter(reporter=TextReporter())
linter.disable('I')
linter.config.persistent = 0
# register checkers
checkers.initialize(linter)
os.environ.pop('PYLINTRC', None)
return linter
示例4: test_html_reporter_msg_template
def test_html_reporter_msg_template(self):
expected = '''
<html>
<body>
<div>
<div>
<h2>Messages</h2>
<table>
<tr class="header">
<th>category</th>
<th>msg_id</th>
</tr>
<tr class="even">
<td>warning</td>
<td>W0332</td>
</tr>
</table>
</div>
</div>
</body>
</html>'''.strip().splitlines()
output = six.StringIO()
linter = PyLinter(reporter=HTMLReporter())
checkers.initialize(linter)
linter.config.persistent = 0
linter.reporter.set_output(output)
linter.set_option('msg-template', '{category}{msg_id}')
linter.open()
linter.set_current_module('0123')
linter.add_message('lowercase-l-suffix', line=1)
linter.reporter.display_results(Section())
self.assertEqual(output.getvalue().splitlines(), expected)
示例5: run_linter
def run_linter(self):
from pylint.lint import PyLinter
from pylint import checkers
from os.path import join
linter = PyLinter(pylintrc=self.lint_config)
# same, but not all pylint versions have load_default_plugins
#linter.load_default_plugins()
checkers.initialize(linter)
linter.read_config_file()
linter.load_config_file()
if self.packages:
self.announce("checking packages", 2)
report_fn = "packages_report." + linter.reporter.extension
report_fn = join(self.build_base, report_fn)
with open(report_fn, "wt") as out:
linter.reporter.set_output(out)
linter.check(self.packages)
self.announce_overview(linter, report_fn)
if self.build_scripts:
self.announce("checking scripts", 2)
report_fn = "scripts_report." + linter.reporter.extension
report_fn = join(self.build_base, report_fn)
with open(report_fn, "wt") as out:
linter.reporter.set_output(out)
linter.check(self.build_scripts)
self.announce_overview(linter, report_fn)
示例6: __init__
def __init__(self, found_files, *args, **kwargs):
self._files = found_files
# set up the standard PyLint linter
PyLinter.__init__(self, *args, **kwargs)
# do some additional things!
# for example, we want to re-initialise the OptionsManagerMixin
# to supress the config error warning
# pylint: disable=W0233
OptionsManagerMixIn.__init__(self, usage=PyLinter.__doc__, quiet=True)
示例7: builder_inited
def builder_inited(app):
# PACKAGE/docs/exts/pylint_extensions.py --> PACKAGE/
base_path = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
linter = PyLinter()
linter.load_default_plugins()
features = os.path.join(base_path, 'doc', 'technical_reference', 'features.rst')
with open(features, 'w') as stream:
stream.write("Pylint features\n")
stream.write("===============\n\n")
stream.write(".. generated by pylint --full-documentation\n\n")
linter.print_full_documentation(stream)
示例8: setUp
def setUp(self):
self.linter = PyLinter(reporter=TextReporter())
self.linter.disable('I')
self.linter.config.persistent = 0
# register checkers
checkers.initialize(self.linter)
os.environ.pop('PYLINTRC', None)
示例9: expand_files
def expand_files(self, modules):
expanded = PyLinter.expand_files(self, modules)
filtered = []
for module in expanded:
if self._files.check_module(module['path']):
filtered.append(module)
return filtered
示例10: __init__
def __init__(self):
"""
Initialize C{PyLinter} object, and load configuration file.
"""
self.allowOptions = True
self.linter = PyLinter(self._makeOptions())
# register standard checkers.
self.linter.load_default_plugins()
# read configuration.
pathConfig = os.path.join(twistedchecker.abspath,
"configuration", "pylintrc")
self.linter.read_config_file(pathConfig)
# now we can load file config and command line, plugins (which can
# provide options) have been registered.
self.linter.load_config_file()
allowedMessages = self.registerCheckers()
# disable messages
disabledMessages = set(self.linter
.cfgfile_parser.get("TWISTEDCHECKER", "disable")
.replace(" ", "").split(","))
if disabledMessages != {""}:
for msg in disabledMessages:
self.linter.disable(msg)
allowedMessages -= disabledMessages
# set default output stream to stdout
self.setOutput(sys.stdout)
# set default reporter to limited reporter
self.setReporter(LimitedReporter(allowedMessages))
示例11: setUp
def setUp(self):
self.linter = PyLinter()
self.linter.disable('I')
self.linter.config.persistent = 0
# register checkers
checkers.initialize(self.linter)
self.linter.set_reporter(TestReporter())
示例12: expand_files
def expand_files(self, modules):
expanded = PyLinter.expand_files(self, modules)
filtered = []
for module in expanded:
if any([m.search(module['path']) for m in self._ignore]):
continue
filtered.append(module)
return filtered
示例13: linter
def linter():
linter = PyLinter()
linter.set_reporter(MinimalTestReporter())
checkers.initialize(linter)
linter.register_checker(BadBuiltinChecker(linter))
linter.disable('I')
return linter
示例14: test_simple_json_output
def test_simple_json_output():
output = StringIO()
reporter = JSONReporter()
linter = PyLinter(reporter=reporter)
checkers.initialize(linter)
linter.config.persistent = 0
linter.reporter.set_output(output)
linter.open()
linter.set_current_module("0123")
linter.add_message("line-too-long", line=1, args=(1, 2))
# we call this method because we didn't actually run the checkers
reporter.display_messages(None)
expected_result = [
[
("column", 0),
("line", 1),
("message", "Line too long (1/2)"),
("message-id", "C0301"),
("module", "0123"),
("obj", ""),
("path", "0123"),
("symbol", "line-too-long"),
("type", "convention"),
]
]
report_result = json.loads(output.getvalue())
report_result = [sorted(report_result[0].items(), key=lambda item: item[0])]
assert report_result == expected_result
示例15: test_parseable_output_regression
def test_parseable_output_regression(self):
output = six.StringIO()
linter = PyLinter(reporter=ParseableTextReporter())
checkers.initialize(linter)
linter.config.persistent = 0
linter.reporter.set_output(output)
linter.set_option('output-format', 'parseable')
linter.open()
linter.set_current_module('0123')
linter.add_message('line-too-long', line=1, args=(1, 2))
self.assertMultiLineEqual(output.getvalue(),
'************* Module 0123\n'
'0123:1: [C0301(line-too-long), ] '
'Line too long (1/2)\n')