You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Pylint检测重构后导入的自定义函数缺失问题

过滤Pylint中导入不存在的函数错误

当你把函数从helper.py迁移到utils.py后,要快速定位代码中仍从helper.py导入已移走函数的错误,可以利用Pylint的错误码和命令行过滤工具实现:

  • 只显示所有模块中找不到名称的错误(对应E0611错误码,即no-name-in-module):

    pylint $(git ls-files '*.py') | grep "E0611"
    
  • 精准过滤helper.py相关的不存在名称错误:

    pylint $(git ls-files '*.py') | grep "E0611.*helper.py"
    
  • 仅启用E0611检查,关闭其他无关输出:

    pylint --disable=all --enable=E0611 $(git ls-files '*.py')
    

E0611是Pylint专门标记“模块中不存在指定导入名称”的错误代码,完全匹配你需要查找的“my_function在helper.py中已不存在”这类场景。

内容的提问来源于stack exchange,提问作者Saurav Pathak

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 17:46:01