避免在 python 脚本名称中出现关于破折号的 pylint 警告 [英] Avoiding a pylint warning about dash in python script name
问题描述
我正在尝试修复我的代码的所有 pylint 警告,只有一个我无法在不禁用警告或重命名脚本的情况下修复:
I'm trying to fix all pylint warnings for my code, and there is just one that I cannot fix without disabling the warning or renaming the script:
C: 1, 0: Invalid module name "foo-bar" (invalid-name)
重命名脚本不是一个选项,因为它的名字是它的公共接口.该脚本以当前名称被广泛使用.
Renaming the script is not an option since its name is its public interface. The script is widely used under the current name.
这是一个顶级程序.该文件不打算用作模块.如果我决定将它作为单元测试的模块导入,我可以使用 __import__("foo-bar")
但不支持其他导入.
That's a top-level program. The file is not intended to be used as a module. If I decide to import it as a module for unit tests, I can use __import__("foo-bar")
but no other import is supported.
有什么好的方法可以告诉 pylint 它是一个顶级脚本,而不是一个模块?
Is there any nice way to tell pylint that it's a top-level script, not a module?
推荐答案
您需要在 CLI 或 pylintrc 文件中覆盖 module-rgx
选项以允许 -代码>s.如需了解更多信息,请查看文档.
You need to override the module-rgx
option either at the CLI or in your pylintrc file to allow -
s. For more on this check out the docs.
这篇关于避免在 python 脚本名称中出现关于破折号的 pylint 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!