• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python lint.PyLinter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pylint.lint.PyLinter的典型用法代码示例。如果您正苦于以下问题:Python PyLinter类的具体用法?Python PyLinter怎么用?Python PyLinter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了PyLinter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
开发者ID:AndreaCrotti,项目名称:scripts,代码行数:7,代码来源:mylint.py


示例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
开发者ID:Vauxoo,项目名称:pylint,代码行数:8,代码来源:unittest_lint.py


示例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
开发者ID:Vauxoo,项目名称:pylint,代码行数:8,代码来源:unittest_reporting.py


示例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)
开发者ID:Wooble,项目名称:pylint,代码行数:32,代码来源:unittest_reporting.py


示例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)
开发者ID:baransn,项目名称:python-javatools,代码行数:33,代码来源:setup.py


示例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)
开发者ID:kamilchm,项目名称:prospector,代码行数:12,代码来源:linter.py


示例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)
开发者ID:AWhetter,项目名称:pylint,代码行数:13,代码来源:pylint_features.py


示例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)
开发者ID:Wooble,项目名称:pylint,代码行数:7,代码来源:unittest_reporting.py


示例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
开发者ID:kamilchm,项目名称:prospector,代码行数:7,代码来源:linter.py


示例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))
开发者ID:twisted,项目名称:twistedchecker,代码行数:28,代码来源:runner.py


示例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())
开发者ID:The-Compiler,项目名称:pylint,代码行数:7,代码来源:unittest_lint.py


示例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
开发者ID:marciusvinicius,项目名称:prospector,代码行数:8,代码来源:linter.py


示例13: linter

def linter():
    linter = PyLinter()
    linter.set_reporter(MinimalTestReporter())
    checkers.initialize(linter)
    linter.register_checker(BadBuiltinChecker(linter))
    linter.disable('I')
    return linter
开发者ID:Vauxoo,项目名称:pylint,代码行数:7,代码来源:test_bad_builtin.py


示例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
开发者ID:aluoch-sheila,项目名称:NEIGHBOURHOOD,代码行数:32,代码来源:unittest_reporters_json.py


示例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')
开发者ID:XHydro,项目名称:PSI-Project-2-Django,代码行数:14,代码来源:unittest_reporting.py


示例16: process_file

def process_file(filename):
    """
    Analyze the file with pylint and write the result
    to a database
    """
    linter = PyLinter()

    checkers.initialize(linter)
    linter.read_config_file()
    linter.quiet = 1

    filemods = linter.expand_files((filename, ))
    if filemods:
        old_stats = config.load_results(filemods[0].get('basename'))
        old_score = old_stats.get('global_note', 0.0)

    linter.check(filename)
    score = eval(linter.config.evaluation, {}, linter.stats)

    # Calculate the credit for both scores
    if score < 0:
        credit = 2.0 * score
    elif score < old_score:
        credit = -1.5 * (old_score - score)
    elif score < MINIMUM_SCORE:
        credit = -1.5 * (MINIMUM_SCORE - score)
    else:
        credit = score - old_score

    return score, old_score, credit
开发者ID:codecollision,项目名称:DropboxToFlickr,代码行数:30,代码来源:huLint.py


示例17: linter

def linter():
    linter = PyLinter()
    linter.set_reporter(MinimalTestReporter())
    checkers.initialize(linter)
    linter.register_checker(OverlappingExceptionsChecker(linter))
    linter.disable('I')
    return linter
开发者ID:Vauxoo,项目名称:pylint,代码行数:7,代码来源:test_overlapping_exceptions.py


示例18: expand_files

 def expand_files(self, modules):
     expanded = PyLinter.expand_files(self, modules)
     filtered = []
     for module in expanded:
         rel_path = os.path.relpath(module['path'], self._rootpath)
         if any([m.search(rel_path) for m in self._ignore]):
             continue
         filtered.append(module)
     return filtered
开发者ID:TomasTomecek,项目名称:prospector,代码行数:9,代码来源:linter.py


示例19: linter

def linter():
    linter = PyLinter()
    linter.set_reporter(MinimalTestReporter())
    checkers.initialize(linter)
    register(linter)
    linter.disable('all')
    linter.enable('too-complex')
    return linter
开发者ID:Vauxoo,项目名称:pylint,代码行数:8,代码来源:test_check_mccabe.py


示例20: linter

def linter(checker, register, enable, disable, reporter):
    _linter = PyLinter()
    _linter.set_reporter(reporter())
    checkers.initialize(_linter)
    if register:
        register(_linter)
    if checker:
        _linter.register_checker(checker(_linter))
    if disable:
        for msg in disable:
            _linter.disable(msg)
    if enable:
        for msg in enable:
            _linter.enable(msg)
    os.environ.pop("PYLINTRC", None)
    return _linter
开发者ID:aluoch-sheila,项目名称:NEIGHBOURHOOD,代码行数:16,代码来源:conftest.py



注:本文中的pylint.lint.PyLinter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python reporters.BaseReporter类代码示例发布时间:2022-05-25
下一篇:
Python lint.preprocess_options函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap