Skip to content

inconsistent behavior depending on the file path being checked #11697

Open

Description

@KotlinIsland

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.

Activity

  1. changed the title [-]inconsistent behavior depending on where mypy is invoked[/-] [+]inconsistent behavior depending on the file path being checked[/+] on Dec 10, 2021
  2. sobolevn commented on Dec 10, 2021

    @sobolevn
    Member

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

  3. KotlinIsland commented on Dec 10, 2021

    @KotlinIsland
    ContributorAuthor

    Then the error correctly displays

  4. sobolevn commented on Dec 10, 2021

    @sobolevn
    Member

    I guess the problem is in name shadowing 🤔

  5. KotlinIsland commented on Dec 10, 2021

    @KotlinIsland
    ContributorAuthor

    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

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