Only search specific directories in Python check (#6225)

Summary:
The new Python syntax check could fail if external entities
were cloned or symlinked to a subdir in a rocksdb git clone. (E.g.
Facebook internal LITE build.) Only look for Python files in specific
subdirs
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6225

Test Plan: python tools/check_all_python.py (still 34 files checked)

Reviewed By: gfosco

Differential Revision: D19186110

Pulled By: pdillinger

fbshipit-source-id: 1fefa54e36b32cd5d96d3d1a43e8a2a694c22ea5
main
Peter Dillinger 5 years ago committed by Facebook Github Bot
parent f295b099f6
commit 1ba92b8582
  1. 15
      tools/check_all_python.py

@ -6,12 +6,17 @@ import glob
# errors. This provides a minimal pre-/post-commit check for python file
# modifications.
count = 0
# Clean this up when we finally upgrade to Python 3
for filename in glob.glob("*.py") + glob.glob("*/*.py") + glob.glob("*/*/*.py") + glob.glob("*/*/*/*.py"):
filenames = []
# Avoid scanning all of ./ because there might be other external repos
# linked in.
for base in ["buckifier", "build_tools", "coverage", "tools"]:
# Clean this up when we finally upgrade to Python 3
for suff in ["*", "*/*", "*/*/*"]:
filenames += glob.glob(base + "/" + suff + ".py")
for filename in filenames:
source = open(filename, 'r').read() + '\n'
# Parses and syntax checks the file, throwing on error. (No pyc written.)
_ = compile(source, filename, 'exec')
count = count + 1
print("No syntax errors in {0} .py files".format(count))
print("No syntax errors in {0} .py files".format(len(filenames)))

Loading…
Cancel
Save