From b9cb0dce3fb3448ed271fe5d5fcfc5f9ff8b7af9 Mon Sep 17 00:00:00 2001 From: Maksim Grebeniuk <122789225+maksim-grebeniuk-sonarsource@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:00:07 +0100 Subject: [PATCH] SONARPY-1252 S5886 (FunctionReturnTypeCheck) should consider type aliases (#1661) --- .../checks/functionReturnTypeAdditionalTests.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python-checks/src/test/resources/checks/functionReturnTypeAdditionalTests.py b/python-checks/src/test/resources/checks/functionReturnTypeAdditionalTests.py index 6510bfdb9e..03e359f0fb 100644 --- a/python-checks/src/test/resources/checks/functionReturnTypeAdditionalTests.py +++ b/python-checks/src/test/resources/checks/functionReturnTypeAdditionalTests.py @@ -23,3 +23,13 @@ def conditional_import(): async def my_iterator() -> Iterator[str]: yield "hello" + + +def type_aliases(): + from typing import Generator + from typing import TypeAlias + + StepGenerator: TypeAlias = Generator[str, None, None] + def ordered_steps() -> StepGenerator: + for i in range(10): + yield str(i)