python - 如何让 pylint 使用 init-hook 正确导入我的文件
问题描述
我按照这些说明如何让 pylint 使用init-hook
.
但是,当我运行终端命令时,pylint server.py --rcfile=../.pylintrc
我得到TypeError: expected str, bytes or os.PathLike object, not NoneType
. (我认为这是因为init-hook
找到 rcfile 的部分以某种方式失败,但我不确定。)
这是我.pylintrc
的相关部分的文件(其余部分只是默认模板):
[MASTER]
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=
# Specify a score threshold to be exceeded before program exits with error.
fail-under=10.0
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS
# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
# THIS GIVES THE ERROR
init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))"
# THIS GIVES THE SAME ERROR
# init-hook="import os, sys, pylint; sys.path.append(os.path.join(os.path.dirname(pylint.config.PYLINTRC), 'platform'))"
我怎样才能让这个 init-hook 代码正常工作?
解决方案
推荐阅读
- c# - 继承 DataGridViewCheckBoxCell 时出现“单元格的格式化值类型错误”错误,即使该类没有实现任何内容
- openlayers-3 - 在选定的边界框中从 Openlayers 3 中获取所有 WMS 图层功能?
- java - 检查包名是否更改
- vue.js - VueJS - onclick 激活新的数组条目不起作用
- firefox - Firefox 下载 SVG 精灵表数百次
- c# - 在c#winform中读取任何文件和打包文件
- sqoop - Sqoop 附加重命名(-Dmapreduce.output.basename)不在 HDFS 中创建文件
- php - 删除重力表单上的文件附件
- reactjs - 将反应元素构建为字符串
- javascript - 在悬停时在图像上设置工具提示