Avoiding a pylint warning about dash in python script name

一笑奈何 提交于 2019-12-13 20:22:33

问题


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.

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.

Is there any nice way to tell pylint that it's a top-level script, not a module?


回答1:


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.



来源:https://stackoverflow.com/questions/51030905/avoiding-a-pylint-warning-about-dash-in-python-script-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!