Skip to content

Source file found twice under different module names mypy #19284

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
Tusenka opened this issue Jun 12, 2025 · 1 comment
Open

Source file found twice under different module names mypy #19284

Tusenka opened this issue Jun 12, 2025 · 1 comment
Labels
bug mypy got something wrong pending Issues that may be closed

Comments

@Tusenka
Copy link

Tusenka commented Jun 12, 2025

Steps to reproduce:

  1. Clone from github repo:

    gh pr checkout 13421

  2. Cd to the repo:

    cd pytest

  3. Run mypy:

    mypy .
    or
    run prcommit:

    precommit --all-files

Expected:

All tests are passed.

Actual:

Source file found twice under different module names: "example_scripts.rewrite.src.main" and "testing.example_scripts.rewrite.src.main"

Example of run:

pytest-dev/pytest#13421

PS:

The _init_ file exists and there are no relative imports of the failed file.

Duplicate:

Despite https://stackoverflow.com/questions/63871252/source-file-found-twice-error-with-mypy-0-780-in-python-for-vscode doesn't contain relative path.

@Tusenka Tusenka added the bug mypy got something wrong label Jun 12, 2025
@brianschubert
Copy link
Collaborator

This is caused by the fact that example_scripts is a top-level package, but at one point you attempt to import from testing.example_scripts.rewrite.src.main import func. You likely need to fix that import and/or the expected import path for that test.

@brianschubert brianschubert added the pending Issues that may be closed label Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong pending Issues that may be closed
Projects
None yet
Development

No branches or pull requests

2 participants