最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - How to tell pylance to correctly read identifiers loaded by their full module name? - Stack Overflow

programmeradmin0浏览0评论

I have a file that depends on a tool from another directory. The structure is:

  • my_subproject
    • util
      • __init__.py
      • my_tool.py
    • __init__.py
    • my_main_file.py

my_tool.py may contain something like:

class MyTool:
    pass

In the main file, I import it by:

import my_subproject.util.my_tool

my_tool_instance = my_subproject.util.my_tool.MyTool()

This works fine when ran in python, but I suspect there are path configurations I am not aware of. I am trying to get it to work in the IDE as well.

Right now, it says:

"my_tool" is not a known attribute of module "my_subproject.my_util"

In the VS Code settings for pylance, I have this:

    "python.autoComplete.extraPaths": [
        "my_subproject"
    ],
    "python.analysis.include": ["my_subproject/**"],
发布评论

评论列表(0)

  1. 暂无评论