我可以使用 pylint 设置自定义"system root"路径吗?



我有一个构建系统,它为嵌入式平台制作了一个完整的系统映像。它包含了大量的Python代码。目前,我正在使用目标平台的Python和Pylint在qemu下运行,但速度很慢。真的很慢。

有没有一种方法可以运行构建平台的linter,但使用目标树中的所有Python文件?

我不知道有什么内置的方法可以做到这一点,但你可以:

  • 使用init_hook选项,您可以在其中修改sys.path以指向嵌入的目标(或您在python中可以做的任何事情(。

  • 依靠您的测试(自主或手动(来查找错误,并逐个禁用已知的假阳性,无论是对每个错误使用pylint: disable=no-member,还是直接在配置中使用:

[TYPECHECK]
# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=REQUEST,
acl_users,
aq_parent
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=SQLObject,optparse.Values,thread._local,_thread._local
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis). It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=
# List of decorators that change the signature of a decorated function.
signature-mutators=

最新更新