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

[question] Current recommended way to use an internal library with type annotations #4608

Closed
mfcabrera opened this issue Feb 21, 2018 · 1 comment
Labels

Comments

@mfcabrera
Copy link

Hi,

I have a question/bug that may be related to this bug and to this pep-0561 but I am using mypy maybe this is the right place to ask-

I have two modules/package:

  • A with inline typing information - it is an internal package and it won't probably be open source. We distribute package A with an internal pipy server.
  • Module B uses module A and wants to make use of A typing information.

Installing the package:
If I do: pip install A or using python setup.py develop / pip install -e . and then try to check with mypy files from module B that import module A I get the message:

B/foo.py:14: error: Cannot find module named `A`
B/foo.py:14: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)

In my case I don't want to use --ignore-missing-imports as module A has type annotations.
I could use MYPYPATH but that would mean that I have to set it for each of my internal packages that contain type annotation.

So the question:
Is there a recommended way to distribute type annotation for non-opensource libraries that mypy can automatically use it?

@ethanhs
Copy link
Collaborator

ethanhs commented Feb 21, 2018

At the moment MYPYPATH is the best way. I have an implementation in #4403 of PEP 561 that will probably not make it in the merge window for mypy 0.570, but it should be included in mypy 0.580. You may also want to read #2625.

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

3 participants