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

Python lint.fix_import_path函数代码示例

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

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



在下文中一共展示了fix_import_path函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_two_similar_args

def test_two_similar_args(fake_path, case):
    with tempdir() as chroot:
        create_files(['a/b/__init__.py', 'a/c/__init__.py'])
        expected = [join(chroot, 'a')] + ["."] + fake_path

        assert sys.path == fake_path
        with lint.fix_import_path(case):
            assert sys.path == expected
        assert sys.path == fake_path
开发者ID:Mariatta,项目名称:pylint,代码行数:9,代码来源:unittest_lint.py


示例2: test_one_arg

def test_one_arg(fake_path, case):
    with tempdir() as chroot:
        create_files(["a/b/__init__.py"])
        expected = [join(chroot, "a")] + ["."] + fake_path

        assert sys.path == fake_path
        with lint.fix_import_path(case):
            assert sys.path == expected
        assert sys.path == fake_path
开发者ID:bluesheeptoken,项目名称:pylint,代码行数:9,代码来源:unittest_lint.py


示例3: test_types_redefined

def test_types_redefined(linter):
    elif_test = osp.join(osp.dirname(osp.abspath(__file__)), 'data',
                         'bad_builtin.py')
    with fix_import_path([elif_test]):
        linter.check([elif_test])
    msgs = sorted(linter.reporter.messages, key=lambda item: item.line)
    assert len(msgs) == 2
    for msg, expected in zip(msgs, EXPECTED):
        assert msg.symbol == 'bad-builtin'
        assert msg.msg == expected
开发者ID:Mariatta,项目名称:pylint,代码行数:10,代码来源:test_bad_builtin.py


示例4: test_types_redefined

 def test_types_redefined(self):
     elif_test = osp.join(osp.dirname(osp.abspath(__file__)), 'data',
                          'bad_builtin.py')
     with fix_import_path([elif_test]):
         self._linter.check([elif_test])
     msgs = sorted(self._linter.reporter.messages, key=lambda item: item.line)
     self.assertEqual(len(msgs), 2)
     for msg, expected in zip(msgs, self.expected):
         self.assertEqual(msg.symbol, 'bad-builtin')
         self.assertEqual(msg.msg, expected)
开发者ID:glennmatthews,项目名称:pylint,代码行数:10,代码来源:test_bad_builtin.py


示例5: test_more_args

def test_more_args(fake_path, case):
    with tempdir() as chroot:
        create_files(['a/b/c/__init__.py', 'a/d/__init__.py', 'a/e/f.py'])
        expected = [
            join(chroot, suffix)
            for suffix in [sep.join(('a', 'b')), 'a', sep.join(('a', 'e'))]
        ] + ["."] + fake_path

        assert sys.path == fake_path
        with lint.fix_import_path(case):
            assert sys.path == expected
        assert sys.path == fake_path
开发者ID:Mariatta,项目名称:pylint,代码行数:12,代码来源:unittest_lint.py


示例6: test_two_similar_args

    def test_two_similar_args(self):
        with tempdir() as chroot:
            create_files(["a/b/__init__.py", "a/c/__init__.py"])
            expected = [join(chroot, "a")] + self.fake

            cases = (["a/b", "a/c"], ["a/c/", "a/b/"], ["a/b/__init__.py", "a/c/__init__.py"], ["a", "a/c/__init__.py"])

            self.assertEqual(sys.path, self.fake)
            for case in cases:
                with lint.fix_import_path(case):
                    self.assertEqual(sys.path, expected)
                self.assertEqual(sys.path, self.fake)
开发者ID:si618,项目名称:pi-time,代码行数:12,代码来源:unittest_lint.py


示例7: check_pylint

    def check_pylint(self):
        """
        Check using pylint.
        """
        options = self.options.get('pylint', self.file_path).copy()
        if not options['enabled']:
            return
        del options['enabled']

        if not self._compiled_tree:
            # We failed to compile the tree.
            return

        from pylint.lint import PyLinter, fix_import_path
        from pylint.reporters import CollectingReporter

        linter = PyLinter()
        linter.load_default_plugins()
        linter.set_reporter(CollectingReporter())

        if options['py3k']:
            linter.python3_porting_mode()
        del options['py3k']

        rcfile = options.get('rcfile', None)
        del options['rcfile']

        if rcfile:
            linter.read_config_file(config_file=rcfile)
            linter.load_config_file()
        else:
            linter.load_configuration_from_config(options)

        # PyLint does its own import and parsing, so we only pass the file
        # name and the precompiled tree.
        with fix_import_path(self.file_path):
            linter.check(self.file_path)

        for message in linter.reporter.messages:
            self.message(
                message.line,
                '%s:%s %s' % (
                    message.msg_id,
                    message.symbol,
                    message.msg,
                    ),
                code=message.msg_id,
                icon='info',
                category='pylint',
                )
