V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ctrlmymood
V2EX  ›  Python

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

  •  
  •   ctrlmymood · 116 天前 · 948 次点击
    这是一个创建于 116 天前的主题,其中的信息可能已经有所发展或是发生改变。
    基于 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
    5 条回复    2024-01-03 14:13:46 +08:00
    xinmans
        1
    xinmans  
       115 天前
    同问,也需要这个功能
    SiLenceControL
        2
    SiLenceControL  
       115 天前
    我直接买了 git copilot ,,不光能函数联想还能 xxx
    liuhai233
        3
    liuhai233  
       115 天前
    你把类型写上就可以了,type hint
    ctrlmymood
        4
    ctrlmymood  
    OP
       115 天前
    @liuhai233 写这个要各种重复导入🤣
    liuhai233
        5
    liuhai233  
       115 天前
    @ctrlmymood emmm ,不可避免的,不写类型无法推断出你的函数,有类型才能提示
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3023 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 13:40 · PVG 21:40 · LAX 06:40 · JFK 09:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.