Skip to content

Better error messages for invalid Python package directory names #2775

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
FuegoFro opened this issue Jan 30, 2017 · 3 comments
Closed

Better error messages for invalid Python package directory names #2775

FuegoFro opened this issue Jan 30, 2017 · 3 comments
Labels

Comments

@FuegoFro
Copy link
Contributor

It looks like mypy can't handle absolute paths to where the parent directory has a dot in the name. Specifically I accidentally had an __init__.py in the root of my project, and cloned my project into a directory with a dot in its name. When I ran mypy it failed with mypy: can't find module '<module-name>'. I realize that what I was doing was wrong, but it took me cloning mypy and stepping through it with a debugger to understand what was wrong and why it was failing. It would be awesome to have a clearer error message in these cases (eg maybe check that the directories found in the crawl_up method are valid package names and fail if they're not:

def crawl_up(arg: str) -> Tuple[str, str]:
)

To repro, create a directory with a dot in it (eg mkdir tmp.dir), place an empty __init__.py and an empty main.py in it, then run mypy $(pwd)/main.py from within that directory.

Note that this is related to but slightly different from #2773.

@JukkaL JukkaL added bug mypy got something wrong priority-1-normal labels Jan 31, 2017
@JukkaL
Copy link
Collaborator

JukkaL commented Jan 31, 2017

Mypy doesn't handle this well -- at least the error message isn't helpful.

@chernrick
Copy link
Contributor

Trying this one for PyCon 2017

@chernrick
Copy link
Contributor

Pull request #3447

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

No branches or pull requests

4 participants