简体   繁体   English

如何为我的根文件夹的名称禁用 pylint?

[英]How do I disable pylint for the name of my root folder?

when I当我

touch __init__.py; pylint $(pwd); rm __init__.py

over my project folder, it triggers a warning complaining about the folder name:在我的项目文件夹上,它会触发一个抱怨文件夹名称的警告:

************* Module car-onboard-computer
__init__.py:1:0: C0103: Module name "car-onboard-computer" doesn't conform to snake_case naming style (invalid-name)

------------------------------------------------------------------
Your code has been rated at 9.93/10 (previous run: 9.93/10, +0.00)

This module is the root folder.该模块是根文件夹。 The name "car-onboard-computer" is provided from GitLab, so I can't do much to change it (even wouldn't make sense). “车载电脑”这个名字是从 GitLab 提供的,所以我不能做太多改变(甚至没有意义)。 How do I disable pylint for the name of my root folder?如何为我的根文件夹的名称禁用 pylint?

ps: adding invalid-name to pylintrc disable= list would affect the whole project, so it is not what I'm looking for. ps:将invalid-name添加到 pylintrc disable= list 会影响整个项目,所以这不是我要找的。

Had the same question and finally solved it today.有同样的问题,今天终于解决了。

Bonus : if your root-dir is autogenerated - will be work too.奖励:如果您的根目录是自动生成的 - 也可以使用。 (hi, Jenkins & k8s autogenerated pods) (嗨,Jenkins 和 k8s 自动生成的 pod)

Solution解决方案

#!/bin/bash
current_dir=$(basename $(pwd))
touch __init__.py
pylint $(pwd) --good-names=${current_dir}
rm __init__.py

or in one row或在一排

current_dir=$(basename $(pwd)); touch __init__.py; pylint $(pwd) --good-names=${current_dir}; rm __init__.py

Solution for Jenkins Jenkins 解决方案

current_dir=$(basename ${WORKSPACE})
touch __init__.py
pylint ${WORKSPACE} --rcfile=.pylintrc --good-names=${current_dir}
rm __init__.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM