microsoft / microsoft/pyright

Instance of "Class definition depends on itself" error is order-dependent

Open
#10,661 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

**Describe the bug**
Repro code https://github.com/vors/pyright_cycle_repro (requires `uv pip install chz`)

```
#> pyright_cycle_repro % pyright a.py b.py
0 errors, 0 warnings, 0 informations
#> pyright_cycle_repro % pyright b.py a.py
pyright_cycle_repro/b.py
pyright_cycle_repro/b.py:15:62 - error: Class definition for "ModelTP" depends on itself (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations
#> pyright_cycle_repro % cde
#> pyright_cycle_repro % pyright --version
pyright 1.1.402
```

Problem: `pyright a.py b.py` and `pyright b.py a.py` give different results. In the more real-case scenario this leads to non-deterministic type checking when a whole repo is checked, because the order of files processing is apparently non-deterministic.

**Code or Screenshots**
see previous section

```
#> uv pip freeze
chz==0.3.0
pyright==1.1.402
torch==2.7.1
typing-extensions==4.14.0
```

**VS Code extension or command-line**
command line

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked pyright_cycle_repro and its a.py and b.py files, then run the two pyright command-line invocations in both argument orders. Trace the type-checking path responsible for the differing Class definition for "ModelTP" result. Done means both orders produce the same correct result, with coverage for this reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.