Skip to content
This repository was archived by the owner on Apr 6, 2022. It is now read-only.

Commit 5b98805

Browse files
marc-hbgalak
authored andcommitted
check_compliance.py: run pylint in GIT_TOP
Running pylint outside ZEPHYR_BASE was: - not intuitive as it required unsetting ZEPHYR_BASE - crashing when running in subdirectories Just run it in GIT_TOP and be done. Signed-off-by: Marc Herbert <[email protected]>
1 parent 09fca8a commit 5b98805

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

scripts/check_compliance.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ class PyLint(ComplianceTest):
728728
_doc = "https://www.pylint.org/"
729729

730730
def run(self):
731-
self.prepare(ZEPHYR_BASE)
731+
self.prepare(GIT_TOP)
732732

733733
# Path to pylint configuration file
734734
pylintrc = os.path.join(os.path.dirname(__file__), "pylintrc")
@@ -741,8 +741,10 @@ def run(self):
741741
":!boards/xtensa/intel_s1000_crb/support/create_board_img.py") \
742742
.splitlines()
743743

744-
# Filter out everything but Python files
745-
py_files = filter_py(files)
744+
# Filter out everything but Python files. Keep filenames
745+
# relative (to GIT_TOP) to stay farther from any command line
746+
# limit.
747+
py_files = filter_py(GIT_TOP, files)
746748
if not py_files:
747749
return
748750

@@ -754,7 +756,7 @@ def run(self):
754756
pylintcmd,
755757
stdout=subprocess.PIPE,
756758
stderr=subprocess.PIPE,
757-
cwd=ZEPHYR_BASE)
759+
cwd=GIT_TOP)
758760
except FileNotFoundError:
759761
self.error("pylint not found. Check that the directory it's in is "
760762
"listed in the PATH environment variable.")
@@ -767,15 +769,17 @@ def run(self):
767769
self.add_failure(stdout.decode("utf-8") + stderr.decode("utf-8"))
768770

769771

770-
def filter_py(fnames):
772+
def filter_py(root, fnames):
771773
# PyLint check helper. Returns all Python script filenames among the
772-
# filenames in 'fnames'. Uses the python-magic library, so that we can
773-
# detect Python files that don't end in .py as well. python-magic is a
774-
# frontend to libmagic, which is also used by 'file'.
774+
# filenames in 'fnames', relative to directory 'root'. Uses the
775+
# python-magic library, so that we can detect Python files that
776+
# don't end in .py as well. python-magic is a frontend to libmagic,
777+
# which is also used by 'file'.
775778

776779
return [fname for fname in fnames
777780
if fname.endswith(".py") or
778-
magic.from_file(fname, mime=True) == "text/x-python"]
781+
magic.from_file(os.path.join(root, fname),
782+
mime=True) == "text/x-python"]
779783

780784

781785
class License(ComplianceTest):

0 commit comments

Comments
 (0)