How to use the dlint.linters.YieldReturnStatementLinter 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_yield_return_statement.py View on Github external
def test_none_return_statement(self):
        python_node = self.get_ast_node(
            """
            from twisted.internet import defer

            @defer.inlineCallbacks
            def func(arg):
                return None
            """
        )

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

        result = linter.get_results()
        expected = [] if IS_PYTHON_3_3 else [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=4,
                message=dlint.linters.YieldReturnStatementLinter._error_tmpl
            )
        ]

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

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

                @defer.inlineCallbacks
                def inner_func():
                    return arg

                return
            """
        )

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

        result = linter.get_results()
        expected = [] if IS_PYTHON_3_3 else [
            dlint.linters.base.Flake8Result(
                lineno=10,
                col_offset=8,
                message=dlint.linters.YieldReturnStatementLinter._error_tmpl
            )
        ]

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

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

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

        result = linter.get_results()
        expected = [] if IS_PYTHON_3_3 else [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=4,
                message=dlint.linters.YieldReturnStatementLinter._error_tmpl
            )
        ]

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

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

        result = linter.get_results()
        expected = []

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

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

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

        result = linter.get_results()
        expected = []

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

            @defer.inlineCallbacks
            def func(arg):
                if condition:
                    return

                if arg > 10:
                    return
                else:
                    return arg
            """
        )

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

        result = linter.get_results()
        expected = [] if IS_PYTHON_3_3 else [
            dlint.linters.base.Flake8Result(
                lineno=12,
                col_offset=8,
                message=dlint.linters.YieldReturnStatementLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_yield_return_statement.py View on Github external
            @defer.inlineCallbacks
            def func(arg):
                return arg
            """
        )

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

        result = linter.get_results()
        expected = [] if IS_PYTHON_3_3 else [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=4,
                message=dlint.linters.YieldReturnStatementLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_twisted / test_yield_return_statement.py View on Github external
def test_not_inlinecallbacks_decorator(self):
        python_node = self.get_ast_node(
            """
            @other_decorator
            def func(arg):
                return arg
            """
        )

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

        result = linter.get_results()
        expected = []

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

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

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

        result = linter.get_results()
        expected = []

        assert result == expected