1.1.405 : Type of "xxx" could not be determined because it refers to itself
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
1.1.405 flags the code below code as faulty.
**Code or Screenshots**
```python
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.
Contributor guide
Research direction
Run the supplied reproduction with pyright 1.1.405 and compare it with 1.1.404, using the command shown in the issue. Start from the reportGeneralTypeIssues diagnostic for the nested coroutine assignment in reproduce.py; done means the valid example no longer reports the self-reference error and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100