2020-05-29 18:24:19 +00:00
|
|
|
#!/usr/bin/env python3
|
2019-12-19 16:29:32 +00:00
|
|
|
# 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.
|
|
|
|
|
2019-12-19 23:35:37 +00:00
|
|
|
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:
|
2024-10-14 10:01:20 +00:00
|
|
|
source = open(filename).read() + "\n"
|
2019-12-19 16:29:32 +00:00
|
|
|
# Parses and syntax checks the file, throwing on error. (No pyc written.)
|
2022-09-21 00:47:52 +00:00
|
|
|
_ = compile(source, filename, "exec")
|
2019-12-19 16:29:32 +00:00
|
|
|
|
2024-10-14 10:01:20 +00:00
|
|
|
print(f"No syntax errors in {len(filenames)} .py files")
|