File: check_all_python.py

package info (click to toggle)
rocksdb 9.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 46,052 kB
  • sloc: cpp: 500,768; java: 42,992; ansic: 9,789; python: 8,373; perl: 5,822; sh: 4,921; makefile: 2,386; asm: 550; xml: 342
file content (22 lines) | stat: -rwxr-xr-x 839 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python3
# 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).read() + "\n"
    # Parses and syntax checks the file, throwing on error. (No pyc written.)
    _ = compile(source, filename, "exec")

print(f"No syntax errors in {len(filenames)} .py files")