使用VSCode v1.61.0 我有一个python包,一个名为“tfmodules”的文件夹,其中包含整个lotta模块,我在init.py中执行以下操作:
from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [ basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')]
在我的代码中,我这样导入它:
from tfmodules import *
然后我用如下方式调用模块:
def write(aci_topology_model, provider_source, provider_version):
with open('fabric-bringup.tf', 'w') as f:
x = fabricbringup.tf_write_fabric_bringup(aci_topology_model, provider_source, provider_version)
f.write(x)
fabricbringup是软件包中的一个模块。 代码运行得很好,但是Pylance抛出了36个reportUndefinedVariable实例,每个调用的模块一个实例
具体错误(来自其中一个模块)为:
"fabricbringup" is not defined Pylance(reportUndefinedVariable)
我已经为vs代码中的venv选择了合适的解释器,并尝试将其添加到settings.json文件中:
"python.analysis.extraPaths": ["tfmodules", "/home/aj/projects/python/dcnet-aci-lld-convert/tfmodules"]
但我还是从派伦斯那里得到了错误。我做错了什么?谢谢
考虑到您不会在运行时添加任何扩展名,那么创建一个直接生成对“\uuuu init\uuuu.py”的所有引用的文件怎么样
结果将如下所示:
相关问题 更多 >
编程相关推荐