-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Support __path__ in packages #1422
Comments
As a workaround for others (given to me by the experts) you can ignore this issue until it's fixed as such:
|
Shouldn't be too hard to fix? |
If it helps a minimal reproducible example can be found below (I wrote one before discovering this issue), A package with the following structure,
with from setuptools import setup, find_packages
setup(
name='mypy-issue-example',
version='0.0',
packages=find_packages(),
) and def check_path() -> str:
import mypy_issue_example
return mypy_issue_example.__path__ Running, $ pip install -e .
$ python -c "import mypy_issue_example; print(mypy_issue_example.__path__)"
['[...]/pkg1/mypy_issue_example']
$ mypy mypy_issue_example
mypy_issue_example/__init__.py:4: error: Module has no attribute "__path__"
Found 1 error in 1 file (checked 1 source file) |
Resolves #1422 Co-authored-by: hauntsaninja <>
I'm still having this error... |
This change hasn't been released yet. |
Error disappeared for me as I upgraded mypy from 0.910 to 0.920 |
python/mypy#1422 was fixed awhile ago. Signed-off-by: Omar Sandoval <osandov@osandov.com>
python/mypy#1422 was fixed awhile ago. Signed-off-by: Omar Sandoval <osandov@osandov.com>
The name
__path__
is defined in packages but mypy doesn't recognize it. It seems that every__init__.py[i]
file should have an implicit__path__
attribute with typeList[str]
. (I encountered some code that uses__path__
-- I didn't know about it until today.)See also: https://docs.python.org/2/tutorial/modules.html#packages-in-multiple-directories
The text was updated successfully, but these errors were encountered: