Skip to content
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

Feature req: -p (--package) arg supporting path to folder #9348

Closed
jamesbraza opened this issue Aug 24, 2020 · 2 comments
Closed

Feature req: -p (--package) arg supporting path to folder #9348

jamesbraza opened this issue Aug 24, 2020 · 2 comments

Comments

@jamesbraza
Copy link
Contributor

I am making a feature request for mypy, not raising a bug.

Within one repository, here is a use case:

  • Package that follows native namespace packaging conventions.
  • In a separate directory: unit tests, which are grouped as a native namespace package as well.
    • This is done so others can pip install and import example use cases from the unit test files
  • One mypy config file, located in repo root
  • Both the package + unit tests are type checked via mypy
    • Note per this comment: for PEP 420 support, mypy should be invoked via mypy -p <folder>

Spoiler alert, this is my use case. I would like to run mypy from the repo root, which requires one to invoke mypy via something like:

mypy -p rel/path/to/package

However, currently, it seems package names don't support slashes. When I enter mypy -p tests/packagename, here's my output:

Package name 'tests/packagename' cannot have a slash in it.

TL;DR the feature request: enable mypy support of relative paths to packages when using -p PACKAGE.


Versions

mypy==0.782
Python==3.6.5
@gvanrossum
Copy link
Member

You know the workaround is simple, right? The way -p is intended to work is

export MYPYPATH=tests
mypy -p packagename

@jamesbraza
Copy link
Contributor Author

jamesbraza commented Aug 24, 2020

Haha thank you @gvanrossum ! That's exactly what I needed, I am very grateful.

I now think this feature request is unnecessary, so I am closing it.

I am a bit embarrassed, and will be re-reading the mypy docs on import discovery :)

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

No branches or pull requests

2 participants