python / python/mypy

inconsistent behavior depending on the file path being checked

Open
#11,697 4 comments 1 reaction 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

given:

projects/
├─ mypy/
│  ├─ a.py
│  ├─ b.py
├─ other/
│  ├─ a.py
│  ├─ b.py

a.py:

from b import b

b.py:

b: int = ""
>mypy projects/mypy/a.py
Success: no issues found in 1 source file
>mypy projects/other/a.py
b.py:1: error: Incompatible types in assignment (expression has type "int", variable has type "str")
Found 1 error in 1 file (checked 1 source file)

I have no idea whats going on here, I can consistently reproduce it with these folders(projects/mypy), but not any other folder.

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

Reproduce the behavior with the shown projects/mypy and projects/other layouts, using the two mypy commands from the report. Compare how a.py imports b.py in each directory and trace the differing diagnostics; done means the same invalid assignment in b.py is reported consistently regardless of the checked path.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.