Skip to content

name.py used as module instead of name module directory #7711

Open
@mortoray

Description

@mortoray

I have a module named mdl with the below __init__.py (The contents don't actually matter).

from .document import load_document

Then I have a file called mdl.py:

import mdl
doc = mdl.load_document( "happy" )

mypy produces the error:

mdl.py:2: error: Module has no attribute "load_document"

If I rename the file to anything_else.py this error doesn't happen.

It appears as though mypy is resolving the mdl import to the file mdl.py instead of the mdl module directory. Since the Python interpreter resolve the names as I intended, I'd assume mypy would as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions