Skip to content

"Source file found twice under different module names" doesn't work in some cases #9058

@bonprosoft

Description

@bonprosoft

I found that "Source file found twice under different module names" error doesn't happen in some cases.

Case1: A Path in the graph is a relative path

Files

Same as case testDuplicateModules in test-data/unit/cmdline.test (source).

.
├── mypy.ini
└── src
    ├── a.py
    ├── foo
    │   ├── bar.py
    │   └── __init__.py
    └── __init__.py

Actual behavior

$ mypy src
src/foo/bar.py: error: Source file found twice under different module names: 'src.foo.bar' and 'foo.bar'
Found 1 error in 1 file (checked 4 source files)

$ mypy `pwd`/src
src/foo/bar.py:1: error: Unsupported operand types for + ("int" and "str")
src/foo/bar.py:1: error: Unsupported operand types for + ("int" and "str")
Found 2 errors in 1 file (checked 4 source files)

Expected behavior

$ mypy src
src/foo/bar.py: error: Source file found twice under different module names: 'src.foo.bar' and 'foo.bar'
Found 1 error in 1 file (checked 4 source files)

$ mypy `pwd`/src
src/foo/bar.py: error: Source file found twice under different module names: 'src.foo.bar' and 'foo.bar'
Found 1 error in 1 file (checked 4 source files)

Case2: A Path in the graph is an absolute path

Files

Same as case testDuplicateModules in test-data/unit/cmdline.test except mypy.ini.

.
├── mypy.ini
└── src
    ├── a.py
    ├── foo
    │   ├── bar.py
    │   └── __init__.py
    └── __init__.py
  • mypy.ini
[mypy]
mypy_path = /absolute/path/to/src

Actual behavior

$ mypy src
src/foo/bar.py:1: error: Unsupported operand types for + ("int" and "str")
src/foo/bar.py:1: error: Unsupported operand types for + ("int" and "str")
Found 2 errors in 1 file (checked 4 source files)

$ mypy `pwd`/src
src/foo/bar.py: error: Source file found twice under different module names: 'src.foo.bar' and 'foo.bar'
Found 1 error in 1 file (checked 4 source files)

Expected behavior

$ mypy src
src/foo/bar.py: error: Source file found twice under different module names: 'src.foo.bar' and 'foo.bar'
Found 1 error in 1 file (checked 4 source files)

$ mypy `pwd`/src
src/foo/bar.py: error: Source file found twice under different module names: 'src.foo.bar' and 'foo.bar'
Found 1 error in 1 file (checked 4 source files)

Versions

$ mypy --version
mypy 0.790+dev.8219564d365ba29dda8c4383594d9db91f26feec
$ python --version
Python 3.6.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions