Skip to content

False positive unreachable for NoReturn coroutine functions #9840

@tomasz-michalski

Description

@tomasz-michalski

Bug description

# pylint: disable=missing-module-docstring,missing-function-docstring

import asyncio
from typing import NoReturn


async def coro() -> NoReturn:
    while True:
        await asyncio.sleep(1)


async def main() -> None:
    asyncio.create_task(coro())
    print("hello")


if __name__ == "__main__":
    asyncio.run(main())

Configuration

No response

Command used

pylint a.py

Pylint output

************* Module a
a.py:14:4: W0101: Unreachable code (unreachable)

-----------------------------------
Your code has been rated at 9.00/10

Expected behavior

No error

Pylint version

pylint 3.2.6
astroid 3.2.4
Python 3.11.9 (main, Apr  6 2024, 17:59:24) [GCC 9.4.0]

OS / Environment

Ubuntu 20.04.6 LTS

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BackportedFalse Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions