[英]mypy gives an error while importing submodule : Module has no attribute
When I am checking my modules through mypy it gives me this error:当我通过 mypy 检查我的模块时,它给了我这个错误:
Module 'django.contrib.gis' has no attribute 'forms'
模块“django.contrib.gis”没有属性“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.我知道这是正确的,但 mypy 显示此错误消息。
I could import like this: from django.contrib import gis
and use forms
as gis.forms
but I do not want to.我可以这样导入:
from django.contrib import gis
并使用forms
作为gis.forms
但我不想。
Can anyone help me to fix this?谁能帮我解决这个问题? Thanks.
谢谢。
It appears that your problem is similar to this issue raised in mypy
's github repo:您的问题似乎与
mypy
的 github 存储库中提出的这个问题类似:
wherein the author of the issue originally ran mypy
with the following line其中问题的作者最初使用以下行运行
mypy
RUN mypy --strict ./mypackage/tests.py
and solved the problem by running mypy
by adding on the --implicit-reexport
flag as follows:并通过添加
--implicit-reexport
标志来运行mypy
解决了这个问题,如下所示:
RUN mypy --strict --implicit-reexport ./mypackage/tests.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.