Skip to content

Source file found twice under different module names #141

Closed

Description

@jaraco

Starting with mypy 0.990, when testing a module in a namespace, mypy starts emitting errors when it encounters that module:

 error: Source file found twice under different module names: "abode" and "jaraco.abode"

The issue almost certainly has the same root cause as pytest-dev/pytest#3396. Pytest is too reliant on the old assumption that a directory without an __init__.py is not a package, but that assumption doesn't hold since Python 3.3.

Activity

  1. jaraco commented on Nov 10, 2022

    @jaraco
    Author

    I observe that a similar error occurs when running the mypy manually:

     jaraco.abode main $ .tox/python/bin/mypy .
    jaraco/abode/helpers/constants.py: error: Source file found twice under different module names: "abode.helpers.constants" and "jaraco.abode.helpers.constants"
    jaraco/abode/helpers/constants.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
    jaraco/abode/helpers/constants.py: note: Common resolutions include: a) adding `__init__.py` somewhere, b) using `--explicit-package-bases` or adjusting MYPYPATH
    Found 1 error in 1 file (errors prevented further checking)
    
  2. jaraco commented on Nov 10, 2022

    @jaraco
    Author

    It seems that mypy is giving a poor experience by default to namespace packages, and can be worked around by setting explicit package bases in the command line or config file.

  3. jaraco commented on Nov 10, 2022

    @jaraco
    Author

    Closing in favor of python/mypy#14057.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions