diff --git a/tests/test_transformer.py b/tests/test_transformer.py index 15cf9d4..93f25e8 100644 --- a/tests/test_transformer.py +++ b/tests/test_transformer.py @@ -1834,6 +1834,39 @@ def foo() -> int: ) +def test_respect_future_import_carriage_return() -> None: + # Regression test for #385 + node = parse( + dedent( + ''' + """module docstring""" + + from __future__ import annotations + + def foo() -> int: + return 1 + ''' + ) + ) + TypeguardTransformer().visit(node) + assert ( + unparse(node) + == dedent( + ''' + """module docstring""" + + from __future__ import annotations + from typeguard import TypeCheckMemo + from typeguard._functions import check_return_type + + def foo() -> int: + memo = TypeCheckMemo(globals(), locals()) + return check_return_type('foo', 1, int, memo) + ''' + ).strip() + ) + + def test_literal() -> None: # Regression test for #399 node = parse(