Skip to content

Commit d72e135

Browse files
nordicjmstephanosio
authored andcommitted
scripts: ci: Enable pylint check for argument parser abbreviations
Enables running CI checks which will now search for initialisation of argument parser where abbreviations are not disabled. Signed-off-by: Jamie McCrae <[email protected]>
1 parent 101ba4a commit d72e135

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

scripts/ci/check_compliance.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,10 @@ def run(self):
816816
pylintrc = os.path.abspath(os.path.join(os.path.dirname(__file__),
817817
"pylintrc"))
818818

819+
# Path to additional pylint check scripts
820+
check_script_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
821+
"../pylint/checkers"))
822+
819823
# List of files added/modified by the commit(s).
820824
files = get_files(filter="d")
821825

@@ -826,14 +830,23 @@ def run(self):
826830
if not py_files:
827831
return
828832

829-
pylintcmd = ["pylint", "--rcfile=" + pylintrc] + py_files
833+
python_environment = os.environ.copy()
834+
if "PYTHONPATH" in python_environment:
835+
python_environment["PYTHONPATH"] = check_script_dir + ":" + \
836+
python_environment["PYTHONPATH"]
837+
else:
838+
python_environment["PYTHONPATH"] = check_script_dir
839+
840+
pylintcmd = ["pylint", "--rcfile=" + pylintrc,
841+
"--load-plugins=argparse-checker"] + py_files
830842
logger.info(cmd2str(pylintcmd))
831843
try:
832844
subprocess.run(pylintcmd,
833845
check=True,
834846
stdout=subprocess.PIPE,
835847
stderr=subprocess.STDOUT,
836-
cwd=GIT_TOP)
848+
cwd=GIT_TOP,
849+
env=python_environment)
837850
except subprocess.CalledProcessError as ex:
838851
output = ex.output.decode("utf-8")
839852
regex = r'^\s*(\S+):(\d+):(\d+):\s*([A-Z]\d{4}):\s*(.*)$'

scripts/ci/pylintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ enable=
247247
deprecated-str-translate-call,
248248
deprecated-itertools-function,
249249
deprecated-types-field,
250+
# Custom Zephyr check scripts
251+
zephyr-arg-parse,
250252

251253
[SIMILARITIES]
252254

0 commit comments

Comments
 (0)