Skip to content

inconsistent behavior depending on the file path being checked #11697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
KotlinIsland opened this issue Dec 10, 2021 · 4 comments
Open

inconsistent behavior depending on the file path being checked #11697

KotlinIsland opened this issue Dec 10, 2021 · 4 comments
Labels
bug mypy got something wrong

Comments

@KotlinIsland
Copy link
Contributor

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.

@KotlinIsland KotlinIsland added the bug mypy got something wrong label Dec 10, 2021
@KotlinIsland KotlinIsland changed the title inconsistent behavior depending on where mypy is invoked inconsistent behavior depending on the file path being checked Dec 10, 2021
@sobolevn
Copy link
Member

What if you rename projects/mypy/a.py to projects/my_mypy/a.py?

@KotlinIsland
Copy link
Contributor Author

KotlinIsland commented Dec 10, 2021

Then the error correctly displays

@sobolevn
Copy link
Member

I guess the problem is in name shadowing 🤔

@KotlinIsland
Copy link
Contributor Author

KotlinIsland commented Dec 10, 2021

It's highly bizarre, any python files in the mypy directory don't check properly, regardless of the current directory where I invoke mypy.

And some things do check properly, if I change b.py to 1 + "" then an error is reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants