Skip to content

error: No parent module -- cannot perform relative import #6682

@renyuneyun

Description

@renyuneyun

Please provide more information to help us understand the issue:

  • Are you reporting a bug, or opening a feature request?

A bug.

  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.

I have PYTHONPATH=$HOME/self/exp, and I'm working on a library under $HOME/self/exp/exp. The directory structure looks like this:

exp
├── exp
     ├── __init__.py
     ├── a.py
     ├── b.py

Sample minimal code is under https://gist.github.com/renyuneyun/0ff13a8c9013f178c760f963b5eba502 . Basically I use relative imports to import another file under the same module.
__init__.py is empty.

  • What is the actual behavior/output?

a.py:4: error: No parent module -- cannot perform relative import

  • What is the behavior/output you expect?

Pass with no errors or warnings

  • What are the versions of mypy and Python you are using?

mypy 0.670
Python 3.7.3

  • Do you see the same issue after installing mypy from Git master?

Yes. No difference.

  • What are the mypy flags you are using? (For example --strict-optional)

No flags.

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