pyright icon indicating copy to clipboard operation
pyright copied to clipboard

1.1.405 : Type of "xxx" could not be determined because it refers to itself

Open ewjoachim opened this issue 2 months ago • 1 comments

Describe the bug

1.1.405 flags the code below code as faulty.

Code or Screenshots

async def func() -> None: ...


class MyClass:
    async def my_func(self) -> None:
        for _ in []:
            coro = func()

            original_coro = coro

            async def _coro():
                return await original_coro

            coro = _coro()  # <- the error line

  reproduce.py:17:20 - error: Type of "_coro" could not be determined because it refers to itself (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations

This is a simplified version of https://github.com/procrastinate-org/procrastinate/blob/0c2e365186c8f5615842edf065203d0daf8b65de/procrastinate/testing.py#L257

VS Code extension or command-line Command line:

uv run pyright procrastinate/prt.py

(This happens with pyright==1.1.405 and not with pyright==1.1.404)

I would tend to consider https://github.com/microsoft/pyright/issues/10850 as one of the possible causes ?

Maybe my code is actually faulty? Given the problem disappears if the loop is removed, I imagine it's part of the problem. Note that if I refactor the content of the loop to its own function, the problem disappears.

ewjoachim avatar Sep 08 '25 10:09 ewjoachim