How to use the dlint.linters.InlineCallbacksYieldStatementLinter function in dlint

To help you get started, we’ve selected a few dlint 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 duo-labs / dlint / tests / test_twisted / test_inlinecallbacks_yield_statement.py View on Github external
def test_raise_with_missing_yield(self):
        python_node = self.get_ast_node(
            """
            from twisted.internet import defer

            @defer.inlineCallbacks
            def func(arg):
                if True:
                    raise NotImplementedError()
                return
            """
        )

        linter = dlint.linters.InlineCallbacksYieldStatementLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=5 if IS_PYTHON_3_8 else 4,
                col_offset=0,
                message=dlint.linters.InlineCallbacksYieldStatementLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_inlinecallbacks_yield_statement.py View on Github external
def test_only_pass_statement(self):
        python_node = self.get_ast_node(
            """
            from twisted.internet import defer

            @defer.inlineCallbacks
            def func(arg):
                pass
            """
        )

        linter = dlint.linters.InlineCallbacksYieldStatementLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_inlinecallbacks_yield_statement.py View on Github external
from twisted.internet import defer

            def func(arg):
                if arg:
                    arg += 5

                @defer.inlineCallbacks
                def inner_func():
                    return

                yield 'foo'
                return
            """
        )

        linter = dlint.linters.InlineCallbacksYieldStatementLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=9 if IS_PYTHON_3_8 else 8,
                col_offset=4,
                message=dlint.linters.InlineCallbacksYieldStatementLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_inlinecallbacks_yield_statement.py View on Github external
def test_multiple_raise_statements(self):
        python_node = self.get_ast_node(
            """
            from twisted.internet import defer

            @defer.inlineCallbacks
            def func(arg):
                raise errors.ApiException(errors.FORBIDDEN)
                raise errors.ApiException(errors.MISSING)
            """
        )

        linter = dlint.linters.InlineCallbacksYieldStatementLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_inlinecallbacks_yield_statement.py View on Github external
def test_empty(self):
        python_node = self.get_ast_node(
            """
            """
        )

        linter = dlint.linters.InlineCallbacksYieldStatementLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_inlinecallbacks_yield_statement.py View on Github external
def bar(self):
                        yield 'baz'

                return
            """
        )

        linter = dlint.linters.InlineCallbacksYieldStatementLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=5 if IS_PYTHON_3_8 else 4,
                col_offset=0,
                message=dlint.linters.InlineCallbacksYieldStatementLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_inlinecallbacks_yield_statement.py View on Github external
"""
            from twisted.internet import defer

            @defer.inlineCallbacks
            def func(arg):
                if arg:
                    arg += 5

                def inner_func():
                    yield 'foo'

                return
            """
        )

        linter = dlint.linters.InlineCallbacksYieldStatementLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=5 if IS_PYTHON_3_8 else 4,
                col_offset=0,
                message=dlint.linters.InlineCallbacksYieldStatementLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_inlinecallbacks_yield_statement.py View on Github external
def test_raise_with_yield(self):
        python_node = self.get_ast_node(
            """
            from twisted.internet import defer

            @defer.inlineCallbacks
            def func(arg):
                if True:
                    raise NotImplementedError()
                yield 'foo'
                return
            """
        )

        linter = dlint.linters.InlineCallbacksYieldStatementLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_inlinecallbacks_yield_statement.py View on Github external
from twisted.internet import defer

            @defer.inlineCallbacks
            def func(arg):
                if arg:
                    arg += 5

                class Foo(object):
                    def bar(self):
                        yield 'baz'

                return
            """
        )

        linter = dlint.linters.InlineCallbacksYieldStatementLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=5 if IS_PYTHON_3_8 else 4,
                col_offset=0,
                message=dlint.linters.InlineCallbacksYieldStatementLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_inlinecallbacks_yield_statement.py View on Github external
def test_only_raise_statement(self):
        python_node = self.get_ast_node(
            """
            from twisted.internet import defer

            @defer.inlineCallbacks
            def func(arg):
                raise NotImplementedError()
            """
        )

        linter = dlint.linters.InlineCallbacksYieldStatementLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected