3

I'm trying to use mypy with a package that I've written, but it can't find my stub file.

I have a workspace which looks like this:

/common

/other_dir

/another_dir

I have used a script to add all of these directories to my sys.path.

Inside each directory is a src/ directory, which contains python packages, and is itself a top-level package (has an init.py).

in /common/src/test1 I have a module called components.py, and I've written another file next to it, components.pyi.

This should work as the stub file for components.py.

In /another/src/example.py, I import like this:

from common.src.test1.components.py import x

x is detected and I can use it, but when I run mypy ./another/src/example.py, it says 'Cannot find implementation or library stub for module named 'common.src.test1.components'.

It would be great if anyone who has experience with mypy could help with this.

Many thanks.

Raph117
  • 3,441
  • 7
  • 29
  • 50
  • 1
    Does this answer your question? [Why does Mypy think library imports are missing?](https://stackoverflow.com/questions/57785471/why-does-mypy-think-library-imports-are-missing) – Georgy Nov 22 '20 at 18:55

1 Answers1

0

try

from common.src.test1.components import x # type: ignore

Oscar K.
  • 21
  • 2
  • 3