Skip to content

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

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

Closed
JukkaL opened this issue Aug 29, 2019 · 4 comments · Fixed by #8927
Closed

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

JukkaL opened this issue Aug 29, 2019 · 4 comments · Fixed by #8927

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Aug 29, 2019

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.

@Shashankjain12
Copy link

Shashankjain12 commented Feb 22, 2020

hello @JukkaL can you assign me the issue so that I can start working on this particular issue?

@JelleZijlstra
Copy link
Member

@Shashankjain12 feel free to just start working on this.

@Shashankjain12
Copy link

hello @JelleZijlstra i am new to open source can you suggest me which file to edit in order to prompt users that they are in wrong directory while executing the code?

@JukkaL
Copy link
Collaborator Author

JukkaL commented Feb 28, 2020

@Shashankjain12 You'll probably need to edit mypy/build.py (and/or maybe some other module imported there). One way to move forward is to find the code that generates the error message about the import, and look around there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants