python / python/mypy

Results vary with the order of the specified files.

Open
#12,592 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

I have a project with many modules. A group of 30 of them are in a cyclic import SCC.

I ran mypy under Visual Studio. While trying to see why some errors appeared, I ran a copy of the mypy code with a debugger. I noticed that I got quite a different set of errors reported.
The difference was that Visual Studio passes filenames to mypy in the order that it finds them in the project, whereas I used "mypy ." for the debugging. mypy processed the same set of input files, but in a different order.

I made a names file with the names in the order used by VS, and then ran mypy using this names file, with same result as running under VS.

I've collected log files from both runs. They include a bunch of extra messages which I put into my code, so as to help me figure out what was going on. It includes details about imports and symbol definitions in this SCC, and two files, cache and solver.common in particular.

I have attached a zip with these logs. It also includes just the error messages extracted from the logs. You will see the greatly different results. 148 errors in one case and 93 errors in the other case.

It's apparent to me that the order of the files in this SCC is what makes the difference. I will be looking at what in detail is different and why that is happening. It has something to do with marking a module as incomplete when it imports * from another incomplete module, and some, but not all, of the needed symbols are imported only during the final iteration.

However, in the meantime, here are the output files, if you want to see what you can make of them. The order of the SCC is shown in line 873 of each log file.
Exp.zip

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 by examining the attached Exp.zip logs and compare the two runs, focusing on the SCC order shown at line 873 and the differing diagnostics. Trace the incomplete-module and import-* behavior described in the report; done means processing the same input files no longer changes the reported errors based on their order.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.