Reputation: 2845
This is a simplified project structure:
aiojira/
aiojira/__init__.py
aiojira/resiliencesession.py
aiojira/__init__.pyi
aiojira/resiliencesesion.pyi
In aiojira/resiliencesession.pyi
, I have the following:
import resiliencesession
However, both PyCharm and mypy
(version 0.641) inform about an error in code. mypy
output:
aiojira/__init__.pyi:1: error: Cannot find module named 'resilientsession'
aiojira/__init__.pyi:1: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)
Upvotes: -1
Views: 1753
Reputation: 5589
Type stubs are syntactically valid Python [...] files with a .pyi suffix.
(From https://typing.readthedocs.io/en/latest/reference/stubs.html#syntax, therefore, usual import statement rules apply.)
The only acceptable syntax for relative imports is
from .[module] import name
. All import forms not starting with.
are interpreted as absolute imports.
(From https://docs.python.org/3.0/whatsnew/3.0.html#removed-syntax)
Relative import should fix this problem.
Try:
from . import resilientsession
Upvotes: 1