mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 16:30:56 +00:00
1ba92b8582
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
23 lines
853 B
Python
23 lines
853 B
Python
#!/usr/bin/env python2
|
|
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
import glob
|
|
|
|
# Checks that all python files in the repository are at least free of syntax
|
|
# errors. This provides a minimal pre-/post-commit check for python file
|
|
# modifications.
|
|
|
|
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')
|
|
|
|
print("No syntax errors in {0} .py files".format(len(filenames)))
|