开发者ID:chevah,项目名称:pocket-lint,代码行数:50,代码来源:formatcheck.py


示例8: test_more_args

def test_more_args(fake_path, case):
    with tempdir() as chroot:
        create_files(["a/b/c/__init__.py", "a/d/__init__.py", "a/e/f.py"])
        expected = (
            [
                join(chroot, suffix)
                for suffix in [sep.join(("a", "b")), "a", sep.join(("a", "e"))]
            ]
            + ["."]
            + fake_path
        )

        assert sys.path == fake_path
        with lint.fix_import_path(case):
            assert sys.path == expected
        assert sys.path == fake_path
开发者ID:bluesheeptoken,项目名称:pylint,代码行数:16,代码来源:unittest_lint.py


示例9: test_two_similar_args

    def test_two_similar_args(self):
        with tempdir() as chroot:
            create_files(['a/b/__init__.py', 'a/c/__init__.py'])
            expected = [join(chroot, 'a')] + ["."] + self.fake

            cases = (
                ['a/b', 'a/c'],
                ['a/c/', 'a/b/'],
                ['a/b/__init__.py', 'a/c/__init__.py'],
                ['a', 'a/c/__init__.py'],
            )

            self.assertEqual(sys.path, self.fake)
            for case in cases:
                with lint.fix_import_path(case):
                    self.assertEqual(sys.path, expected)
                self.assertEqual(sys.path, self.fake)
开发者ID:The-Compiler,项目名称:pylint,代码行数:17,代码来源:unittest_lint.py


示例10: main

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()
    checkers.register(linter)

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

    return linter.msg_status
开发者ID:wowkin2,项目名称:django_linter,代码行数:18,代码来源:main.py


示例11: test_more_args

    def test_more_args(self):
        with tempdir() as chroot:
            create_files(["a/b/c/__init__.py", "a/d/__init__.py", "a/e/f.py"])
            expected = [
                join(chroot, suffix) for suffix in [sep.join(("a", "b")), "a", sep.join(("a", "e"))]
            ] + self.fake

            cases = (
                ["a/b/c/__init__.py", "a/d/__init__.py", "a/e/f.py"],
                ["a/b/c", "a", "a/e"],
                ["a/b/c", "a", "a/b/c", "a/e", "a"],
            )

            self.assertEqual(sys.path, self.fake)
            for case in cases:
                with lint.fix_import_path(case):
                    self.assertEqual(sys.path, expected)
                self.assertEqual(sys.path, self.fake)
开发者ID:si618,项目名称:pi-time,代码行数:18,代码来源:unittest_lint.py


示例12: test_more_args

    def test_more_args(self):
        with tempdir() as chroot:
            create_files(['a/b/c/__init__.py', 'a/d/__init__.py', 'a/e/f.py'])
            expected = [
                join(chroot, suffix)
                for suffix in [sep.join(('a', 'b')), 'a', sep.join(('a', 'e'))]
            ] + ["."] + self.fake

            cases = (
                ['a/b/c/__init__.py', 'a/d/__init__.py', 'a/e/f.py'],
                ['a/b/c', 'a', 'a/e'],
                ['a/b/c', 'a', 'a/b/c', 'a/e', 'a'],
            )

            self.assertEqual(sys.path, self.fake)
            for case in cases:
                with lint.fix_import_path(case):
                    self.assertEqual(sys.path, expected)
                self.assertEqual(sys.path, self.fake)
开发者ID:The-Compiler,项目名称:pylint,代码行数:19,代码来源:unittest_lint.py


示例13: test_no_args

 def test_no_args(self):
     with lint.fix_import_path([]):
         self.assertEqual(sys.path, ["."] + self.fake)
     self.assertEqual(sys.path, self.fake)
开发者ID:The-Compiler,项目名称:pylint,代码行数:4,代码来源:unittest_lint.py


示例14: test_no_args

def test_no_args(fake_path):
    with lint.fix_import_path([]):
        assert sys.path == ["."] + fake_path
    assert sys.path == fake_path
开发者ID:Mariatta,项目名称:pylint,代码行数:4,代码来源:unittest_lint.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python lint.preprocess_options函数代码示例发布时间:2022-05-25
下一篇:
Python config.find_pylintrc函数代码示例发布时间: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