How to use the dlint.linters.ReturnValueInInlineCallbacksLinter 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_returnvalue_in_inlinecallbacks.py View on Github external
"""
            from twisted.internet import defer

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

                @defer.inlineCallbacks
                def inner_func():
                    defer.returnValue('foo')

                defer.returnValue('qux')
            """
        )

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

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=4,
                col_offset=0,
                message=dlint.linters.ReturnValueInInlineCallbacksLinter._error_tmpl
            )
        ]

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

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

                def inner_func():
                    defer.returnValue('qux')

                return 'foo'
            """
        )

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

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=8,
                col_offset=4,
                message=dlint.linters.ReturnValueInInlineCallbacksLinter._error_tmpl
            )
        ]

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

            CONST = 5

            @module.other_decorator(CONST)
            def func(arg):
                defer.returnValue(arg)
            """
        )

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

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=7 if IS_PYTHON_3_8 else 6,
                col_offset=0,
                message=dlint.linters.ReturnValueInInlineCallbacksLinter._error_tmpl
            )
        ]

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

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

                class Foo(object):
                    @defer.inlineCallbacks
                    def bar(self):
                        defer.returnValue('baz')

                defer.returnValue('qux')
            """
        )

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

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=4,
                col_offset=0,
                message=dlint.linters.ReturnValueInInlineCallbacksLinter._error_tmpl
            )
        ]

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

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

                def inner_func():
                    return 'foo'

                defer.returnValue('qux')
            """
        )

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

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=4,
                col_offset=0,
                message=dlint.linters.ReturnValueInInlineCallbacksLinter._error_tmpl
            )
        ]

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

            @inlineCallbacks
            def func(arg):
                yield 'foo'
                returnValue('foo')
            """
        )

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

        result = linter.get_results()
        expected = []

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

            def func(arg):
                foo = yield bar()
                defer.returnValue('baz')
            """
        )

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

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=4,
                col_offset=0,
                message=dlint.linters.ReturnValueInInlineCallbacksLinter._error_tmpl
            )
        ]

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

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

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

                defer.returnValue('qux')
            """
        )

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

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=4,
                col_offset=0,
                message=dlint.linters.ReturnValueInInlineCallbacksLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_returnvalue_in_inlinecallbacks.py View on Github external
def inner_func():
                    defer.returnValue('qux')

                return 'foo'
            """
        )

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

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=8,
                col_offset=4,
                message=dlint.linters.ReturnValueInInlineCallbacksLinter._error_tmpl
            )
        ]

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

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

        result = linter.get_results()
        expected = []

        assert result == expected