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

Viewed 350

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). How do I disable pylint for the name of my root folder?

ps: adding invalid-name to pylintrc disable= list would affect the whole project, so it is not what I'm looking for.

1 Answers

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)

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

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