简体   繁体   中英

mypy gives an error while importing submodule : Module has no attribute

When I am checking my modules through mypy it gives me this error:

Module 'django.contrib.gis' has no attribute 'forms'

and I am importing forms like this:

from django.contrib.gis import forms

I know it is correct but mypy shows this error message.

I could import like this: from django.contrib import gis and use forms as gis.forms but I do not want to.

Can anyone help me to fix this? Thanks.

It appears that your problem is similar to this issue raised in mypy 's github repo:

Module X has no attribute Y, since version 0.700 (works fine with 0.670)

wherein the author of the issue originally ran mypy with the following line

RUN mypy --strict ./mypackage/tests.py

and solved the problem by running mypy by adding on the --implicit-reexport flag as follows:

RUN mypy --strict --implicit-reexport ./mypackage/tests.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM