求助: vscode 如何 Python 支持函数提示功能

128 天前
 ctrlmymood
基于 pytest 测试框架,包含三个层级 conftest.pyconftest.py 会把各种业务的具体接口类给 import 然后利用 fixture 引用,当 testCases 里的各个 test_xxx.py 调用 conftest.py 中各个 fixture 功能函数变量在写具体测试用例步骤,fixture 功能函数变量无法自动联想或者提示变量对应的类的方法、变量或者模块中的函数,
以下是我部分代码部分,test_cpu_board_info.py 中有端代码是:
def test_cpu_board(self, log, system_page):
system_page_obj = system_page
system_page.get_cpu_board_name()

system_page 对应 class 是在 conftest.py 中被导入且使用 fixture 引用,然后直接作为插件给 testCase 模块使用,但是在上述代码中 get_cpu_board_name()无法被联想,( PS:使用 Pycharm 是可以自动联想的,我推测是建立工程时 pycharm 应该就做好一些配置)
vscode 暂时我无法解决这个办法,问 GPT 也没能帮我解决-_-!

localhost$ tree
.
├── config
│   ├── conf.py
│   └── default.yaml
├── datas
│   ├── original
│   ├── output
├── logs
│   ├── 2024-01-02_11_18_18.log
│   ├── 2024-01-02_11_19_44.log
│   ├── cli
│   │   ├── base_cli.py
│   │   └── power_cli.py
│   └── web
│   ├── __pycache__
│   │   ├── base_page.cpython-39.pyc
│   │   ├── cpu.cpython-39-pytest-7.4.0.pyc
│   │   ├── login_page.cpython-39.pyc
│   │   ├── navbar.cpython-39.pyc
│   │   └── system_page.cpython-39.pyc
│   ├── base_page.py
│   ├── login_page.py
│   ├── navbar.py
│   └── system_page.py
├── pytest.ini
├── reports
├── testCases
│   ├── __init__.py
│   ├── conftest.py
│   └── test_hardware_info
│   ├── __init__.py
│   ├── conftest.py
│   ├── test_cpu_board_info
│   │   ├── conftest.py
│   │   └── test_cpu_board_info.py
963 次点击
所在节点    Python
5 条回复
xinmans
127 天前
同问,也需要这个功能
SiLenceControL
127 天前
我直接买了 git copilot ,,不光能函数联想还能 xxx
liuhai233
127 天前
你把类型写上就可以了,type hint
ctrlmymood
127 天前
@liuhai233 写这个要各种重复导入🤣
liuhai233
127 天前
@ctrlmymood emmm ,不可避免的,不写类型无法推断出你的函数,有类型才能提示

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1005229

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX