Skip to content

Explain that mypy should be run in the package root directory #7405

@JukkaL

Description

@JukkaL

If I have a package pkg/ and I run mypy while the current working directory is pkg, mypy can't resolve imports from pkg. This is consistent with how Python works (see #7389 for discussion), but it may be surprising for some users. Mypy could detect this issue and generate a note that would tell the user to switch to another directory.

More details: If an imported module can't be resolved, but the current working directory contains a __init__.py[i] file, see if the import could be resolved if some parent directory was added to the search path. If yes, add a note suggesting that the current working directory should perhaps be changed to a parent directory.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions