Please provide
- Operating system: Ubuntu 25.04
- SonarQube for VS Code plugin version: 4.35.0
- Programming language you’re coding in: Python
- Is connected mode used: No
And a thorough description of the problem / question:
When assigning an asyncio.Task to a variable using type hints, python:S7502 will be raised. For example:
import asyncio
async def my_func() -> None:
await asyncio.sleep(1)
async def main() -> None:
my_task: asyncio.Task[None] = asyncio.create_task(my_func())
await my_task
if __name__ == "__main__":
asyncio.run(main())
But it is not raised in the following example:
import asyncio
async def my_func() -> None:
await asyncio.sleep(1)
async def main() -> None:
my_task = asyncio.create_task(my_func())
await my_task
if __name__ == "__main__":
asyncio.run(main())