Skip to content

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

Closed

Description

@KotlinIsland

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

Activity

  1. JelleZijlstra commented on Dec 9, 2021

    @JelleZijlstra
    Member

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

  2. KotlinIsland commented on Dec 9, 2021

    @KotlinIsland
    ContributorAuthor

    Happens on wsl and not windows

  3. hauntsaninja commented on Dec 9, 2021

    @hauntsaninja
    Collaborator

    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
    
  4. KotlinIsland commented on Dec 10, 2021

    @KotlinIsland
    ContributorAuthor

    @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
  5. hauntsaninja commented on Dec 10, 2021

    @hauntsaninja
    Collaborator

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

  6. KotlinIsland commented on Dec 10, 2021

    @KotlinIsland
    ContributorAuthor

    testing it now

  7. KotlinIsland commented on Dec 10, 2021

    @KotlinIsland
    ContributorAuthor

    I think that change resolves the issue

  8. KotlinIsland commented on Dec 10, 2021

    @KotlinIsland
    ContributorAuthor

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

  9. KotlinIsland commented on Dec 10, 2021

    @KotlinIsland
    ContributorAuthor

    Raised it here #11697

  10. pranavrajpal commented on Dec 10, 2021

    @pranavrajpal
    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?

  11. KotlinIsland commented on Dec 10, 2021

    @KotlinIsland
    ContributorAuthor

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

  12. added a commit that references this issue on Dec 10, 2021
    e537705
  13. added a commit that references this issue on Dec 13, 2021
    4d2ff58
  14. added a commit that references this issue on Jan 20, 2022
    1874a77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions