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
susecjh
V2EX  ›  Python

关于 Python Language Server 在 VsCode 中增加代码提示的问题

  •  
  •   susecjh · 2021-10-31 15:02:30 +08:00 · 1696 次点击
    这是一个创建于 901 天前的主题,其中的信息可能已经有所发展或是发生改变。

    先说说我干了啥,在 Python 的初始化的时候,自动为每个 View 生成 Schema class(使用 pydantic ,联动对应的 Model)用以校验请求入参和出参,并且生成了对应的 schema 对象(例如:req_obj, resp_obj),现在我在想,有没有可能,我在写某个对应的 View 时,使用到了req_obj/resp_obj能够在 VsCode 展示对应的提示,现在想到了两种方式:

    1. 使用 VsCode 插件
    2. 对 Language Server 做插件

    两种方式都没有做过,想来问问各位大佬有木有建议教教小弟

    2 条回复    2021-10-31 20:08:10 +08:00
    janxin
        1
    janxin  
       2021-10-31 17:52:42 +08:00
    没太明白你的需求,type hint 不能满足你的需求吗
    susecjh
        2
    susecjh  
    OP
       2021-10-31 20:08:10 +08:00 via Android
    @janxin 我的 schema class 是运行时生成的,用 type hint 搞不定吧,毕竟对于不同的 model 会生成不同的 schema class
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2512 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:37 · PVG 23:37 · LAX 08:37 · JFK 11:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.