Skip to content
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

error listed twice with wrong filename(capitalization) in output #11690

Closed
KotlinIsland opened this issue Dec 9, 2021 · 11 comments · Fixed by #11708
Closed

error listed twice with wrong filename(capitalization) in output #11690

KotlinIsland opened this issue Dec 9, 2021 · 11 comments · Fixed by #11708
Labels
bug mypy got something wrong

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Dec 9, 2021

given:

folder/
├─ src/
│  ├─ __init__.py
│  ├─ thing.py
├─ test.py

src/__init__.py:

from src.thing import Thing as Thing

src/thing.py:

class Thing(asdf): ...

test.py:

from src import Thing
> mypy -V
mypy 0.920+dev.1393e3fec49a9505fd3a31f3406ddd4e2e1c54b8
> mypy --strict test.py
src/thing.py:1: error: Name "asdf" is not defined
src/Thing.py:1: error: Name "asdf" is not defined

Edit:
This is observed with WSL on the windows file system and not WSL on the Linux fs

@KotlinIsland KotlinIsland added the bug mypy got something wrong label Dec 9, 2021
@JelleZijlstra
Copy link
Member

Is this on an OS with case-insensitive files? We've had some similar issues.

@KotlinIsland
Copy link
Contributor Author

Happens on wsl and not windows

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Dec 9, 2021

Can you delete your mypy cache and then check if the following patch fixes:

diff --git a/mypy/fscache.py b/mypy/fscache.py
index c77b941c5..fb651326f 100644
--- a/mypy/fscache.py
+++ b/mypy/fscache.py
@@ -202,9 +202,6 @@ class FileSystemCache:
 
         The caller must ensure that prefix is a valid file system prefix of path.
         """
-        if sys.platform == "linux":
-            # Assume that the file system on Linux is case sensitive
-            return self.isfile(path)
         if not self.isfile(path):
             # Fast path
             return False

@KotlinIsland
Copy link
Contributor Author

@hauntsaninja did you know that github supports diff as a code block language.

diff --git a/mypy/fscache.py b/mypy/fscache.py
index c77b941c5..fb651326f 100644
--- a/mypy/fscache.py
+++ b/mypy/fscache.py
@@ -202,9 +202,6 @@ class FileSystemCache:
 
         The caller must ensure that prefix is a valid file system prefix of path.
         """
-        if sys.platform == "linux":
-            # Assume that the file system on Linux is case sensitive
-            return self.isfile(path)
         if not self.isfile(path):
             # Fast path
             return False

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Dec 10, 2021

I knew that. Does the diff fix the issue or not? (I don't have a system I can repro the issue on)

@KotlinIsland
Copy link
Contributor Author

testing it now

@KotlinIsland
Copy link
Contributor Author

I think that change resolves the issue

@KotlinIsland
Copy link
Contributor Author

KotlinIsland commented Dec 10, 2021

Very strange, on another machine with the exact same files it doesn't follow the imports at all.

@KotlinIsland
Copy link
Contributor Author

Raised it here #11697

@pranavrajpal
Copy link
Contributor

Happens on wsl and not windows

Is this happening on WSL 1 or 2? Also, are you using the Windows file system or the Linux file system?

@KotlinIsland
Copy link
Contributor Author

KotlinIsland commented Dec 10, 2021

wsl 2 on the windows file system, it does not happen with wsl + linux fs

hauntsaninja pushed a commit to hauntsaninja/mypy that referenced this issue Dec 10, 2021
JukkaL pushed a commit that referenced this issue Dec 13, 2021
Originally added in #10093

Fixes #11690, fixes #10661, fixes #10822

Co-authored-by: hauntsaninja <>
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this issue Jan 20, 2022
Originally added in python#10093

Fixes python#11690, fixes python#10661, fixes python#10822

Co-authored-by: hauntsaninja <>
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

Successfully merging a pull request may close this issue.

4 participants