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

Neovim 的代码检查、补全问题

  •  
  •   superhxl · 6 天前 · 987 次点击

    Neovim 采用 nvim-cmp + pyright 进行 Python 代码检查、补全,但是对于复杂的代码,譬如自定义类,继承自父类的一些属性、方法就检测不到,提示错误。如图: 自定义类 MoneyAgent 中有继承自父类 CellAgent 的对象 cell ,cell 具有属性 neighborhood ,pyright 完全意识不到。 请教: 1 、是不是有设置方法可以改进、提升 2 、除了 pyright 或者 nvim-cmp ,是不是还有更好的补全工具? 谢谢,请各位 V 友不吝赐教。

    5 条回复    2025-11-07 15:50:14 +08:00
    yb2313
        1
    yb2313  
       6 天前   ❤️ 1
    我觉得应该是 lsp 能力有限, 之前在 vsc 上试过也是一样的, 嵌套过深就不行, 最终还是得用 ide.包括 pyrefly 的跳转也是完全不能用.
    apple115
        2
    apple115  
       6 天前
    或许可以试试 basepyright
    superhxl
        3
    superhxl  
    OP
       6 天前
    @apple115 一样的,存在同样的问题。
    Syiize
        4
    Syiize  
       6 天前
    给 cell 手动加个 type hint 就好了,比如 def __init__(self, model, cell: CLASS_TYPE)
    Alias4ck
        5
    Alias4ck  
       4 天前
    pylance /pyrefly/ty
    虽然 ty/prefly 有很多功能没有支持
    可以用 pylance 的 crack 版本 delance😄
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2722 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 15:00 · PVG 23:00 · LAX 07:00 · JFK 10:00
    ♥ Do have faith in what you're doing.